Skip to content

Commit 33b1cc3

Browse files
committed
Merged in [10780] from rjsparks@nostrum.com:
Stop making active unknown-email- objects. Mark existing such objects as inactive. Tweak exception handling in submit/utils to make it obvious that the utilities will not change the person an existing Email record is pointing to. - Legacy-Id: 10787 Note: SVN reference [10780] has been migrated to Git commit c8c45e2
2 parents e5dcacf + c8c45e2 commit 33b1cc3

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import migrations
5+
6+
def forward(apps, schema_editor):
7+
Email = apps.get_model('person','Email')
8+
Email.objects.filter(address__startswith="unknown-email-",active=True).update(active=False)
9+
10+
def reverse(apps,schema_editor):
11+
pass
12+
13+
class Migration(migrations.Migration):
14+
15+
dependencies = [
16+
('person', '0004_auto_20150308_0440'),
17+
]
18+
19+
operations = [
20+
migrations.RunPython(forward,reverse)
21+
]

ietf/submit/utils.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,21 +317,26 @@ def ensure_person_email_info_exists(name, email):
317317

318318
# make sure we have an email address
319319
if email:
320+
active = True
320321
addr = email.lower()
321322
else:
322323
# we're in trouble, use a fake one
324+
active = False
323325
addr = u"unknown-email-%s" % person.name.replace(" ", "-")
324326

325327
try:
326328
email = person.email_set.get(address=addr)
327329
except Email.DoesNotExist:
328330
try:
329-
# maybe it's pointing to someone else
330-
email = Email.objects.get(address=addr)
331+
# An Email object pointing to some other person will not exist
332+
# at this point, because get_person_from_name_email would have
333+
# returned that person, but it's possible that an Email record
334+
# not associated with any Person exists
335+
email = Email.objects.get(address=addr,person__isnull=True)
331336
except Email.DoesNotExist:
332337
# most likely we just need to create it
333338
email = Email(address=addr)
334-
email.active = True
339+
email.active = active
335340

336341
email.person = person
337342
email.save()

0 commit comments

Comments
 (0)