Fix .email() on PersonOrOrgInfo so it handles priority (only used on

import) and doesn't try to do a bad job at cleaning the address
 - Legacy-Id: 3324
This commit is contained in:
Ole Laursen 2011-08-18 17:29:33 +00:00
parent 4a36338031
commit 132b4cb85b

View file

@ -276,9 +276,12 @@ class PersonOrOrgInfo(models.Model):
def email(self, priority=1, type=None):
name = unicode(self)
email = ''
addresses = self.emailaddress_set.filter(address__contains="@").order_by('priority')[:1]
addresses = self.emailaddress_set.filter(address__contains="@").order_by('priority')
if addresses:
email = addresses[0].address.replace('<', '').replace('>', '')
email = addresses[0].address
for a in addresses:
if a.priority == priority:
email = a.address
return (name, email)
# Added by Sunny Lee to display person's affiliation - 5/26/2007
def affiliation(self, priority=1):