Subversion Repositories SmartDukaan

Rev

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

Rev 15076 Rev 15090
Line 818... Line 818...
818
    return data
818
    return data
819
 
819
 
820
def getAllManualDeals(offset, limit):
820
def getAllManualDeals(offset, limit):
821
    data = []
821
    data = []
822
    collection = get_mongo_connection().Catalog.ManualDeals
822
    collection = get_mongo_connection().Catalog.ManualDeals
823
    cursor = collection.find({'endDate':{'$gte':to_java_date(datetime.now())}}).skip(offset).limit(limit)
823
    cursor = collection.find().skip(offset).limit(limit)
824
    for val in cursor:
824
    for val in cursor:
825
        master = list(get_mongo_connection().Catalog.MasterData.find({'_id':val['sku']}))
825
        master = list(get_mongo_connection().Catalog.MasterData.find({'_id':val['sku']}))
826
        if len(master) > 0:
826
        if len(master) > 0:
827
            val['brand'] = master[0]['brand']
827
            val['brand'] = master[0]['brand']
828
            val['source_product_name'] = master[0]['source_product_name']
828
            val['source_product_name'] = master[0]['source_product_name']
Line 835... Line 835...
835
    return data
835
    return data
836
    
836
    
837
def addManualDeal(data, multi):
837
def addManualDeal(data, multi):
838
    if multi !=1:
838
    if multi !=1:
839
        collection = get_mongo_connection().Catalog.ManualDeals
839
        collection = get_mongo_connection().Catalog.ManualDeals
840
        cursor = collection.find({'sku':data['sku'],'startDate':{'$lte':data['startDate']},'endDate':{'$gte':data['endDate']}})
840
        cursor = collection.find({'sku':data['sku']})
841
        if cursor.count() > 0:
841
        if cursor.count() > 0:
842
            return {0:"Sku information already present."}
842
            return {0:"Sku information already present."}
843
        else:
843
        else:
844
            collection.insert(data)
844
            collection.insert(data)
845
            get_mongo_connection().Catalog.MasterData.update({'_id':data['sku']},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=False)
845
            get_mongo_connection().Catalog.MasterData.update({'_id':data['sku']},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=False)
Line 847... Line 847...
847
    else:
847
    else:
848
        skuIds = __getBundledSkusfromSku(data['sku'])
848
        skuIds = __getBundledSkusfromSku(data['sku'])
849
        for sku in skuIds:
849
        for sku in skuIds:
850
            data['sku'] = sku.get('_id')
850
            data['sku'] = sku.get('_id')
851
            collection = get_mongo_connection().Catalog.ManualDeals
851
            collection = get_mongo_connection().Catalog.ManualDeals
852
            cursor = collection.find({'sku':data['sku'],'startDate':{'$lte':data['startDate']},'endDate':{'$gte':data['endDate']}})
852
            cursor = collection.find({'sku':data['sku']})
853
            if cursor.count() > 0:
853
            if cursor.count() > 0:
854
                continue
854
                continue
855
            else:
855
            else:
856
                data.pop('_id',None)
856
                data.pop('_id',None)
857
                collection.insert(data)
857
                collection.insert(data)