Subversion Repositories SmartDukaan

Rev

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

Rev 557 Rev 563
Line 200... Line 200...
200
    Order order = getOrder(c.getAddressId(), lineItem);
200
    Order order = getOrder(c.getAddressId(), lineItem);
201
    order.addToLineitems(lineItem);
201
    order.addToLineitems(lineItem);
202
    orders.add(order);
202
    orders.add(order);
203
"""
203
"""
204
    
204
    
205
def validate_cart(cartId):
205
def validate_cart(cartId, inventory_client):
-
 
206
    retval = True
206
    # No need to validate duplicate items since there are only two ways
207
    # No need to validate duplicate items since there are only two ways
207
    # to add items to a cart and both of them check whether the item being
208
    # to add items to a cart and both of them check whether the item being
208
    # added is a duplicate of an already existing item.
209
    # added is a duplicate of an already existing item.
-
 
210
    cart = Cart.get_by(id=cartId)
-
 
211
    cart_lines = cart.lines
-
 
212
    for line in cart_lines:
-
 
213
        item_id = line.item_id
-
 
214
        if not inventory_client.is_active(item_id):
-
 
215
            line.delete()
-
 
216
            retval = False
209
    return True
217
    return retval
210
    
218
    
211
def merge_cart(fromCartId, toCartId):
219
def merge_cart(fromCartId, toCartId):
212
    fromCart = Cart.get_by(id=fromCartId)
220
    fromCart = Cart.get_by(id=fromCartId)
213
    toCart = Cart.get_by(id=toCartId)
221
    toCart = Cart.get_by(id=toCartId)
214
    
222