-
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.
Update edit profile main email (#451)
- Loading branch information
Showing
8 changed files
with
99 additions
and
34 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Generated by Django 4.1.10 on 2023-09-05 13:06 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
def populate_contact_email(apps, schema_editor): | ||
""" | ||
Set the contact email to the email address if it is blank. | ||
""" | ||
Person = apps.get_model("peoplefinder", "Person") | ||
Person.objects.exclude(contact_email__isnull=False).update( | ||
contact_email=models.F("email"), | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("peoplefinder", "0109_person_preferred_first_name"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
populate_contact_email, | ||
reverse_code=migrations.RunPython.noop, | ||
), | ||
] |
45 changes: 45 additions & 0 deletions
45
src/peoplefinder/migrations/0111_alter_person_contact_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,45 @@ | ||
# Generated by Django 4.1.10 on 2023-09-13 14:47 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("peoplefinder", "0110_person_contact_email"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="person", | ||
name="contact_email", | ||
field=models.EmailField( | ||
blank=True, | ||
help_text="The work email you want people to contact you on.", | ||
max_length=254, | ||
null=True, | ||
verbose_name="Email address", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="person", | ||
name="primary_phone_number", | ||
field=models.CharField( | ||
blank=True, | ||
help_text="Enter the country's dialling code in place of the first 0. The UK's dialling code is +44.", | ||
max_length=42, | ||
null=True, | ||
verbose_name="Phone number", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="person", | ||
name="secondary_phone_number", | ||
field=models.CharField( | ||
blank=True, | ||
help_text="Enter the country's dialling code in place of the first 0. The UK's dialling code is +44.", | ||
max_length=160, | ||
null=True, | ||
verbose_name="Alternative phone number", | ||
), | ||
), | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -424,13 +424,13 @@ def test_profile_edit_contact_view(state): | |
response = state.client.get(view_url) | ||
|
||
assert response.status_code == 200 | ||
assert state.person.contact_email is None | ||
assert state.person.contact_email == "[email protected]" | ||
assert state.person.primary_phone_number is None | ||
assert state.person.secondary_phone_number is None | ||
|
||
form = ContactProfileEditForm( | ||
{ | ||
"contact_email": "jane.smith@test.com", | ||
"contact_email": "jane.smith123@test.com", | ||
"primary_phone_number": "01234567890", | ||
"secondary_phone_number": "09876543210", | ||
}, | ||
|
@@ -445,7 +445,7 @@ def test_profile_edit_contact_view(state): | |
|
||
assert response.status_code == 302 | ||
assert response.url == view_url | ||
assert state.person.contact_email == "jane.smith@test.com" | ||
assert state.person.contact_email == "jane.smith123@test.com" | ||
assert state.person.primary_phone_number == "01234567890" | ||
assert state.person.secondary_phone_number == "09876543210" | ||
|
||
|
@@ -462,9 +462,9 @@ def test_profile_edit_teams_view(state): | |
response = state.client.get(view_url) | ||
|
||
assert response.status_code == 200 | ||
assert state.person.contact_email is None | ||
assert state.person.primary_phone_number is None | ||
assert state.person.secondary_phone_number is None | ||
assert state.person.grade is None | ||
assert state.person.manager is None | ||
assert state.person.do_not_work_for_dit is False | ||
|
||
grade = Grade.objects.all().first() | ||
|
||
|
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