| Line 11... |
Line 11... |
| 11 |
|
11 |
|
| 12 |
from shop2020.thriftpy.model.v1.order.ttypes import Transaction as TTransaction,\
|
12 |
from shop2020.thriftpy.model.v1.order.ttypes import Transaction as TTransaction,\
|
| 13 |
TransactionStatus as TTransactionStatus, Order as TOrder, LineItem as TLineItem, OrderStatus
|
13 |
TransactionStatus as TTransactionStatus, Order as TOrder, LineItem as TLineItem, OrderStatus
|
| 14 |
|
14 |
|
| 15 |
from shop2020.thriftpy.model.v1.catalog.ttypes import Item as TItem
|
15 |
from shop2020.thriftpy.model.v1.catalog.ttypes import Item as TItem
|
| 16 |
from shop2020.thriftpy.logistics.ttypes import LogisticsInfo as TLogisticsInfo
|
16 |
from shop2020.thriftpy.logistics.ttypes import LogisticsInfo as TLogisticsInfo,\
|
| - |
|
17 |
LogisticsServiceException
|
| 17 |
|
18 |
|
| 18 |
from shop2020.clients.TransactionClient import TransactionClient
|
19 |
from shop2020.clients.TransactionClient import TransactionClient
|
| 19 |
from shop2020.clients.InventoryClient import InventoryClient
|
20 |
from shop2020.clients.InventoryClient import InventoryClient
|
| 20 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
21 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
| 21 |
from shop2020.model.v1 import user
|
22 |
from shop2020.model.v1 import user
|
| Line 294... |
Line 295... |
| 294 |
old_estimate = line.estimate
|
295 |
old_estimate = line.estimate
|
| 295 |
item_id = line.item_id
|
296 |
item_id = line.item_id
|
| 296 |
if inventory_client.isActive(item_id):
|
297 |
if inventory_client.isActive(item_id):
|
| 297 |
try:
|
298 |
try:
|
| 298 |
item_delivery_estimate = logistics_client.getLogisticsEstimation(item_id, customer_pincode).deliveryTime
|
299 |
item_delivery_estimate = logistics_client.getLogisticsEstimation(item_id, customer_pincode).deliveryTime
|
| - |
|
300 |
except LogisticsServiceException:
|
| - |
|
301 |
item_delivery_estimate = -1
|
| 299 |
#FIXME setting 3 days is not the way to go.
|
302 |
#TODO Use the exception clause to set the retval appropriately
|
| 300 |
except:
|
303 |
except :
|
| 301 |
item_delivery_estimate = 3
|
304 |
item_delivery_estimate = -1
|
| 302 |
if old_estimate != item_delivery_estimate:
|
305 |
if old_estimate != item_delivery_estimate:
|
| 303 |
line.estimate = item_delivery_estimate
|
306 |
line.estimate = item_delivery_estimate
|
| 304 |
cart.updated_on = current_time
|
307 |
cart.updated_on = current_time
|
| 305 |
retval = False
|
308 |
retval = False
|
| 306 |
else:
|
309 |
else:
|
| 307 |
line.delete()
|
310 |
line.delete()
|
| 308 |
retval = False
|
311 |
retval = False
|
| 309 |
if cart.checked_out_on is not None:
|
312 |
if cart.checked_out_on is not None:
|
| 310 |
if cart.updated_on > cart.checked_out_on:
|
313 |
if cart.updated_on > cart.checked_out_on:
|
| - |
|
314 |
cart.checked_out_on = None
|
| 311 |
retval = False
|
315 |
retval = False
|
| 312 |
session.commit()
|
316 |
session.commit()
|
| 313 |
return retval
|
317 |
return retval
|
| 314 |
|
318 |
|
| 315 |
def merge_cart(fromCartId, toCartId):
|
319 |
def merge_cart(fromCartId, toCartId):
|