Subversion Repositories SmartDukaan

Rev

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

Rev 14485 Rev 14495
Line 620... Line 620...
620
    return data
620
    return data
621
 
621
 
622
def getAllManualDeals(offset, limit):
622
def getAllManualDeals(offset, limit):
623
    data = []
623
    data = []
624
    collection = get_mongo_connection().Catalog.ManualDeals
624
    collection = get_mongo_connection().Catalog.ManualDeals
625
    cursor = collection.find({'startDate':{'$lte':to_java_date(datetime.now())},'endDate':{'$gte':to_java_date(datetime.now())}}).skip(offset).limit(limit)
625
    cursor = collection.find({'endDate':{'$gte':to_java_date(datetime.now())}}).skip(offset).limit(limit)
626
    for val in cursor:
626
    for val in cursor:
627
        master = list(get_mongo_connection().Catalog.MasterData.find({'_id':val['sku']}))
627
        master = list(get_mongo_connection().Catalog.MasterData.find({'_id':val['sku']}))
628
        if len(master) > 0:
628
        if len(master) > 0:
629
            val['brand'] = master[0]['brand']
629
            val['brand'] = master[0]['brand']
630
            val['source_product_name'] = master[0]['source_product_name']
630
            val['source_product_name'] = master[0]['source_product_name']
Line 636... Line 636...
636
        data.append(val)
636
        data.append(val)
637
    return data
637
    return data
638
    
638
    
639
def addManualDeal(data):
639
def addManualDeal(data):
640
    collection = get_mongo_connection().Catalog.ManualDeals
640
    collection = get_mongo_connection().Catalog.ManualDeals
641
    cursor = collection.find({'sku':data['sku'],'startDate':{'$lte':to_java_date(datetime.now())},'endDate':{'$gte':to_java_date(datetime.now())}})
641
    cursor = collection.find({'sku':data['sku'],'startDate':{'$lte':data['startDate']},'endDate':{'$gte':data['endDate']}})
642
    if cursor.count() > 0:
642
    if cursor.count() > 0:
643
        return {0:"Sku information already present."}
643
        return {0:"Sku information already present."}
644
    else:
644
    else:
645
        collection.insert(data)
645
        collection.insert(data)
646
        get_mongo_connection().Catalog.MasterData.update({'_id':data['sku']},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=False)
646
        get_mongo_connection().Catalog.MasterData.update({'_id':data['sku']},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=False)
Line 672... Line 672...
672
            data.append(record)
672
            data.append(record)
673
    except:
673
    except:
674
        pass
674
        pass
675
    return data
675
    return data
676
 
676
 
-
 
677
def getAllFeaturedDeals(offset, limit):
-
 
678
    data = []
-
 
679
    collection = get_mongo_connection().Catalog.FeaturedDeals
-
 
680
    cursor = collection.find({'endDate':{'$gte':to_java_date(datetime.now())}}).skip(offset).limit(limit)
-
 
681
    for val in cursor:
-
 
682
        master = list(get_mongo_connection().Catalog.MasterData.find({'_id':val['sku']}))
-
 
683
        if len(master) > 0:
-
 
684
            val['brand'] = master[0]['brand']
-
 
685
            val['source_product_name'] = master[0]['source_product_name']
-
 
686
            val['skuBundleId'] = master[0]['skuBundleId']
-
 
687
        else:
-
 
688
            val['brand'] = ""
-
 
689
            val['source_product_name'] = ""
-
 
690
            val['skuBundleId'] = ""
-
 
691
        data.append(val)
-
 
692
    return data
-
 
693
    
-
 
694
def addFeaturedDeal(data):
-
 
695
    collection = get_mongo_connection().Catalog.ManualDeals
-
 
696
    cursor = collection.find({'sku':data['sku'],'startDate':{'$lte':data['startDate']},'endDate':{'$gte':data['endDate']}})
-
 
697
    if cursor.count() > 0:
-
 
698
        return {0:"Sku information already present."}
-
 
699
    else:
-
 
700
        collection.insert(data)
-
 
701
        get_mongo_connection().Catalog.MasterData.update({'_id':data['sku']},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=False)
-
 
702
        return {1:"Data added successfully"}
-
 
703
 
-
 
704
 
677
def main():
705
def main():
678
    print searchMaster(0, 10, "iphone")
706
    print searchMaster(0, 10, "iphone")
679
    
707
    
680
    
708
    
681
if __name__=='__main__':
709
if __name__=='__main__':