-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1938 from uktrade/uat
PROD Release 22_04_23
- Loading branch information
Showing
13 changed files
with
274 additions
and
148 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
Large diffs are not rendered by default.
Oops, something went wrong.
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.2.11 on 2024-04-11 14:51 | ||
|
||
from django.db import migrations | ||
|
||
|
||
def update_teams_on_advice(apps, schema_editor): | ||
Advice = apps.get_model("cases", "Advice") | ||
|
||
teams = set(Advice.objects.values_list("user__team", flat=True)) | ||
for team in teams: | ||
advice_without_a_team = Advice.objects.filter(team__isnull=True, user__team=team) | ||
advice_without_a_team.update(team=team) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("cases", "0063_ecjuquery_chaser_email_sent_on"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
update_teams_on_advice, | ||
reverse_code=migrations.RunPython.noop, | ||
), | ||
] |
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,78 @@ | ||
from django_test_migrations.contrib.unittest_case import MigratorTestCase | ||
|
||
from api.core.constants import Roles | ||
|
||
|
||
class TestAdviceTeamMigration(MigratorTestCase): | ||
migrate_from = ("cases", "0063_ecjuquery_chaser_email_sent_on") | ||
migrate_to = ("cases", "0064_update_teams_on_advice") | ||
|
||
def prepare(self): | ||
Role = self.old_state.apps.get_model("users", "Role") | ||
Role.objects.create(id=Roles.INTERNAL_DEFAULT_ROLE_ID) | ||
|
||
Team = self.old_state.apps.get_model("teams", "Team") | ||
self.a_team = Team.objects.create(name="a_team") | ||
self.b_team = Team.objects.create(name="b_team") | ||
|
||
BaseUser = self.old_state.apps.get_model("users", "BaseUser") | ||
a_team_base_user = BaseUser.objects.create(email="[email protected]") # /PS-IGNORE | ||
b_team_base_user = BaseUser.objects.create(email="[email protected]") # /PS-IGNORE | ||
|
||
GovUser = self.old_state.apps.get_model("users", "GovUser") | ||
a_team_user = GovUser.objects.create( | ||
baseuser_ptr=a_team_base_user, | ||
team=self.a_team, | ||
) | ||
b_team_user = GovUser.objects.create( | ||
baseuser_ptr=b_team_base_user, | ||
team=self.b_team, | ||
) | ||
|
||
Organisation = self.old_state.apps.get_model("organisations", "Organisation") | ||
organisation = Organisation.objects.create(name="test") | ||
|
||
CaseType = self.old_state.apps.get_model("cases", "CaseType") | ||
case_type = CaseType.objects.get(pk="00000000-0000-0000-0000-000000000004") | ||
|
||
Case = self.old_state.apps.get_model("cases", "Case") | ||
case = Case.objects.create( | ||
case_type=case_type, | ||
organisation=organisation, | ||
) | ||
|
||
Advice = self.old_state.apps.get_model("cases", "Advice") | ||
self.user_advice_with_same_team = Advice.objects.create( | ||
case=case, | ||
team=self.a_team, | ||
user=a_team_user, | ||
) | ||
self.user_advice_with_different_team = Advice.objects.create( | ||
case=case, | ||
team=self.a_team, | ||
user=b_team_user, | ||
) | ||
self.user_advice_without_team = Advice.objects.create( | ||
case=case, | ||
team=None, | ||
user=a_team_user, | ||
) | ||
|
||
def test_migration_0064_update_teams_on_advice(self): | ||
self.user_advice_with_same_team.refresh_from_db() | ||
self.assertEqual( | ||
self.user_advice_with_same_team.team, | ||
self.a_team, | ||
) | ||
|
||
self.user_advice_with_different_team.refresh_from_db() | ||
self.assertEqual( | ||
self.user_advice_with_different_team.team, | ||
self.a_team, | ||
) | ||
|
||
self.user_advice_without_team.refresh_from_db() | ||
self.assertEqual( | ||
self.user_advice_without_team.team, | ||
self.a_team, | ||
) |
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
24 changes: 24 additions & 0 deletions
24
api/external_data/migrations/0022_denialentity_entity_type.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,24 @@ | ||
# Generated by Django 4.2.11 on 2024-04-18 08:45 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("external_data", "0021_denialentity_denial_id"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="denialentity", | ||
name="entity_type", | ||
field=models.TextField( | ||
blank=True, | ||
choices=[("consignee", "Consignee"), ("end_user", "End-user"), ("third_party", "Third party")], | ||
default="", | ||
help_text="Type of entity being denied", | ||
null=True, | ||
), | ||
), | ||
] |
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