Subversion Repositories SmartDukaan

Rev

Rev 690 | Rev 702 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 690 Rev 691
Line 320... Line 320...
320
    toCart.updatedOn = datetime.datetime.now() 
320
    toCart.updatedOn = datetime.datetime.now() 
321
    
321
    
322
    fromCart.expired_on = datetime.datetime.now()
322
    fromCart.expired_on = datetime.datetime.now()
323
    fromCart.cart_status = CartStatus.INACTIVE
323
    fromCart.cart_status = CartStatus.INACTIVE
324
    session.commit()
324
    session.commit()
-
 
325
 
-
 
326
def check_out(cartId):
-
 
327
    if cartId is None:
-
 
328
        raise ShoppingCartException(101, "Cart id not specified")
-
 
329
    cart = Cart.get_by(cartId)
-
 
330
    if cart is None:
-
 
331
        raise ShoppingCartException(102, "The specified cart couldn't be found")
-
 
332
    cart.checked_out_on = datetime.datetime.now()
-
 
333
    session.commit()
-
 
334
    return True
-
 
335
 
-
 
336
def reset_cart(cartId, items):
-
 
337
    if cartId is None:
-
 
338
        raise ShoppingCartException(101, "Cart id not specified")
-
 
339
    for item_id, quantity in items.iteritems():
-
 
340
        line = Line.query.filter_by(cart_id=cartId, item_id=item_id).one()
-
 
341
        if line is not None:
-
 
342
            line.quantity = line.quantity - quantity
-
 
343
            if line.quantity == 0:
-
 
344
                line.delete()
-
 
345
    cart = Cart.get_by(cartId)
-
 
346
    cart.updated_on = datetime.datetime.now()
-
 
347
    session.commit()
-
 
348
    return True
325
349