Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
dave-kennedy-ecs committed Jan 6, 2025
2 parents d2f1d1f + 1e12459 commit 2de0225
Show file tree
Hide file tree
Showing 6 changed files with 765 additions and 692 deletions.
1 change: 0 additions & 1 deletion docs/dev-practices/code_review.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Pull requests should be titled in the format of `#issue_number: Descriptive name
Pull requests including a migration should be suffixed with ` - MIGRATION`

After creating a pull request, pull request submitters should:
- Add at least 2 developers as PR reviewers (only 1 will need to approve).
- Message on Slack or in standup to notify the team that a PR is ready for review.
- If any model was updated to modify/add/delete columns, run makemigrations and commit the associated migrations file.

Expand Down
1,321 changes: 671 additions & 650 deletions src/Pipfile.lock

Large diffs are not rendered by default.

26 changes: 24 additions & 2 deletions src/registrar/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2736,8 +2736,30 @@ def changelist_view(self, request, extra_context=None):
return response

def change_view(self, request, object_id, form_url="", extra_context=None):
"""Display restricted warning,
Setup the auditlog trail and pass it in extra context."""
"""Display restricted warning, setup the auditlog trail and pass it in extra context,
display warning that status cannot be changed from 'Approved' if domain is in Ready state"""

# Fetch the domain request instance
domain_request: models.DomainRequest = models.DomainRequest.objects.get(pk=object_id)
if domain_request.approved_domain and domain_request.approved_domain.state == models.Domain.State.READY:
domain = domain_request.approved_domain
# get change url for domain
app_label = domain_request.approved_domain._meta.app_label
model_name = domain._meta.model_name
obj_id = domain.id
change_url = reverse("admin:%s_%s_change" % (app_label, model_name), args=[obj_id])

message = format_html(
"The status of this domain request cannot be changed because it has been joined to a domain in Ready status: " # noqa: E501
"<a href='{}'>{}</a>",
mark_safe(change_url), # nosec
escape(str(domain)),
)
messages.warning(
request,
message,
)

obj = self.get_object(request, object_id)
self.display_restricted_warning(request, obj)

Expand Down
4 changes: 0 additions & 4 deletions src/registrar/templates/domain_request_dotgov_domain.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
<ul class="usa-list">
<li>Be available </li>
<li>Relate to your organization’s name, location, and/or services </li>
{% if portfolio %}
<li>Be clear to the general public. Your domain name must not be easily confused with other organizations.</li>
{% else %}
<li>Be unlikely to mislead or confuse the general public (even if your domain is only intended for a specific audience) </li>
{% endif %}
</ul>
</p>

Expand Down
37 changes: 36 additions & 1 deletion src/registrar/tests/test_admin_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
AllowedEmail,
Suborganization,
)
from registrar.models.host import Host
from registrar.models.public_contact import PublicContact
from .common import (
MockSESClient,
completed_domain_request,
Expand All @@ -39,7 +41,7 @@
MockEppLib,
GenericTestHelper,
)
from unittest.mock import patch
from unittest.mock import ANY, patch

from django.conf import settings
import boto3_mocking # type: ignore
Expand Down Expand Up @@ -79,6 +81,8 @@ def setUpClass(self):

def tearDown(self):
super().tearDown()
Host.objects.all().delete()
PublicContact.objects.all().delete()
Domain.objects.all().delete()
DomainInformation.objects.all().delete()
DomainRequest.objects.all().delete()
Expand Down Expand Up @@ -1889,6 +1893,37 @@ def test_change_view_with_restricted_creator(self):
"Cannot edit a domain request with a restricted creator.",
)

@less_console_noise_decorator
def test_approved_domain_request_with_ready_domain_has_warning_message(self):
"""Tests if the domain request has a warning message when the approved domain is in Ready state"""
# Create an instance of the model
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
# Approve the domain request
domain_request.approve()
domain_request.save()

# Add nameservers to get to Ready state
domain_request.approved_domain.nameservers = [
("ns1.city.gov", ["1.1.1.1"]),
("ns2.city.gov", ["1.1.1.2"]),
]
domain_request.approved_domain.save()

with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with patch("django.contrib.messages.warning") as mock_warning:
# Create a request object
self.client.force_login(self.superuser)
self.client.get(
"/admin/registrar/domainrequest/{}/change/".format(domain_request.pk),
follow=True,
)

# Assert that the error message was called with the correct argument
mock_warning.assert_called_once_with(
ANY, # don't care about the request argument
f"The status of this domain request cannot be changed because it has been joined to a domain in Ready status: <a href='/admin/registrar/domain/{domain_request.approved_domain.id}/change/'>{domain_request.approved_domain.name}</a>", # noqa
)

def trigger_saving_approved_to_another_state(self, domain_is_active, another_state, rejection_reason=None):
"""Helper method that triggers domain request state changes from approved to another state,
with an associated domain that can be either active (READY) or not.
Expand Down
68 changes: 34 additions & 34 deletions src/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
-i https://pypi.python.org/simple
annotated-types==0.7.0; python_version >= '3.8'
asgiref==3.8.1; python_version >= '3.8'
boto3==1.35.41; python_version >= '3.8'
botocore==1.35.41; python_version >= '3.8'
boto3==1.35.91; python_version >= '3.8'
botocore==1.35.91; python_version >= '3.8'
cachetools==5.5.0; python_version >= '3.7'
certifi==2024.8.30; python_version >= '3.6'
certifi==2024.12.14; python_version >= '3.6'
cfenv==0.5.3
cffi==1.17.1; platform_python_implementation != 'PyPy'
charset-normalizer==3.4.0; python_full_version >= '3.7.0'
cryptography==43.0.1; python_version >= '3.7'
cffi==1.17.1; python_version >= '3.8'
charset-normalizer==3.4.1; python_version >= '3.7'
cryptography==44.0.0; python_version >= '3.7' and python_full_version not in '3.9.0, 3.9.1'
defusedxml==0.7.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
diff-match-patch==20230430; python_version >= '3.7'
dj-database-url==2.2.0
diff-match-patch==20241021; python_version >= '3.7'
dj-database-url==2.3.0
dj-email-url==1.0.6
django==4.2.17; python_version >= '3.8'
django-admin-multiple-choice-list-filter==0.1.1
django-allow-cidr==0.7.1
django-auditlog==3.0.0; python_version >= '3.8'
django-cache-url==3.4.5
django-cors-headers==4.5.0; python_version >= '3.9'
django-cors-headers==4.6.0; python_version >= '3.9'
django-csp==3.8
django-fsm==2.8.1
django-import-export==4.1.1; python_version >= '3.8'
django-import-export==4.3.3; python_version >= '3.9'
django-login-required-middleware==0.9.0
django-phonenumber-field[phonenumberslite]==8.0.0; python_version >= '3.8'
django-waffle==4.1.0; python_version >= '3.8'
django-waffle==4.2.0; python_version >= '3.8'
django-widget-tweaks==1.5.0; python_version >= '3.8'
environs[django]==11.0.0; python_version >= '3.8'
faker==30.3.0; python_version >= '3.8'
fred-epplib@ git+https://github.com/cisagov/epplib.git@d56d183f1664f34c40ca9716a3a9a345f0ef561c
environs[django]==11.2.1; python_version >= '3.8'
faker==33.1.0; python_version >= '3.8'
fred-epplib @ git+https://github.com/cisagov/epplib.git@d56d183f1664f34c40ca9716a3a9a345f0ef561c
furl==2.1.3
future==1.0.0; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'
gevent==24.10.2; python_version >= '3.9'
future==1.0.0; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'
gevent==24.11.1; python_version >= '3.9'
greenlet==3.1.1; python_version >= '3.7'
gunicorn==23.0.0; python_version >= '3.7'
idna==3.10; python_version >= '3.6'
jmespath==1.0.1; python_version >= '3.7'
lxml==5.3.0; python_version >= '3.6'
mako==1.3.5; python_version >= '3.8'
markupsafe==3.0.1; python_version >= '3.9'
marshmallow==3.22.0; python_version >= '3.8'
mako==1.3.8; python_version >= '3.8'
markupsafe==3.0.2; python_version >= '3.9'
marshmallow==3.23.2; python_version >= '3.9'
oic==1.7.0; python_version ~= '3.8'
orderedmultidict==1.0.1
packaging==24.1; python_version >= '3.8'
phonenumberslite==8.13.47
psycopg2-binary==2.9.9; python_version >= '3.7'
packaging==24.2; python_version >= '3.8'
phonenumberslite==8.13.52
psycopg2-binary==2.9.10; python_version >= '3.8'
pycparser==2.22; python_version >= '3.8'
pycryptodomex==3.21.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
pydantic==2.9.2; python_version >= '3.8'
pydantic-core==2.23.4; python_version >= '3.8'
pydantic-settings==2.5.2; python_version >= '3.8'
pydantic==2.10.4; python_version >= '3.8'
pydantic-core==2.27.2; python_version >= '3.8'
pydantic-settings==2.7.1; python_version >= '3.8'
pyjwkest==1.4.2
python-dateutil==2.9.0.post0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
python-dateutil==2.9.0.post0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'
python-dotenv==1.0.1; python_version >= '3.8'
pyzipper==0.3.6; python_version >= '3.4'
requests==2.32.3; python_version >= '3.8'
s3transfer==0.10.3; python_version >= '3.8'
setuptools==75.1.0; python_version >= '3.8'
six==1.16.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
sqlparse==0.5.1; python_version >= '3.8'
tablib[html,ods,xls,xlsx,yaml]==3.5.0; python_version >= '3.8'
s3transfer==0.10.4; python_version >= '3.8'
setuptools==75.6.0; python_version >= '3.9'
six==1.17.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'
sqlparse==0.5.3; python_version >= '3.8'
tablib==3.7.0; python_version >= '3.9'
tblib==3.0.0; python_version >= '3.8'
typing-extensions==4.12.2; python_version >= '3.8'
urllib3==2.2.3; python_version >= '3.8'
whitenoise==6.7.0; python_version >= '3.8'
urllib3==2.3.0; python_version >= '3.9'
whitenoise==6.8.2; python_version >= '3.9'
zope.event==5.0; python_version >= '3.7'
zope.interface==7.1.0; python_version >= '3.8'
zope.interface==7.2; python_version >= '3.8'

0 comments on commit 2de0225

Please sign in to comment.