diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 0e98493708..3250815751 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -1295,7 +1295,7 @@ class DraftDomainAdmin(ListHeaderAdmin): search_help_text = "Search by draft domain name." -class VeryImportantPersonAdmin(ListHeaderAdmin): +class VerifiedByStaffAdmin(ListHeaderAdmin): list_display = ("email", "requestor", "truncated_notes", "created_at") search_fields = ["email"] search_help_text = "Search by email." @@ -1338,4 +1338,4 @@ def save_model(self, request, obj, form, change): admin.site.register(models.PublicContact, AuditedAdmin) admin.site.register(models.DomainApplication, DomainApplicationAdmin) admin.site.register(models.TransitionDomain, TransitionDomainAdmin) -admin.site.register(models.VeryImportantPerson, VeryImportantPersonAdmin) +admin.site.register(models.VerifiedByStaff, VerifiedByStaffAdmin) diff --git a/src/registrar/migrations/0066_rename_veryimportantperson_verifiedbystaff_and_more.py b/src/registrar/migrations/0066_rename_veryimportantperson_verifiedbystaff_and_more.py new file mode 100644 index 0000000000..d167334a0b --- /dev/null +++ b/src/registrar/migrations/0066_rename_veryimportantperson_verifiedbystaff_and_more.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2.7 on 2024-01-29 22:21 + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("registrar", "0065_create_groups_v06"), + ] + + operations = [ + migrations.RenameModel( + old_name="VeryImportantPerson", + new_name="VerifiedByStaff", + ), + migrations.AlterModelOptions( + name="verifiedbystaff", + options={"verbose_name_plural": "Verified by staff"}, + ), + ] diff --git a/src/registrar/migrations/0067_create_groups_v07.py b/src/registrar/migrations/0067_create_groups_v07.py new file mode 100644 index 0000000000..85138d4af2 --- /dev/null +++ b/src/registrar/migrations/0067_create_groups_v07.py @@ -0,0 +1,37 @@ +# This migration creates the create_full_access_group and create_cisa_analyst_group groups +# It is dependent on 0035 (which populates ContentType and Permissions) +# If permissions on the groups need changing, edit CISA_ANALYST_GROUP_PERMISSIONS +# in the user_group model then: +# [NOT RECOMMENDED] +# step 1: docker-compose exec app ./manage.py migrate --fake registrar 0035_contenttypes_permissions +# step 2: docker-compose exec app ./manage.py migrate registrar 0036_create_groups +# step 3: fake run the latest migration in the migrations list +# [RECOMMENDED] +# Alternatively: +# step 1: duplicate the migration that loads data +# step 2: docker-compose exec app ./manage.py migrate + +from django.db import migrations +from registrar.models import UserGroup +from typing import Any + + +# For linting: RunPython expects a function reference, +# so let's give it one +def create_groups(apps, schema_editor) -> Any: + UserGroup.create_cisa_analyst_group(apps, schema_editor) + UserGroup.create_full_access_group(apps, schema_editor) + + +class Migration(migrations.Migration): + dependencies = [ + ("registrar", "0066_rename_veryimportantperson_verifiedbystaff_and_more"), + ] + + operations = [ + migrations.RunPython( + create_groups, + reverse_code=migrations.RunPython.noop, + atomic=True, + ), + ] diff --git a/src/registrar/models/__init__.py b/src/registrar/models/__init__.py index 90cb2e286b..d9ccd64cb8 100644 --- a/src/registrar/models/__init__.py +++ b/src/registrar/models/__init__.py @@ -13,7 +13,7 @@ from .user_group import UserGroup from .website import Website from .transition_domain import TransitionDomain -from .very_important_person import VeryImportantPerson +from .verified_by_staff import VerifiedByStaff __all__ = [ "Contact", @@ -30,7 +30,7 @@ "UserGroup", "Website", "TransitionDomain", - "VeryImportantPerson", + "VerifiedByStaff", ] auditlog.register(Contact) @@ -47,4 +47,4 @@ auditlog.register(UserGroup, m2m_fields=["permissions"]) auditlog.register(Website) auditlog.register(TransitionDomain) -auditlog.register(VeryImportantPerson) +auditlog.register(VerifiedByStaff) diff --git a/src/registrar/models/user.py b/src/registrar/models/user.py index 269569bfed..bf904a0445 100644 --- a/src/registrar/models/user.py +++ b/src/registrar/models/user.py @@ -7,7 +7,7 @@ from .domain_invitation import DomainInvitation from .transition_domain import TransitionDomain -from .very_important_person import VeryImportantPerson +from .verified_by_staff import VerifiedByStaff from .domain import Domain from phonenumber_field.modelfields import PhoneNumberField # type: ignore @@ -91,7 +91,7 @@ def needs_identity_verification(cls, email, uuid): return False # New users flagged by Staff to bypass ial2 - if VeryImportantPerson.objects.filter(email=email).exists(): + if VerifiedByStaff.objects.filter(email=email).exists(): return False # A new incoming user who is being invited to be a domain manager (that is, diff --git a/src/registrar/models/user_group.py b/src/registrar/models/user_group.py index 2658ec52d7..a32406a055 100644 --- a/src/registrar/models/user_group.py +++ b/src/registrar/models/user_group.py @@ -68,8 +68,8 @@ def create_cisa_analyst_group(apps, schema_editor): }, { "app_label": "registrar", - "model": "veryimportantperson", - "permissions": ["add_veryimportantperson", "change_veryimportantperson", "delete_veryimportantperson"], + "model": "verifiedbystaff", + "permissions": ["add_verifiedbystaff", "change_verifiedbystaff", "delete_verifiedbystaff"], }, ] diff --git a/src/registrar/models/very_important_person.py b/src/registrar/models/verified_by_staff.py similarity index 85% rename from src/registrar/models/very_important_person.py rename to src/registrar/models/verified_by_staff.py index 9134cb893a..4c9e76e9d9 100644 --- a/src/registrar/models/very_important_person.py +++ b/src/registrar/models/verified_by_staff.py @@ -3,7 +3,7 @@ from .utility.time_stamped_model import TimeStampedModel -class VeryImportantPerson(TimeStampedModel): +class VerifiedByStaff(TimeStampedModel): """emails that get added to this table will bypass ial2 on login.""" @@ -28,5 +28,8 @@ class VeryImportantPerson(TimeStampedModel): help_text="Notes", ) + class Meta: + verbose_name_plural = "Verified by staff" + def __str__(self): return self.email diff --git a/src/registrar/tests/test_admin.py b/src/registrar/tests/test_admin.py index ebf3dfed98..f88e25c2f6 100644 --- a/src/registrar/tests/test_admin.py +++ b/src/registrar/tests/test_admin.py @@ -14,11 +14,11 @@ ContactAdmin, DomainInformationAdmin, UserDomainRoleAdmin, - VeryImportantPersonAdmin, + VerifiedByStaffAdmin, ) from registrar.models import Domain, DomainApplication, DomainInformation, User, DomainInvitation, Contact, Website from registrar.models.user_domain_role import UserDomainRole -from registrar.models.very_important_person import VeryImportantPerson +from registrar.models.verified_by_staff import VerifiedByStaff from .common import ( MockSESClient, AuditedAdminMockData, @@ -1820,7 +1820,7 @@ def tearDown(self): User.objects.all().delete() -class VeryImportantPersonAdminTestCase(TestCase): +class VerifiedByStaffAdminTestCase(TestCase): def setUp(self): self.superuser = create_superuser() self.factory = RequestFactory() @@ -1829,13 +1829,13 @@ def test_save_model_sets_user_field(self): self.client.force_login(self.superuser) # Create an instance of the admin class - admin_instance = VeryImportantPersonAdmin(model=VeryImportantPerson, admin_site=None) + admin_instance = VerifiedByStaffAdmin(model=VerifiedByStaff, admin_site=None) - # Create a VeryImportantPerson instance - vip_instance = VeryImportantPerson(email="test@example.com", notes="Test Notes") + # Create a VerifiedByStaff instance + vip_instance = VerifiedByStaff(email="test@example.com", notes="Test Notes") # Create a request object - request = self.factory.post("/admin/yourapp/veryimportantperson/add/") + request = self.factory.post("/admin/yourapp/VerifiedByStaff/add/") request.user = self.superuser # Call the save_model method diff --git a/src/registrar/tests/test_migrations.py b/src/registrar/tests/test_migrations.py index cf28aa81ae..773a885c10 100644 --- a/src/registrar/tests/test_migrations.py +++ b/src/registrar/tests/test_migrations.py @@ -43,9 +43,9 @@ def test_groups_created(self): "change_user", "delete_userdomainrole", "view_userdomainrole", - "add_veryimportantperson", - "change_veryimportantperson", - "delete_veryimportantperson", + "add_verifiedbystaff", + "change_verifiedbystaff", + "delete_verifiedbystaff", "change_website", ] diff --git a/src/registrar/tests/test_models.py b/src/registrar/tests/test_models.py index ef65227474..d0005cbd56 100644 --- a/src/registrar/tests/test_models.py +++ b/src/registrar/tests/test_models.py @@ -16,7 +16,7 @@ import boto3_mocking from registrar.models.transition_domain import TransitionDomain -from registrar.models.very_important_person import VeryImportantPerson # type: ignore +from registrar.models.verified_by_staff import VerifiedByStaff # type: ignore from .common import MockSESClient, less_console_noise, completed_application from django_fsm import TransitionNotAllowed @@ -656,7 +656,7 @@ def test_identity_verification_with_transition_user(self): def test_identity_verification_with_very_important_person(self): """A Very Important Person should return False when tested with class method needs_identity_verification""" - VeryImportantPerson.objects.get_or_create(email=self.user.email) + VerifiedByStaff.objects.get_or_create(email=self.user.email) self.assertFalse(User.needs_identity_verification(self.user.email, self.user.username)) def test_identity_verification_with_invited_user(self):