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

Issue:
Update Domain management permissions 
### Issue Description

Domain management, specifically that of DNS specific information, should be reserved for approved domain requests. Currently, if an item is in the list of registered domains and the status of the associated domain request switches to something like Withdrawn/Investigating, then the user can still edit the domain information AND the domain still appears in Active domains

AC

1. In Active Domain Request table, do not show domain applications that are approved. 


Suggestion: check to make sure when you change states  on an application that the domain management page doesn't show when the status shouldn't allow it.


### Additional Context (optional)

see [slack thread](https://cisa-corp.slack.com/archives/C05BDEA3C11/p1689089565297719)

### Issue Links
may relate to #701 
relates to: #818 
_No response_


Discussion:
It was discussed today in Eng huddle and confirmed that only approved domains should appear in the active domain section and only non-approved domains in the registered domain section

Resolving patch:
diff --git a/src/registrar/views/index.py b/src/registrar/views/index.py
--- a/src/registrar/views/index.py
+++ b/src/registrar/views/index.py
@@ -9,7 +9,10 @@ def index(request):
     context = {}
     if request.user.is_authenticated:
         applications = DomainApplication.objects.filter(creator=request.user)
-        context["domain_applications"] = applications
+        # Let's exclude the approved applications since our
+        # domain_applications context will be used to populate
+        # the active applications table
+        context["domain_applications"] = applications.exclude(status="approved")
 
         domains = request.user.permissions.values(
             "role",


Test patch:
diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py
--- a/src/registrar/tests/test_views.py
+++ b/src/registrar/tests/test_views.py
@@ -1500,3 +1500,18 @@ def test_application_status_no_permissions(self):
                         reverse(url_name, kwargs={"pk": application.pk})
                     )
                     self.assertEqual(page.status_code, 403)
+
+    def test_approved_application_not_in_active_requests(self):
+        """An approved application is not shown in the Active
+        Requests table on home.html."""
+        application = completed_application(
+            status=DomainApplication.APPROVED, user=self.user
+        )
+        application.save()
+
+        home_page = self.app.get("/")
+        # This works in our test environment because creating
+        # an approved application here does not generate a
+        # domain object, so we do not expect to see 'city.gov'
+        # in either the Domains or Requests tables.
+        self.assertNotContains(home_page, "city.gov")
Repository: cisagov/manage.get.gov

Issue:
Add "withdrawn" confirmation email
### Ticket Description

Now that we are using a finite-state-machine transition method for withdrawing domain applications, we can add an email confirmation in that method, as described in [this document](https://docs.google.com/document/d/1I4sx-z2pbxdehj2Skci_sFZQvV8gEKE-nLu1CxxvaGc).

To add this email we need to

- [x] draft the email content
- [x] Add the templates and hook up `send_templated_email` in our `withdraw()` transition method


Note: see comments below the content is updated and this is ready for development
### Issue Type

development

### Link dependent issues

_No response_


Discussion:
[Content for withdrawn email ](https://docs.google.com/document/d/1mMdBHOSrqWVsOlBuFd3BItdUnbGbsllJAxkDOujaSl4/edit#heading=h.gjdgxs)approved on 8/9/23. 
@abroddrick The content for this email has been approved and linked in my earlier comment. Looks like dev implementation is part of this same ticket, so letting you know it's ready.
Thank you so much I was wondering about this!
@Katherine-Osos I am removing you as assigned so that it appears clear for the other engineers. Otherwise I feel like it looks like someone is already working on this which you don't scroll down to the comments. Also removing the content label. Let me know if either is an issue

Resolving patch:
diff --git a/src/registrar/models/domain_application.py b/src/registrar/models/domain_application.py
--- a/src/registrar/models/domain_application.py
+++ b/src/registrar/models/domain_application.py
@@ -590,6 +590,11 @@ def approve(self):
     @transition(field="status", source=[SUBMITTED, IN_REVIEW], target=WITHDRAWN)
     def withdraw(self):
         """Withdraw an application that has been submitted."""
+        self._send_status_update_email(
+            "withdraw",
+            "emails/domain_request_withdrawn.txt",
+            "emails/domain_request_withdrawn_subject.txt",
+        )
 
     @transition(field="status", source=[IN_REVIEW, APPROVED], target=REJECTED)
     def reject(self):


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

Issue:
Add applications to fixtures with status "action needed" and "rejected"
### Story

As a developer or designer
I want to pre-populate our sandboxes with applications that have a status of "action needed" and "rejected"
so that we can test / user test our application with mock data.


### Acceptance Criteria

Loading fixtures on a sandbox will populate it with the usual data plus an application with status "action needed" and another one with status "rejected" for each user.

### Additional Context

_No response_

### Issue Links

_No response_


Discussion:

Resolving patch:
diff --git a/src/registrar/fixtures.py b/src/registrar/fixtures.py
--- a/src/registrar/fixtures.py
+++ b/src/registrar/fixtures.py
@@ -86,6 +86,12 @@ class UserFixture:
             "first_name": "Alysia-Analyst",
             "last_name": "Alysia-Analyst",
         },
+        {
+            "username": "91a9b97c-bd0a-458d-9823-babfde7ebf44",
+            "first_name": "Katherine-Analyst",
+            "last_name": "Osos-Analyst",
+            "email": "kosos@truss.works",
+        },
         {
             "username": "2cc0cde8-8313-4a50-99d8-5882e71443e8",
             "first_name": "Zander-Analyst",
@@ -248,6 +254,14 @@ class DomainApplicationFixture:
             "status": "withdrawn",
             "organization_name": "Example - Withdrawn",
         },
+        {
+            "status": "action needed",
+            "organization_name": "Example - Action Needed",
+        },
+        {
+            "status": "rejected",
+            "organization_name": "Example - Rejected",
+        },
     ]
 
     @classmethod


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

Issue:
Fix for checkbox accessibility no longer working
### Current Behavior

Checkboxes in django admin superuser no longer generated with an associated label.

### Expected Behavior

Expect to see accessible checkboxes in django admin, no missing columns in either superuser or staff views.

### Steps to Reproduce

1. Log in as superuser
2. Go to list view on a model
3. Run ANDI  or inspect checkboxes


### Environment

_No response_

### Additional Context

Traced this to the fix for missing columns in staff view. The check {% if results.0.form %} did not work and failed silently. Have a fix for this.

Will prioritize implementation and deployment to staging since we have some accessibility testing in progress.

### Issue Links

_No response_


Discussion:

Resolving patch:
diff --git a/src/registrar/templatetags/custom_filters.py b/src/registrar/templatetags/custom_filters.py
--- a/src/registrar/templatetags/custom_filters.py
+++ b/src/registrar/templatetags/custom_filters.py
@@ -40,3 +40,11 @@ def slice_after(value, substring):
         result = value[index + len(substring) :]
         return result
     return value
+
+
+@register.filter
+def contains_checkbox(html_list):
+    for html_string in html_list:
+        if re.search(r'<input[^>]*type="checkbox"', html_string):
+            return True
+    return False


Test patch:
diff --git a/src/registrar/tests/test_templatetags.py b/src/registrar/tests/test_templatetags.py
--- a/src/registrar/tests/test_templatetags.py
+++ b/src/registrar/tests/test_templatetags.py
@@ -8,6 +8,7 @@
     extract_a_text,
     find_index,
     slice_after,
+    contains_checkbox,
 )
 
 
@@ -83,3 +84,21 @@ def test_slice_after(self):
         self.assertEqual(
             result, value
         )  # Should return the original value if substring not found
+
+    def test_contains_checkbox_with_checkbox(self):
+        # Test the filter when HTML list contains a checkbox
+        html_list = [
+            '<input type="checkbox" name="_selected_action">',
+            "<div>Some other HTML content</div>",
+        ]
+        result = contains_checkbox(html_list)
+        self.assertTrue(result)  # Expecting True
+
+    def test_contains_checkbox_without_checkbox(self):
+        # Test the filter when HTML list does not contain a checkbox
+        html_list = [
+            "<div>Some HTML content without checkbox</div>",
+            "<p>More HTML content</p>",
+        ]
+        result = contains_checkbox(html_list)
+        self.assertFalse(result)  # Expecting False
Repository: cisagov/manage.get.gov

Issue:
Time skew between login.gov and cloud.gov ('issued in the future') causing a 401 on login
### Current Behavior

User gets a 401 error screen on login occasionally (about 60% of the time). Issue seems more prevalent on sandboxes and in fresh browsers with clear cache.

User is usually able to bypass this error screen by clicking login again or clicking on the .gov site logo (sometimes it takes more than one attempt).

### Expected Behavior

Succefull login and no error screen.

### Steps to Reproduce

1. Log into a sandbox in a fresh browser or incognito window.
2. Try a couple of times if the error does not trigger at first.


### Environment

_No response_

### Additional Context

_No response_

### Issue Links

_No response_


Discussion:

Resolving patch:
diff --git a/src/djangooidc/oidc.py b/src/djangooidc/oidc.py
--- a/src/djangooidc/oidc.py
+++ b/src/djangooidc/oidc.py
@@ -238,6 +238,9 @@ def _request_token(self, state, code, session):
                     "client_secret": self.client_secret,
                 },
                 authn_method=self.registration_response["token_endpoint_auth_method"],
+                # There is a time desync issue between login.gov and cloud
+                # this addresses that by adding a clock skew.
+                skew=10,
             )
         except Exception as err:
             logger.error(err)


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

Issue:
Implement (isActive)
### Issue Description

Requires #851 
isActive will return true if the domain has a state of CREATED
Note: check the domain status

### Additional Context (optional)

separate function b/c we might check if this is live on the internet.


This will be used when check if an approved domain can be switched to ineligible or rejected.

### Issue Links

_No response_


Discussion:

Resolving patch:
diff --git a/src/registrar/models/domain.py b/src/registrar/models/domain.py
--- a/src/registrar/models/domain.py
+++ b/src/registrar/models/domain.py
@@ -338,6 +338,9 @@ def __str__(self) -> str:
         help_text="Very basic info about the lifecycle of this domain object",
     )
 
+    def isActive(self):
+        return self.state == Domain.State.CREATED
+
     # ForeignKey on UserDomainRole creates a "permissions" member for
     # all of the user-roles that are in place for this domain
 


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

Issue:
Fixtures loads 8 times on docker-compose up
### Current Behavior

When starting up the application, the console log shows that the fixtures file is executed 8 times in a row. However, current logic on the fixtures file is preventing duplicate entries in the database.

### Expected Behavior

Data should just be loaded into the db once when using fixtures.

### Steps to Reproduce

1. locally run docker-compose up
2. observe the logs
3. see that the logs for loading domain application, users, etc are repeated 8 times each. Also note the warning messages that show an attempt was made to enter data that already exists in the db.


### Environment

local & on sandbox (see the deploy logs)

### Additional Context

see this [slack thread](https://cisa-corp.slack.com/archives/C05BGB4L5NF/p1687988129781299)

### Issue Links

_No response_


Discussion:

Resolving patch:
diff --git a/src/registrar/management/commands/load.py b/src/registrar/management/commands/load.py
--- a/src/registrar/management/commands/load.py
+++ b/src/registrar/management/commands/load.py
@@ -2,6 +2,7 @@
 
 from django.core.management.base import BaseCommand
 from auditlog.context import disable_auditlog  # type: ignore
+from django.conf import settings
 
 from registrar.fixtures import UserFixture, DomainApplicationFixture, DomainFixture
 
@@ -12,8 +13,11 @@ class Command(BaseCommand):
     def handle(self, *args, **options):
         # django-auditlog has some bugs with fixtures
         # https://github.com/jazzband/django-auditlog/issues/17
-        with disable_auditlog():
-            UserFixture.load()
-            DomainApplicationFixture.load()
-            DomainFixture.load()
-            logger.info("All fixtures loaded.")
+        if settings.DEBUG:
+            with disable_auditlog():
+                UserFixture.load()
+                DomainApplicationFixture.load()
+                DomainFixture.load()
+                logger.info("All fixtures loaded.")
+        else:
+            logger.warn("Refusing to load fixture data in a non DEBUG env")
diff --git a/src/registrar/signals.py b/src/registrar/signals.py
--- a/src/registrar/signals.py
+++ b/src/registrar/signals.py
@@ -1,8 +1,6 @@
 import logging
 
-from django.conf import settings
-from django.core.management import call_command
-from django.db.models.signals import post_save, post_migrate
+from django.db.models.signals import post_save
 from django.dispatch import receiver
 
 from .models import User, Contact
@@ -55,13 +53,3 @@ def handle_profile(sender, instance, **kwargs):
                 "There are multiple Contacts with the same email address."
                 f" Picking #{contacts[0].id} for User #{instance.id}."
             )
-
-
-@receiver(post_migrate)
-def handle_loaddata(**kwargs):
-    """Attempt to load test fixtures when in DEBUG mode."""
-    if settings.DEBUG:
-        try:
-            call_command("load")
-        except Exception as e:
-            logger.warning(e)


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

Issue:
Update all TBD (yellow) links on the info site and registrar
### Issue Description
On the get.gov info site (unauthenticated public site) AND the registrar site, there is placeholder text (highlighted in yellow) that denotes a link needs to be added. Go through the site and replace those with active links or remove the placeholder if a link is no longer needed.

### Acceptance Criteria
All TBD placeholders have been identified and replaced with active links.

### Additional Context (optional)
Reference [this table](https://docs.google.com/spreadsheets/d/1EeO_JDz7aD_XV0sgwSHP0JpZB_7c69ojcNzW873N5so/edit#gid=226737863) for TBD links to replace.

### Issue Links



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
@@ -6,12 +6,12 @@
 
 from django import forms
 from django.core.validators import RegexValidator, MaxLengthValidator
-from django.urls import reverse
 from django.utils.safestring import mark_safe
 
 from api.views import DOMAIN_API_MESSAGES
 
 from registrar.models import Contact, DomainApplication, DraftDomain, Domain
+from registrar.templatetags.url_helpers import public_site_url
 from registrar.utility import errors
 
 logger = logging.getLogger(__name__)
@@ -181,7 +181,6 @@ def clean(self):
             self.cleaned_data["federally_recognized_tribe"]
             or self.cleaned_data["state_recognized_tribe"]
         ):
-            todo_url = reverse("todo")
             raise forms.ValidationError(
                 # no sec because we are using it to include an internal URL
                 # into a link. There should be no user-facing input in the
@@ -190,10 +189,10 @@ def clean(self):
                     "You can’t complete this application yet. "
                     "Only tribes recognized by the U.S. federal government "
                     "or by a U.S. state government are eligible for .gov "
-                    'domains. Please use our <a href="{}">contact form</a> to '
+                    'domains. Use our <a href="{}">contact form</a> to '
                     "tell us more about your tribe and why you want a .gov "
                     "domain. We’ll review your information and get back "
-                    "to you.".format(todo_url)
+                    "to you.".format(public_site_url("contact"))
                 ),
                 code="invalid",
             )


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

Issue:
Add nameserver button stopped working
### Current Behavior

![Screen Shot 2023-09-21 at 5 12 46 PM](https://github.com/cisagov/getgov/assets/107004823/a0c4d9cb-ed8a-4d7d-b918-8b7f272cb66a)

The add nameserver button stopped working and now throws a console error

### Expected Behavior

Add another nameserver should create a new nameserver input on the page

### Steps to Reproduce

1. Navigate to manage your domain, nameservers
2. Click on Add another name server


### Environment

Local, staging, main branch

### Additional Context

We can easily make the error go away by [editing the JS](https://github.com/cisagov/getgov/blob/70e0f4cfc6f28af0dcba76059d7c1c7ff715fd18/src/registrar/assets/js/get-gov.js#L249C10-L249C10) to clone the first item in the array instead of the 3rd one, but that won't solve the source issue. 

The real issue is that this formset is built to present the user a minumum of 3 fields for nameservers whether there's data for them or not (in which case, blank fields): 2 required and one non-required. The cloning of the 3rd element in the JS array makes sense because nameservers 4+ will always be non-required.

The solution is to trick the nameservers form to alway display a minimum of 3 fields regardless of what registry returns. 

### Issue Links

_No response_


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
@@ -138,10 +138,17 @@ def get_initial(self):
         """The initial value for the form (which is a formset here)."""
         domain = self.get_object()
         nameservers = domain.nameservers
-        if nameservers is None:
-            return []
+        initial_data = []
 
-        return [{"server": name} for name, *ip in domain.nameservers]
+        if nameservers is not None:
+            # Add existing nameservers as initial data
+            initial_data.extend({"server": name} for name, *ip in nameservers)
+
+        # Ensure at least 3 fields, filled or empty
+        while len(initial_data) < 2:
+            initial_data.append({})
+
+        return initial_data
 
     def get_success_url(self):
         """Redirect to the nameservers page for the domain."""
@@ -157,6 +164,7 @@ def get_context_data(self, **kwargs):
     def get_form(self, **kwargs):
         """Override the labels and required fields every time we get a formset."""
         formset = super().get_form(**kwargs)
+
         for i, form in enumerate(formset):
             form.fields["server"].label += f" {i+1}"
             if i < 2:


Test patch:
diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py
--- a/src/registrar/tests/test_views.py
+++ b/src/registrar/tests/test_views.py
@@ -1293,6 +1293,7 @@ def test_domain_nameservers(self):
         )
         self.assertContains(page, "Domain name servers")
 
+    @skip("Broken by adding registry connection fix in ticket 848")
     def test_domain_nameservers_form(self):
         """Can change domain's nameservers.
Repository: cisagov/manage.get.gov

Issue:
Transition Domains has created state instead of Ready
### Current Behavior

The Transition domains table has a state of Created allowed

### Expected Behavior

Created needs to be changed to ready instead

### Steps to Reproduce

1.go to the transition domains table
2. see the states allowed are created and onhold




### Environment

_No response_

### Additional Context

_No response_

### Issue Links

blocks: #980 



Discussion:

Resolving patch:
diff --git a/src/registrar/migrations/0032_alter_transitiondomain_status.py b/src/registrar/migrations/0032_alter_transitiondomain_status.py
new file mode 100644
--- /dev/null
+++ b/src/registrar/migrations/0032_alter_transitiondomain_status.py
@@ -0,0 +1,24 @@
+# Generated by Django 4.2.1 on 2023-09-27 00:18
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+    dependencies = [
+        ("registrar", "0031_transitiondomain_and_more"),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name="transitiondomain",
+            name="status",
+            field=models.CharField(
+                blank=True,
+                choices=[("ready", "Ready"), ("hold", "Hold")],
+                default="ready",
+                help_text="domain status during the transfer",
+                max_length=255,
+                verbose_name="Status",
+            ),
+        ),
+    ]
diff --git a/src/registrar/models/transition_domain.py b/src/registrar/models/transition_domain.py
--- a/src/registrar/models/transition_domain.py
+++ b/src/registrar/models/transition_domain.py
@@ -3,15 +3,16 @@
 from .utility.time_stamped_model import TimeStampedModel
 
 
+class StatusChoices(models.TextChoices):
+    READY = "ready", "Ready"
+    HOLD = "hold", "Hold"
+
+
 class TransitionDomain(TimeStampedModel):
     """Transition Domain model stores information about the
     state of a domain upon transition between registry
     providers"""
 
-    class StatusChoices(models.TextChoices):
-        CREATED = "created", "Created"
-        HOLD = "hold", "Hold"
-
     username = models.TextField(
         null=False,
         blank=False,
@@ -27,6 +28,7 @@ class StatusChoices(models.TextChoices):
         max_length=255,
         null=False,
         blank=True,
+        default=StatusChoices.READY,
         choices=StatusChoices.choices,
         verbose_name="Status",
         help_text="domain status during the transfer",
@@ -39,4 +41,9 @@ class StatusChoices(models.TextChoices):
     )
 
     def __str__(self):
-        return self.username
+        return (
+            f"username: {self.username} "
+            f"domainName: {self.domain_name} "
+            f"status: {self.status} "
+            f"email sent: {self.email_sent} "
+        )


Test patch: