def createAndAdd(self, data): """ """ am = IAddressManagement(self.context) am.addAddress(data) self.redirectToNextURL()
def createAndAdd(self, data): """ """ am = IAddressManagement(self.context) am.addAddress(data) self.redirectToNextURL()
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)
def testAddAddress(self): """ """ am = IAddressManagement(self.customer) id = am.addAddress({ "firstname": u"John", "lastname": u"Doe", "address_1": u"Doe Str. 1", "zip_code": u"4711", "city": u"Doe City", "country": u"Germany" }) ids = [a.getId() for a in am.getAddresses()] self.assertEqual(ids, ["address_1", "address_2", "address_3", id])
def testAddAddress(self): """ """ am = IAddressManagement(self.customer) id = am.addAddress({ "firstname" : u"John", "lastname" : u"Doe", "address_1" : u"Doe Str. 1", "zip_code" : u"4711", "city" : u"Doe City", "country" : u"Germany" }) ids = [a.getId() for a in am.getAddresses()] self.assertEqual(ids, ["address_1", "address_2", "address_3", id])
def testIsComplete(self): """ """ c = ICompleteness(self.shop.customers.customer) self.assertEqual(c.isComplete(), False) am = IAddressManagement(self.customer) id = am.addAddress({ "firstname" : u"John", "lastname" : u"Doe", "address_1" : u"Doe Str. 1", "zip_code" : u"4711", "city" : u"Doe City", "country" : u"Germany" }) self.customer.selected_invoice_address= id self.customer.selected_shipping_address = id self.assertEqual(c.isComplete(), False) view = getMultiAdapter((self.shop.products.product_1, self.shop.products.product_1.REQUEST), name="addToCart") view.addToCart() self.assertEqual(c.isComplete(), True)