Subversion Repositories SmartDukaan

Rev

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

Rev 14596 Rev 14597
Line 927... Line 927...
927
    except Exception as e:
927
    except Exception as e:
928
        print e
928
        print e
929
        return {0:'Unable to add data.'}
929
        return {0:'Unable to add data.'}
930
 
930
 
931
def updateMaster(data, multi):
931
def updateMaster(data, multi):
932
    try:
-
 
933
        if multi != 1:
932
    if multi != 1:
934
            _id = data.pop('_id')
933
        _id = data.pop('_id')
935
            skuBundleId = data.pop('skuBundleId')
934
        skuBundleId = data.pop('skuBundleId')
936
            data['updatedOn'] = to_java_date(datetime.now())
935
        data['updatedOn'] = to_java_date(datetime.now())
937
            get_mongo_connection().Catalog.MasterData.update({'_id':_id},{"$set":data},upsert=False)
936
        get_mongo_connection().Catalog.MasterData.update({'_id':_id},{"$set":data},upsert=False)
938
            return {1:'Data updated successfully.'}
937
        return {1:'Data updated successfully.'}
939
        else:
938
    else:
940
            _id = data.pop('_id')
939
        _id = data.pop('_id')
941
            skuBundleId = data.pop('skuBundleId')
940
        skuBundleId = data.pop('skuBundleId')
942
            get_mongo_connection().MasterData.Catalog.update({'_id':_id},{"$set":data},upsert=False)
941
        get_mongo_connection().Catalog.MasterData.update({'_id':_id},{"$set":data},upsert=False)
943
            similarItems = get_mongo_connection().Catalog.MasterData.find({'skuBundleId':skuBundleId})
942
        similarItems = get_mongo_connection().Catalog.MasterData.find({'skuBundleId':skuBundleId})
944
            for item in similarItems:
943
        for item in similarItems:
945
                if item['_id'] == data['_id']:
944
            if item['_id'] == data['_id']:
946
                    continue
945
                continue
947
                item['updatedOn'] = to_java_date(datetime.now())
946
            item['updatedOn'] = to_java_date(datetime.now())
948
                item['thumbnail'] = data['thumbnail']
947
            item['thumbnail'] = data['thumbnail']
949
                item['category'] = data['category']
948
            item['category'] = data['category']
950
                item['category_id'] = data['category_id']
949
            item['category_id'] = data['category_id']
951
                item['tagline'] = data['tagline']
950
            item['tagline'] = data['tagline']
952
                item['is_shortage'] = data['is_shortage']
951
            item['is_shortage'] = data['is_shortage']
953
                item['mrp'] = data['mrp']
952
            item['mrp'] = data['mrp']
954
                get_mongo_connection().Catalog.MasterData.update({'_id':item['_id']},{"$set":item},upsert=False)
953
            get_mongo_connection().Catalog.MasterData.update({'_id':item['_id']},{"$set":item},upsert=False)
955
            return {1:'Data updated successfully.'}
954
        return {1:'Data updated successfully.'}
956
    except Exception as e:
-
 
957
        print e
-
 
958
        return {1:'Unable to update data'}            
-
 
959
        
955
        
960
def main():
956
def main():
961
    print __getBundledSkusfromSku(1)
957
    print __getBundledSkusfromSku(1)
962
    
958
    
963
    
959