Subversion Repositories SmartDukaan

Rev

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

Rev 766 Rev 776
Line 274... Line 274...
274
    # No need to validate duplicate items since there are only two ways
274
    # No need to validate duplicate items since there are only two ways
275
    # to add items to a cart and both of them check whether the item being
275
    # to add items to a cart and both of them check whether the item being
276
    # added is a duplicate of an already existing item.
276
    # added is a duplicate of an already existing item.
277
    cart = Cart.get_by(id=cartId)
277
    cart = Cart.get_by(id=cartId)
278
    cart_lines = cart.lines
278
    cart_lines = cart.lines
279
    customer_pincode = ""
279
    customer_pincode = None
280
    current_time = datetime.datetime.now()
280
    current_time = datetime.datetime.now()
281
    if cart.address_id:
281
    if cart.address_id:
282
        address = Address.get_by(id=cart.address_id)
282
        address = Address.get_by(id=cart.address_id)
283
        customer_pincode = address.pin
283
        customer_pincode = address.pin
-
 
284
    if not customer_pincode:
-
 
285
        default_address_id = User.get_by(active_cart_id = cartId).default_address_id
-
 
286
        if default_address_id:
-
 
287
            address = Address.get_by(id = default_address_id)
-
 
288
            customer_pincode = address.pin
-
 
289
    if not customer_pincode:
-
 
290
        #FIXME should not be hard coded. May be we can pick from config server.
-
 
291
        customer_pincode = "110001"
284
    for line in cart_lines:
292
    for line in cart_lines:
285
        old_estimate = line.estimate
293
        old_estimate = line.estimate
286
        item_id = line.item_id
294
        item_id = line.item_id
287
        if inventory_client.isActive(item_id):
295
        if inventory_client.isActive(item_id):
288
            if customer_pincode:
-
 
289
                try:
296
            try:
290
                    item_delivery_estimate = logistics_client.getLogisticsEstimation(item_id, customer_pincode).deliveryTime
297
                item_delivery_estimate = logistics_client.getLogisticsEstimation(item_id, customer_pincode).deliveryTime
-
 
298
                #FIXME setting 3 days is not the way to go.
291
                except:
299
            except:
292
                    item_delivery_estimate = 3
300
                item_delivery_estimate = 3
293
                if old_estimate != item_delivery_estimate:
301
            if old_estimate != item_delivery_estimate:
294
                    line.estimate = item_delivery_estimate
302
                line.estimate = item_delivery_estimate
295
                    cart.updated_on = current_time
303
                cart.updated_on = current_time
296
                    retval = False
304
                retval = False
297
        else:
305
        else:
298
            line.delete()
306
            line.delete()
299
            retval = False
307
            retval = False
300
    if cart.checked_out_on is not None:
308
    if cart.checked_out_on is not None:
301
        if cart.updated_on > cart.checked_out_on:
309
        if cart.updated_on > cart.checked_out_on: