Subversion Repositories SmartDukaan

Rev

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

Rev 16483 Rev 16488
Line 24... Line 24...
24
COLLECTION_MAP = {
24
COLLECTION_MAP = {
25
                  'ExceptionalNlc':'skuBundleId',
25
                  'ExceptionalNlc':'skuBundleId',
26
                  'SkuDealerPrices':'skuBundleId',
26
                  'SkuDealerPrices':'skuBundleId',
27
                  'SkuDiscountInfo':'skuBundleId',
27
                  'SkuDiscountInfo':'skuBundleId',
28
                  'SkuSchemeDetails':'skuBundleId',
28
                  'SkuSchemeDetails':'skuBundleId',
29
                  
29
                  'DealPoints':'skuBundleId'
30
                  }
30
                  }
31
 
31
 
32
def get_mongo_connection(host='localhost', port=27017):
32
def get_mongo_connection(host='localhost', port=27017):
33
    global con
33
    global con
34
    if con is None:
34
    if con is None:
Line 1339... Line 1339...
1339
    else:
1339
    else:
1340
        orders = get_mongo_connection().Catalog.MasterData.find_one({'skuBundleId':sku})
1340
        orders = get_mongo_connection().Catalog.MasterData.find_one({'skuBundleId':sku})
1341
        if orders is None:
1341
        if orders is None:
1342
            return {}
1342
            return {}
1343
        return orders
1343
        return orders
-
 
1344
 
-
 
1345
def addDealPoints(data):
-
 
1346
    collection = get_mongo_connection().Catalog.DealPoints
-
 
1347
    cursor = collection.find({'skuBundleId':data['skuBundleId']})
-
 
1348
    if cursor.count() > 0:
-
 
1349
        return {0:"Sku information already present."}
1344
    
1350
    else:
-
 
1351
        collection.insert(data)
-
 
1352
        get_mongo_connection().Catalog.MasterData.update({'skuBundleId':data['skuBundleId']},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=True)
-
 
1353
        return {1:"Data added successfully"}
-
 
1354
 
-
 
1355
def getAllBundlesWithDealPoints(offset, limit):
-
 
1356
    data = []
-
 
1357
    collection = get_mongo_connection().Catalog.DealPoints
-
 
1358
    cursor = collection.find().sort([('endDate',pymongo.DESCENDING)]).skip(offset).limit(limit)
-
 
1359
    for val in cursor:
-
 
1360
        master = get_mongo_connection().Catalog.MasterData.find_one({'skuBundleId':val.get('skuBundleId')})
-
 
1361
        if master is not None:
-
 
1362
            val['brand'] = master['brand']
-
 
1363
            val['source_product_name'] = master['product_name']
1345
    
1364
        else:
-
 
1365
            val['brand'] = ""
-
 
1366
            val['source_product_name'] = ""
-
 
1367
        data.append(val)
-
 
1368
    return data
1346
    
1369
    
1347
def main():
1370
def main():
1348
    print getDealsForNotification("1,2,34,5")
1371
    print COLLECTION_MAP
1349
    
1372
    
1350
    
1373
    
1351
    
1374
    
1352
if __name__=='__main__':
1375
if __name__=='__main__':
1353
    main()
1376
    main()