Skip to content

Commit 698965e

Browse files
committed
Fix one last fake email addresses that managed to escape the migration
- Legacy-Id: 12743
1 parent 9308948 commit 698965e

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

ietf/doc/migrations/0021_remove_fake_email_adresses.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ def fix_invalid_emails(apps, schema_editor):
77
Email = apps.get_model("person", "Email")
88
Role = apps.get_model("group", "Role")
99
RoleHistory = apps.get_model("group", "RoleHistory")
10+
DocumentAuthor = apps.get_model("doc", "DocumentAuthor")
11+
DocHistoryAuthor = apps.get_model("doc", "DocHistoryAuthor")
1012

1113
e = Email.objects.filter(address="unknown-email-Gigi-Karmous-Edwards").first()
1214
if e:
@@ -29,14 +31,20 @@ def fix_invalid_emails(apps, schema_editor):
2931
RoleHistory.objects.filter(email=e).update(email=new_e)
3032
e.delete()
3133

32-
Email = apps.get_model("person", "Email")
33-
DocumentAuthor = apps.get_model("doc", "DocumentAuthor")
34-
DocHistoryAuthor = apps.get_model("doc", "DocHistoryAuthor")
34+
e = Email.objects.filter(address="unknown-email-Greg-<gregimirsky@gmail.com>>").first()
35+
if e:
36+
# current email
37+
new_e = Email.objects.get(address="gregimirsky@gmail.com")
38+
DocumentAuthor.objects.filter(email=e).update(email=new_e)
39+
DocHistoryAuthor.objects.filter(email=e).update(email=new_e)
40+
e.delete()
3541

3642
DocumentAuthor.objects.filter(email__address__startswith="unknown-email-").exclude(email__address__contains="@").update(email=None)
3743
DocHistoryAuthor.objects.filter(email__address__startswith="unknown-email-").exclude(email__address__contains="@").update(email=None)
3844
Email.objects.exclude(address__contains="@").filter(address__startswith="unknown-email-").delete()
3945

46+
assert not Email.objects.filter(address__startswith="unknown-email-")
47+
4048
class Migration(migrations.Migration):
4149

4250
dependencies = [

0 commit comments

Comments
 (0)