Rev 7256 | Rev 7281 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on 23-Mar-2010@author: ashish'''from shop2020.model.v1.catalog.impl.DataService import Insurerfrom shop2020.thriftpy.model.v1.catalog.ttypes import Item, Category, \SourceItemPricing, Source, ItemType, \ProductNotificationRequest as TProductNotificationRequest, \ProductNotificationRequestCount as TProductNotificationRequestCount, \VoucherItemMapping, EntityTag as TEntityTag, Banner as TBanner, \BannerMap as TBannerMap, Insurer as TInsurer, BrandInfo as TBrandInfofrom shop2020.utils.Utils import to_java_datedef to_t_item(item):t_item = Item()if item is None:return t_itemt_item.id = item.idt_item.productGroup = item.product_groupt_item.brand = item.brandt_item.modelNumber = item.model_numbert_item.modelName = item.model_namet_item.color = item.colort_item.category = item.categoryt_item.catalogItemId = item.catalog_item_idt_item.weight = item.weightt_item.featureId = item.feature_idt_item.featureDescription = item.feature_descriptionif item.startDate:t_item.startDate = to_java_date(item.startDate)if item.comingSoonStartDate:t_item.comingSoonStartDate = to_java_date(item.comingSoonStartDate)if item.expectedArrivalDate:t_item.expectedArrivalDate = to_java_date(item.expectedArrivalDate)if item.addedOn:t_item.addedOn = to_java_date(item.addedOn)if item.updatedOn:t_item.updatedOn = to_java_date(item.updatedOn)t_item.itemStatus = item.statust_item.status_description = item.status_descriptionif item.sellingPrice:t_item.sellingPrice = item.sellingPriceif item.mrp:t_item.mrp = item.mrpif item.comments:t_item.comments = item.commentsif item.bestDealText:t_item.bestDealText = item.bestDealTextif item.bestDealsDetailsText:t_item.bestDealsDetailsText = item.bestDealsDetailsTextif item.bestDealsDetailsLink:t_item.bestDealsDetailsLink = item.bestDealsDetailsLinkif item.bestDealValue:t_item.bestDealValue = item.bestDealValuet_item.defaultForEntity = item.defaultForEntityt_item.bestSellingRank = item.bestSellingRankt_item.risky = item.riskyt_item.expectedDelay = item.expectedDelayt_item.isWarehousePreferenceSticky = item.isWarehousePreferenceStickyt_item.warrantyPeriod = item.warranty_periodt_item.preferredVendor = item.preferredVendort_item.type = ItemType._NAMES_TO_VALUES[item.type]t_item.hasItemNo = item.hasItemNot_item.activeOnStore = item.activeOnStoret_item.showSellingPrice = item.showSellingPricet_item.preferredInsurer = item.preferredInsurerreturn t_itemdef to_t_insurer(insurer):t_insurer = TInsurer()t_insurer.id = insurer.idt_insurer.name = insurer.namet_insurer.address = insurer.addresst_insurer.declaredAmount = insurer.declaredAmountt_insurer.creditedAmount = insurer.creditedAmountreturn t_insurerdef to_t_voucher_item_mapping(voucher):t_voucher = VoucherItemMapping()t_voucher.voucherType = voucher.voucherTypet_voucher.itemId = voucher.item.idt_voucher.amount = voucher.amountreturn t_voucherdef to_t_category(category):t_category = Category()t_category.id = category.idt_category.label = category.labelt_category.description = category.descriptiont_category.parent_category_id = category.parent_category_idt_category.display_name = category.display_namereturn t_categorydef to_t_source_item_pricing(source_item_pricing):t_source_item_pricing = SourceItemPricing()t_source_item_pricing.sourceId = source_item_pricing.source.idt_source_item_pricing.itemId = source_item_pricing.item.idt_source_item_pricing.mrp = source_item_pricing.mrpt_source_item_pricing.sellingPrice = source_item_pricing.sellingPricereturn t_source_item_pricingdef to_t_source(source):t_source = Source()t_source.id = source.idt_source.name = source.namet_source.identifier = source.identifierreturn t_sourcedef to_t_product_notification_request(product_notification_request):t_product_notification_request = TProductNotificationRequest()if product_notification_request:t_product_notification_request.item = to_t_item(product_notification_request.item)t_product_notification_request.email = product_notification_request.emailt_product_notification_request.addedOn = to_java_date(product_notification_request.addedOn)return t_product_notification_requestdef to_t_product_notification_request_count(product_notification_request_count):t_product_notification_request_count = TProductNotificationRequestCount()if product_notification_request_count:item, count = product_notification_request_countt_product_notification_request_count.item = to_t_item(item)t_product_notification_request_count.count = countreturn t_product_notification_request_countdef to_t_entity_tag(entity_tag):t_entity_tag = TEntityTag()t_entity_tag.entityId = entity_tag.entityIdt_entity_tag.tag = entity_tag.tagdef to_t_banner(banner):t_banner = TBanner()t_banner.bannerName = banner.bannerNamet_banner.imageName = banner.imageNamet_banner.link = banner.linkt_banner.priority = banner.priorityt_banner.isActive = banner.isActivet_banner.hasMap = banner.hasMapreturn t_bannerdef to_t_banner_map(banner_map):t_banner_map = TBannerMap()t_banner_map.bannerName = banner_map.bannerNamet_banner_map.mapLink = banner_map.mapLinkt_banner_map.coordinates = banner_map.coordinatesreturn t_banner_mapdef to_t_brand_info(brand_info):t_brand_info = TBrandInfo()t_brand_info.name = brand_info.namet_brand_info.serviceCenterLocatorUrl = brand_info.serviceCenterLocatorUrlreturn t_brand_info