| Line 771... |
Line 771... |
| 771 |
item[0]['showDp'] = 0
|
771 |
item[0]['showDp'] = 0
|
| 772 |
try:
|
772 |
try:
|
| 773 |
item[0]['thumbnail'] = item[0]['thumbnail'].strip()
|
773 |
item[0]['thumbnail'] = item[0]['thumbnail'].strip()
|
| 774 |
except:
|
774 |
except:
|
| 775 |
pass
|
775 |
pass
|
| - |
|
776 |
|
| - |
|
777 |
try:
|
| - |
|
778 |
if item[0]['showVideo']==0:
|
| - |
|
779 |
item[0]['videoLink'] =""
|
| - |
|
780 |
except:
|
| - |
|
781 |
item[0]['videoLink'] =""
|
| - |
|
782 |
try:
|
| - |
|
783 |
if item[0]['quantity'] >1:
|
| - |
|
784 |
ppq = float(item[0]['available_price'])/item[0]['quantity']
|
| - |
|
785 |
|
| - |
|
786 |
if ppq == round(ppq):
|
| - |
|
787 |
item[0]['ppq'] = int(ppq)
|
| - |
|
788 |
else:
|
| - |
|
789 |
item[0]['ppq'] = round(ppq,2)
|
| - |
|
790 |
item[0]['tagline'] = ""
|
| - |
|
791 |
else:
|
| - |
|
792 |
item[0]['ppq'] = 0
|
| - |
|
793 |
except:
|
| - |
|
794 |
item[0]['ppq'] = 0
|
| - |
|
795 |
try:
|
| - |
|
796 |
item[0]['filterLink'] = '/category/'+str(int(item[0]['category_id']))+'?filter=brand&brands='+str(int(item[0]['brand_id']))
|
| - |
|
797 |
except:
|
| - |
|
798 |
item[0]['filterLink'] = ""
|
| 776 |
temp.append(item[0])
|
799 |
temp.append(item[0])
|
| 777 |
if len(temp) > 1:
|
800 |
if len(temp) > 1:
|
| 778 |
temp = sorted(temp, key = lambda x: (x['available_price']),reverse=False)
|
801 |
temp = sorted(temp, key = lambda x: (x['available_price']),reverse=False)
|
| 779 |
dealsListMap.append(temp)
|
802 |
dealsListMap.append(temp)
|
| 780 |
return dealsListMap
|
803 |
return dealsListMap
|
| Line 1366... |
Line 1389... |
| 1366 |
data['skuBundleId'] = max_bundle[0]['skuBundleId'] + 1
|
1389 |
data['skuBundleId'] = max_bundle[0]['skuBundleId'] + 1
|
| 1367 |
data['identifier'] = str(data['identifier'])
|
1390 |
data['identifier'] = str(data['identifier'])
|
| 1368 |
data['secondaryIdentifier'] = str(data['secondaryIdentifier'])
|
1391 |
data['secondaryIdentifier'] = str(data['secondaryIdentifier'])
|
| 1369 |
data['model_name'] = str(data['model_name'])
|
1392 |
data['model_name'] = str(data['model_name'])
|
| 1370 |
data['brand_id'] = __getBrandIdForBrand(data['brand'], data['category_id'])
|
1393 |
data['brand_id'] = __getBrandIdForBrand(data['brand'], data['category_id'])
|
| - |
|
1394 |
if data['category_id'] ==6 and data['subCategoryId'] ==0:
|
| - |
|
1395 |
raise
|
| 1371 |
get_mongo_connection().Catalog.MasterData.insert(data)
|
1396 |
get_mongo_connection().Catalog.MasterData.insert(data)
|
| 1372 |
return {1:'Data added successfully'}
|
1397 |
return {1:'Data added successfully'}
|
| 1373 |
except Exception as e:
|
1398 |
except Exception as e:
|
| 1374 |
print e
|
1399 |
print e
|
| 1375 |
return {0:'Unable to add data.'}
|
1400 |
return {0:'Unable to add data.'}
|
| Line 1385... |
Line 1410... |
| 1385 |
data['_id'] = max_id[0]['_id'] + 1
|
1410 |
data['_id'] = max_id[0]['_id'] + 1
|
| 1386 |
data['identifier'] = str(data['identifier'])
|
1411 |
data['identifier'] = str(data['identifier'])
|
| 1387 |
data['secondaryIdentifier'] = str(data['secondaryIdentifier'])
|
1412 |
data['secondaryIdentifier'] = str(data['secondaryIdentifier'])
|
| 1388 |
data['model_name'] = str(data['model_name'])
|
1413 |
data['model_name'] = str(data['model_name'])
|
| 1389 |
data['brand_id'] = __getBrandIdForBrand(data['brand'], data['category_id'])
|
1414 |
data['brand_id'] = __getBrandIdForBrand(data['brand'], data['category_id'])
|
| - |
|
1415 |
if data['category_id'] ==6 and data['subCategoryId'] ==0:
|
| - |
|
1416 |
raise
|
| 1390 |
get_mongo_connection().Catalog.MasterData.insert(data)
|
1417 |
get_mongo_connection().Catalog.MasterData.insert(data)
|
| 1391 |
return {1:'Data added successfully.'}
|
1418 |
return {1:'Data added successfully.'}
|
| 1392 |
except Exception as e:
|
1419 |
except Exception as e:
|
| 1393 |
print e
|
1420 |
print e
|
| 1394 |
return {0:'Unable to add data.'}
|
1421 |
return {0:'Unable to add data.'}
|
| Line 1404... |
Line 1431... |
| 1404 |
data['updatedOn'] = to_java_date(datetime.now())
|
1431 |
data['updatedOn'] = to_java_date(datetime.now())
|
| 1405 |
data['identifier'] = str(data['identifier'])
|
1432 |
data['identifier'] = str(data['identifier'])
|
| 1406 |
data['secondaryIdentifier'] = str(data['secondaryIdentifier'])
|
1433 |
data['secondaryIdentifier'] = str(data['secondaryIdentifier'])
|
| 1407 |
data['model_name'] = str(data['model_name'])
|
1434 |
data['model_name'] = str(data['model_name'])
|
| 1408 |
data['brand_id'] = __getBrandIdForBrand(data['brand'], data['category_id'])
|
1435 |
data['brand_id'] = __getBrandIdForBrand(data['brand'], data['category_id'])
|
| - |
|
1436 |
if data['category_id'] ==6 and data['subCategoryId'] ==0:
|
| - |
|
1437 |
raise
|
| 1409 |
get_mongo_connection().Catalog.MasterData.update({'_id':_id},{"$set":data},upsert=False)
|
1438 |
get_mongo_connection().Catalog.MasterData.update({'_id':_id},{"$set":data},upsert=False)
|
| 1410 |
return {1:'Data updated successfully.'}
|
1439 |
return {1:'Data updated successfully.'}
|
| 1411 |
else:
|
1440 |
else:
|
| 1412 |
_id = data.pop('_id')
|
1441 |
_id = data.pop('_id')
|
| 1413 |
skuBundleId = data.pop('skuBundleId')
|
1442 |
skuBundleId = data.pop('skuBundleId')
|
| 1414 |
data['updatedOn'] = to_java_date(datetime.now())
|
1443 |
data['updatedOn'] = to_java_date(datetime.now())
|
| 1415 |
data['identifier'] = str(data['identifier'])
|
1444 |
data['identifier'] = str(data['identifier'])
|
| 1416 |
data['secondaryIdentifier'] = str(data['secondaryIdentifier'])
|
1445 |
data['secondaryIdentifier'] = str(data['secondaryIdentifier'])
|
| 1417 |
data['brand_id'] = __getBrandIdForBrand(data['brand'], data['category_id'])
|
1446 |
data['brand_id'] = __getBrandIdForBrand(data['brand'], data['category_id'])
|
| 1418 |
data['model_name'] = str(data['model_name'])
|
1447 |
data['model_name'] = str(data['model_name'])
|
| - |
|
1448 |
if data['category_id'] ==6 and data['subCategoryId'] ==0:
|
| - |
|
1449 |
raise
|
| 1419 |
get_mongo_connection().Catalog.MasterData.update({'_id':_id},{"$set":data},upsert=False)
|
1450 |
get_mongo_connection().Catalog.MasterData.update({'_id':_id},{"$set":data},upsert=False)
|
| 1420 |
similarItems = get_mongo_connection().Catalog.MasterData.find({'skuBundleId':skuBundleId})
|
1451 |
similarItems = get_mongo_connection().Catalog.MasterData.find({'skuBundleId':skuBundleId})
|
| 1421 |
for item in similarItems:
|
1452 |
for item in similarItems:
|
| 1422 |
if item['_id'] == _id:
|
1453 |
if item['_id'] == _id:
|
| 1423 |
continue
|
1454 |
continue
|
| Line 1429... |
Line 1460... |
| 1429 |
item['is_shortage'] = data['is_shortage']
|
1460 |
item['is_shortage'] = data['is_shortage']
|
| 1430 |
item['mrp'] = data['mrp']
|
1461 |
item['mrp'] = data['mrp']
|
| 1431 |
item['status'] = data['status']
|
1462 |
item['status'] = data['status']
|
| 1432 |
item['maxPrice'] = data['maxPrice']
|
1463 |
item['maxPrice'] = data['maxPrice']
|
| 1433 |
item['brand_id'] = data['brand_id']
|
1464 |
item['brand_id'] = data['brand_id']
|
| - |
|
1465 |
item['subCategoryId'] = data['subCategoryId']
|
| - |
|
1466 |
item['subCategory'] = data['subCategory']
|
| 1434 |
similar_item_id = item.pop('_id')
|
1467 |
similar_item_id = item.pop('_id')
|
| 1435 |
get_mongo_connection().Catalog.MasterData.update({'_id':similar_item_id},{"$set":item},upsert=False)
|
1468 |
get_mongo_connection().Catalog.MasterData.update({'_id':similar_item_id},{"$set":item},upsert=False)
|
| 1436 |
return {1:'Data updated successfully.'}
|
1469 |
return {1:'Data updated successfully.'}
|
| - |
|
1470 |
except:
|
| - |
|
1471 |
return {0:'Unable to update data'}
|
| 1437 |
finally:
|
1472 |
finally:
|
| 1438 |
session.close()
|
1473 |
session.close()
|
| 1439 |
|
1474 |
|
| 1440 |
def getLiveCricScore():
|
1475 |
def getLiveCricScore():
|
| 1441 |
return mc.get('liveScore')
|
1476 |
return mc.get('liveScore')
|
| Line 2059... |
Line 2094... |
| 2059 |
if returnMap['cheapest'] ==None:
|
2094 |
if returnMap['cheapest'] ==None:
|
| 2060 |
dum = get_mongo_connection().Catalog.MasterData.find_one({'skuBundleId':skuBundleId,'source_id':{"$in":SOURCE_MAP.keys()}})
|
2095 |
dum = get_mongo_connection().Catalog.MasterData.find_one({'skuBundleId':skuBundleId,'source_id':{"$in":SOURCE_MAP.keys()}})
|
| 2061 |
returnMap['cheapest'] = {'thumbnail':dum['thumbnail'],'source_product_name':dum['source_product_name']}
|
2096 |
returnMap['cheapest'] = {'thumbnail':dum['thumbnail'],'source_product_name':dum['source_product_name']}
|
| 2062 |
return returnMap
|
2097 |
return returnMap
|
| 2063 |
|
2098 |
|
| - |
|
2099 |
|
| 2064 |
def addDealObject(data):
|
2100 |
def addDealObject(data):
|
| 2065 |
if data.get('img_url') is None or data.get('img_url')=="" or data.get('name') is None or data.get('name')=="":
|
2101 |
if data.get('img_url') is None or data.get('img_url')=="" or data.get('name') is None or data.get('name')=="":
|
| 2066 |
return {0:'Invalid data'}
|
2102 |
return {0:'Invalid data'}
|
| 2067 |
try:
|
2103 |
try:
|
| 2068 |
max_id = list(get_mongo_connection().Catalog.DealObject.find().sort([('_id',pymongo.DESCENDING)]).limit(1))
|
2104 |
max_id = list(get_mongo_connection().Catalog.DealObject.find().sort([('_id',pymongo.DESCENDING)]).limit(1))
|