Add helper function email() to PersonOrOrgInfo, which returns the
email address in a 2-tuple that email.Utils.formataddr() accepts. - Legacy-Id: 160
This commit is contained in:
parent
19d77b754a
commit
0ceb9e2b0c
|
@ -209,6 +209,13 @@ class PersonOrOrgInfo(models.Model):
|
||||||
return "PersonOrOrgInfo with multiple priority-1 addresses!"
|
return "PersonOrOrgInfo with multiple priority-1 addresses!"
|
||||||
return "%s" % ( postal.affiliated_company or postal.department or "???" )
|
return "%s" % ( postal.affiliated_company or postal.department or "???" )
|
||||||
return "%s %s" % ( self.first_name or "<nofirst>", self.last_name or "<nolast>")
|
return "%s %s" % ( self.first_name or "<nofirst>", self.last_name or "<nolast>")
|
||||||
|
def email(self, priority=1, type='INET'):
|
||||||
|
name = str(self)
|
||||||
|
try:
|
||||||
|
email = self.emailaddress_set.get(priority=priority, type=type).address
|
||||||
|
except EmailAddress.DoesNotExist:
|
||||||
|
email = ''
|
||||||
|
return (name, email)
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'person_or_org_info'
|
db_table = 'person_or_org_info'
|
||||||
ordering = ['last_name']
|
ordering = ['last_name']
|
||||||
|
|
Loading…
Reference in a new issue