Skip to content

Commit c347552

Browse files
committed
Import affiliation and fix bug in clean_email_address
- Legacy-Id: 3307
1 parent ef28ba9 commit c347552

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

redesign/importing/utils.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33

44
def clean_email_address(addr):
55
addr = addr.replace("!", "@").replace("(at)", "@") # some obvious @ replacements
6-
addr = addr[addr.rfind('<') + 1:addr.find('>')] # whack surrounding <...>
6+
# whack surrounding <...>
7+
addr = addr[addr.rfind('<') + 1:]
8+
end = addr.find('>')
9+
if end != -1:
10+
addr = addr[:end]
711
addr = addr.strip()
812
if not "@" in addr:
913
return ""
@@ -42,8 +46,15 @@ def get_or_create_email(o, create_fake):
4246
if aliases:
4347
p = aliases[0].person
4448
else:
45-
p = Person.objects.create(id=person.pk, name=n, ascii=asciified)
46-
# FIXME: fill in address?
49+
p = Person(id=person.pk, name=n, ascii=asciified)
50+
51+
from ietf.idtracker.models import PostalAddress
52+
addresses = person.postaladdress_set.filter(address_priority=1)
53+
if addresses:
54+
p.affiliation = (addresses[0].affiliated_company or "").strip()
55+
# should probably import p.address here
56+
57+
p.save()
4758

4859
Alias.objects.create(name=n, person=p)
4960
if asciified != n:

0 commit comments

Comments
 (0)