| Line 12... |
Line 12... |
| 12 |
from shop2020.model.v1.catalog.impl import DataService
|
12 |
from shop2020.model.v1.catalog.impl import DataService
|
| 13 |
from shop2020.model.v1.catalog.impl.CategoryManager import CategoryManager
|
13 |
from shop2020.model.v1.catalog.impl.CategoryManager import CategoryManager
|
| 14 |
from shop2020.model.v1.catalog.impl.Convertors import to_t_item, to_t_source
|
14 |
from shop2020.model.v1.catalog.impl.Convertors import to_t_item, to_t_source
|
| 15 |
from shop2020.model.v1.catalog.impl.DataService import Item, ItemChangeLog, \
|
15 |
from shop2020.model.v1.catalog.impl.DataService import Item, ItemChangeLog, \
|
| 16 |
Category, EntityIDGenerator, SimilarItems, ProductNotification, Source, \
|
16 |
Category, EntityIDGenerator, SimilarItems, ProductNotification, Source, \
|
| 17 |
SourceItemPricing, AuthorizationLog, VoucherItemMapping, CategoryVatMaster
|
17 |
SourceItemPricing, AuthorizationLog, VoucherItemMapping, CategoryVatMaster,\
|
| - |
|
18 |
OOSTracker
|
| 18 |
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemShippingInfo, \
|
19 |
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemShippingInfo, \
|
| 19 |
ItemType
|
20 |
ItemType
|
| 20 |
from shop2020.thriftpy.model.v1.inventory.ttypes import \
|
21 |
from shop2020.thriftpy.model.v1.inventory.ttypes import \
|
| 21 |
InventoryServiceException
|
22 |
InventoryServiceException
|
| 22 |
from shop2020.utils import EmailAttachmentSender
|
23 |
from shop2020.utils import EmailAttachmentSender
|
| Line 406... |
Line 407... |
| 406 |
item.status_description = "This item is currently out of stock"
|
407 |
item.status_description = "This item is currently out of stock"
|
| 407 |
#This will clear cache from tomcat
|
408 |
#This will clear cache from tomcat
|
| 408 |
__clear_homepage_cache()
|
409 |
__clear_homepage_cache()
|
| 409 |
elif item.status == status.ACTIVE:
|
410 |
elif item.status == status.ACTIVE:
|
| 410 |
item.status_description = "This item is active"
|
411 |
item.status_description = "This item is active"
|
| 411 |
__send_mail("Item '{0}' is Active. Item id is {1}".format(__get_product_name(item), item_id), "")
|
- |
|
| 412 |
elif item.status == status.IN_PROCESS:
|
412 |
elif item.status == status.IN_PROCESS:
|
| 413 |
item.status_description = "This item is in process"
|
413 |
item.status_description = "This item is in process"
|
| 414 |
elif item.status == status.CONTENT_COMPLETE:
|
414 |
elif item.status == status.CONTENT_COMPLETE:
|
| 415 |
item.status_description = "This item is in process"
|
415 |
item.status_description = "This item is in process"
|
| 416 |
session.commit()
|
416 |
session.commit()
|
| Line 428... |
Line 428... |
| 428 |
change_item_status(item.id, status.PAUSED_BY_RISK)
|
428 |
change_item_status(item.id, status.PAUSED_BY_RISK)
|
| 429 |
__send_mail_for_oos_item(item)
|
429 |
__send_mail_for_oos_item(item)
|
| 430 |
else:
|
430 |
else:
|
| 431 |
if item.status == status.PAUSED_BY_RISK:
|
431 |
if item.status == status.PAUSED_BY_RISK:
|
| 432 |
change_item_status(item.id, status.ACTIVE)
|
432 |
change_item_status(item.id, status.ACTIVE)
|
| - |
|
433 |
__send_mail_for_active_item(item.id, "Item '{0}' is Active. Item id is {1}".format(__get_product_name(item), item_id), "")
|
| 433 |
session.commit()
|
434 |
session.commit()
|
| 434 |
|
435 |
|
| 435 |
def mark_item_as_content_complete(entity_id, category, brand, modelName, modelNumber):
|
436 |
def mark_item_as_content_complete(entity_id, category, brand, modelName, modelNumber):
|
| 436 |
'''
|
437 |
'''
|
| 437 |
Get all the items for this entityID and update category, brand, modelName and modelNumber for all.
|
438 |
Get all the items for this entityID and update category, brand, modelName and modelNumber for all.
|
| Line 794... |
Line 795... |
| 794 |
except:
|
795 |
except:
|
| 795 |
print "Not able to log risky flag change"
|
796 |
print "Not able to log risky flag change"
|
| 796 |
item.risky = risky
|
797 |
item.risky = risky
|
| 797 |
if not risky and item.status == status.PAUSED_BY_RISK:
|
798 |
if not risky and item.status == status.PAUSED_BY_RISK:
|
| 798 |
change_item_status(item.id, status.ACTIVE)
|
799 |
change_item_status(item.id, status.ACTIVE)
|
| - |
|
800 |
__send_mail_for_active_item(item.id, "Item '{0}' is Active. Item id is {1}".format(__get_product_name(item), item_id), "")
|
| 799 |
session.commit()
|
801 |
session.commit()
|
| 800 |
flag = "ON" if risky else "OFF"
|
802 |
flag = "ON" if risky else "OFF"
|
| 801 |
subject = "Risky flag is {0} for Item {1}.".format(flag, __get_product_name(item))
|
803 |
subject = "Risky flag is {0} for Item {1}.".format(flag, __get_product_name(item))
|
| 802 |
__send_mail(subject,"")
|
804 |
__send_mail(subject,"")
|
| 803 |
|
805 |
|
| Line 1208... |
Line 1210... |
| 1208 |
authorize_log.username = username
|
1210 |
authorize_log.username = username
|
| 1209 |
authorize_log.reason = reason
|
1211 |
authorize_log.reason = reason
|
| 1210 |
session.commit()
|
1212 |
session.commit()
|
| 1211 |
return True
|
1213 |
return True
|
| 1212 |
|
1214 |
|
| 1213 |
def __send_mail_for_oos_item(item):
|
1215 |
def __send_mail_for_oos_item(item):
|
| - |
|
1216 |
oos = OOSTracker.get_by(itemId = item.id)
|
| - |
|
1217 |
if oos is None:
|
| - |
|
1218 |
oos = OOSTracker()
|
| - |
|
1219 |
oos.itemId = item.id
|
| - |
|
1220 |
session.commit()
|
| 1214 |
try:
|
1221 |
try:
|
| 1215 |
EmailAttachmentSender.mail(mail_user, mail_password, to_addresses + ["abhishek.mathur@shop2020.in"], "Item is out of stock. ID: " + str(item.id) + " " + str(item.brand) + " " + str(item.model_name) + " " + str(item.model_number)+ " " + str(item.color), None)
|
1222 |
EmailAttachmentSender.mail(mail_user, mail_password, to_addresses + ["abhishek.mathur@shop2020.in"], "Item is out of stock. ID: " + str(item.id) + " " + str(item.brand) + " " + str(item.model_name) + " " + str(item.model_number)+ " " + str(item.color), None)
|
| 1216 |
except Exception as e:
|
1223 |
except Exception as e:
|
| 1217 |
print e
|
1224 |
print e
|
| - |
|
1225 |
|
| - |
|
1226 |
def __send_mail_for_active_item(itemId, subject, message):
|
| - |
|
1227 |
oos = OOSTracker.get_by(itemId = itemId)
|
| - |
|
1228 |
if oos is not None:
|
| - |
|
1229 |
oos.delete()
|
| - |
|
1230 |
session.commit()
|
| - |
|
1231 |
__send_mail(subject, message)
|
| 1218 |
|
1232 |
|
| 1219 |
def __send_mail(subject, message):
|
1233 |
def __send_mail(subject, message):
|
| 1220 |
try:
|
1234 |
try:
|
| 1221 |
thread = threading.Thread(target=partial(mail, mail_user, mail_password, to_addresses, subject, message))
|
1235 |
thread = threading.Thread(target=partial(mail, mail_user, mail_password, to_addresses, subject, message))
|
| 1222 |
thread.start()
|
1236 |
thread.start()
|