| Line 20... |
Line 20... |
| 20 |
sheet = workbook.sheet_by_index(0)
|
20 |
sheet = workbook.sheet_by_index(0)
|
| 21 |
num_rows = sheet.nrows
|
21 |
num_rows = sheet.nrows
|
| 22 |
updatedOn = datetime.datetime.now()
|
22 |
updatedOn = datetime.datetime.now()
|
| 23 |
for rownum in range(1, num_rows):
|
23 |
for rownum in range(1, num_rows):
|
| 24 |
print sheet.row_values(rownum)
|
24 |
print sheet.row_values(rownum)
|
| 25 |
brand, model_number, color, model_name, mrp, mop, dp, weight, start_date, deal_text, deal_value, comments = sheet.row_values(rownum)[0:12]
|
25 |
brand, model_number, color, model_name, mrp, mop, dp, weight, start_date, deal_text, deal_value, comments, entity_id, category_id = sheet.row_values(rownum)[0:14]
|
| 26 |
if isinstance(model_number, float):
|
26 |
if isinstance(model_number, float):
|
| 27 |
model_number = str(int(model_number))
|
27 |
model_number = str(int(model_number))
|
| 28 |
item = Item.get_by(manufacturer_name=brand, model_number=model_number, color=color)
|
28 |
item = Item.get_by(manufacturer_name=brand, model_number=model_number, color=color)
|
| 29 |
if item is None:
|
29 |
if item is None:
|
| 30 |
print "[ADDING:]{0} {1} {2} to our catalogue.".format(brand, model_number, color)
|
30 |
print "[ADDING:]{0} {1} {2} to our catalogue.".format(brand, model_number, color)
|
| Line 45... |
Line 45... |
| 45 |
item.catalog_item_id = entity_id.id + 1
|
45 |
item.catalog_item_id = entity_id.id + 1
|
| 46 |
entity_id.id = entity_id.id + 1
|
46 |
entity_id.id = entity_id.id + 1
|
| 47 |
else:
|
47 |
else:
|
| 48 |
#If it already exists for a brand and model_number, set it as same.
|
48 |
#If it already exists for a brand and model_number, set it as same.
|
| 49 |
item.catalog_item_id = similar_item.catalog_item_id
|
49 |
item.catalog_item_id = similar_item.catalog_item_id
|
| - |
|
50 |
|
| - |
|
51 |
#added category and entity id
|
| - |
|
52 |
'''
|
| - |
|
53 |
item.catalog_item_id = int(entity_id)
|
| - |
|
54 |
item.category = int(category_id)
|
| - |
|
55 |
'''
|
| - |
|
56 |
|
| 50 |
item.model_name = model_name
|
57 |
item.model_name = model_name
|
| - |
|
58 |
if mrp != "":
|
| 51 |
item.mrp = mrp
|
59 |
item.mrp = mrp
|
| - |
|
60 |
if mop != "":
|
| 52 |
item.mop = mop
|
61 |
item.mop = mop
|
| - |
|
62 |
if dp != "":
|
| 53 |
item.dealerPrice = dp
|
63 |
item.dealerPrice = dp
|
| - |
|
64 |
if weight != "":
|
| 54 |
item.weight = weight
|
65 |
item.weight = weight
|
| 55 |
item.startDate = datetime.datetime(*xlrd.xldate_as_tuple(start_date, workbook.datemode))
|
66 |
item.startDate = datetime.datetime(*xlrd.xldate_as_tuple(start_date, workbook.datemode))
|
| 56 |
item.bestDealText = deal_text
|
67 |
item.bestDealText = deal_text
|
| 57 |
item.bestDealValue = deal_value
|
68 |
item.bestDealValue = deal_value
|
| 58 |
item.comments = comments
|
69 |
item.comments = comments
|
| 59 |
item.updatedOn = updatedOn
|
70 |
item.updatedOn = updatedOn
|