internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: cisagov/manage.get.gov

Issue:
Implement confirmation message when a user cancels a domain manager invitation
### Issue description

To follow other patterns across the application, we need to implement a confirmation message when a user cancels a domain manager invitation.

### Acceptance criteria

- [ ] When user clicks cancel in the Invitations table on the Domain managers page
- [ ] The confirmation message is: "Canceled invitation to [email address]."

### Additional context

_No response_

### Links to other issues

Design ticket: #1379 
[Figma design ](https://www.figma.com/file/aJbuDLJNNikqQObTuCNKQa/GetGov_Designs_ECS-Truss?type=design&node-id=3328%3A18978&mode=dev)


Discussion:

Resolving patch:
diff --git a/src/registrar/views/domain.py b/src/registrar/views/domain.py
--- a/src/registrar/views/domain.py
+++ b/src/registrar/views/domain.py
@@ -787,14 +787,17 @@ def form_valid(self, form):
         return redirect(self.get_success_url())
 
 
-class DomainInvitationDeleteView(DomainInvitationPermissionDeleteView, SuccessMessageMixin):
+# The order of the superclasses matters here. BaseDeleteView has a bug where the
+# "form_valid" function does not call super, so it cannot use SuccessMessageMixin.
+# The workaround is to use SuccessMessageMixin first.
+class DomainInvitationDeleteView(SuccessMessageMixin, DomainInvitationPermissionDeleteView):
     object: DomainInvitation  # workaround for type mismatch in DeleteView
 
     def get_success_url(self):
         return reverse("domain-users", kwargs={"pk": self.object.domain.id})
 
     def get_success_message(self, cleaned_data):
-        return f"Successfully canceled invitation for {self.object.email}."
+        return f"Canceled invitation to {self.object.email}."
 
 
 class DomainDeleteUserView(UserDomainRolePermissionDeleteView):


Test patch:
Repository: cisagov/manage.get.gov

Issue:
Update button text for adding a domain manager
Changed "Add a domain manager" to "Add domain manager." The latter reflects that the user is adding a specific domain manager. 


Discussion:
🥳 Successfully deployed to developer sandbox **[ko](https://getgov-ko.app.cloud.gov/)**.

Resolving patch:
diff --git a/src/registrar/admin.py b/src/registrar/admin.py
--- a/src/registrar/admin.py
+++ b/src/registrar/admin.py
@@ -758,6 +758,14 @@ class DomainInformationAdmin(ListHeaderAdmin):
     # to activate the edit/delete/view buttons
     filter_horizontal = ("other_contacts",)
 
+    autocomplete_fields = [
+        "creator",
+        "domain_application",
+        "authorizing_official",
+        "domain",
+        "submitter",
+    ]
+
     # Table ordering
     ordering = ["domain__name"]
 
@@ -1080,6 +1088,14 @@ class DomainInformationInline(admin.StackedInline):
     # to activate the edit/delete/view buttons
     filter_horizontal = ("other_contacts",)
 
+    autocomplete_fields = [
+        "creator",
+        "domain_application",
+        "authorizing_official",
+        "domain",
+        "submitter",
+    ]
+
     def formfield_for_manytomany(self, db_field, request, **kwargs):
         """customize the behavior of formfields with manytomany relationships.  the customized
         behavior includes sorting of objects in lists as well as customizing helper text"""


Test patch:
Repository: cisagov/manage.get.gov

Issue:
Use one error message for zip code validation or when a zip code field is empty
Let's use one error message for empty zip code fields and invalid zip codes. Currently, in the manage domain > org mailing address flow, we have one error message if the zip code is empty or invalid. In the new domain request > org mailing address flow, we have one message for an empty zip code field and a different message for an invalid zip code.

AC:

- [ ] Zip code fields show the same error message whether the field is empty or invalid. The error message should be "Enter a zip code in the form of 12345 or 12345-6789."


Discussion:

Resolving patch:
diff --git a/src/registrar/forms/application_wizard.py b/src/registrar/forms/application_wizard.py
--- a/src/registrar/forms/application_wizard.py
+++ b/src/registrar/forms/application_wizard.py
@@ -284,6 +284,7 @@ class OrganizationContactForm(RegistrarForm):
                 message="Enter a zip code in the form of 12345 or 12345-6789.",
             )
         ],
+        error_messages={"required": ("Enter a zip code in the form of 12345 or 12345-6789.")},
     )
     urbanization = forms.CharField(
         required=False,


Test patch:
Repository: cisagov/manage.get.gov

Issue:
Django admin: the "Investigator" filter is showing repeat entries in the "domain application" table  
### Current Behavior

The "Investigator" filter is showing repeat entries in the "domain application" table.

See screenshot in [slack thread](https://cisa-corp.slack.com/archives/C05BGB4L5NF/p1708995722466379)


### Expected Behavior

The "Investigator" filter is should not show repeat entries.

### Steps to Reproduce

1. logon to Django admin
2. navigate to domain application
3. view filtering options


### Environment

_No response_

### Additional Context

_No response_

### 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
@@ -838,13 +838,19 @@ def lookups(self, request, model_admin):
             )
 
             # Annotate the full name and return a values list that lookups can use
-            privileged_users_annotated = privileged_users.annotate(
-                full_name=Coalesce(
-                    Concat("investigator__first_name", Value(" "), "investigator__last_name", output_field=CharField()),
-                    "investigator__email",
-                    output_field=CharField(),
+            privileged_users_annotated = (
+                privileged_users.annotate(
+                    full_name=Coalesce(
+                        Concat(
+                            "investigator__first_name", Value(" "), "investigator__last_name", output_field=CharField()
+                        ),
+                        "investigator__email",
+                        output_field=CharField(),
+                    )
                 )
-            ).values_list("investigator__id", "full_name")
+                .values_list("investigator__id", "full_name")
+                .distinct()
+            )
 
             return privileged_users_annotated
 


Test patch:
Repository: cisagov/manage.get.gov

Issue:
Investigate csv_export excluding data and possible CZDS interference
### Current Behavior
The `data` job on dotgov-data is current failing.

There are two things to note here:
1. The csv export function appears to be excluding data that it otherwise should. Note the disparity between dotgov-data and current-full.csv.
2. The CZDS action was recently implemented
### Expected Behavior
The data job on dotgov-data should work as expected. In addition, the csv export function should mostly be in parity with the current-full.csv and current-federal.csv files on dotgov-data, minus small alterations

### Steps to Reproduce
Visit this [link](https://github.com/cisagov/dotgov-data/actions/runs/8076071354) to view the failing job.

To run the reports:
1. Go to stable
2. Click the export current-full.csv and current-federal.csv files
3. Compare these to the dotgov-data repo


### Environment

_No response_

### Additional Context

_No response_

### Issue Links

_No response_


Discussion:

Resolving patch:
diff --git a/src/registrar/utility/csv_export.py b/src/registrar/utility/csv_export.py
--- a/src/registrar/utility/csv_export.py
+++ b/src/registrar/utility/csv_export.py
@@ -167,9 +167,12 @@ def write_csv(
         max_dm_count = max(len(domain_info.domain.permissions.all()) for domain_info in all_domain_infos)
         update_columns_with_domain_managers(columns, max_dm_count)
 
+    if should_write_header:
+        write_header(writer, columns)
+
     for page_num in paginator.page_range:
-        page = paginator.page(page_num)
         rows = []
+        page = paginator.page(page_num)
         for domain_info in page.object_list:
             try:
                 row = parse_row(columns, domain_info, security_emails_dict, get_domain_managers)
@@ -180,10 +183,7 @@ def write_csv(
                 logger.error("csv_export -> Error when parsing row, domain was None")
                 continue
 
-    if should_write_header:
-        write_header(writer, columns)
-
-    writer.writerows(rows)
+        writer.writerows(rows)
 
 
 def export_data_type_to_csv(csv_file):


Test patch:
Repository: cisagov/manage.get.gov

Issue:
Optimize Gunicorn gthread setup
### Issue description

We recently switched to using gthread with only one worker as part of our gunicorn setup (see run.sh). However, the documentation references that there should be more than one worker, and in our case ideally 3 workers.

### Acceptance criteria

- [ ] update the gunicorn setup to have multiple workers (3 would be ideal unless dev determines otherwise)
- [ ] add a shared cache between the workers (otherwise errors will occur)

### Additional context

_No response_

### Links to other issues

_No response_


Discussion:
General implementation note (may be obvious, but worth nothing anyway!):

I would like to note that "workers", from the context of guincorn, are a set of _instances_ - rather than threads. This is a distinction I originally did not make.  _Threading_ is done automatically by the library. This distinction is due to how "threading" works in python with the GIL.
https://dev.to/lsena/gunicorn-worker-types-how-to-choose-the-right-one-4n2c

We already do instancing for load balancing purposes through cloud.gov, so that should be kept in mind as we start scaling this up. There may be some wonky interaction there, or there may not be!

![image](https://github.com/cisagov/manage.get.gov/assets/141044360/35ec18f7-cf3f-4439-b267-9ebc008202f8)


Resolving patch:
diff --git a/src/registrar/config/settings.py b/src/registrar/config/settings.py
--- a/src/registrar/config/settings.py
+++ b/src/registrar/config/settings.py
@@ -188,15 +188,12 @@
 # https://docs.djangoproject.com/en/4.0/howto/static-files/
 
 
-# Caching is disabled by default.
-# For a low to medium traffic site, caching causes more
-# problems than it solves. Should caching be desired,
-# a reasonable start might be:
-# CACHES = {
-#     "default": {
-#         "BACKEND": "django.core.cache.backends.db.DatabaseCache",
-#     }
-# }
+CACHES = {
+    "default": {
+        "BACKEND": "django.core.cache.backends.db.DatabaseCache",
+        "LOCATION": "cache_table",
+    }
+}
 
 # Absolute path to the directory where `collectstatic`
 # will place static files for deployment.


Test patch:
Repository: cisagov/manage.get.gov

Issue:
On Domain applications table, replace "Created at" column with "Submitted at"
### Issue description

Not all "created" requests get submitted, so sorting by the creation date in the `Domain applications` (soon `Domain requests`) table isn't helpful for analysts.



### Acceptance criteria

- [ ] Replace "Created at" column with "Submitted at"

### Additional context

This data seems likely to change if a requestor withdraws, resubmits. For analyst purposes, that's ok.

notes this field is in DomainApplications and is called submission_date

### Links to other issues

_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
@@ -942,7 +942,7 @@ def queryset(self, request, queryset):
         "custom_election_board",
         "city",
         "state_territory",
-        "created_at",
+        "submission_date",
         "submitter",
         "investigator",
     ]


Test patch:
Repository: cisagov/manage.get.gov

Issue:
Remove filter for the "Verified by Staff" table
### Issue description

Django admin: On the "Verified by Staff" page, the "by requestor" filter is unnecessary and it lists every requestor in the registrar (making it impossible to use).

### Acceptance criteria

- [ ] Remove the "by requestor" filter on the "Verified by Staff" page in the admin

### Additional context
Remove this:
<img width="297" alt="image" src="https://github.com/cisagov/manage.get.gov/assets/603901/52233001-44a1-4f8f-a0b9-850d63852b8d">


### Links to other issues

_No response_


Discussion:
Per Cameron to move it from "future analyst experience" to " analyst quick wins". (3/4 - refinement trio).

Resolving patch:
diff --git a/src/registrar/admin.py b/src/registrar/admin.py
--- a/src/registrar/admin.py
+++ b/src/registrar/admin.py
@@ -1807,9 +1807,6 @@ class VerifiedByStaffAdmin(ListHeaderAdmin):
     list_display = ("email", "requestor", "truncated_notes", "created_at")
     search_fields = ["email"]
     search_help_text = "Search by email."
-    list_filter = [
-        "requestor",
-    ]
     readonly_fields = [
         "requestor",
     ]


Test patch:
Repository: cisagov/manage.get.gov

Issue:
Request access to admin (add fixtures for Riley Orr)
### Issue description

Add fixtures so Riley can access the sandboxes

### Acceptance criteria

- [ ]  Fixtures added for Riley Orr

### Additional context

_No response_

### Links to other issues

_No response_


Discussion:

Resolving patch:
diff --git a/src/registrar/fixtures_users.py b/src/registrar/fixtures_users.py
--- a/src/registrar/fixtures_users.py
+++ b/src/registrar/fixtures_users.py
@@ -93,6 +93,12 @@ class UserFixture:
             "last_name": "Chin",
             "email": "szu.chin@associates.cisa.dhs.gov",
         },
+        {
+            "username": "012f844d-8a0f-4225-9d82-cbf87bff1d3e",
+            "first_name": "Riley",
+            "last_name": "Orr",
+            "email": "riley+320@truss.works",
+        },
     ]
 
     STAFF = [
@@ -169,6 +175,12 @@ class UserFixture:
             "last_name": "Mcelya-Analyst",
             "email": "ALEXANDER.MCELYA@cisa.dhs.gov",
         },
+        {
+            "username": "082a066f-e0a4-45f6-8672-4343a1208a36",
+            "first_name": "Riley-Analyst",
+            "last_name": "Orr-Analyst",
+            "email": "riley+321@truss.works",
+        },
     ]
 
     def load_users(cls, users, group_name):


Test patch:
Repository: cisagov/manage.get.gov

Issue:
Django admin: Analyst can not delete a domain manager from a domain
### Current Behavior

Analyst can not remove a domain manager through the domain management page. It results in a 403 error likely as a result of me not being a listed manager on the domain. 

### Expected Behavior

Analyst can remove a domain manager through the domain management page regardless of whether they are listed as a manager on the domain. 

### Steps to Reproduce

1. Logon as analyst
2. Remove manager from domain management page
3. Results in a 403 error


### Environment

Environment: Stable

### Additional Context

[Slack thread ](https://cisa-corp.slack.com/archives/C05BGB4L5NF/p1708731699023449)

### Issue Links

_No response_


Discussion:

Resolving patch:
diff --git a/src/registrar/views/utility/mixins.py b/src/registrar/views/utility/mixins.py
--- a/src/registrar/views/utility/mixins.py
+++ b/src/registrar/views/utility/mixins.py
@@ -307,7 +307,12 @@ def has_permission(self):
             domain=domain_pk,
             domain__permissions__user=self.request.user,
         ).exists()
-        if not has_delete_permission:
+
+        user_is_analyst_or_superuser = self.request.user.has_perm(
+            "registrar.analyst_access_permission"
+        ) or self.request.user.has_perm("registrar.full_access_permission")
+
+        if not (has_delete_permission or user_is_analyst_or_superuser):
             return False
 
         # Check if more than one manager exists on the domain.


Test patch:
Repository: cisagov/manage.get.gov

Issue:
Provide documentation about user_groups and permission changes
### Issue description

If we edit permissions for User Groups, such as to make different items viewable on django admin, this requires a very specific set of instructions that is only documentated inside user group migration files. We should reference this documentation somewhere else in our developer readme so it's clear what is needed to be done if you ever change permissions in the future.

 We had a case where permissions were changed and it wasn't clear what needed to be done (make a manual migration). The developers lost time trying to figure out why permissions didn't show and why running makemigrations changed nothing. I suggest adding an inline code comment around where permissions are set in user_groups too that points to documentation in developer readme. This may save future developer's time.

### Acceptance criteria

- [ ] update developer documentation (inline and md) about user_group/ permission changes

### Additional context
the migration files that have documentation about this are all ones that say _create_groups_v (followed by a number), such as 0075_create_groups_v08.py. See those for the current documentation and note that this was hard for developers to find.
[Slack thread](https://cisa-corp.slack.com/archives/C05BGB4L5NF/p1709939481415349)

### Links to other issues

_No response_


Discussion:

Resolving patch:
diff --git a/src/registrar/models/user_group.py b/src/registrar/models/user_group.py
--- a/src/registrar/models/user_group.py
+++ b/src/registrar/models/user_group.py
@@ -5,6 +5,11 @@
 
 
 class UserGroup(Group):
+    """
+    UserGroup sets read and write permissions for superusers (who have full access)
+    and analysts. For more details, see the dev docs for user-permissions.
+    """
+
     class Meta:
         verbose_name = "User group"
         verbose_name_plural = "User groups"


Test patch:
Repository: cisagov/manage.get.gov

Issue:
Django admin: Add column that indicates whether Contact is also a "user"
### Issue description

Within the Contacts table in the admin, we currently have columns for the contact's name and email address. It would also be helpful to know if the contact is a "user" in the system.  (i.e. not all contacts are users)

### Acceptance criteria

- [ ] Within the Contacts table, add a column for "Is user" (after the email column) that indicates yes/no whether the contact is also a "user" of the system

### Additional context

This is an update that came out of the [recent audit](https://docs.google.com/spreadsheets/d/1dXe28ZpyghFpxB_T-GZsDpFUKb96AdztsNPhFL0BvpE/edit#gid=616839927) of Django field labels.

ON the contact model you can just make a new property tag- which allows a function to respond to a getter (or setter) like we do on domain.security_contact  and domain.nameservers. 

```
@property
def is_user(self):
     return self.user is not None

```
then add to the on ContactAdmin this is_user as part of the list_display value

### Links to other issues

_No response_


Discussion:
Accepted into backlog. Suggested timeline: sprint 42.
@Katherine-Osos  ""user" of the admin" in the AC should just read ""user" of the system" right?

Resolving patch:
diff --git a/src/registrar/admin.py b/src/registrar/admin.py
--- a/src/registrar/admin.py
+++ b/src/registrar/admin.py
@@ -663,6 +663,7 @@ class ContactAdmin(ListHeaderAdmin):
     list_display = [
         "contact",
         "email",
+        "user_exists",
     ]
     # this ordering effects the ordering of results
     # in autocomplete_fields for user
@@ -679,6 +680,13 @@ class ContactAdmin(ListHeaderAdmin):
 
     change_form_template = "django/admin/email_clipboard_change_form.html"
 
+    def user_exists(self, obj):
+        """Check if the Contact has a related User"""
+        return "Yes" if obj.user is not None else "No"
+
+    user_exists.short_description = "Is user"  # type: ignore
+    user_exists.admin_order_field = "user"  # type: ignore
+
     # We name the custom prop 'contact' because linter
     # is not allowing a short_description attr on it
     # This gets around the linter limitation, for now.


Test patch:
Repository: cisagov/manage.get.gov

Issue:
Add Christina to fixtures
### Issue description

Christina (@witha-c ) will need a sandbox soon and should be added to fixtures so she can access admin on her own sandbox once fixtures are loaded to it

### Acceptance criteria

- [ ] add Christina to fixtures as analyst and superuser

### Additional context

_No response_

### Links to other issues

_No response_


Discussion:

Resolving patch:
diff --git a/src/registrar/fixtures_users.py b/src/registrar/fixtures_users.py
--- a/src/registrar/fixtures_users.py
+++ b/src/registrar/fixtures_users.py
@@ -93,6 +93,12 @@ class UserFixture:
             "last_name": "Chin",
             "email": "szu.chin@associates.cisa.dhs.gov",
         },
+        {
+            "username": "66bb1a5a-a091-4d7f-a6cf-4d772b4711c7",
+            "first_name": "Christina",
+            "last_name": "Burnett",
+            "email": "christina.burnett@cisa.dhs.gov",
+        },
         {
             "username": "012f844d-8a0f-4225-9d82-cbf87bff1d3e",
             "first_name": "Riley",
@@ -169,6 +175,12 @@ class UserFixture:
             "last_name": "Chin-Analyst",
             "email": "szu.chin@ecstech.com",
         },
+        {
+            "username": "22f88aa5-3b54-4b1f-9c57-201fb02ddba7",
+            "first_name": "Christina-Analyst",
+            "last_name": "Burnett-Analyst",
+            "email": "christina.burnett@gwe.cisa.dhs.gov",
+        },
         {
             "username": "d9839768-0c17-4fa2-9c8e-36291eef5c11",
             "first_name": "Alex-Analyst",


Test patch:
Repository: cisagov/manage.get.gov

Issue:
Update to V3 of django audit logs
### Issue description

V3 of Django audit logs has been released which includes accessing values as a dictionary instead of json objects. That said, it is also a breaking change that doesn't work without other code changes. 

### Acceptance criteria

- [ ] our django audit logs is updated to V3 without any breaking changes

### Additional context

Note, when I updated to this version, it through an error once something tried to log to the audit logs (user login) in my case, but I didn't notice an error when starting the app an the sandbox. 


current error shown when a log occurs when upgraded to v3:
![image](https://github.com/cisagov/manage.get.gov/assets/109625347/61b04da0-9765-462f-84f2-43a197b15aef)

### Links to other issues

Relates to #1849 


Discussion:

Resolving patch:
diff --git a/src/registrar/config/settings.py b/src/registrar/config/settings.py
--- a/src/registrar/config/settings.py
+++ b/src/registrar/config/settings.py
@@ -780,3 +780,11 @@
         # due to Docker, bypass Debug Toolbar's check on INTERNAL_IPS
         "SHOW_TOOLBAR_CALLBACK": lambda _: True,
     }
+
+# From https://django-auditlog.readthedocs.io/en/latest/upgrade.html
+# Run:
+# cf run-task getgov-<> --wait --command 'python manage.py auditlogmigratejson --traceback' --name auditlogmigratejson
+# on our staging and stable, then remove these 2 variables or set to False
+AUDITLOG_TWO_STEP_MIGRATION = True
+
+AUDITLOG_USE_TEXT_CHANGES_IF_JSON_IS_NOT_PRESENT = True


Test patch:
diff --git a/src/registrar/tests/test_views_domain.py b/src/registrar/tests/test_views_domain.py
--- a/src/registrar/tests/test_views_domain.py
+++ b/src/registrar/tests/test_views_domain.py
@@ -344,8 +344,6 @@ class TestDomainManagers(TestDomainOverview):
     def tearDown(self):
         """Ensure that the user has its original permissions"""
         super().tearDown()
-        self.user.is_staff = False
-        self.user.save()
 
     def test_domain_managers(self):
         response = self.client.get(reverse("domain-users", kwargs={"pk": self.domain.id}))