File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,6 +75,9 @@ class Areas(models.Model):
7575 extra_email_addresses = models .TextField (blank = True )
7676 def __str__ (self ):
7777 return self .area_acronym .acronym
78+ def active_area_choices ():
79+ return [(area .area_acronym_id , area .area_acronym .acronym ) for area in Areas .objects .filter (status = 1 ).select_related ().order_by ('acronym.acronym' )]
80+ active_area_choices = staticmethod (active_area_choices )
7881 class Meta :
7982 db_table = 'areas'
8083 #ordering = ['area_acronym_id']
@@ -197,6 +200,14 @@ def save(self):
197200 self .last_name_key = self .last_name .upper ()
198201 super (PersonOrOrgInfo , self ).save ()
199202 def __str__ (self ):
203+ if self .first_name == '' and self .last_name == '' :
204+ try :
205+ postal = self .postaladdress_set .get (address_priority = 1 )
206+ except PostalAddress .DoesNotExist :
207+ return "PersonOrOrgInfo with no name, no postal address!"
208+ except AssertionError :
209+ return "PersonOrOrgInfo with multiple priority-1 addresses!"
210+ return "%s" % ( postal .affiliated_company or postal .department or "???" )
200211 return "%s %s" % ( self .first_name or "<nofirst>" , self .last_name or "<nolast>" )
201212 class Meta :
202213 db_table = 'person_or_org_info'
You can’t perform that action at this time.
0 commit comments