diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-01-13 17:13:44 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-01-13 17:13:44 +0100 | 
| commit | c4134e27d21b7b641a3b68c78cdf6e08cfb15557 (patch) | |
| tree | 594146e712448260d2ac209875506dc56b2e564e /ishtar_common/models.py | |
| parent | a2312380213fb30b88da6115663d8f9d72aced7b (diff) | |
| download | Ishtar-c4134e27d21b7b641a3b68c78cdf6e08cfb15557.tar.bz2 Ishtar-c4134e27d21b7b641a3b68c78cdf6e08cfb15557.zip | |
Sheets: Full address display for organizations and persons
Diffstat (limited to 'ishtar_common/models.py')
| -rw-r--r-- | ishtar_common/models.py | 31 | 
1 files changed, 27 insertions, 4 deletions
| diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 2745bf4b6..61376e079 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1069,8 +1069,18 @@ class Address(BaseHistorizedItem):      class Meta:          abstract = True +    def simple_lbl(self): +        return unicode(self) + +    def full_address(self): +        lbl = self.simple_lbl() +        if lbl: +            lbl += u"\n" +        lbl += self.address_lbl() +        return lbl +      def address_lbl(self): -        lbl = '' +        lbl = u''          if self.address:              lbl += self.address          if self.address_complement: @@ -1085,11 +1095,11 @@ class Address(BaseHistorizedItem):                  " " if self.postal_code and self.town else '',                  self.town or '')          if self.phone: -            lbl += "{}{}".format(_("Tel:"), self.phone) +            lbl += "{}{}".format(unicode(_("Tel:")), self.phone)          if self.mobile_phone: -            lbl += "{}{}".format(_("Mobile: "), self.mobile_phone) +            lbl += "{}{}".format(unicode(_("Mobile: ")), self.mobile_phone)          if self.email: -            lbl += "{}{}".format(_("Email: "), self.email) +            lbl += "{}{}".format(unicode(_("Email: ")), self.email)          return lbl @@ -1880,6 +1890,12 @@ class Organization(Address, Merge, OwnPerms, ValueGetter):               ugettext(u"Can delete own Organization")),          ) +    def simple_lbl(self): +        if self.name: +            return self.name +        return u"{} - {}".format(self.organization_type, +                                 self.town or "") +      def __unicode__(self):          if self.name:              return self.name @@ -1949,6 +1965,13 @@ class Person(Address, Merge, OwnPerms, ValueGetter):              ("delete_own_person", ugettext(u"Can delete own Person")),          ) +    def simple_lbl(self): +        values = [unicode(getattr(self, attr)) for attr in ('surname', 'name') +                  if getattr(self, attr)] +        if not values and self.raw_name: +            values = [self.raw_name] +        return u" ".join(values) +      def __unicode__(self):          values = [unicode(getattr(self, attr)) for attr in ('surname', 'name')                    if getattr(self, attr)] | 
