Skip to content

Commit a2156d8

Browse files
committed
Try harder to find a relevant email address. The new code will eventually fall back to a broad search which matches that of the perl code which creates WG charter pages, where the old code would sometimes result in django-generated charter pages with missing email addresses.
- Legacy-Id: 2025
1 parent 944ad2a commit a2156d8

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

ietf/idtracker/models.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,19 @@ def __unicode__(self):
289289
if self.first_name == '' and self.last_name == '':
290290
return u"(Person #%s)" % self.person_or_org_tag
291291
return u"%s %s" % ( self.first_name or u"<nofirst>", self.last_name or u"<nolast>")
292-
def email(self, priority=1, type='INET'):
292+
def email(self, priority=1, type=None):
293293
name = str(self)
294-
try:
295-
email = self.emailaddress_set.get(priority=priority, type=type).address
296-
except (EmailAddress.DoesNotExist, AssertionError):
297-
email = ''
294+
email = ''
295+
types = type and [ type ] or [ "INET", "Prim", None ]
296+
for type in types:
297+
try:
298+
if type:
299+
email = self.emailaddress_set.get(priority=priority, type=type).address
300+
else:
301+
email = self.emailaddress_set.get(priority=priority).address
302+
break
303+
except (EmailAddress.DoesNotExist, AssertionError):
304+
pass
298305
return (name, email)
299306
# Added by Sunny Lee to display person's affiliation - 5/26/2007
300307
def affiliation(self, priority=1):
@@ -307,7 +314,7 @@ def affiliation(self, priority=1):
307314
return "%s" % ( postal.affiliated_company or postal.department or "???" )
308315
class Meta:
309316
db_table = 'person_or_org_info'
310-
ordering = ['last_name']
317+
ordering = ['last_name']
311318
verbose_name="Rolodex Entry"
312319
verbose_name_plural="Rolodex"
313320
class Admin:

0 commit comments

Comments
 (0)