Subversion Repositories SmartDukaan

Rev

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

Rev 17603 Rev 17604
Line 7... Line 7...
7
    user_actions, Brands, app_offers, approved_app_transactions, user_app_cashbacks, \
7
    user_actions, Brands, app_offers, approved_app_transactions, user_app_cashbacks, \
8
    user_app_installs, appmasters, notification_campaigns
8
    user_app_installs, appmasters, notification_campaigns
9
from dtr.storage.MemCache import MemCache
9
from dtr.storage.MemCache import MemCache
10
from dtr.utils.MailSender import Email
10
from dtr.utils.MailSender import Email
11
from dtr.utils.utils import to_java_date, CB_PENDING, CB_APPROVED, CB_INIT, \
11
from dtr.utils.utils import to_java_date, CB_PENDING, CB_APPROVED, CB_INIT, \
12
    to_py_date, CB_REJECTED
12
    to_py_date, CB_REJECTED, SUB_CATEGORY_MAP
13
from sqlalchemy.sql.expression import func, func, or_, desc, asc, case
13
from sqlalchemy.sql.expression import func, func, or_, desc, asc, case
14
from elixir import *
14
from elixir import *
15
from operator import itemgetter
15
from operator import itemgetter
16
from pymongo.command_cursor import CommandCursor
16
from pymongo.command_cursor import CommandCursor
17
import pymongo
17
import pymongo
Line 1391... Line 1391...
1391
        data['secondaryIdentifier'] = str(data['secondaryIdentifier'])
1391
        data['secondaryIdentifier'] = str(data['secondaryIdentifier'])
1392
        data['model_name'] = str(data['model_name'])
1392
        data['model_name'] = str(data['model_name'])
1393
        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:
1394
        if data['category_id'] ==6 and data['subCategoryId'] ==0:
1395
            raise
1395
            raise
-
 
1396
        data['subCategory'] = SUB_CATEGORY_MAP.get(data['subCategoryId'])
1396
        get_mongo_connection().Catalog.MasterData.insert(data)
1397
        get_mongo_connection().Catalog.MasterData.insert(data)
1397
        return {1:'Data added successfully'}
1398
        return {1:'Data added successfully'}
1398
    except Exception as e:
1399
    except Exception as e:
1399
        print e
1400
        print e
1400
        return {0:'Unable to add data.'}
1401
        return {0:'Unable to add data.'}
Line 1412... Line 1413...
1412
        data['secondaryIdentifier'] = str(data['secondaryIdentifier'])
1413
        data['secondaryIdentifier'] = str(data['secondaryIdentifier'])
1413
        data['model_name'] = str(data['model_name'])
1414
        data['model_name'] = str(data['model_name'])
1414
        data['brand_id'] = __getBrandIdForBrand(data['brand'], data['category_id'])
1415
        data['brand_id'] = __getBrandIdForBrand(data['brand'], data['category_id'])
1415
        if data['category_id'] ==6 and data['subCategoryId'] ==0:
1416
        if data['category_id'] ==6 and data['subCategoryId'] ==0:
1416
            raise
1417
            raise
-
 
1418
        data['subCategory'] = SUB_CATEGORY_MAP.get(data['subCategoryId'])
1417
        get_mongo_connection().Catalog.MasterData.insert(data)
1419
        get_mongo_connection().Catalog.MasterData.insert(data)
1418
        return {1:'Data added successfully.'}
1420
        return {1:'Data added successfully.'}
1419
    except Exception as e:
1421
    except Exception as e:
1420
        print e
1422
        print e
1421
        return {0:'Unable to add data.'}
1423
        return {0:'Unable to add data.'}
Line 1433... Line 1435...
1433
            data['secondaryIdentifier'] = str(data['secondaryIdentifier'])
1435
            data['secondaryIdentifier'] = str(data['secondaryIdentifier'])
1434
            data['model_name'] = str(data['model_name'])
1436
            data['model_name'] = str(data['model_name'])
1435
            data['brand_id'] = __getBrandIdForBrand(data['brand'], data['category_id'])
1437
            data['brand_id'] = __getBrandIdForBrand(data['brand'], data['category_id'])
1436
            if data['category_id'] ==6 and data['subCategoryId'] ==0:
1438
            if data['category_id'] ==6 and data['subCategoryId'] ==0:
1437
                raise
1439
                raise
-
 
1440
            data['subCategory'] = SUB_CATEGORY_MAP.get(data['subCategoryId'])
1438
            get_mongo_connection().Catalog.MasterData.update({'_id':_id},{"$set":data},upsert=False)
1441
            get_mongo_connection().Catalog.MasterData.update({'_id':_id},{"$set":data},upsert=False)
1439
            return {1:'Data updated successfully.'}
1442
            return {1:'Data updated successfully.'}
1440
        else:
1443
        else:
1441
            _id = data.pop('_id')
1444
            _id = data.pop('_id')
1442
            skuBundleId = data.pop('skuBundleId')
1445
            skuBundleId = data.pop('skuBundleId')
Line 1445... Line 1448...
1445
            data['secondaryIdentifier'] = str(data['secondaryIdentifier'])
1448
            data['secondaryIdentifier'] = str(data['secondaryIdentifier'])
1446
            data['brand_id'] = __getBrandIdForBrand(data['brand'], data['category_id'])
1449
            data['brand_id'] = __getBrandIdForBrand(data['brand'], data['category_id'])
1447
            data['model_name'] = str(data['model_name'])
1450
            data['model_name'] = str(data['model_name'])
1448
            if data['category_id'] ==6 and data['subCategoryId'] ==0:
1451
            if data['category_id'] ==6 and data['subCategoryId'] ==0:
1449
                raise
1452
                raise
-
 
1453
            data['subCategory'] = SUB_CATEGORY_MAP.get(data['subCategoryId'])
1450
            get_mongo_connection().Catalog.MasterData.update({'_id':_id},{"$set":data},upsert=False)
1454
            get_mongo_connection().Catalog.MasterData.update({'_id':_id},{"$set":data},upsert=False)
1451
            similarItems = get_mongo_connection().Catalog.MasterData.find({'skuBundleId':skuBundleId})
1455
            similarItems = get_mongo_connection().Catalog.MasterData.find({'skuBundleId':skuBundleId})
1452
            for item in similarItems:
1456
            for item in similarItems:
1453
                if item['_id'] == _id:
1457
                if item['_id'] == _id:
1454
                    continue
1458
                    continue