| Line 8... |
Line 8... |
| 8 |
import os
|
8 |
import os
|
| 9 |
sys.path.insert(0, os.getcwd())
|
9 |
sys.path.insert(0, os.getcwd())
|
| 10 |
|
10 |
|
| 11 |
from shop2020.thriftpy.model.v1.catalog.ttypes import status
|
11 |
from shop2020.thriftpy.model.v1.catalog.ttypes import status
|
| 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.DataService import Item, EntityIDGenerator
|
13 |
from shop2020.model.v1.catalog.impl.DataService import Item, EntityIDGenerator,\
|
| - |
|
14 |
ItemChangeLog
|
| 14 |
from elixir import *
|
15 |
from elixir import *
|
| 15 |
|
16 |
|
| 16 |
def load_item_data(filename):
|
17 |
def load_item_data(filename):
|
| 17 |
DataService.initialize()
|
18 |
DataService.initialize()
|
| 18 |
|
19 |
|
| Line 20... |
Line 21... |
| 20 |
sheet = workbook.sheet_by_index(0)
|
21 |
sheet = workbook.sheet_by_index(0)
|
| 21 |
num_rows = sheet.nrows
|
22 |
num_rows = sheet.nrows
|
| 22 |
updatedOn = datetime.datetime.now()
|
23 |
updatedOn = datetime.datetime.now()
|
| 23 |
for rownum in range(1, num_rows):
|
24 |
for rownum in range(1, num_rows):
|
| 24 |
print sheet.row_values(rownum)
|
25 |
print sheet.row_values(rownum)
|
| 25 |
brand, model_number, color, model_name, mrp, mop, dp, weight, start_date, deal_text, deal_value, comments, catalog_item_id, category_id = sheet.row_values(rownum)[0:14]
|
26 |
hotspot_category, brand, model_number, color, model_name, mrp, mop, dp, xfer_price, weight, start_date, deal_text, deal_value, comments, catalog_item_id, category_id = sheet.row_values(rownum)[0:17]
|
| 26 |
if isinstance(model_number, float):
|
27 |
if isinstance(model_number, float):
|
| 27 |
model_number = str(int(model_number))
|
28 |
model_number = str(int(model_number))
|
| 28 |
item = Item.get_by(manufacturer_name=brand, model_number=model_number, color=color)
|
29 |
item = Item.get_by(manufacturer_name=brand, model_number=model_number, color=color)
|
| 29 |
if item is None:
|
30 |
if item is None:
|
| 30 |
print "[ADDING:]{0} {1} {2} to our catalogue.".format(brand, model_number, color)
|
31 |
print "[ADDING:]{0} {1} {2} to our catalogue.".format(brand, model_number, color)
|
| Line 52... |
Line 53... |
| 52 |
'''
|
53 |
'''
|
| 53 |
item.catalog_item_id = int(catalog_item_id)
|
54 |
item.catalog_item_id = int(catalog_item_id)
|
| 54 |
item.category = int(category_id)
|
55 |
item.category = int(category_id)
|
| 55 |
item.status = status.ACTIVE
|
56 |
item.status = status.ACTIVE
|
| 56 |
'''
|
57 |
'''
|
| 57 |
|
58 |
item.hotspotCategory = hotspot_category
|
| 58 |
item.model_name = model_name
|
59 |
item.model_name = model_name
|
| 59 |
if mrp != "":
|
60 |
if mrp != "":
|
| 60 |
item.mrp = mrp
|
61 |
item.mrp = mrp
|
| 61 |
if mop != "":
|
62 |
if mop != "":
|
| 62 |
item.mop = mop
|
63 |
item.mop = mop
|
| 63 |
if dp != "":
|
64 |
if dp != "":
|
| 64 |
item.dealerPrice = dp
|
65 |
item.dealerPrice = dp
|
| 65 |
item.sellingPrice = dp
|
66 |
item.sellingPrice = dp
|
| - |
|
67 |
if xfer_price !="":
|
| - |
|
68 |
item.transfer_price = xfer_price
|
| 66 |
if weight != "":
|
69 |
if weight != "":
|
| 67 |
item.weight = weight
|
70 |
item.weight = weight
|
| 68 |
if start_date != "":
|
71 |
if start_date != "":
|
| 69 |
item.startDate = datetime.datetime(*xlrd.xldate_as_tuple(start_date, workbook.datemode))
|
72 |
item.startDate = datetime.datetime(*xlrd.xldate_as_tuple(start_date, workbook.datemode))
|
| 70 |
item.bestDealText = deal_text
|
73 |
item.bestDealText = deal_text
|
| 71 |
if deal_value != "":
|
74 |
if deal_value != "":
|
| 72 |
item.bestDealValue = deal_value
|
75 |
item.bestDealValue = deal_value
|
| 73 |
item.comments = comments
|
76 |
item.comments = comments
|
| 74 |
item.updatedOn = updatedOn
|
77 |
item.updatedOn = updatedOn
|
| - |
|
78 |
|
| - |
|
79 |
item_change_log = ItemChangeLog()
|
| - |
|
80 |
item_change_log.new_status = item.status
|
| - |
|
81 |
item_change_log.timestamp = updatedOn
|
| - |
|
82 |
item_change_log.item = item
|
| 75 |
session.commit()
|
83 |
session.commit()
|
| 76 |
|
84 |
|
| 77 |
session.execute("UPDATE " + str(Item.table) + " SET status=" + str(status.PHASED_OUT) + ", updatedOn='"+ str(updatedOn) +"' WHERE updatedOn <> '" + str(updatedOn) + "'", mapper=Item)
|
85 |
session.execute("UPDATE " + str(Item.table) + " SET status=" + str(status.PHASED_OUT) + ", updatedOn='"+ str(updatedOn) +"' WHERE updatedOn <> '" + str(updatedOn) + "'", mapper=Item)
|
| 78 |
session.commit()
|
86 |
session.commit()
|
| 79 |
print "Successfully updated the item list information."
|
87 |
print "Successfully updated the item list information."
|