class IParaImage(Interface): title = schema.TextLine( title=_(u'Parameter title'), required=True, ) showName = schema.TextLine( title=_(u'Parameter show name'), required=True, ) image_s = NamedBlobImage( title=_(u'Small Image'), required=True, ) image = NamedBlobImage( title=_(u'image'), required=True, ) price = schema.Int( title=_(u'Price'), required=True, )
class IKeyword(model.Schema): """ Add Keyword field """ keyword = schema.TextLine( title=_(u'Keyword'), description=_(u"keyword, split with common."), required=False, )
class IDocWithBigImage(Interface): title = schema.TextLine( title=_(u'Document With Big Image'), required=True, ) description = schema.Text( title=_(u'Description'), required=False, )
class IFaq(Interface): title = schema.TextLine( title=_(u'Question'), required=True, ) description = schema.Text( title=_(u'Description'), required=False, )
def getOrderItem(self, orderId): self.orderItemList = [ _(u'p_UID'), _(u'qty'), _(u'unitPrice'), _(u'parameterNo'), _(u'sNumber') ] execStr = "SELECT p_UID, qty, unitPrice, parameterNo, sNumber\ FROM orderItem WHERE orderId = '%s'" % orderId return self.execSql(execStr)
def validateImageSize(data): for i in range(10): imageObj = getattr(data, 'mainSlide_%s' % str(i+1)) if hasattr(imageObj, 'getImageSize'): if imageObj.getImageSize() != (1280, 680): raise WrongImageSize(_(u"Wrong image size, Please check Main Slider Image size, must be 1280x680 px.")) for i in range(6): imageObj = getattr(data, 'moreDesignImage_%s' % str(i+1)) if hasattr(imageObj, 'getImageSize'): if imageObj.getImageSize() != (640, 270): raise WrongImageSize(_(u"Wrong image size, Please check More Design Image size, must be 640x270 px."))
class IProduct(Interface): title = schema.TextLine( title=_(u'Title'), required=True, ) pType = schema.Choice( title=_(u'Product Type'), vocabulary=product_type, required=True, ) basePrice = schema.Int( title=_(u"Base Price"), required=True, ) urgentCase = RelationList( title=_(u"Urgent Case"), value_type=RelationChoice(title=_(u"Related"), source=CatalogSource(Type='ParaText'),), required=False, ) discount = schema.Int( title=_(u"Discount, base on basePrice percentage(%), default value 100 is no discount."), default=100, max=100, min=20, required=True, ) snPrefix = schema.TextLine( title=_(u'SN Prefix'), description=_(u'Headphone / earplugs mustbe fill.'), required=False, ) description = schema.Text( title=_(u'Description'), required=False, ) image = NamedBlobImage( title=_(u"Cover image, show in listing"), required=True, )
class IParaText(Interface): title = schema.TextLine( title=_(u'Parameter title'), required=True, ) showName = schema.TextLine( title=_(u'Parameter show name'), required=True, ) price = schema.Int( title=_(u'Price'), required=True, )
class IFeatured(model.Schema): """ Add featured field """ form.mode(featured='hidden') featured = schema.Bool( title=_(u"Featured"), description=_(u"Checked it for featured."), default=False, required=False, ) # form.mode(headWeight='hidden') headWeight = schema.Int( title=_(u"Head Weight"), description=_(u"Please set Head Weight value, default:10."), default=10, required=True, )
class IMusicMan(model.Schema): """ Add Music Man behavior """ model.fieldset('musicman', label=_(u"musicman / recommend"), fields=[ 'mmTitle', 'mmInfo', 'mmImage', 'mmAudio', ]) mmTitle = schema.TextLine( title=_(u"Music Man Title"), required=False, ) mmInfo = schema.Text( title=_(u"Music Man Infomation"), required=False, ) mmImage = NamedBlobImage( title=_(u"Music Man Image"), required=False, ) mmAudio = NamedBlobFile( title=_(u"Music Man Audio"), description=_(u"Audio file format: *.mp3"), required=False, )
class IBigImage(model.Schema): """ Add bigImage_* field """ model.fieldset('bigImage', label=_(u"bigImage"), fields=[ 'bigImage_1', 'bigImage_2', 'bigImage_3', 'bigImage_4', 'bigImage_5', ]) bigImage_1 = NamedBlobImage( title=_(u"Big Image"), description=_(u"Big image for page. Size:1900 X 950"), required=False, ) bigImage_2 = NamedBlobImage( title=_(u"Big Image"), description=_(u"Big image for page. Size:1900 X 950"), required=False, ) bigImage_3 = NamedBlobImage( title=_(u"Big Image"), description=_(u"Big image for page. Size:1900 X 950"), required=False, ) bigImage_4 = NamedBlobImage( title=_(u"Big Image"), description=_(u"Big image for page. Size:1900 X 950"), required=False, ) bigImage_5 = NamedBlobImage( title=_(u"Big Image"), description=_(u"Big image for page. Size:1900 X 950"), required=False, )
class IContentMedia(model.Schema): """ Add content media field """ model.fieldset('contentMedia', label=_(u"contentMedia"), fields=[ 'mainImage', 'aboveText', 'image_1', 'image_2', 'image_3', 'youtube', 'belowText' ]) mainImage = NamedBlobImage( title=_(u"Main Image"), description=_(u"Size: 600 X 450"), required=False, ) aboveText = RichText( title=_(u'Above Text'), required=False, ) image_1 = NamedBlobImage( title=_(u"Image"), description=_(u"Size: 600 X 450"), required=False, ) image_2 = NamedBlobImage( title=_(u"Image"), description=_(u"Size: 600 X 450"), required=False, ) image_3 = NamedBlobImage( title=_(u"Image"), description=_(u"Size: 600 X 450"), required=False, ) youtube = schema.TextLine( title=_(u'Youtube URL'), required=False, ) belowText = RichText( title=_(u'Below Text'), required=False, )
# -*- coding: utf-8 -*- from morear.content import _ from plone.app.registry.browser.controlpanel import RegistryEditForm from plone.app.registry.browser.controlpanel import ControlPanelFormWrapper from plone.z3cform import layout from z3c.form import form from plone.directives import form as Form from zope import schema class IMorearSetting(Form.Schema): """ Basic setting for Morear """ faqCat = schema.Text( title=_(u"Faq Categories Setting"), required=True, ) class MorearSettingControlPanelForm(RegistryEditForm): form.extends(RegistryEditForm) schema = IMorearSetting MorearSettingControlPanelView = layout.wrap_form(MorearSettingControlPanelForm, ControlPanelFormWrapper) MorearSettingControlPanelView.label = _(u"Morear Setting")
class ICover(Interface): @invariant def validateImageSize(data): for i in range(10): imageObj = getattr(data, 'mainSlide_%s' % str(i+1)) if hasattr(imageObj, 'getImageSize'): if imageObj.getImageSize() != (1280, 680): raise WrongImageSize(_(u"Wrong image size, Please check Main Slider Image size, must be 1280x680 px.")) for i in range(6): imageObj = getattr(data, 'moreDesignImage_%s' % str(i+1)) if hasattr(imageObj, 'getImageSize'): if imageObj.getImageSize() != (640, 270): raise WrongImageSize(_(u"Wrong image size, Please check More Design Image size, must be 640x270 px.")) title = schema.TextLine( title=_(u'Title'), required=True, ) description = schema.Text( title=_(u'Description'), required=False, ) model.fieldset( 'mainSlide', label=_(u"mainSlide"), description=_(u"Must be select image size at 1280x680."), fields=['mainSlide_1', 'mainUrl_1', 'mainSlide_2', 'mainUrl_2', 'mainSlide_3', 'mainUrl_3', 'mainSlide_4', 'mainUrl_4', 'mainSlide_5', 'mainUrl_5', 'mainSlide_6', 'mainUrl_6', 'mainSlide_7', 'mainUrl_7', 'mainSlide_8', 'mainUrl_8', 'mainSlide_9', 'mainUrl_9', 'mainSlide_10', 'mainUrl_10',] ) mainSlide_1 = NamedBlobImage( title=_(u"Main Slide"), description=_(u"Size: 1280 X 680"), required=True, ) mainUrl_1 = schema.URI( title=_(u"Main Slider URL"), required=True, ) mainSlide_2 = NamedBlobImage( title=_(u"Main Slide"), description=_(u"Size: 1280 X 680"), required=False, ) mainUrl_2 = schema.URI( title=_(u"Main Slider URL"), required=False, ) mainSlide_3 = NamedBlobImage( title=_(u"Main Slide"), description=_(u"Size: 1280 X 680"), required=False, ) mainUrl_3 = schema.URI( title=_(u"Main Slider URL"), required=False, ) mainSlide_4 = NamedBlobImage( title=_(u"Main Slide"), description=_(u"Size: 1280 X 680"), required=False, ) mainUrl_4 = schema.URI( title=_(u"Main Slider URL"), required=False, ) mainSlide_5 = NamedBlobImage( title=_(u"Main Slide"), description=_(u"Size: 1280 X 680"), required=False, ) mainUrl_5 = schema.URI( title=_(u"Main Slider URL"), required=False, ) mainSlide_6 = NamedBlobImage( title=_(u"Main Slide"), description=_(u"Size: 1280 X 680"), required=False, ) mainUrl_6 = schema.URI( title=_(u"Main Slider URL"), required=False, ) mainSlide_7 = NamedBlobImage( title=_(u"Main Slide"), description=_(u"Size: 1280 X 680"), required=False, ) mainUrl_7 = schema.URI( title=_(u"Main Slider URL"), required=False, ) mainSlide_8 = NamedBlobImage( title=_(u"Main Slide"), description=_(u"Size: 1280 X 680"), required=False, ) mainUrl_8 = schema.URI( title=_(u"Main Slider URL"), required=False, ) mainSlide_9 = NamedBlobImage( title=_(u"Main Slide"), description=_(u"Size: 1280 X 680"), required=False, ) mainUrl_9 = schema.URI( title=_(u"Main Slider URL"), required=False, ) mainSlide_10 = NamedBlobImage( title=_(u"Main Slide"), description=_(u"Size: 1280 X 680"), required=False, ) mainUrl_10 = schema.URI( title=_(u"Main Slider URL"), required=False, ) model.fieldset( 'whatsNew', label=_(u"whatsNEW"), fields=['whatsNew_title', 'whatsNew_text', 'whatsNew_URI','whatsNew_bigImage', 'whatsNew_smallImage'] ) whatsNew_title = schema.TextLine( title=_(u"What's New title."), required=True, ) whatsNew_text = schema.Text( title=_(u"What's New Text."), required=True, ) whatsNew_URI = schema.URI( title=_(u"What's New URI."), required=True, ) whatsNew_bigImage = NamedBlobImage( title=_(u"What's New Big Image, 800X400"), required=True, ) whatsNew_smallImage = NamedBlobImage( title=_(u"What's New Small Image, 411X153."), required=False, ) model.fieldset( 'moreDesign', label=_(u"moreDesign"), description=_(u"Must be select image size at 640x270."), fields=['moreDesignImage_1', 'moreDesignUrl_1', 'moreDesignImage_2', 'moreDesignUrl_2', 'moreDesignImage_3', 'moreDesignUrl_3', 'moreDesignImage_4', 'moreDesignUrl_4', 'moreDesignImage_5', 'moreDesignUrl_5', 'moreDesignImage_6', 'moreDesignUrl_6',] ) moreDesignImage_1 = NamedBlobImage( title=_(u"More Design Image"), description=_(u"Size: 640X270"), required=True, ) moreDesignUrl_1 = schema.URI( title=_(u"More Design URL"), required=True, ) moreDesignImage_2 = NamedBlobImage( title=_(u"More Design Image"), description=_(u"Size: 640X270"), required=True, ) moreDesignUrl_2 = schema.URI( title=_(u"More Design URL"), required=True, ) moreDesignImage_3 = NamedBlobImage( title=_(u"More Design Image"), description=_(u"Size: 640X270"), required=True, ) moreDesignUrl_3 = schema.URI( title=_(u"More Design URL"), required=True, ) moreDesignImage_4 = NamedBlobImage( title=_(u"More Design Image"), description=_(u"Size: 640X270"), required=True, ) moreDesignUrl_4 = schema.URI( title=_(u"More Design URL"), required=True, ) moreDesignImage_5 = NamedBlobImage( title=_(u"More Design Image"), description=_(u"Size: 640X270"), required=True, ) moreDesignUrl_5 = schema.URI( title=_(u"More Design URL"), required=True, ) moreDesignImage_6 = NamedBlobImage( title=_(u"More Design Image"), description=_(u"Size: 640X270"), required=True, ) moreDesignUrl_6 = schema.URI( title=_(u"More Design URL"), required=True, ) model.fieldset( 'moreFeast', label=_(u"More Feast Text"), fields=['moreFeast_text', 'spotifyEmbed', 'moreFeast_bgImg'], ) moreFeast_text = schema.Text( title=_(u"More Feast Text"), required=True, ) spotifyEmbed = schema.Text( title=_(u"Spotify Embeded Code"), required=True, ) moreFeast_bgImg = NamedBlobImage( title=_(u"MoreFeast Background Image"), description=_(u"Size: 1280 X 400"), required=True, ) model.fieldset( 'aboutMorear', label=_(u"About Morear Text"), fields=['aboutMorear', 'aboutMorearImage'], ) aboutMorear = schema.Text( title=_(u"About Morear Text"), required=True, ) aboutMorearImage = NamedBlobImage( title=_(u"About Morear Background Image"), description=_(u"Size: 1280 X 290"), required=True, )
class WrongImageSize(Invalid): __doc__ = _(u"Get a wrong image size.")
class ILocation(Interface): title = schema.TextLine( title=_(u'Location Title'), required=True, ) description = schema.Text( title=_(u'Description'), required=False, ) city = schema.TextLine( title=_(u'City'), required=True, ) district = schema.TextLine( title=_(u'District'), required=True, ) weekendService = schema.Bool( title=_(u'Weekend Service'), default=False, required=True, ) serviceTime = schema.Text( title=_(u'Service Time'), required=True, ) phone = schema.TextLine( title=_(u'Phone Number'), required=True, ) address = schema.TextLine( title=_(u'Address'), required=True, ) image = NamedBlobImage( title=_(u"Image"), required=True, ) mapCode = schema.Text( title=_(u'Map Code'), description=_(u'Google map embeded code.'), required=True, ) note = schema.Text( title=_(u'Note Text'), required=False, )
def getOrderInfo(self, orderId): self.orderInfoList = [ _(u'userId'), _(u'b_email'), _(u'orderId'), _(u'b_name'), _(u'b_city'), _(u'b_addr'), _(u'b_phone'), _(u'pickupType'), _(u'pickupTime'), _(u'r_name'), _(u'r_email'), _(u'r_city'), _(u'r_addr'), _(u'r_phone'), _(u'i_2list'), _(u'i_invoiceNo'), _(u'i_city'), _(u'i_addr'), _(u'pickupStoreUID'), _(u'ecpayNo'), _(u'createDate') ] execStr = "SELECT userId, b_email, orderId, b_name, b_city, b_addr, b_phone,\ pickupType, pickupTime, r_name, r_email, r_city, r_addr, r_phone,\ i_2list, i_invoiceNo, i_city, i_addr, pickupStoreUID, ecpayNo, createDate\ FROM orderInfo WHERE orderId = '%s'" % orderId return self.execSql(execStr)[0]
class IParameterSet(model.Schema): """ Add product's parameter set """ model.fieldset(_('headphone'), label=_(u""), fields=[ 'bgImage_left', 'bgImage_right', 'driver', 'lineLength', 'lineColor', 'shell3D', 'surfaceColorR', 'surfaceColorL', 'logoColorR', 'logoColorL' ]) form.mode(lineColor='hidden') lineColor = RelationList( title=_(u"Line Color"), value_type=RelationChoice( title=_(u"Related"), source=CatalogSource(Type='ParaImage'), ), required=False, ) shell3D = RelationList( title=_(u"3D Print Shell"), value_type=RelationChoice( title=_(u"Related"), source=CatalogSource(Type='ParaImage'), ), required=False, ) bgImage_left = NamedBlobImage( title=_(u'Background Image, Left'), required=False, ) bgImage_right = NamedBlobImage( title=_(u'Background Image, Right'), required=False, ) """ driver = schema.Choice( title=_(u'Driver'), vocabulary=driverType, required=False, ) """ driver = RelationChoice( title=_(u'Driver'), source=CatalogSource(Type='ParaText'), required=False, ) lineLength = RelationList( title=_(u"Line Length"), value_type=RelationChoice( title=_(u"Related"), source=CatalogSource(Type='ParaText'), ), required=False, ) surfaceColorR = RelationList( title=_(u"Surface Color, Right"), value_type=RelationChoice( title=_(u"Related"), source=CatalogSource(Type='ParaImage'), ), required=False, ) surfaceColorL = RelationList( title=_(u"Surface Color, Left"), value_type=RelationChoice( title=_(u"Related"), source=CatalogSource(Type='ParaImage'), ), required=False, ) logoColorR = RelationList( title=_(u"Logo Color, Right"), value_type=RelationChoice( title=_(u"Related"), source=CatalogSource(Type='ParaImage'), ), required=False, ) logoColorL = RelationList( title=_(u"Logo Color, Left"), value_type=RelationChoice( title=_(u"Related"), source=CatalogSource(Type='ParaImage'), ), required=False, ) model.fieldset(_('earplugs'), label=_(u""), fields=[ 'ep_bgImage_left', 'ep_bgImage_right', 'ep_material', 'ep_typeNo', 'ep_colorR', 'ep_colorL', ]) ep_bgImage_left = NamedBlobImage( title=_(u'Background Image, Left'), required=False, ) ep_bgImage_right = NamedBlobImage( title=_(u'Background Image, Right'), required=False, ) ep_material = RelationList( title=_(u"Material"), value_type=RelationChoice( title=_(u"Related"), source=CatalogSource(Type='ParaText'), ), required=False, ) ep_typeNo = RelationList( title=_(u"Type No."), value_type=RelationChoice( title=_(u"Related"), source=CatalogSource(Type='ParaText'), ), required=False, ) ep_colorL = RelationList( title=_(u"Color, Left"), value_type=RelationChoice( title=_(u"Related"), source=CatalogSource(Type='ParaImage'), ), required=False, ) ep_colorR = RelationList( title=_(u"Color, Right"), value_type=RelationChoice( title=_(u"Related"), source=CatalogSource(Type='ParaImage'), ), required=False, )
class IMorearSetting(Form.Schema): """ Basic setting for Morear """ faqCat = schema.Text( title=_(u"Faq Categories Setting"), required=True, )
from zope.interface import Interface from plone.namedfile.field import NamedBlobImage from plone.supermodel import model from zope.publisher.interfaces.browser import IDefaultBrowserLayer from zope.interface import invariant, Invalid from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm from z3c.relationfield.schema import RelationList, RelationChoice from plone.app.vocabularies.catalog import CatalogSource class IMorearContentLayer(IDefaultBrowserLayer): """Marker interface that defines a browser layer.""" product_type = SimpleVocabulary( [SimpleTerm(value=u'normal', title=_(u'Normal')), SimpleTerm(value=u'headphone', title=_(u'Headphone')), SimpleTerm(value=u'earplugs', title=_(u'Earplugs'))] ) class IProduct(Interface): title = schema.TextLine( title=_(u'Title'), required=True, ) pType = schema.Choice( title=_(u'Product Type'), vocabulary=product_type,