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
This commit is contained in:
parent
776b95106f
commit
c8c45e2213
21
ietf/person/migrations/0005_deactivate_unknown_email.py
Normal file
21
ietf/person/migrations/0005_deactivate_unknown_email.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
def forward(apps, schema_editor):
|
||||
Email = apps.get_model('person','Email')
|
||||
Email.objects.filter(address__startswith="unknown-email-",active=True).update(active=False)
|
||||
|
||||
def reverse(apps,schema_editor):
|
||||
pass
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('person', '0004_auto_20150308_0440'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(forward,reverse)
|
||||
]
|
|
@ -313,21 +313,26 @@ def ensure_person_email_info_exists(name, email):
|
|||
|
||||
# make sure we have an email address
|
||||
if email:
|
||||
active = True
|
||||
addr = email.lower()
|
||||
else:
|
||||
# we're in trouble, use a fake one
|
||||
active = False
|
||||
addr = u"unknown-email-%s" % person.name.replace(" ", "-")
|
||||
|
||||
try:
|
||||
email = person.email_set.get(address=addr)
|
||||
except Email.DoesNotExist:
|
||||
try:
|
||||
# maybe it's pointing to someone else
|
||||
email = Email.objects.get(address=addr)
|
||||
# An Email object pointing to some other person will not exist
|
||||
# at this point, because get_person_from_name_email would have
|
||||
# returned that person, but it's possible that an Email record
|
||||
# not associated with any Person exists
|
||||
email = Email.objects.get(address=addr,person__isnull=True)
|
||||
except Email.DoesNotExist:
|
||||
# most likely we just need to create it
|
||||
email = Email(address=addr)
|
||||
email.active = True
|
||||
email.active = active
|
||||
|
||||
email.person = person
|
||||
email.save()
|
||||
|
|
Loading…
Reference in a new issue