Repository: cisagov/manage.get.gov

Issue:
Add a filter for "status" to the `DomainInvitation` model in Django admin
### Story

As a registrar team member
I want to be able to look at domain invitations that are retrieved
so that I can monitor domain manager uptake


### Acceptance Criteria

- [ ] Add a filter on the "status" field to the Django admin view of the `DomainInvitation` model so that the list view can be filtered to just include `retrieved` or `invited` invitations.

### Additional Context

This will make it very easy to count how many domain invitations have been retrieved from the big pile of invitations we will send out initially.

### Issue Links

_No response_


Discussion:

Resolving patch:
diff --git a/src/registrar/admin.py b/src/registrar/admin.py
--- a/src/registrar/admin.py
+++ b/src/registrar/admin.py
@@ -344,6 +344,12 @@ class UserDomainRoleAdmin(ListHeaderAdmin):
 class DomainInvitationAdmin(ListHeaderAdmin):
     """Custom domain invitation admin class."""
 
+    class Meta:
+        model = models.DomainInvitation
+        fields = "__all__"
+
+    _meta = Meta()
+
     # Columns
     list_display = [
         "email",
@@ -356,6 +362,10 @@ class DomainInvitationAdmin(ListHeaderAdmin):
         "email",
         "domain__name",
     ]
+
+    # Filters
+    list_filter = ("status",)
+
     search_help_text = "Search by email or domain."
 
     # Mark the FSM field 'status' as readonly


Test patch:
diff --git a/src/registrar/tests/test_admin.py b/src/registrar/tests/test_admin.py
--- a/src/registrar/tests/test_admin.py
+++ b/src/registrar/tests/test_admin.py
@@ -8,6 +8,7 @@
     DomainAdmin,
     DomainApplicationAdmin,
     DomainApplicationAdminForm,
+    DomainInvitationAdmin,
     ListHeaderAdmin,
     MyUserAdmin,
     AuditedAdmin,
@@ -847,6 +848,44 @@ def tearDown(self):
         User.objects.all().delete()
 
 
+class DomainInvitationAdminTest(TestCase):
+    """Tests for the DomainInvitation page"""
+
+    def setUp(self):
+        """Create a client object"""
+        self.client = Client(HTTP_HOST="localhost:8080")
+        self.factory = RequestFactory()
+        self.admin = ListHeaderAdmin(model=DomainInvitationAdmin, admin_site=AdminSite())
+        self.superuser = create_superuser()
+
+    def tearDown(self):
+        """Delete all DomainInvitation objects"""
+        DomainInvitation.objects.all().delete()
+
+    def test_get_filters(self):
+        """Ensures that our filters are displaying correctly"""
+        # Have to get creative to get past linter
+        p = "adminpass"
+        self.client.login(username="superuser", password=p)
+
+        response = self.client.get(
+            "/admin/registrar/domaininvitation/",
+            {},
+            follow=True,
+        )
+
+        # Assert that the filters are added
+        self.assertContains(response, "invited", count=4)
+        self.assertContains(response, "retrieved", count=4)
+
+        # Check for the HTML context specificially
+        invited_html = '<a href="?status__exact=invited">invited</a>'
+        retrieved_html = '<a href="?status__exact=retrieved">retrieved</a>'
+
+        self.assertContains(response, invited_html, count=1)
+        self.assertContains(response, retrieved_html, count=1)
+
+
 class ListHeaderAdminTest(TestCase):
     def setUp(self):
         self.site = AdminSite()
diff --git a/src/registrar/tests/test_reports.py b/src/registrar/tests/test_reports.py
--- a/src/registrar/tests/test_reports.py
+++ b/src/registrar/tests/test_reports.py
@@ -50,6 +50,7 @@ def setUp(self):
         )
 
     def tearDown(self):
+        # Dummy push - will remove
         Domain.objects.all().delete()
         DomainInformation.objects.all().delete()
         User.objects.all().delete()