Skip to content

Commit c8c45e2

Browse files
committed
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. Commit ready for merge.
- Legacy-Id: 10780
1 parent 776b951 commit c8c45e2

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
@@ -313,21 +313,26 @@ def ensure_person_email_info_exists(name, email):
313313

314314
# make sure we have an email address
315315
if email:
316+
active = True
316317
addr = email.lower()
317318
else:
318319
# we're in trouble, use a fake one
320+
active = False
319321
addr = u"unknown-email-%s" % person.name.replace(" ", "-")
320322

321323
try:
322324
email = person.email_set.get(address=addr)
323325
except Email.DoesNotExist:
324326
try:
325-
# maybe it's pointing to someone else
326-
email = Email.objects.get(address=addr)
327+
# An Email object pointing to some other person will not exist
328+
# at this point, because get_person_from_name_email would have
329+
# returned that person, but it's possible that an Email record
330+
# not associated with any Person exists
331+
email = Email.objects.get(address=addr,person__isnull=True)
327332
except Email.DoesNotExist:
328333
# most likely we just need to create it
329334
email = Email(address=addr)
330-
email.active = True
335+
email.active = active
331336

332337
email.person = person
333338
email.save()

0 commit comments

Comments
 (0)