class ISubscribe(Interface): """ 電子報訂閱清單 """ subscribeList = schema.List( title=_(u"Subscribe List"), value_type=schema.TextLine(title=_(u'Subscribe'), required=False,), required=False, )
class IBrand(Interface): """ 品牌 & 主題 """ title = schema.TextLine( title=_(u"Brand or Category Title"), required=True, ) nickname = schema.Text( title=_(u"Brand Nickname or Category Keywords"), description=_("Please listing all nickname that about this brand. For example, Microfost and MS, Separated by commas."), required=True, ) """ bannerImage = NamedBlobImage( title=_(u"Banner Image"), description=_(u"Banner image, about 1500X350 around."), required=True, )""" image = NamedBlobImage( title=_(u"Brand or Category Logo"), description=_(u"Brand or category logo image"), required=True, )
class IQuestion(Interface): """ 專家給問 """ title = schema.TextLine( title=_(u"Question Title"), required=True, ) form.mode(description='hidden') description = schema.Text( title=_(u"Question Detail"), required=False, ) question = RichText( title=_(u"Question Detail"), default_mime_type='text/plain', allowed_mime_types=['text/plain', 'text/plain'], required=True, ) form.write_permission(image='cmf.ReviewPortalContent') image = NamedBlobImage( title=_(u"Image"), description=_(u"If want to show this page to home page, please upload a image."), required=False, )
class IBannerImage(model.Schema): """Add banner image to content """ bannerImage = NamedBlobImage( title=_(u"Banner Image"), description=_(u"Banner image, about 1500X350 around."), required=True, )
def importProducts(folder, event): """ Import Products """ if not folder.productsFile: return if folder.productsFile.filename != '%s.zip' % folder.id: message = _(u"file name must be same as provider id and extension is zip.") api.portal.show_message(message=message, request=folder.REQUEST, type='error') folder.productsFile = None folder.reindexObject() return portal = api.portal.get() catalog = api.portal.get_tool(name='portal_catalog') zipFolderName = '/tmp/%s' % folder.id zipFileName = '%s.zip' % folder.id with open('/tmp/%s' % zipFileName, 'w') as file: file.write(folder.productsFile.data) with open('/tmp/%s' % zipFileName) as file: zf = zipfile.ZipFile(file) zf.extractall('/tmp') # import pdb; pdb.set_trace() csvPath = '%s/%s.csv' % (zipFolderName, folder.id) with open(csvPath, 'rb') as file: for row in csv.DictReader(file): # import pdb; pdb.set_trace() brain = catalog({'Type':'Product', 'productId':row['productId'], 'parentId':folder.id}) if brain: try: modifyItem(brain, row, zipFolderName) except: logger.error('%s: productId:position 1, %s, title:%s' % ( safe_unicode(_(u"Import product error")), safe_unicode(row['productId']), safe_unicode(row['title']),) ) continue else: try: creatItem(folder, row, zipFolderName) except: logger.error('%s: productId:position 2, %s, title:%s' % ( safe_unicode(_(u"Import product error")), safe_unicode(row['productId']), safe_unicode(row['title']),) ) continue folder.productsFile = None folder.reindexObject()
class IProvider(Interface): """ 供應商檔案 """ title = schema.TextLine( title=_(u"Provider Name"), required=True, ) description = schema.Text( title=_(u"Description"), required=False, ) image = NamedBlobImage( title=_(u"Provider Logo"), description=_(u"Provider logo image"), required=False, ) webSite = schema.URI( title=_(u"Website"), description=_(u"Provider website url, must include http:// or https://"), required=False, ) form.write_permission(productsFile='cmf.ReviewPortalContent') productsFile = NamedBlobFile( title=_(u"Products File"), description=_(u"zip file, include a .cvs file and image files"), required=False, )
class IAnswer(Interface): """ 回答(for 專家給問) """ form.mode(title='hidden') title = schema.TextLine( title=_(u"Title"), required=False, ) text = RichText( title=_(u"Reply Question"), default_mime_type='text/plain', allowed_mime_types=['text/plain', 'text/plain'], required=True, )
class IPost(Interface): """ 貼文分享 """ title = schema.TextLine( title=_(u"Title"), required=True, ) form.write_permission(image='cmf.ReviewPortalContent') image = NamedBlobImage( title=_(u"Image"), description=_(u"If want to show this page to home page, please upload a image."), required=False, ) form.write_permission(shortText='cmf.ReviewPortalContent') shortText = schema.TextLine( title=_(u"Short Text"), description=_(u"Short Text, show in Cover."), required=False, ) url = schema.URI( title=_(u"URL"), required=False, ) text = RichText( title=_(u"Text"), default_mime_type='text/html', allowed_mime_types=['text/html', 'text/plain'], required=True, )
def modifyItem(brain, row, zipFolderName): if len(brain) > 1: logger.error('%s: productId:%s, title:%s' % ( safe_unicode(_(u"Brain more than 1 item")), safe_unicode(brain[0].productId), safe_unicode(brain[0].title),) ) item = brain[0].getObject() item.title=row['title'] item.description=row['description'] item.productUrl=row['productUrl'] item.inStock=True if row['inStock'].strip().lower() == 'y' else False item.brand=row['brand'] item.listPrice=int(row['listPrice']) item.salePrice=int(row['salePrice']) item.standardShippingCost=int(row['standardShippingCost']) item.setSubject(tuple(row['subjects'].split(','))) try: if row['image_1'].strip(): with open('%s/%s' % (zipFolderName, safe_unicode(row['image_1'].strip()))) as file: item.image_1 = namedfile.NamedBlobImage(data=file, filename=safe_unicode('%s' % file.name.split('/')[-1])) except:pass try: if row['image_2'].strip(): with open('%s/%s' % (zipFolderName, safe_unicode(row['image_2'].strip()))) as file: item.image_2 = namedfile.NamedBlobImage(data=file, filename=safe_unicode('%s' % file.name.split('/')[-1])) except:pass try: if row['image_3'].strip(): with open('%s/%s' % (zipFolderName, safe_unicode(row['image_3'].strip()))) as file: item.image_3 = namedfile.NamedBlobImage(data=file, filename=safe_unicode('%s' % file.name.split('/')[-1])) except:pass try: if row['image_4'].strip(): with open('%s/%s' % (zipFolderName, safe_unicode(row['image_4'].strip()))) as file: item.image_4 = namedfile.NamedBlobImage(data=file, filename=safe_unicode('%s' % file.name.split('/')[-1])) except:pass try: if row['image_5'].strip(): with open('%s/%s' % (zipFolderName, safe_unicode(row['image_5'].strip()))) as file: item.image_5 = namedfile.NamedBlobImage(data=file, filename=safe_unicode('%s' % file.name.split('/')[-1])) except:pass item.promotionalText = RichTextValue(safe_unicode(row['promotionalText'])) item.reindexObject() transaction.commit()
def __call__(self): context = self.context request = self.request response = request.response catalog = context.portal_catalog portal = api.portal.get() if not request.form.get('email'): response.redirect(portal.absolute_url()) return if not request.form.get('g-recaptcha-response'): return self.template() secret = api.portal.get_registry_record( 'i8d.content.browser.coverSetting.ICoverSetting.googleSecret') postUrl = 'https://www.google.com/recaptcha/api/siteverify' data = { 'secret': secret, 'response': request.form.get('g-recaptcha-response'), 'remoteip': request.get('REMOTE_ADDR'), } recaptchaResult = json.loads(self.post(postUrl, data)) email = request.form.get('email') if not (recaptchaResult.get('success') and email): response.redirect(portal.absolute_url()) return subscribe = portal['resource']['subscribe'] if email not in subscribe.subscribeList: subscribe.subscribeList.append(email) transaction.commit() api.portal.show_message( message=_(u'You are already subscribe, thanks.'), request=request, type='info') response.redirect(portal.absolute_url()) return
from i8d.content import _ from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm ORDER_STATE = SimpleVocabulary( [SimpleTerm(value=u'ordered', title=_(u'ordered')), SimpleTerm(value=u'paid', title=_(u'paid')), SimpleTerm(value=u'shipped', title=_(u'shipped')), SimpleTerm(value=u'arrived', title=_(u'arrived')), SimpleTerm(value=u'inreturn', title=_(u'inreturn')), SimpleTerm(value=u'returned', title=_(u'returned')), SimpleTerm(value=u'overdue', title=_(u'overdue')),] )
class ICover(Interface): """ 首頁 """ title = schema.TextLine( title=_(u"Title"), required=True, ) description = schema.Text( title=_(u"Description"), required=False, ) heros = RelationList( title=_(u"Heros"), description=_(u"Rleated items for hero section"), value_type=RelationChoice(title=_(u"Related"), source=CatalogSource(portal_type='Product'),), required=True, ) newProduct = RelationList( title=_(u"New Product"), description=_(u"Rleated items for home page new product list"), value_type=RelationChoice(title=_(u"Related"), source=CatalogSource(portal_type='Product'),), required=True, ) hotProduct = RelationList( title=_(u"Hot Product"), description=_(u"Rleated items for home page not product list"), value_type=RelationChoice(title=_(u"Related"), source=CatalogSource(portal_type='Product'),), required=True, ) article = RelationList( title=_(u"Article"), description=_(u"Rleated items for home page article list"), value_type=RelationChoice(title=_(u"Related"), source=CatalogSource(portal_type='Post', path='/i8d/ishare', review_state='published'),), required=True, ) healthy = RelationList( title=_(u"Healthy"), description=_(u"Rleated items for home page article list"), value_type=RelationChoice(title=_(u"Related"), source=CatalogSource(portal_type='Post', path='/i8d/healthy', review_state='published'),), required=True, ) # 先改為 post 給健康專欄用, 以後看狀況再改 question = RelationList( title=_(u"Question"), description=_(u"Rleated items for home page question list"), value_type=RelationChoice(title=_(u"Related"), source=CatalogSource(portal_type='Question', ),), required=True, )
def __call__(self): context = self.context request = self.request response = request.response catalog = context.portal_catalog itemInCart = request.cookies.get('itemInCart', '') itemInCart_list = itemInCart.split() portal = api.portal.get() if request.form.get( 'LogisticsType') == 'home' and not request.form.get('address'): api.portal.show_message( message=_(u'Please fill full address information'), request=request, type='error') response.redirect('%s/@@checkout_confirm' % portal.absolute_url()) return if api.user.is_anonymous(): profile = None else: currentId = api.user.get_current().getId() profile = portal['members'][currentId] brain = catalog({'UID': itemInCart_list}) totalAmount = 0 itemName = '' itemDescription = '' productUIDs = {} shippingFee = 0 discount = 0 # specialDiscount , 滿3000折520 specialDiscount = 0 for item in brain: qty = int(request.cookies.get(item.UID, 1)) productUIDs[item.UID] = qty totalAmount += item.salePrice * qty itemName += '%s $%s X %s#' % (item.Title, item.salePrice, qty) itemDescription += '%s: $%s X %s || ' % (item.Title, item.salePrice, qty) shippingFee += item.standardShippingCost if not api.user.is_anonymous(): discount += int(item.salePrice * item.maxUsedBonus) * int( request.cookies.get(item.UID, 1)) # 計算是否滿3000,是就折520 / 本活動已於8/24結束 # if totalAmount >= 3000: # specialDiscount = 520 # 8/25 開始促銷 start if totalAmount >= 5000: itemName += ', 滿5000加贈皇家珍珠鈣(100顆)' itemDescription += ', 滿3000加贈皇家珍珠鈣(100顆)' elif totalAmount >= 3000: itemName += ', 滿3000加贈皇家珍珠鈣(50顆)' itemDescription += ', 滿3000加贈皇家珍珠鈣(50顆)' # 8/25 開始促銷 end totalAmount += shippingFee if profile: if request.form['usingbonus'] == 'n': discount = 0 if discount > profile.bonus: discount = profile.bonus totalAmount -= discount # 折抵 Special Discount totalAmount -= specialDiscount itemName += 'shipping Fee: %s, discount: %s' % (shippingFee, discount) itemDescription += 'shipping Fee: %s, discount: %s' % (shippingFee, discount) # Special Discount資訊 if specialDiscount > 0: itemName += ', Special Discount: %s' % (specialDiscount) itemDescription += ', Special Discount: %s' % (specialDiscount) else: itemName += 'shipping Fee: %s' % (shippingFee) itemDescription += 'shipping Fee: %s' % (shippingFee) # 折抵 Special Discount totalAmount -= specialDiscount # Special Discount資訊 if specialDiscount > 0: itemName += ', Special Discount: %s' % (specialDiscount) itemDescription += ', Special Discount: %s' % (specialDiscount) merchantTradeNo = '%s%s' % (DateTime().strftime('%Y%m%d%H%M%S'), random.randint(10000, 99999)) portal = api.portal.get() with api.env.adopt_roles(['Manager']): # import pdb ;pdb.set_trace() order = api.content.create( type='Order', title=merchantTradeNo, description='%s, Total: $%s' % (itemDescription, totalAmount), productUIDs=productUIDs, amount=totalAmount, receiver=request.form.get('receiver', ''), phone=request.form.get('phone', ''), cellPhone=request.form.get('cellphone', ''), email=request.form.get('email', ''), addr_city=request.form.get('city', ''), addr_district=request.form.get('district', ''), addr_zip=request.form.get('zipcode', ''), addr_address=request.form.get('address', ''), taxId=request.form.get('taxid', ''), companyTitle=request.form.get('companytitle', ''), container=portal['resource']['order'], ) if profile: profile.bonus -= discount else: api.content.transition(obj=order, transition='publish') transaction.commit() paymentInfoURL = api.portal.get_registry_record( 'i8d.content.browser.coverSetting.ICoverSetting.paymentInfoURL') clientBackURL = api.portal.get_registry_record( 'i8d.content.browser.coverSetting.ICoverSetting.clientBackURL') payment_info = { 'TotalAmount': totalAmount, 'ChoosePayment': 'ALL', 'MerchantTradeNo': merchantTradeNo, 'ItemName': itemName, 'PaymentInfoURL': paymentInfoURL, 'ClientBackURL': '%s?MerchantTradeNo=%s&LogisticsType=%s&LogisticsSubType=%s' % (clientBackURL, merchantTradeNo, request.form.get('LogisticsType', 'cvs'), request.form.get('LogisticsSubType', 'UNIMART')), #可以使用 get 帶參數 } ap = AllPay(payment_info) # check out, this will return a dictionary containing checkValue...etc. dict_url = ap.check_out() # generate the submit form html. form_html = ap.gen_check_out_form(dict_url) return form_html
class ICoverSetting(Form.Schema): serviceExplanation = schema.Text( title=_(u"Service Explanation"), description=_(u"Header service explanation"), required=False, ) brandShowInNav = schema.Text( title=_(u"Brand Show In Nav"), description=_(u"help_show_in_nav"), required=False, ) providerShowInNav = schema.Text( title=_(u"Provider Show In Nav"), description=_(u"help_show_in_nav"), required=False, ) productShowInNav = schema.Text( title=_(u"Product Show In Nav"), description=_(u"help_show_in_nav"), required=False, ) """ Basic setting for AllPay """ merchantID = schema.TextLine( title=_(u"Merchant ID"), description=_(u"Merchant ID, for allPay"), required=True, ) """ Checkout(cash flow) setting for AllPay """ checkoutHashKey = schema.TextLine( title=_(u"Checkout Hash Key"), description=_(u"Checkout HashKey, for allPay"), required=True, ) checkoutHashIV = schema.TextLine( title=_(u"Checkout Hash IV"), description=_(u"Checkout Hash IV, for allPay"), required=True, ) aioCheckoutURL = schema.TextLine( title=_(u"All in one(AIO) Checkout Server URL"), description=_(u"aio server url, mapping to allpay aio server url"), required=True, ) paymentInfoURL = schema.TextLine( title=_(u"Payment Info URL"), description=_(u"Payment info url."), required=True, ) clientBackURL = schema.TextLine( title=_(u"Client Back URL"), description=_(u"Client back url."), required=True, ) returnURL = schema.TextLine( title=_(u"Return URL"), description=_(u"Return url, for checkout."), required=True, ) """ Checkout(cash flow) setting for AllPay """ """ Logistics setting for AllPay """ logisticsMapURL = schema.TextLine( title=_(u"Logistics Map URL"), description=_(u"Logistics map url"), required=True, ) logisticsExpressCreateURL = schema.TextLine( title=_(u"Logistics Express Create URL"), description=_("Logistics express create url."), ) logisticsHashKey = schema.TextLine( title=_(u"Logistics Hash Key"), description=_(u"Logistics HashKey, for allPay"), required=True, ) logisticsHashIV = schema.TextLine( title=_(u"Logistics Hash IV"), description=_(u"Logistics Hash IV, for allPay"), required=True, ) serverReplyURL = schema.TextLine( title=_(u"Server Reply URL, for MAP"), description=_(u"ServerReplyURL, for allPay's logistics"), required=True, ) serverReplyURL_Express = schema.TextLine( title=_(u"Server Reply URL, for Express Create"), description=_(u"ServerReplyURL, for allPay's logistics"), required=True, ) clientReplyURL = schema.TextLine( title=_(u"Client Reply URL"), description=_(u"ClientReplyURL, for allPay's logistics"), required=True, ) logisticsC2CReplyURL = schema.TextLine( title=_(u"Logistics C2C Reply URL"), description=_(u"Logistics C2C Reply URL, for allPay's logistics"), required=True, ) """ Logistics setting for AllPay """ initialBonus = schema.Int( title=_(u"Initial Bonus Setting"), description=_(u"Initial Bonus Setting"), default=0, min=0, ) bayesFilter = schema.Text( title=_(u"Bayes Filter"), description=_(u"Keywords filter, using bayes."), required=False, ) googleSecret = schema.TextLine( title=_(u"Google reCAPTCHA Secret"), required=False, )
required=True, ) """ Logistics setting for AllPay """ initialBonus = schema.Int( title=_(u"Initial Bonus Setting"), description=_(u"Initial Bonus Setting"), default=0, min=0, ) bayesFilter = schema.Text( title=_(u"Bayes Filter"), description=_(u"Keywords filter, using bayes."), required=False, ) googleSecret = schema.TextLine( title=_(u"Google reCAPTCHA Secret"), required=False, ) class CoverSettingControlPanelForm(RegistryEditForm): form.extends(RegistryEditForm) schema = ICoverSetting CoverSettingControlPanelView = layout.wrap_form(CoverSettingControlPanelForm, ControlPanelFormWrapper) CoverSettingControlPanelView.label = _(u"Cover Setting")
def __call__(self): context = self.context request = self.request response = request.response catalog = context.portal_catalog itemInCart = request.cookies.get('itemInCart', '') itemInCart_list = itemInCart.split() portal = api.portal.get() if request.form.get('LogisticsType') == 'home' and not request.form.get('address'): api.portal.show_message(message=_(u'Please fill full address information'), request=request, type='error') response.redirect('%s/@@checkout_confirm' % portal.absolute_url()) return if api.user.is_anonymous(): profile = None else: currentId = api.user.get_current().getId() profile = portal['members'][currentId] brain = catalog({'UID':itemInCart_list}) totalAmount = 0 itemName = '' itemDescription = '' productUIDs = {} shippingFee = 0 discount = 0 # specialDiscount , 滿3000折520 specialDiscount = 0 for item in brain: qty = int(request.cookies.get(item.UID, 1)) productUIDs[item.UID] = qty totalAmount += item.salePrice * qty itemName += '%s $%s X %s#' % (item.Title, item.salePrice, qty) itemDescription += '%s: $%s X %s || ' % (item.Title, item.salePrice, qty) shippingFee += item.standardShippingCost if not api.user.is_anonymous(): discount += int(item.salePrice * item.maxUsedBonus) * int(request.cookies.get(item.UID, 1)) # 計算是否滿3000,是就折520 / 本活動已於8/24結束 # if totalAmount >= 3000: # specialDiscount = 520 # 8/25 開始促銷 start if totalAmount >= 5000: itemName += ', 滿5000加贈皇家珍珠鈣(100顆)' itemDescription += ', 滿3000加贈皇家珍珠鈣(100顆)' elif totalAmount >= 3000: itemName += ', 滿3000加贈皇家珍珠鈣(50顆)' itemDescription += ', 滿3000加贈皇家珍珠鈣(50顆)' # 8/25 開始促銷 end totalAmount += shippingFee if profile: if request.form['usingbonus'] == 'n': discount = 0 if discount > profile.bonus: discount = profile.bonus totalAmount -= discount # 折抵 Special Discount totalAmount -= specialDiscount itemName += 'shipping Fee: %s, discount: %s' % (shippingFee, discount) itemDescription += 'shipping Fee: %s, discount: %s' % (shippingFee, discount) # Special Discount資訊 if specialDiscount > 0: itemName += ', Special Discount: %s' % (specialDiscount) itemDescription += ', Special Discount: %s' % (specialDiscount) else: itemName += 'shipping Fee: %s' % (shippingFee) itemDescription += 'shipping Fee: %s' % (shippingFee) # 折抵 Special Discount totalAmount -= specialDiscount # Special Discount資訊 if specialDiscount > 0: itemName += ', Special Discount: %s' % (specialDiscount) itemDescription += ', Special Discount: %s' % (specialDiscount) merchantTradeNo = '%s%s' % (DateTime().strftime('%Y%m%d%H%M%S'), random.randint(10000,99999)) portal = api.portal.get() with api.env.adopt_roles(['Manager']): # import pdb ;pdb.set_trace() order = api.content.create( type='Order', title=merchantTradeNo, description = '%s, Total: $%s' % (itemDescription, totalAmount), productUIDs = productUIDs, amount = totalAmount, receiver = request.form.get('receiver', ''), phone = request.form.get('phone', ''), cellPhone = request.form.get('cellphone', ''), email = request.form.get('email',''), addr_city = request.form.get('city', ''), addr_district = request.form.get('district', ''), addr_zip = request.form.get('zipcode', ''), addr_address = request.form.get('address', ''), taxId = request.form.get('taxid', ''), companyTitle = request.form.get('companytitle', ''), container=portal['resource']['order'], ) if profile: profile.bonus -= discount else: api.content.transition(obj=order, transition='publish') transaction.commit() paymentInfoURL = api.portal.get_registry_record('i8d.content.browser.coverSetting.ICoverSetting.paymentInfoURL') clientBackURL = api.portal.get_registry_record('i8d.content.browser.coverSetting.ICoverSetting.clientBackURL') payment_info = {'TotalAmount': totalAmount, 'ChoosePayment': 'ALL', 'MerchantTradeNo': merchantTradeNo, 'ItemName': itemName, 'PaymentInfoURL': paymentInfoURL, 'ClientBackURL': '%s?MerchantTradeNo=%s&LogisticsType=%s&LogisticsSubType=%s' % (clientBackURL, merchantTradeNo, request.form.get('LogisticsType', 'cvs'), request.form.get('LogisticsSubType', 'UNIMART')), #可以使用 get 帶參數 } ap = AllPay(payment_info) # check out, this will return a dictionary containing checkValue...etc. dict_url = ap.check_out() # generate the submit form html. form_html = ap.gen_check_out_form(dict_url) return form_html
serverReplyURL_Express = schema.TextLine( title=_(u"Server Reply URL, for Express Create"), description=_(u"ServerReplyURL, for allPay's logistics"), required=True, ) clientReplyURL = schema.TextLine( title=_(u"Client Reply URL"), description=_(u"ClientReplyURL, for allPay's logistics"), required=True ) logisticsC2CReplyURL = schema.TextLine( title=_(u"Logistics C2C Reply URL"), description=_(u"Logistics C2C Reply URL, for allPay's logistics"), required=True, ) """ Logistics setting for AllPay """ initialBonus = schema.Int( title=_(u"Initial Bonus Setting"), description=_(u"Initial Bonus Setting"), default=0, min=0 ) class CoverSettingControlPanelForm(RegistryEditForm): form.extends(RegistryEditForm) schema = ICoverSetting CoverSettingControlPanelView = layout.wrap_form(CoverSettingControlPanelForm, ControlPanelFormWrapper) CoverSettingControlPanelView.label = _(u"Cover Setting")
class IProfile(Interface): """ 個人頁面,含專家檔案 """ title = schema.TextLine( title=_(u"Profile Name"), required=True, ) description = schema.Text( title=_(u"Description"), required=False, ) isExpert = schema.Bool( title=_(u"Is Expert"), default=False, required=True, ) image = NamedBlobImage( title=_(u"Expert Image."), description=_(u"Expert image."), required=False, ) phone = schema.TextLine( title=_(u"Phone"), description=_(u"Phone Number."), required=False, ) cellPhone = schema.TextLine( title=_(u"Cell Phone"), description=_(u"Cell Phone number."), required=False, ) email = schema.TextLine( title=_(u"Email"), description=_(u"Email."), required=False, ) addr_city = schema.TextLine( title=_(u"City"), description=_(u"City name."), required=False, ) addr_district = schema.TextLine( title=_(u"District"), description=_(u"District"), required=False, ) addr_zip = schema.TextLine( title=_(u"ZIP Code"), description=_(u"ZIP code"), required=False, ) addr_address = schema.TextLine( title=_(u"Address"), description=_(u"Address"), required=False, ) addr2_city = schema.TextLine( title=_(u"City"), description=_(u"City name."), required=False, ) addr2_district = schema.TextLine( title=_(u"District"), description=_(u"District"), required=False, ) addr2_zip = schema.TextLine( title=_(u"ZIP Code"), description=_(u"ZIP code"), required=False, ) addr2_address = schema.TextLine( title=_(u"Address"), description=_(u"Address"), required=False, ) bonus = schema.Int( title=_(u"Bonus"), description=_(u"Bonus"), default=0, min=0, required=False, )
def creatItem(folder, row, zipFolderName): portal = api.portal.get() logger.info('Begin Create Content, %s' % safe_unicode(row['title'])) if row['listPrice'] and row['salePrice'] and row['standardShippingCost']: pass else: logger.error('Lost data, title:%s, please check "listPirce, saleprice, standardShippingCost"' % row['title']) message = _(u"Lost data, title:%s, please check 'listPirce, saleprice, standardShippingCost'") api.portal.show_message(message=message, request=folder.REQUEST, type='error') item = api.content.create( type='Product', title=row['title'], productId=row['productId'], description=row['description'], productUrl=row['productUrl'], inStock=True if row['inStock'].strip().lower() == 'y' else False, brand=row['brand'], listPrice=int(row['listPrice']), salePrice=int(row['salePrice']), standardShippingCost=int(row['standardShippingCost']), container=portal['products'][folder.id], ) logger.info('Content Created, %s' % safe_unicode(row['title'])) item.setSubject(tuple(row['subjects'].split(','))) if row['image_1'].strip(): with open('%s/%s' % (zipFolderName, safe_unicode(row['image_1'].strip()))) as file: item.image_1 = namedfile.NamedBlobImage(data=file, filename=safe_unicode('%s' % file.name.split('/')[-1])) try: if row['image_2'].strip(): with open('%s/%s' % (zipFolderName, safe_unicode(row['image_2'].strip()))) as file: item.image_2 = namedfile.NamedBlobImage(data=file, filename=safe_unicode('%s' % file.name.split('/')[-1])) except: logger.error('creatItem position 1, title:%s' % title) pass try: if row['image_3'].strip(): with open('%s/%s' % (zipFolderName, safe_unicode(row['image_3'].strip()))) as file: item.image_3 = namedfile.NamedBlobImage(data=file, filename=safe_unicode('%s' % file.name.split('/')[-1])) except: logger.error('creatItem position 2, title:%s' % title) pass try: if row['image_4'].strip(): with open('%s/%s' % (zipFolderName, safe_unicode(row['image_4'].strip()))) as file: item.image_4 = namedfile.NamedBlobImage(data=file, filename=safe_unicode('%s' % file.name.split('/')[-1])) except: logger.error('creatItem position 3, title:%s' % title) pass try: if row['image_5'].strip(): with open('%s/%s' % (zipFolderName, safe_unicode(row['image_5'].strip()))) as file: item.image_5 = namedfile.NamedBlobImage(data=file, filename=safe_unicode('%s' % file.name.split('/')[-1])) except: logger.error('creatItem position 4, title:%s' % title) pass item.promotionalText = RichTextValue(safe_unicode(row['promotionalText'])) item.reindexObject() transaction.commit() logger.info('Commit OK, %s' % safe_unicode(row['title']))
class IOrder(Interface): """ 訂單 """ title = schema.TextLine( title=_(u"Order Title"), description=_(u"Mapping to allPay's MerchantTradeNo"), required=True, ) description = schema.Text( title=_(u"Description"), description=_(u"Mapping to allPay's ItemName"), required=False, ) receiver = schema.TextLine( title=_(u"Receiver"), description=_(u"Receiver name."), required=False, ) phone = schema.TextLine( title=_(u"Phone"), description=_(u"Phone Number."), required=False, ) cellPhone = schema.TextLine( title=_(u"Cell Phone"), description=_(u"Cell Phone number."), required=False, ) email = schema.TextLine( title=_(u"Email"), description=_(u"Email."), required=False, ) addr_city = schema.TextLine( title=_(u"City"), description=_(u"City name."), required=False, ) addr_district = schema.TextLine( title=_(u"District"), description=_(u"District"), required=False, ) addr_zip = schema.TextLine( title=_(u"ZIP Code"), description=_(u"ZIP code"), required=False, ) addr_address = schema.TextLine( title=_(u"Address"), description=_(u"Address"), required=False, ) taxId = schema.TextLine( title=_(u"Tax ID"), description=_(u"Tax ID"), required=False, ) companyTitle = schema.TextLine( title=_(u"Company Title"), description=_(u"Company Title"), required=False, ) form.write_permission(productUIDs='cmf.ManagePortal') productUIDs = schema.Dict( title=_(u"Product UID(s)"), description=_(u"Product UID(s) at shopping cart, include qty."), key_type=schema.TextLine(title=u"Key"), value_type=schema.Int(title=u"Value"), required=False, ) form.write_permission(amount='cmf.ManagePortal') amount = schema.Int( title=_(u"Amount"), description=_(u"Amount"), required=True, ) form.write_permission(orderState='cmf.ManagePortal') orderState = schema.Choice( title=_(u"Order State"), description=_(u"Order state."), vocabulary=ORDER_STATE, default=u'ordered', required=True, ) result = schema.Dict( title=_(u"Trading Results"), description=_(u"Trading Results, feedback from allPay."), key_type=schema.TextLine(title=u"Key"), value_type=schema.TextLine(title=u"Value"), required=False, ) logisticsMapResult = schema.Dict( title=_(u"Logistics Map Results"), description=_(u"Logistics map results, feedback from allPay."), key_type=schema.TextLine(title=u"Key"), value_type=schema.TextLine(title=u"Value"), required=False, ) logisticsExpressResult = schema.Dict( title=_(u"Logistics Express Create Results"), description=_(u"Logistics express create results, feedback from allPay."), key_type=schema.TextLine(title=u"Key"), value_type=schema.TextLine(title=u"Value"), required=False, )
from i8d.content import _ from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm ORDER_STATE = SimpleVocabulary([ SimpleTerm(value=u'ordered', title=_(u'ordered')), SimpleTerm(value=u'paid', title=_(u'paid')), SimpleTerm(value=u'shipped', title=_(u'shipped')), SimpleTerm(value=u'arrived', title=_(u'arrived')), SimpleTerm(value=u'inreturn', title=_(u'inreturn')), SimpleTerm(value=u'returned', title=_(u'returned')), SimpleTerm(value=u'overdue', title=_(u'overdue')), ])
class IProduct(Interface): """ 產品 """ dexteritytextindexer.searchable('title') title = schema.TextLine( title=_(u"Product Name"), required=True, ) productId = schema.TextLine( title=_(u"Product Id"), required=True, ) description = schema.Text( title=_(u"Description"), required=False, ) productUrl = schema.URI( title=_(u"Pruduct URL"), description=_(u"Product introduction web page include http:// or https://"), required=False, ) inStock = schema.Bool( title=_(u"In Stock?"), description=_(u"If In Stock, Please check it."), default=True, required=False, ) brand = schema.TextLine( title=_(u"Brand"), description=_(u"Brand name."), required=False, ) """ categoryTag = schema.TextLine( title=_(u"Category Tag"), description=_(u"Category tag for product, Provider define. Separated by commas."), required=False, ) """ listPrice = schema.Int( title=_(u"List Price"), description=_(u"The list price of the product."), required=True, ) salePrice = schema.Int( title=_(u"Sale price"), description=_(u"Sale price for the product if different from the list price, must be <= listPrice."), required=True, ) image_1 = NamedBlobImage( title=_(u"Product Image."), description=_(u"Product image for header."), required=True, ) image_2 = NamedBlobImage( title=_(u"Product Image."), description=_(u"Product image."), required=False, ) image_3 = NamedBlobImage( title=_(u"Product Image."), description=_(u"Product image."), required=False, ) image_4 = NamedBlobImage( title=_(u"Product Image."), description=_(u"Product image."), required=False, ) image_5 = NamedBlobImage( title=_(u"Product Image."), description=_(u"Product image."), required=False, ) """ special = schema.TextLine( title=_(u"Special"), description=_(u"Used to denote a special offer. Can be used by a publisher to identify unique products, Will be YES, NO or empty."), required=False, ) """ # 紅利點數發放比率,以小數點表示百分比 bonusPoint = schema.Float( title=_(u"Bonus Point"), description=_(u"Bonus point setting, please filling decimal point. maximum is 0.05 (5%)"), default=DEFAULT_BONUS_RATE, min=MIN_BONUS_RATE, max=MAX_BONUS_RATE, required=True, ) # 今日折扣,使用紅利點數可折抵折扣率,以小數點表示百分比 maxUsedBonus = schema.Float( title=_(u"Maximum Used Bonus Points"), description=_(u"You can use a maximum bonus points."), default=DEFAULT_USED_BONUS_RATE, min=MIN_USED_BONUS_RATE, max=MAX_USED_BONUS_RATE, required=True, ) dexteritytextindexer.searchable('promotionalText') promotionalText = RichText( title=_(u"Promotional Text"), description=_(u"Promotional Text, support html format richtext."), required=False, ) # 產品要放在首頁推廣,則本欄必填, 該用 ReviewPortalContent? or ManagePortal? 再考量 form.write_permission(heroText='cmf.ReviewPortalContent') heroText = schema.Text( title=_(u"Hero Text"), description=_(u"Promotional Text for Hero page"), required=False, ) # 運費,以單品計算, 若一張訂單有多樣商品,須依規則另計 standardShippingCost = schema.Int( title=_(u"Standard shipping cost"), description=_(u"Usually is the cost for the typical standard, lowest cost shipping method. This is provided for informational purposes and the actual shipping cost could vary depending on the visitor."), required=False, ) lastUpdated = schema.Datetime( title=_(u"Last Updated"), description=_(u"Date of the most recent update to the product."), default=datetime.now(), required=True, ) sharingText = schema.Text( title=_(u"Sharing Text"), required=False, )