def SearchableText(self): """ """ text = [] text.append(self.firstname) text.append(self.lastname) text.append(self.email) am = IAddressManagement(self) for address in am.getAddresses(): if address.firstname: text.append(address.firstname) if address.lastname: text.append(address.lastname) if address.address_1: text.append(address.address_1) if address.zip_code: text.append(address.zip_code) if address.city: text.append(address.city) if address.country_title(): text.append(address.country_title()) return " ".join(text)
def getAddresses(self): """ """ customer = self._getCustomer() if customer is None: return None goto = self.context.absolute_url() goto += "?letter=%s" % self.request.get("letter") goto += "&id=%s" % customer.id goto = urllib.quote(goto) am = IAddressManagement(customer) addresses = [] for address in am.getAddresses(): # create name name = address.firstname + " " + address.lastname addresses.append({ "name": name, "address1": address.address_1, "phone": address.phone, "url": address.absolute_url() + "/@@edit?goto=" + goto }) return addresses
def testDeleteAddress(self): """ """ am = IAddressManagement(self.customer) am.deleteAddress("address_1") ids = [a.getId() for a in am.getAddresses()] self.assertEqual(ids, ["address_2", "address_3"]) am.deleteAddress("address_2") ids = [a.getId() for a in am.getAddresses()] self.assertEqual(ids, ["address_3"]) am.deleteAddress("address_3") ids = [a.getId() for a in am.getAddresses()] self.assertEqual(ids, [])
def getAddresses(self): """ """ customer = self._getCustomer() if customer is None: return None goto = self.context.absolute_url() goto += "?letter=%s" % self.request.get("letter") goto += "&id=%s" % customer.id goto = urllib.quote(goto) am = IAddressManagement(customer) addresses = [] for address in am.getAddresses(): # create name name = address.firstname + " " + address.lastname addresses.append({ "name" : name, "address1" : address.address_1, "phone" : address.phone, "url" : address.absolute_url() + "/@@edit?goto=" + goto }) return addresses
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 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 testDeleteAddress(self): """ """ am = IAddressManagement(self.customer) am.deleteAddress("address_1") ids = [a.getId() for a in am.getAddresses()] self.assertEqual(ids, ["address_2", "address_3"]) am.deleteAddress("address_2") ids = [a.getId() for a in am.getAddresses()] self.assertEqual(ids, ["address_3"]) am.deleteAddress("address_3") ids = [a.getId() for a in am.getAddresses()] self.assertEqual(ids, [])
def SearchableText(self): """ """ text = [] text.append(self.firstname) text.append(self.lastname) text.append(self.email) am = IAddressManagement(self) for address in am.getAddresses(): if address.firstname: text.append(address.firstname) if address.lastname: text.append(address.lastname) if address.address_1: text.append(address.address_1) if address.zip_code: text.append(address.zip_code) if address.city: text.append(address.city) if address.country_title(): text.append(address.country_title()) return " ".join(text)
def _getAddressesAsDL(self): """Returns all addresses as DisplayList. """ dl = DisplayList() am = IAddressManagement(self) for address in am.getAddresses(): dl.add(address.getId(), address.getName() + " - " + address.getAddress1()) return dl
def _getAddressesAsDL(self): """Returns all addresses as DisplayList. """ dl = DisplayList() am = IAddressManagement(self) for address in am.getAddresses(): dl.add(address.getId(), address.getName() + " - " + address.getAddress1()) return dl
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 getAddresses(self): """ """ customer = self._getCustomer() if customer is None: return None goto = self.context.absolute_url() goto += "?letter=%s" % self.request.get("letter") goto += "&uid=%s" % customer.UID() goto = urllib.quote(goto) am = IAddressManagement(customer) addresses = [] for address in am.getAddresses(): # create name name = address.getFirstname() + " " + address.getLastname() # create address 1 address1 = address.getAddress1() if address.getAddress2(): address1 += " / " address1 += address.getAddress2() # create address 2 address2 = address.getZipCode() + " " + \ address.getCity() + " - " + \ address.getCountry() addresses.append({ "name": name, "address1": address1, "address2": address2, "phone": address.getPhone(), "url": address.absolute_url() + "/@@edit?goto=" + goto }) return addresses
def SearchableText(self): """ """ text = [] text.append(self.getFirstname()) text.append(self.getLastname()) text.append(self.getEmail()) am = IAddressManagement(self) for address in am.getAddresses(): text.append(address.getFirstname()) text.append(address.getLastname()) text.append(address.getAddress1()) text.append(address.getZipCode()) text.append(address.getCity()) text.append(address.getCountry()) return " ".join(text)
def SearchableText(self): """ """ text = [] text.append(self.getFirstname()) text.append(self.getLastname()) text.append(self.getEmail()) am = IAddressManagement(self) for address in am.getAddresses(): text.append(address.getFirstname()) text.append(address.getLastname()) text.append(address.getAddress1()) text.append(address.getZipCode()) text.append(address.getCity()) text.append(address.getCountry()) return " ".join(text)
def getAddresses(self): """ """ customer = self._getCustomer() if customer is None: return None goto = self.context.absolute_url() goto += "?letter=%s" % self.request.get("letter") goto += "&uid=%s" % customer.UID() goto = urllib.quote(goto) am = IAddressManagement(customer) addresses = [] for address in am.getAddresses(): # create name name = address.getFirstname() + " " + address.getLastname() # create address 1 address1 = address.getAddress1() if address.getAddress2(): address1 += " / " address1 += address.getAddress2() # create address 2 address2 = address.getZipCode() + " " + \ address.getCity() + " - " + \ address.getCountry() addresses.append({ "name" : name, "address1" : address1, "address2" : address2, "phone" : address.getPhone(), "url" : address.absolute_url() + "/@@edit?goto=" + goto }) return addresses
def testGetAddresses(self): """ """ am = IAddressManagement(self.customer) ids = [a.getId() for a in am.getAddresses()] self.assertEqual(ids, ["address_1", "address_2", "address_3"])
def testGetAddresses(self): """ """ am = IAddressManagement(self.customer) self.assertEqual([], am.getAddresses())
def getAddresses(self): """ """ am = IAddressManagement(self.context) return am.getAddresses()
def testGetAddresses(self): """ """ am = IAddressManagement(self.customer) ids = [a.getId() for a in am.getAddresses()] self.assertEqual(ids, ["address_1", "address_2", "address_3"])
def getAddresses(self): """ """ am = IAddressManagement(self.context) return am.getAddresses()
def testGetAddresses(self): """ """ am = IAddressManagement(self.customer) self.assertEqual([], am.getAddresses())