-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify email metadata storage and access (#48)
- Loading branch information
1 parent
fb41971
commit dcc610c
Showing
15 changed files
with
334 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ def test_create_identity(self): | |
id="[email protected]", | ||
first_name="Billy", | ||
last_name="Bob", | ||
emails=[{"address": "[email protected]"}], | ||
all_emails=["[email protected]"], | ||
) | ||
self.assertEqual(user.sso_email_id, "[email protected]") | ||
self.assertEqual(user.is_active, True) | ||
|
@@ -28,5 +28,5 @@ def test_create_identity(self): | |
id="[email protected]", | ||
first_name="Billy", | ||
last_name="Bob", | ||
emails=[{"address": "[email protected]"}], | ||
all_emails=["[email protected]"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,23 +20,15 @@ def test_existing_user(self) -> None: | |
sso_email_id, | ||
"Billy", | ||
"Bob", | ||
[ | ||
{ | ||
"address": "[email protected]", | ||
"type": "", | ||
"preferred": False, | ||
}, | ||
], | ||
["[email protected]"], | ||
) | ||
|
||
def test_new_user(self) -> None: | ||
profile = services.create_identity( | ||
"[email protected]", | ||
"Billy", | ||
"Bob", | ||
[ | ||
{"address": "[email protected]", "type": "", "preferred": False}, | ||
], | ||
["[email protected]"], | ||
) | ||
self.assertTrue(isinstance(profile, Profile)) | ||
self.assertTrue(profile.pk) | ||
|
58 changes: 58 additions & 0 deletions
58
profiles/migrations/0003_alter_staffssoprofileemail_unique_together_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Generated by Django 5.1.4 on 2025-01-02 13:10 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
def forward(apps, schema_editor): | ||
StaffSSOProfileEmail = apps.get_model("profiles", "StaffSSOProfileEmail") | ||
records_to_update = StaffSSOProfileEmail.objects.filter(type="work") | ||
records_to_update.update(type="verified") | ||
|
||
|
||
def backward(apps, scheme_editor): | ||
StaffSSOProfileEmail = apps.get_model("profiles", "StaffSSOProfileEmail") | ||
records_to_update = StaffSSOProfileEmail.objects.filter(type="verified") | ||
records_to_update.update(type="work") | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("profiles", "0002_historicalprofile_is_active_profile_is_active"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterUniqueTogether( | ||
name="staffssoprofileemail", | ||
unique_together=set(), | ||
), | ||
migrations.AlterField( | ||
model_name="historicalstaffssoprofileemail", | ||
name="type", | ||
field=models.CharField( | ||
choices=[ | ||
("VERIFIED", "verified"), | ||
("CONTACT", "contact"), | ||
("USER_ADDED", "user-added"), | ||
], | ||
max_length=50, | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="staffssoprofileemail", | ||
name="type", | ||
field=models.CharField( | ||
choices=[ | ||
("VERIFIED", "verified"), | ||
("CONTACT", "contact"), | ||
("USER_ADDED", "user-added"), | ||
], | ||
max_length=50, | ||
), | ||
), | ||
migrations.AlterUniqueTogether( | ||
name="staffssoprofileemail", | ||
unique_together={("profile", "email", "type", "preferred")}, | ||
), | ||
migrations.RunPython(forward, backward), | ||
] |
65 changes: 65 additions & 0 deletions
65
profiles/migrations/0004_rename_preferred_email_historicalprofile_primary_email_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Generated by Django 5.1.4 on 2025-01-02 17:04 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("profiles", "0003_alter_staffssoprofileemail_unique_together_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name="historicalprofile", | ||
old_name="preferred_email", | ||
new_name="primary_email", | ||
), | ||
migrations.RenameField( | ||
model_name="historicalstaffssoprofileemail", | ||
old_name="preferred", | ||
new_name="is_primary", | ||
), | ||
migrations.RenameField( | ||
model_name="profile", | ||
old_name="preferred_email", | ||
new_name="primary_email", | ||
), | ||
migrations.RenameField( | ||
model_name="staffssoprofileemail", | ||
old_name="preferred", | ||
new_name="is_primary", | ||
), | ||
migrations.RemoveField( | ||
model_name="historicalstaffssoprofileemail", | ||
name="type", | ||
), | ||
migrations.AlterUniqueTogether( | ||
name="staffssoprofileemail", | ||
unique_together={("profile", "email")}, | ||
), | ||
migrations.AddField( | ||
model_name="historicalprofile", | ||
name="contact_email", | ||
field=models.CharField(blank=True, max_length=100, null=True), | ||
), | ||
migrations.AddField( | ||
model_name="historicalstaffssoprofileemail", | ||
name="is_contact", | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.AddField( | ||
model_name="profile", | ||
name="contact_email", | ||
field=models.CharField(blank=True, max_length=100, null=True), | ||
), | ||
migrations.AddField( | ||
model_name="staffssoprofileemail", | ||
name="is_contact", | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.RemoveField( | ||
model_name="staffssoprofileemail", | ||
name="type", | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.