def validator(self, action, data): """ """ errors = [] if self.request.get("form.id") == "direct_debit_new": for widget_name in ("account_number", "depositor", "bank_name", "bank_identification_code"): if self.request.get("form.%s" % widget_name, u"") == u"": widget = self.widgets[widget_name] error = WidgetInputError( widget.name, widget.label, "%s" + _(u" is required" % widget.label)) widget._error = error errors.append(error) elif self.request.get("form.id") == "credit_card_new": for widget_name in ("card_type", "card_owner", "card_number"): if self.request.get("form.%s" % widget_name, u"") == u"": widget = self.widgets[widget_name] error = WidgetInputError( widget.name, widget.label, _(u"%s is required" % widget.label)) widget._error = error errors.append(error) return errors
def validator(self, action, data): """ """ errors = [] if self.request.get("form.id") == "direct_debit_new": for widget_name in ("account_number", "depositor", "bank_name", "bank_identification_code"): if self.request.get("form.%s" % widget_name, u"") == u"": widget = self.widgets[widget_name] error = WidgetInputError( widget.name, widget.label, "%s" + _(u" is required" % widget.label) ) widget._error = error errors.append(error) elif self.request.get("form.id") == "credit_card_new": for widget_name in ("card_type", "card_owner", "card_number"): if self.request.get("form.%s" % widget_name, u"") == u"": widget = self.widgets[widget_name] error = WidgetInputError( widget.name, widget.label, _(u"%s is required" % widget.label) ) widget._error = error errors.append(error) return errors
def sendRecommendation(self): """ """ if self.request.get("email", "") == "": utool = getToolByName(self.context, "plone_utils") utool.addPortalMessage(_("Please add a e-mail address.")) url = "%s/thank-you" % self.context.absolute_url() else: # Get charset props = getToolByName(self.context, "portal_properties").site_properties charset = props.getProperty("default_charset") template = getMultiAdapter((self.context, self.request), name="send-recommendation-template") text = template() sendMultipartMail( context=self.context, from_=self.context.getMailFrom(), to=self.request.get("email"), subject="Empfehlung Demmelhuber Holz und Raum GmbH", text=text, charset=charset, ) utool = getToolByName(self.context, "plone_utils") utool.addPortalMessage(_("Your mail has been sent.")) url = "%s/thank-you" % self.context.absolute_url() self.request.response.redirect(url)
def sendRecommendation(self): """ """ if self.request.get("email", "") == "": utool = getToolByName(self.context, "plone_utils") utool.addPortalMessage(_("Please add a e-mail address.")) url = "%s/thank-you" % self.context.absolute_url() else: # Get charset props = getToolByName(self.context, "portal_properties").site_properties charset = props.getProperty("default_charset") template = getMultiAdapter((self.context, self.request), name="send-recommendation-template") text = template() sendMultipartMail( context=self.context, from_=self.context.getMailFrom(), to=self.request.get("email"), subject="Empfehlung Demmelhuber Holz und Raum GmbH", text=text, charset=charset) utool = getToolByName(self.context, "plone_utils") utool.addPortalMessage(_("Your mail has been sent.")) url = "%s/thank-you" % self.context.absolute_url() self.request.response.redirect(url)
def _getBasesAsDL(self): """ """ dl = DisplayList() dl.add("product", _("Product")) dl.add("cart_item", _("Cart Item")) return dl
def _getTypesAsDL(self): """ """ dl = DisplayList() dl.add("absolute", _("Absolute")) dl.add("percentage", _("Percentage")) return dl
class UserAddForm(formbase.AddForm): """ """ template = pagetemplatefile.ZopeTwoPageTemplateFile("user.pt") form_fields = form.Fields(IUserAddForm) label = _(u"Add User") form_name = _(u"Add User") @form.action(_(u"label_save", default=u"Save"), condition=form.haveInputWidgets, name=u'save') def handle_save_action(self, action, data): """ """ self.createAndAdd(data) def createAndAdd(self, data): """ """ username = data.get("username") username = username.encode( "utf-8") # rtool doesn't understand unicode. password = data.get("password_1") request = self.context.REQUEST rtool = getToolByName(self.context, "portal_registration") rtool.addMember(username, password) utool = getToolByName(self.context, "portal_url") portal_url = utool.getPortalObject().absolute_url() # Plone's logged_in script (see below) redirects to given came_from, # hence we just have to pass the next url to it to get to the next url # within the checkout process. came_from = ICheckoutManagement( self.context).getNextURL("AFTER_ADDED_USER") parameters = { "came_from": came_from, "__ac_name": username, "__ac_password": password, "form.submitted": "1", "js_enabled": "1", "cookies_enabled": "1", "login_name": username, "pwd_empty": "0", } temp = [] for key, value in parameters.items(): if value != "": temp.append("%s=%s" % (key, value)) url = "%s/logged_in?%s" % (portal_url, "&".join(temp)) request.RESPONSE.redirect(url)
class BankAccountAddForm(base.AddForm): """ """ template = pagetemplatefile.ZopeTwoPageTemplateFile(DEFAULT_SHOP_FORM) form_fields = form.Fields(IBankAccount) label = _(u"Add Bank Information") form_name = _(u"Add Bank Information") @form.action(_(u"label_save", default=u"Save"), condition=form.haveInputWidgets, name=u'save') def handle_save_action(self, action, data): """ """ self.createAndAdd(data) @form.action(_(u"label_cancel", default=u"Cancel"), validator=null_validator, name=u'cancel') def handle_cancel_action(self, action, data): """ """ self.context.reindexObject() self.nextUrl() def createAndAdd(self, data): """ """ # add address id = self.context.generateUniqueId("BankAccount") direct_debit = BankAccount(id) direct_debit.account_number = data.get("account_number") direct_debit.bank_identification_code = data.get( "bank_identification_code") direct_debit.depositor = data.get("depositor") direct_debit.bank_name = data.get("bank_name") self.context._setObject(id, direct_debit) direct_debit.reindexObject() self.nextUrl() def nextUrl(self): """ """ url = self.request.get("goto", "") if url != "": self.request.response.redirect(url) else: url = self.context.absolute_url() + "/manage-payment-methods" self.request.response.redirect(url)
class CustomerEditForm(base.EditForm): """ """ template = pagetemplatefile.ZopeTwoPageTemplateFile(DEFAULT_SHOP_FORM) form_fields = form.Fields(ICustomer) label = _(u"Edit Customer") description = _("Please edit the form below and press save.") form_name = _(u"Edit Customer") @form.action(_(u"label_save", default="Save"), condition=form.haveInputWidgets, name=u'save') def handle_save_action(self, action, data): """ """ utils = getToolByName(self.context, "plone_utils") utils.addPortalMessage(_(u"Changes saved"), "info") if form.applyChanges(self.context, self.form_fields, data, self.adapters): zope.event.notify( zope.lifecycleevent.ObjectModifiedEvent(self.context)) zope.event.notify(EditSavedEvent(self.context)) else: zope.event.notify(EditCancelledEvent(self.context)) self.context.reindexObject() self._nextUrl() @form.action(_(u"label_cancel", default=u"Cancel"), validator=null_validator, name=u'cancel') def handle_cancel_action(self, action, data): """ """ utils = getToolByName(self.context, "plone_utils") utils.addPortalMessage(_(u"Edit canceled"), "info") zope.event.notify(EditCancelledEvent(self.context)) self._nextUrl() def _nextUrl(self): """ """ url = self.request.get("goto", "") if url != "": self.request.response.redirect(url) else: url = self.context.absolute_url() url += "/my-account" self.request.response.redirect(url)
class IBankAccount(IPaymentInformation): """Stores information of a bank account. """ account_number = schema.TextLine( title=_(u'Account Number'), description=_(u"Please enter your account number"), default=u'', required=True, ) bank_identification_code = schema.TextLine( title=_(u'Bank Information Code'), description=_(u"Please enter your bank information code"), default=u'', required=True, ) depositor = schema.TextLine( title=_(u'Depositor'), description=_(u"Please enter the depositor of the account"), default=u'', required=True, ) bank_name = schema.TextLine( title=_(u'Bank Name'), description=_(u"Please enter the bank name"), default=u'', required=True, )
class AddressEditForm(base.EditForm): """ """ template = pagetemplatefile.ZopeTwoPageTemplateFile(DEFAULT_SHOP_FORM) form_fields = form.Fields(IAddress).omit("email") label = _(u"Edit Address") description = _("To change your address edit the form and press save.") form_name = _(u"Edit Address") @form.action(_(u"label_save", default="Save"), condition=form.haveInputWidgets, name=u'save') def handle_save_action(self, action, data): """ """ if form.applyChanges(self.context, self.form_fields, data, self.adapters): notify(ObjectModifiedEvent(self.context)) notify(EditSavedEvent(self.context)) self.status = "Changes saved" else: notify(EditCancelledEvent(self.context)) self.status = "No changes" self.context.reindexObject() self.context.aq_inner.aq_parent.reindexObject() self.redirectToNextURL() @form.action(_(u"label_cancel", default=u"Cancel"), validator=null_validator, name=u'cancel') def handle_cancel_action(self, action, data): """ """ notify(EditCancelledEvent(self.context)) self.redirectToNextURL() def redirectToNextURL(self): """ """ url = self.request.get("goto", "") if url != "": self.request.response.redirect(url) else: customer = self.context.aq_inner.aq_parent url = "%s/manage-addressbook" % customer.absolute_url() self.request.response.redirect(url)
class IInformationPage(Interface): """A page to hold the information as HTML and downloadable file. """ text = schema.Text( title=_(u'Text'), description=_(u"The information as HTML"), default=u'', required=False, ) text = schema.Bytes( title=_(u'File'), description=_(u"The information as downloadable file."), required=False, )
class BankAccountEditForm(base.EditForm): """ """ template = pagetemplatefile.ZopeTwoPageTemplateFile(DEFAULT_SHOP_FORM) form_fields = form.Fields(IBankAccount) label = _(u"Edit Bank Account") description = _( "To change your bank information edit the form and press save.") form_name = _(u"Edit Bank Account") @form.action(_(u"label_save", default="Save"), condition=form.haveInputWidgets, name=u'save') def handle_save_action(self, action, data): """ """ if form.applyChanges(self.context, self.form_fields, data, self.adapters): notify(ObjectModifiedEvent(self.context)) notify(EditSavedEvent(self.context)) self.status = "Changes saved" else: notify(EditCancelledEvent(self.context)) self.status = "No changes" self.context.reindexObject() self.nextUrl() @form.action(_(u"label_cancel", default=u"Cancel"), validator=null_validator, name=u'cancel') def handle_cancel_action(self, action, data): """ """ notify(EditCancelledEvent(self.context)) self.nextUrl() def nextUrl(self): """ """ url = self.request.get("goto", "") if url != "": self.request.response.redirect(url) else: parent = self.context.aq_inner.aq_parent url = parent.absolute_url() + "/manage-payment-methods" self.request.response.redirect(url)
def FORM_BUTTON(id, value="Save", klass="context"): return """ <input class="%s" value="%s" id="%s" type="submit" /> """ % (klass, _(value), id)
class ICategoriesPortlet(IPortletDataProvider): """ """ expand_all = schema.Bool( title=_(u'Expand all'), description=_(u'If selected all categories are expanded by default.'), required=False, default=False, ) show_quantity = schema.Bool( title=_(u'Show quantity'), description=_( u'If selected amount of product per categories is displayed.'), required=False, default=False, )
def handle_cancel_action(self, action, data): """ """ utils = getToolByName(self.context, "plone_utils") utils.addPortalMessage(_(u"Edit canceled"), "info") zope.event.notify(EditCancelledEvent(self.context)) self._nextUrl()
def _getPropertiesForConfiguration(self): """ """ u = queryUtility(INumberConverter) cm = ICurrencyManagement(self.context) selected_options = {} for name, value in self.request.items(): if name.startswith("property"): selected_options[name[42:]] = value pm = IPropertyManagement(self.context) result = [] for property in pm.getProperties(): # Only properties with at least one option are displayed. if len(property.getOptions()) == 0: continue # Preset with select option options = [{ "id" : "select", "title" : _(u"Select"), "selected" : False, }] for option in property.getOptions(): # generate value string option_id = option["id"] option_name = option["name"] option_price = option["price"] if option_price != "0.0": option_price = u.stringToFloat(option_price) option_price = cm.priceToString(option_price, "long", "after", suffix=None) content = "%s %s" % (option_name, option_price) else: content = option_name # is option selected? selected_option = selected_options.get(property.getId(), "") selected = option_id == selected_option options.append({ "id" : option_id, "title" : content, "selected" : selected, }) result.append({ "id" : "property_%s_%s" % (self.context.UID(), property.getId()), "title" : property.Title(), "options" : options, }) return result
def _getAddAddressForm(self): """ """ html = """<h1>%s</h1>""" % _(u"Add Address") html += """<div class="description">%s</div>""" % _(u"Please enter a new address and click save.") html += FORM_HEADER("add-address-form") html += FORM_TEXT_FIELD("Firstname", "firstname", True) html += FORM_TEXT_FIELD("Lastname", "lastname", True) html += FORM_TEXT_FIELD("Company Name", "companyName", False) html += FORM_TEXT_FIELD("Address 1", "address1", True) html += FORM_TEXT_FIELD("Zip Code", "zipCode", True) html += FORM_TEXT_FIELD("City", "city", True) html += FORM_TEXT_FIELD("Phone", "phone", False) html += FORM_BUTTON(id="add-address") html += FORM_BUTTON(id="cancel-address", value="Cancel", klass="standalone") html += FORM_FOOTER() return html
class AddressAddForm(base.AddForm): """ """ template = pagetemplatefile.ZopeTwoPageTemplateFile(DEFAULT_SHOP_FORM) form_fields = form.Fields(IAddress).omit("email") label = _(u"Add Address") form_name = _(u"Add Address") @form.action(_(u"label_save", default=u"Save"), condition=form.haveInputWidgets, name=u'save') def handle_save_action(self, action, data): """ """ self.createAndAdd(data) @form.action(_(u"label_cancel", default=u"Cancel"), validator=null_validator, name=u'cancel') def handle_cancel_action(self, action, data): """ """ self.redirectToNextURL() def createAndAdd(self, data): """ """ am = IAddressManagement(self.context) am.addAddress(data) self.redirectToNextURL() def redirectToNextURL(self): """ """ url = self.request.get("goto", "") if url != "": self.request.response.redirect(url) else: url = "%s/manage-addressbook" % self.context.absolute_url() self.request.response.redirect(url)
def process(self, order=None): """ """ shop = IShopManagement(self.context).getShop() customer = ICustomerManagement(shop).getAuthenticatedCustomer() credit_card = IPaymentInformationManagement(customer).getSelectedPaymentInformation() card_num = credit_card.card_number exp_date = "%s/%s" % (credit_card.card_expiration_date_month, credit_card.card_expiration_date_year) line_items = [] for i, item in enumerate(IItemManagement(order).getItems()): if item.getProductTax() > 0: tax = "Y" else: tax = "N" line_items.append(( str(i+1), item.getProduct().Title(), str(item.getProductQuantity()), str(item.getProductPriceGross()), tax, )) amount = "%.2f" % IPrices(order).getPriceForCustomer() cc = EasyShopCcProcessor( server="test.authorize.net", login="******", key="9ME22bvLnu87P4FY") # Used for authorizeAndCapture result = cc.authorizeAndCapture( amount = amount, card_num = card_num, exp_date = exp_date) if result.response == "approved": return PaymentResult(PAYED, _(u"Your order has been payed.")) else: return PaymentResult(ERROR, _(result.response_reason))
def isComplete(self): """Checks the completeness of an address. """ if self.context.address_1 and self.context.zip_code and \ self.context.city and self.context.country: return True self.context.plone_utils.addPortalMessage( _("Some address data is missing. Please check your Address")) return False
class AddressEditForm(base.EditForm): """This form let anonymous users edit their already entered invoice and shipping address. This happens when they click checkout again and they have already entered addresses within the same sessions. """ template = pagetemplatefile.ZopeTwoPageTemplateFile("address_form.pt") form_fields = form.Fields(IAddress) label = _(u"Edit Address") description = _("To change your address edit the form and press save.") form_name = _(u"Edit Address") @form.action(_(u"label_save", default="Save"), condition=form.haveInputWidgets, name=u'save') def handle_save_action(self, action, data): """ """ if form.applyChanges(self.context, self.form_fields, data, self.adapters): notify(ObjectModifiedEvent(self.context)) notify(EditSavedEvent(self.context)) self.status = "Changes saved" else: notify(EditCancelledEvent(self.context)) self.status = "No changes" shop = IShopManagement(self.context).getShop() ICheckoutManagement(shop).redirectToNextURL("EDITED_ADDRESS") def getAddressType(self): """ """ return self.request.get("address_type", "shipping") def isShippingAddress(self): """ """ return self.getAddressType() == "shipping"
def handle_save_action(self, action, data): """ """ utils = getToolByName(self.context, "plone_utils") utils.addPortalMessage(_(u"Changes saved"), "info") if form.applyChanges(self.context, self.form_fields, data, self.adapters): zope.event.notify(zope.lifecycleevent.ObjectModifiedEvent(self.context)) zope.event.notify(EditSavedEvent(self.context)) else: zope.event.notify(EditCancelledEvent(self.context)) self.context.reindexObject() self._nextUrl()
def validator(self, action, data): """ """ errors = [] if self.request.get("form.confirmation", "") == "": error_msg = _(u"Please confirm our terms and conditions.") widget = self.widgets["confirmation"] error = WidgetInputError(widget.name, widget.label, error_msg) widget._error = error widget.error = error_msg errors.append(error) return errors
def _getAddAddressForm(self): """ """ html = """<h1>%s</h1>""" % _(u"Add Address") html += """<div class="description">%s</div>""" % _( u"Please enter a new address and click save.") html += FORM_HEADER("add-address-form") html += FORM_TEXT_FIELD("Firstname", "firstname", True) html += FORM_TEXT_FIELD("Lastname", "lastname", True) html += FORM_TEXT_FIELD("Company Name", "companyName", False) html += FORM_TEXT_FIELD("Address 1", "address1", True) html += FORM_TEXT_FIELD("Zip Code", "zipCode", True) html += FORM_TEXT_FIELD("City", "city", True) html += FORM_TEXT_FIELD("Phone", "phone", False) html += FORM_BUTTON(id="add-address") html += FORM_BUTTON(id="cancel-address", value="Cancel", klass="standalone") html += FORM_FOOTER() return html
def handle_save_action(self, action, data): """ """ utils = getToolByName(self.context, "plone_utils") utils.addPortalMessage(_(u"Changes saved"), "info") if form.applyChanges(self.context, self.form_fields, data, self.adapters): zope.event.notify( zope.lifecycleevent.ObjectModifiedEvent(self.context)) zope.event.notify(EditSavedEvent(self.context)) else: zope.event.notify(EditCancelledEvent(self.context)) self.context.reindexObject() self._nextUrl()
class ICreditCard(IPaymentInformation): """Stores information of a credit card. """ card_type = schema.Choice( title=_(u"Card Type"), description=_(u"Please select the type of the card."), vocabulary=schema.vocabulary.SimpleVocabulary.fromItems( CREDIT_CARDS_CHOICES.items())) card_owner = schema.TextLine( title=_(u'Card Owner'), description=_(u"Please enter the name of the card owner."), default=u'', required=True, ) card_number = schema.TextLine( title=_(u'Card Number'), description=_(u"Please enter your the card number."), default=u'', required=True, ) card_expiration_date_month = schema.Choice( title=_(u'Expiration Date Month'), description=_(u"Please enter the expiration date of the card."), vocabulary=schema.vocabulary.SimpleVocabulary.fromItems( CREDIT_CARD_MONTHS_CHOICES), default=u"01") card_expiration_date_year = schema.Choice( title=_(u'Expiration Date Year'), description=_(u"Please enter the expiration date of the card."), vocabulary=schema.vocabulary.SimpleVocabulary.fromItems( CREDIT_CARD_YEARS_CHOICES), default=u"2007")
class ICustomer(Interface): """A customer can buy products from the shop. """ firstname = schema.TextLine( title=_(u'Firstname'), description=_(u"Please enter your firstname."), default=u'', required=True, ) lastname = schema.TextLine( title=_(u'Lastname'), description=_(u"Please enter your lastname."), default=u'', required=True, ) vatreg = schema.TextLine( title=_(u'VAT reg'), description=_(u"Please enter your VAT registration number."), default=u'', required=False, ) email = schema.TextLine( title=_(u'E-Mail'), description=_(u"Please enter your e-mail."), default=u'', required=True, ) selected_invoice_address = Attribute("The selected invoice address.") selected_shipping_address = Attribute("The selected shipping address.") selected_payment_method = Attribute("The selected payment method.") selected_shipping_method = Attribute("The selected shipping method.") selected_country = \ Attribute("""Country which is used to calculate the shipping price, if the customer has not yet entered a invoice address""") selected_payment_method = \ Attribute("""The payment is processed with this method.""") selected_payment_information = \ Attribute("""Some payment methods need additional information (e.g. Credit Card)""")
class ShippingSelectForm(formbase.EditForm): """ """ template = pagetemplatefile.ZopeTwoPageTemplateFile("shipping.pt") form_fields = form.Fields(IShippingSelectForm) @form.action(_(u"label_next", default="Next"), condition=form.haveInputWidgets, name=u'next') def handle_next_action(self, action, data): """ """ customer = ICustomerManagement(self.context).getAuthenticatedCustomer() customer.selected_shipping_method = data.get("shipping_method", "") ICheckoutManagement( self.context).redirectToNextURL("SELECTED_SHIPPING_METHOD") def getShippingMethods(self): """ """ customer = ICustomerManagement(self.context).getAuthenticatedCustomer() selected_shipping_id = customer.selected_shipping_method sm = IShippingMethodManagement(self.context) shipping_methods = [] for shipping in sm.getShippingMethods(): if selected_shipping_id == safe_unicode(shipping.getId()): checked = True elif selected_shipping_id == u"" and shipping.getId( ) == "standard": checked = True else: checked = False shipping_methods.append({ "id": shipping.getId(), "title": shipping.Title, "description": shipping.Description, "checked": checked, }) return shipping_methods
class IUserAddForm(Interface): """ """ username = schema.TextLine( title=_(u'Username'), description=_(u"Username"), default=u'', required=False, ) password_1 = schema.TextLine( title=_(u'Password'), description=_(u"Please enter your password."), default=u'', required=False, ) password_2 = schema.TextLine( title=_(u'Password Confirmation'), description=_(u"Please confirm your password."), default=u'', required=False, )
"""Holds all relevant informations for direct debit payment method. This is a bank account. """ implements(IBankAccount) portal_type = "BankAccount" account_number = FieldProperty(IBankAccount["account_number"]) bank_identification_code = FieldProperty( IBankAccount["bank_identification_code"]) bank_name = FieldProperty(IBankAccount["bank_name"]) depositor = FieldProperty(IBankAccount["depositor"]) def Title(self): """ """ return self.bank_name + " - " + self.account_number def displayInfo(self): """ returns relevant payment information as dictionary """ return ( self.account_number, self.bank_identification_code, self.bank_name, self.depositor, ) bankAccountFactory = Factory(BankAccount, title=_(u"Create a new bank account"))
def title(self): """ """ return _(u"EasyMall Categories")
def title(self): """ """ return _(u"EasyShop: Last Seen")
return self.getName() def getName(self, reverse=False): """ """ if reverse: name = self.lastname if name != "": name += ", " name += self.firstname else: name = self.firstname if name != "": name += " " name += self.lastname return name def country_title(self): """ """ vocab = queryUtility(IVocabularyFactory, name="easyshop.countries") try: country = vocab(self).getTerm(self.country) return country.title except: # country was not found in vocab. happens sometimes # if ES is updated from old revision to r1634 or newer return self.country addressFactory = Factory(Address, title=_(u"Create a new address"))
class IAddress(Interface): """A address of a customer. """ firstname = schema.TextLine( title=_(u'Firstname'), description=_(u"Please enter your firstname."), default=u'', required=True, ) lastname = schema.TextLine( title=_(u'Lastname'), description=_(u"Please enter your lastname."), default=u'', required=True, ) company_name = schema.TextLine( title=_(u'Company Name'), description=_(u"Please enter your company name."), default=u'', required=False, ) address_1 = schema.TextLine( title=_(u'Address 1'), description=_(u"Please enter your address."), default=u'', required=True, ) zip_code = schema.TextLine( title=_(u'Zip Code'), description=_(u"Please enter your zip code."), default=u'', required=True, ) city = schema.TextLine( title=_(u'City'), description=_(u"Please enter your city."), default=u'', required=True, ) country = schema.Choice(title=_(u'Country'), description=_(u"Please enter your country."), vocabulary="easyshop.countries") email = schema.TextLine( title=_(u'E-Mail'), description=_(u"Please enter your e-mail address."), default=u'', required=True, ) phone = schema.TextLine( title=_(u'Phone'), description=_(u"Please enter your phone number."), default=u'', required=False, )
class AddressSelectForm(formbase.EditForm): """ """ template = pagetemplatefile.ZopeTwoPageTemplateFile("address_select.pt") form_fields = form.Fields(IAddressSelectForm) @form.action(_(u"label_next", default="Next"), condition=form.haveInputWidgets, name=u'next') def handle_next_action(self, action, data): """ """ customer = ICustomerManagement(self.context).getAuthenticatedCustomer() customer.selected_invoice_address = data.get("invoice_address", "") customer.selected_shipping_address = data.get("shipping_address", "") ICheckoutManagement( self.context).redirectToNextURL("SELECTED_ADDRESSES") @form.action(_(u"label_add_address", default="Add Address"), name=u'add_address') def handle_add_address_action(self, action, data): """ """ customer = ICustomerManagement(self.context).getAuthenticatedCustomer() customer_url = customer.absolute_url() template_url = self.context.absolute_url( ) + "/checkout-select-addresses" url = customer_url + "/add-address?goto=" + template_url self.request.response.redirect(url) def getShippingAddresses(self): """Returns all addresses with the currently selected invoice address checked. """ customer = ICustomerManagement(self.context).getAuthenticatedCustomer() am = IAddressManagement(customer) found_selected_address = False result = [] line = [] for index, address in enumerate(am.getAddresses()): checked = False if safe_unicode( address.getId()) == customer.selected_shipping_address: checked = "checked" found_selected_address = True address_as_dict = self._getAddressAsDict(address) address_as_dict["checked"] = checked line.append(address_as_dict) if (index + 1) % 3 == 0: result.append(line) line = [] result.append(line) if len(result) > 0 and found_selected_address == False: result[0][0]["checked"] = True return result def getInvoiceAddresses(self): """ """ customer = ICustomerManagement(self.context).getAuthenticatedCustomer() am = IAddressManagement(customer) found_selected_address = False result = [] line = [] for index, address in enumerate(am.getAddresses()): checked = False if safe_unicode( address.getId()) == customer.selected_invoice_address: checked = "checked" found_selected_address = True address_as_dict = self._getAddressAsDict(address) address_as_dict["checked"] = checked line.append(address_as_dict) if (index + 1) % 3 == 0: result.append(line) line = [] result.append(line) if found_selected_address == False: result[0][0]["checked"] = True return result def _getAddressAsDict(self, address): """Returns given address as dictionary. """ return { "id": address.getId(), "url": address.absolute_url(), "firstname": address.firstname, "lastname": address.lastname, "companyname": address.company_name, "address1": address.address_1, "zipcode": address.zip_code, "city": address.city, "country": address.country_title(), "phone": address.phone, }
def title(self): """ """ return _(u"EasyShop: Sorting")
def title(self): """ """ return _(u"EasyShop: Stock Information")
# easyshop imports from easyshop.core.config import _ from easyshop.core.interfaces import IBankAccount class BankAccount(Item): """Holds all relevant informations for direct debit payment method. This is a bank account. """ implements(IBankAccount) portal_type = "BankAccount" account_number = FieldProperty(IBankAccount["account_number"]) bank_identification_code = FieldProperty(IBankAccount["bank_identification_code"]) bank_name = FieldProperty(IBankAccount["bank_name"]) depositor = FieldProperty(IBankAccount["depositor"]) def Title(self): """ """ return self.bank_name + " - " + self.account_number def displayInfo(self): """ returns relevant payment information as dictionary """ return (self.account_number, self.bank_identification_code, self.bank_name, self.depositor) bankAccountFactory = Factory(BankAccount, title=_(u"Create a new bank account"))
def title(self): """ """ return _(u"EasyShop: Formatter")
def title(self): """ """ return _(u"EasyShop: Search Results")
text.append(address.country_title()) return " ".join(text) def getFirstname(self): """ """ return self.firstname def getLastname(self): """ """ return self.lastname def getVATRegistration(self): """ """ return self.vatreg def getEmail(self): """ """ return self.email def getId(self): """ """ return self.id customerFactory = Factory(Customer, title=_(u"Create a new customer"))
def title(self): """ """ return _(u"EasyShop: Categories")