summaryrefslogtreecommitdiff
path: root/ishtar_common/models_common.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/models_common.py')
-rw-r--r--ishtar_common/models_common.py55
1 files changed, 34 insertions, 21 deletions
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py
index e164677ba..22244e4e2 100644
--- a/ishtar_common/models_common.py
+++ b/ishtar_common/models_common.py
@@ -2248,38 +2248,51 @@ class Address(BaseHistorizedItem):
lbl += self.address_lbl()
return lbl
- def address_lbl(self):
- lbl = ""
+ def address_lbl(self, list=False):
+ lbls = []
prefix = ""
if self.alt_address_is_prefered:
prefix = "alt_"
if getattr(self, prefix + "address"):
- lbl += getattr(self, prefix + "address")
+ lbls.append((
+ getattr(self, prefix + "address"),
+ _("Address")
+ ))
if getattr(self, prefix + "address_complement"):
- if lbl:
- lbl += "\n"
- lbl += getattr(self, prefix + "address_complement")
+ lbls.append((
+ getattr(self, prefix + "address_complement"),
+ _("Address complement")
+ ))
postal_code = getattr(self, prefix + "postal_code")
town = getattr(self, prefix + "town")
if postal_code or town:
- if lbl:
- lbl += "\n"
- lbl += "{}{}{}".format(
- postal_code or "", " " if postal_code and town else "", town or ""
- )
+ lbls.append((
+ " ".join([postal_code, town]),
+ _("Postal code - Town")
+ ))
if self.phone:
- if lbl:
- lbl += "\n"
- lbl += "{} {}".format(str(_("Tel: ")), self.phone)
+ lbls.append((
+ self.phone,
+ _("Phone")
+ ))
if self.mobile_phone:
- if lbl:
- lbl += "\n"
- lbl += "{} {}".format(str(_("Mobile: ")), self.mobile_phone)
+ lbls.append((
+ self.mobile_phone,
+ _("Mobile")
+ ))
if self.email:
- if lbl:
- lbl += "\n"
- lbl += "{} {}".format(str(_("Email: ")), self.email)
- return lbl
+ lbls.append((
+ self.email,
+ _("Email")
+ ))
+ if list:
+ return lbls
+ return "\n".join([
+ value for value, lbl in lbls
+ ])
+
+ def address_lbl_list(self):
+ return self.address_lbl(list=True)
class Merge(models.Model):