def countries(context): """ """ terms = [] # terms.append(SimpleTerm("Germany", u"Germany")) # terms.append(SimpleTerm("USA", u"USA")) # terms.append(SimpleTerm("Polen", u"Polen")) shop = IShopManagement(context).getShop() if shop is None: # BBB: this is ugly because if we create a new address # we dont have any context. try to guess the first EasyShop # in portal_catalog and hope we are in luck! # XXX: this breaks if the site has more than one EasyShop instances!!! sm = getSiteManager() cat_query = sm.portal_catalog.queryCatalog( dict(portal_type='EasyShop')) if len(cat_query)<1: # this is not possible, because we weren't in this vocab if # we hadn't an EasyShop instance __traceback_info__ = "no Easyshop found in portal_catalog" raise Exception shop = cat_query[0].getObject() for country in shop.getCountries(): country = safe_unicode(country) term_value = queryUtility(IIDNormalizer).normalize(country) terms.append(SimpleTerm(term_value, term_value, country)) return SimpleVocabulary(terms)
def getCountries(self): """Returns available countries. """ result = [] customer = ICustomerManagement(self.context).getAuthenticatedCustomer() shop = IShopManagement(self.context).getShop() for country in shop.getCountries(): result.append({ "title" : country, "selected" : safe_unicode(country) == customer.selected_country }) return result
def getCountries(self): """ """ selected_country = self.request.get("country", "Deutschland") shop = IShopManagement(self.context).getShop() result = [] for country in shop.getCountries(): result.append({ "name" : country, "selected" : (selected_country == country) }) return result
def getCountries(self): """Returns available countries. """ result = [] customer = ICustomerManagement(self.context).getAuthenticatedCustomer() shop = IShopManagement(self.context).getShop() for country in shop.getCountries(): result.append({ "title": country, "selected": safe_unicode(country) == customer.selected_country }) return result
def createAndAdd(self, data): """ """ customer = ICustomerManagement(self.context).getAuthenticatedCustomer() am = IAddressManagement(customer) # Set firstname and lastname of the superior customer object. if len(customer.firstname) == 0: customer.firstname = data.get("firstname") customer.lastname = data.get("lastname") # Set email of the superior customer object. if len(customer.email) == 0: customer.email = data.get("email", u"") # Reset country selection. shop = IShopManagement(self.context).getShop() for country in shop.getCountries(): if queryUtility(IIDNormalizer).normalize(country) == data.get("country"): customer.selected_country = country am.addAddress(data)