Skip to content

Commit

Permalink
Merge pull request #1709 from cisagov/ab/1708-vip-table-to-verified-b…
Browse files Browse the repository at this point in the history
…y-staff

1708: Change VIP table to Verified by staff
  • Loading branch information
abroddrick authored Jan 30, 2024
2 parents 78e43ca + c850e1d commit fe21a3f
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/registrar/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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)
Original file line number Diff line number Diff line change
@@ -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"},
),
]
37 changes: 37 additions & 0 deletions src/registrar/migrations/0067_create_groups_v07.py
Original file line number Diff line number Diff line change
@@ -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,
),
]
6 changes: 3 additions & 3 deletions src/registrar/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -30,7 +30,7 @@
"UserGroup",
"Website",
"TransitionDomain",
"VeryImportantPerson",
"VerifiedByStaff",
]

auditlog.register(Contact)
Expand All @@ -47,4 +47,4 @@
auditlog.register(UserGroup, m2m_fields=["permissions"])
auditlog.register(Website)
auditlog.register(TransitionDomain)
auditlog.register(VeryImportantPerson)
auditlog.register(VerifiedByStaff)
4 changes: 2 additions & 2 deletions src/registrar/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/registrar/models/user_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
},
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand All @@ -28,5 +28,8 @@ class VeryImportantPerson(TimeStampedModel):
help_text="Notes",
)

class Meta:
verbose_name_plural = "Verified by staff"

def __str__(self):
return self.email
14 changes: 7 additions & 7 deletions src/registrar/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand All @@ -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="[email protected]", notes="Test Notes")
# Create a VerifiedByStaff instance
vip_instance = VerifiedByStaff(email="[email protected]", 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
Expand Down
6 changes: 3 additions & 3 deletions src/registrar/tests/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]

Expand Down
4 changes: 2 additions & 2 deletions src/registrar/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit fe21a3f

Please sign in to comment.