Subversion Repositories SmartDukaan

Rev

Rev 7281 | Rev 7367 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
94 ashish 1
'''
2
Created on 23-Mar-2010
3
 
4
@author: ashish
5
'''
7272 amit.gupta 6
from shop2020.model.v1.catalog.impl.DataService import Insurer
6511 kshitij.so 7
from shop2020.thriftpy.model.v1.catalog.ttypes import Item, Category, \
8
    SourceItemPricing, Source, ItemType, \
5110 mandeep.dh 9
    ProductNotificationRequest as TProductNotificationRequest, \
10
    ProductNotificationRequestCount as TProductNotificationRequestCount, \
7281 kshitij.so 11
    VoucherItemMapping, EntityTag as TEntityTag, Banner as TBanner, BannerMap as TBannerMap, \
12
    Insurer as TInsurer, BrandInfo as TBrandInfo, Amazonlisted as TAmazonlisted
5110 mandeep.dh 13
from shop2020.utils.Utils import to_java_date
94 ashish 14
 
15
def to_t_item(item):
16
    t_item = Item()
576 chandransh 17
    if item is None:
18
        return t_item
94 ashish 19
    t_item.id = item.id
963 chandransh 20
    t_item.productGroup = item.product_group
21
    t_item.brand = item.brand
591 chandransh 22
    t_item.modelNumber = item.model_number
23
    t_item.modelName = item.model_name
609 chandransh 24
    t_item.color = item.color
591 chandransh 25
    t_item.category = item.category
122 ashish 26
    t_item.catalogItemId = item.catalog_item_id
27
    t_item.weight = item.weight
28
    t_item.featureId = item.feature_id
29
    t_item.featureDescription = item.feature_description
30
    if item.startDate:
31
        t_item.startDate = to_java_date(item.startDate)
5217 amit.gupta 32
    if item.comingSoonStartDate:
33
        t_item.comingSoonStartDate = to_java_date(item.comingSoonStartDate)
34
    if item.expectedArrivalDate:
35
        t_item.expectedArrivalDate = to_java_date(item.expectedArrivalDate)
122 ashish 36
    if item.addedOn:
37
        t_item.addedOn = to_java_date(item.addedOn)
609 chandransh 38
    if item.updatedOn:
39
        t_item.updatedOn = to_java_date(item.updatedOn)
122 ashish 40
    t_item.itemStatus = item.status
2035 rajveer 41
    t_item.status_description = item.status_description
501 rajveer 42
    if item.sellingPrice:
609 chandransh 43
        t_item.sellingPrice = item.sellingPrice
630 chandransh 44
    if item.mrp:
501 rajveer 45
        t_item.mrp = item.mrp    
122 ashish 46
 
2028 ankur.sing 47
    if item.comments:
48
        t_item.comments = item.comments
609 chandransh 49
    if item.bestDealText:
50
        t_item.bestDealText = item.bestDealText
6777 vikram.rag 51
    if item.bestDealsDetailsText:
52
        t_item.bestDealsDetailsText = item.bestDealsDetailsText
53
    if item.bestDealsDetailsLink:
54
        t_item.bestDealsDetailsLink = item.bestDealsDetailsLink 
609 chandransh 55
    if item.bestDealValue:
56
        t_item.bestDealValue = item.bestDealValue
7291 vikram.rag 57
    if item.asin:
58
        t_item.asin = item.asin    
1910 varun.gupt 59
    t_item.defaultForEntity = item.defaultForEntity
2065 ankur.sing 60
    t_item.bestSellingRank = item.bestSellingRank
2251 ankur.sing 61
    t_item.risky = item.risky
3355 chandransh 62
    t_item.expectedDelay = item.expectedDelay
4406 anupam.sin 63
    t_item.isWarehousePreferenceSticky = item.isWarehousePreferenceSticky
4295 varun.gupt 64
    t_item.warrantyPeriod = item.warranty_period
4506 phani.kuma 65
    t_item.preferredVendor = item.preferredVendor
5110 mandeep.dh 66
    t_item.type = ItemType._NAMES_TO_VALUES[item.type]
5385 phani.kuma 67
    t_item.hasItemNo = item.hasItemNo
7256 rajveer 68
    t_item.activeOnStore = item.activeOnStore
6241 amit.gupta 69
    t_item.showSellingPrice = item.showSellingPrice
6805 anupam.sin 70
    t_item.preferredInsurer = item.preferredInsurer
7291 vikram.rag 71
    t_item.holdInventory = item.holdInventory
72
    t_item.defaultInventory = item.defaultInventory
94 ashish 73
    return t_item
122 ashish 74
 
6805 anupam.sin 75
def to_t_insurer(insurer):
76
    t_insurer = TInsurer()
77
    t_insurer.id = insurer.id
78
    t_insurer.name = insurer.name 
79
    t_insurer.address = insurer.address
6903 anupam.sin 80
    t_insurer.declaredAmount = insurer.declaredAmount
81
    t_insurer.creditedAmount = insurer.creditedAmount
6805 anupam.sin 82
    return t_insurer
83
 
5504 phani.kuma 84
def to_t_voucher_item_mapping(voucher):
85
    t_voucher = VoucherItemMapping()
86
    t_voucher.voucherType = voucher.voucherType
87
    t_voucher.itemId = voucher.item.id
88
    t_voucher.amount = voucher.amount
89
    return t_voucher
90
 
1970 rajveer 91
def to_t_category(category):
92
    t_category = Category()
93
    t_category.id = category.id
94
    t_category.label = category.label
95
    t_category.description = category.description
96
    t_category.parent_category_id = category.parent_category_id
4762 phani.kuma 97
    t_category.display_name = category.display_name
3557 rajveer 98
    return t_category
99
 
100
def to_t_source_item_pricing(source_item_pricing):
101
    t_source_item_pricing = SourceItemPricing()
102
    t_source_item_pricing.sourceId = source_item_pricing.source.id
103
    t_source_item_pricing.itemId = source_item_pricing.item.id
104
    t_source_item_pricing.mrp = source_item_pricing.mrp
105
    t_source_item_pricing.sellingPrice = source_item_pricing.sellingPrice
106
    return t_source_item_pricing
107
 
108
def to_t_source(source):
109
    t_source = Source()
110
    t_source.id = source.id
111
    t_source.name = source.name
112
    t_source.identifier = source.identifier
113
    return t_source
4295 varun.gupt 114
 
115
def to_t_product_notification_request(product_notification_request):
116
    t_product_notification_request = TProductNotificationRequest()
117
 
118
    if product_notification_request:
119
        t_product_notification_request.item = to_t_item(product_notification_request.item)
120
        t_product_notification_request.email = product_notification_request.email
121
        t_product_notification_request.addedOn = to_java_date(product_notification_request.addedOn)
122
 
123
    return t_product_notification_request
124
 
125
def to_t_product_notification_request_count(product_notification_request_count):
126
 
127
    t_product_notification_request_count = TProductNotificationRequestCount()
128
 
129
    if product_notification_request_count:
130
        item, count = product_notification_request_count
131
        t_product_notification_request_count.item = to_t_item(item)
132
        t_product_notification_request_count.count = count
133
 
6511 kshitij.so 134
    return t_product_notification_request_count
135
 
136
def to_t_entity_tag(entity_tag):
137
    t_entity_tag = TEntityTag()
138
    t_entity_tag.entityId = entity_tag.entityId
6848 kshitij.so 139
    t_entity_tag.tag = entity_tag.tag
140
 
141
def to_t_banner(banner):
142
    t_banner = TBanner()
143
    t_banner.bannerName = banner.bannerName
144
    t_banner.imageName = banner.imageName
145
    t_banner.link = banner.link
146
    t_banner.priority = banner.priority
147
    t_banner.isActive = banner.isActive
148
    t_banner.hasMap = banner.hasMap
149
    return t_banner
150
 
151
def to_t_banner_map(banner_map):
152
    t_banner_map = TBannerMap()
153
    t_banner_map.bannerName = banner_map.bannerName
154
    t_banner_map.mapLink = banner_map.mapLink
155
    t_banner_map.coordinates = banner_map.coordinates
156
    return t_banner_map
7272 amit.gupta 157
 
7281 kshitij.so 158
def to_t_Amazonlisted(Amazonlisted):
159
    t_amazonlisted = TAmazonlisted()
160
    t_amazonlisted.asin = Amazonlisted.asin
161
    t_amazonlisted.brand = Amazonlisted.brand 
162
    t_amazonlisted.itemid = Amazonlisted.itemId
163
    t_amazonlisted.model = Amazonlisted.model
164
    t_amazonlisted.manufacturer_name = Amazonlisted.manufacturer_name
165
    t_amazonlisted.upc = Amazonlisted.upc
166
    t_amazonlisted.part_number = Amazonlisted.part_number
167
    t_amazonlisted.name = Amazonlisted.name
168
    t_amazonlisted.ean = Amazonlisted.ean
169
    t_amazonlisted.fbaPrice = Amazonlisted.fbaPrice
170
    t_amazonlisted.sellingPrice = Amazonlisted.sellingPrice
171
    t_amazonlisted.isFba = Amazonlisted.isFba
172
    t_amazonlisted.isNonFba = Amazonlisted.isNonFba
173
    t_amazonlisted.isInventoryOverride = Amazonlisted.isInventoryOverride
174
    t_amazonlisted.color = Amazonlisted.color
175
    t_amazonlisted.category = Amazonlisted.category
7291 vikram.rag 176
    return t_amazonlisted
177