Subversion Repositories SmartDukaan

Rev

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

Rev 1965 Rev 2035
Line 74... Line 74...
74
        if item is None:
74
        if item is None:
75
            #print "[ADDING:]{0} {1} {2} {3} to our catalogue.".format(product_group, brand, model_number, color)
75
            #print "[ADDING:]{0} {1} {2} {3} to our catalogue.".format(product_group, brand, model_number, color)
76
            new_items.append(rownum)
76
            new_items.append(rownum)
77
            item = Item()
77
            item = Item()
78
            item.status = status.IN_PROCESS
78
            item.status = status.IN_PROCESS
-
 
79
            item.status_description = "This item is in process"
79
            item.addedOn = updatedOn
80
            item.addedOn = updatedOn
80
            item.hotspotCategory = category
81
            item.hotspotCategory = category
81
            
82
            
82
            if category == 'Handsets':
83
            if category == 'Handsets':
83
                item.preferredWarehouse = 1
84
                item.preferredWarehouse = 1
Line 94... Line 95...
94
            if catalog_item_id !=None and catalog_item_id != "":
95
            if catalog_item_id !=None and catalog_item_id != "":
95
                #Add category and entity id
96
                #Add category and entity id
96
                item.catalog_item_id = int(catalog_item_id)
97
                item.catalog_item_id = int(catalog_item_id)
97
                item.category = int(category_id)
98
                item.category = int(category_id)
98
                item.status = status.ACTIVE
99
                item.status = status.ACTIVE
-
 
100
                item.status_description = "This item is active"
99
            else:
101
            else:
100
                # Check if a similar item already exists in our database
102
                # Check if a similar item already exists in our database
101
                similar_item = Item.query.filter_by(product_group=product_group, brand = our_brand, model_number=our_model_number, hotspotCategory=category).first()
103
                similar_item = Item.query.filter_by(product_group=product_group, brand = our_brand, model_number=our_model_number, hotspotCategory=category).first()
102
                print "[SIMILAR ITEM FOUND:] FOR {0} {1} {2} {3}".format(product_group, brand, model_number, color)
104
                print "[SIMILAR ITEM FOUND:] FOR {0} {1} {2} {3}".format(product_group, brand, model_number, color)
103
                             
105
                             
Line 110... Line 112...
110
                else:
112
                else:
111
                    #If a similar item already exists for a product group, brand and model_number, set it as same.
113
                    #If a similar item already exists for a product group, brand and model_number, set it as same.
112
                    item.catalog_item_id = similar_item.catalog_item_id
114
                    item.catalog_item_id = similar_item.catalog_item_id
113
                    item.category = similar_item.category
115
                    item.category = similar_item.category
114
                    item.status = similar_item.status
116
                    item.status = similar_item.status
-
 
117
                    item.status_description = similar_item.status_description
115
        else:
118
        else:
116
            # If this item already existed and one of its price parameters has changed
119
            # If this item already existed and one of its price parameters has changed
117
            # in which case we add it to the list of updated items for reporting.
120
            # in which case we add it to the list of updated items for reporting.
118
            if item.status == status.PHASED_OUT:
121
            if item.status == status.PHASED_OUT:
119
                item.status = status.IN_PROCESS #Not the ideal choice but we don't know whether content has been generated for it beforehand.
122
                item.status = status.IN_PROCESS #Not the ideal choice but we don't know whether content has been generated for it beforehand.
-
 
123
                item.status_description = "This item is in process"
120
            vendor_item_pricing = VendorItemPricing.get_by(vendor=vendor, item=item)
124
            vendor_item_pricing = VendorItemPricing.get_by(vendor=vendor, item=item)
121
            if vendor_item_pricing is None:
125
            if vendor_item_pricing is None:
122
                vendor_item_pricing = VendorItemPricing(vendor=vendor, item=item)
126
                vendor_item_pricing = VendorItemPricing(vendor=vendor, item=item)
123
                session.add(vendor_item_pricing)
127
                session.add(vendor_item_pricing)
124
            
128
            
Line 193... Line 197...
193
    write_report("updated_items.csv", updated_items, sheet, True)
197
    write_report("updated_items.csv", updated_items, sheet, True)
194
    phased_out_items = [key.split('|') for key in list(existing_vendor_item_mappings_set)]
198
    phased_out_items = [key.split('|') for key in list(existing_vendor_item_mappings_set)]
195
    write_report("phased_out_items.csv", phased_out_items, sheet, True)
199
    write_report("phased_out_items.csv", phased_out_items, sheet, True)
196
    
200
    
197
    if (not dry_run) and full_update:
201
    if (not dry_run) and full_update:
198
        query_string =  "UPDATE " + str(Item.table) + " SET status=" + str(status.PHASED_OUT) + ", updatedOn='"+ str(updatedOn) +"'"+\
202
        query_string =  "UPDATE " + str(Item.table) + " SET status=" + str(status.PHASED_OUT) + ", status_description='This item has been phased out'" + ", updatedOn='"+ str(updatedOn) +"'"+\
199
                        " WHERE updatedOn <> '" + str(updatedOn) + "' AND hotspotCategory='" + category +"'";
203
                        " WHERE updatedOn <> '" + str(updatedOn) + "' AND hotspotCategory='" + category +"'";
200
        session.execute(query_string, mapper=Item)
204
        session.execute(query_string, mapper=Item)
201
        session.commit()
205
        session.commit()
202
    
206
    
203
    print "Successfully updated the item list information."
207
    print "Successfully updated the item list information."