mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-14 16:47:02 +02:00
Add CISA region on domain requests change form
This commit is contained in:
parent
1cfb054d73
commit
a961328d78
4 changed files with 198 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
{% extends "admin/fieldset.html" %}
|
||||
{% load custom_filters %}
|
||||
{% load static url_helpers %}
|
||||
|
||||
{% comment %}
|
||||
|
@ -126,5 +127,16 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
|
|||
</details>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% elif field.field.name == "state_territory" %}
|
||||
<div class="flex-container margin-top-2">
|
||||
<span>
|
||||
CISA Region:
|
||||
{% if original_object.generic_org_type != "federal" %}
|
||||
{{ original_object.state_territory|get_region }}
|
||||
{% else %}
|
||||
N/A
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock after_help_text %}
|
||||
|
|
|
@ -67,3 +67,66 @@ def get_organization_long_name(generic_org_type):
|
|||
@register.filter(name="has_permission")
|
||||
def has_permission(user, permission):
|
||||
return user.has_perm(permission)
|
||||
|
||||
|
||||
@register.filter
|
||||
def get_region(state):
|
||||
regions = {
|
||||
"CT": 1,
|
||||
"ME": 1,
|
||||
"MA": 1,
|
||||
"NH": 1,
|
||||
"RI": 1,
|
||||
"VT": 1,
|
||||
"NJ": 2,
|
||||
"NY": 2,
|
||||
"PR": 2,
|
||||
"VI": 2,
|
||||
"DE": 3,
|
||||
"DC": 3,
|
||||
"MD": 3,
|
||||
"PA": 3,
|
||||
"VA": 3,
|
||||
"WV": 3,
|
||||
"AL": 4,
|
||||
"FL": 4,
|
||||
"GA": 4,
|
||||
"KY": 4,
|
||||
"MS": 4,
|
||||
"NC": 4,
|
||||
"SC": 4,
|
||||
"TN": 4,
|
||||
"IL": 5,
|
||||
"IN": 5,
|
||||
"MI": 5,
|
||||
"MN": 5,
|
||||
"OH": 5,
|
||||
"WI": 5,
|
||||
"AR": 6,
|
||||
"LA": 6,
|
||||
"NM": 6,
|
||||
"OK": 6,
|
||||
"TX": 6,
|
||||
"IA": 7,
|
||||
"KS": 7,
|
||||
"MO": 7,
|
||||
"NE": 7,
|
||||
"CO": 8,
|
||||
"MT": 8,
|
||||
"ND": 8,
|
||||
"SD": 8,
|
||||
"UT": 8,
|
||||
"WY": 8,
|
||||
"AZ": 9,
|
||||
"CA": 9,
|
||||
"HI": 9,
|
||||
"NV": 9,
|
||||
"GU": 9,
|
||||
"AS": 9,
|
||||
"MP": 9,
|
||||
"AK": 10,
|
||||
"ID": 10,
|
||||
"OR": 10,
|
||||
"WA": 10,
|
||||
}
|
||||
return regions.get(state.upper(), None)
|
||||
|
|
|
@ -2392,6 +2392,66 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
|
||||
self.assertEqual(expected_list, actual_list)
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_staff_can_see_cisa_region_federal(self):
|
||||
"""Tests if staff can see CISA Region: N/A"""
|
||||
|
||||
# Create a fake domain request
|
||||
_domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
|
||||
|
||||
p = "userpass"
|
||||
self.client.login(username="staffuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/domainrequest/{}/change/".format(_domain_request.pk),
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure the page loaded, and that we're on the right page
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, _domain_request.requested_domain.name)
|
||||
|
||||
# Test if the page has the right CISA region
|
||||
expected_html = '<div class="flex-container margin-top-2">' "<span>CISA Region: N/A</span>" "</div>"
|
||||
# Remove whitespace from expected_html
|
||||
expected_html = "".join(expected_html.split())
|
||||
|
||||
# Remove whitespace from response content
|
||||
response_content = "".join(response.content.decode().split())
|
||||
|
||||
# Check if response contains expected_html
|
||||
self.assertIn(expected_html, response_content)
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_staff_can_see_cisa_region_non_federal(self):
|
||||
"""Tests if staff can see the correct CISA region"""
|
||||
|
||||
# Create a fake domain request. State will be NY (2).
|
||||
_domain_request = completed_domain_request(
|
||||
status=DomainRequest.DomainRequestStatus.IN_REVIEW, generic_org_type="interstate"
|
||||
)
|
||||
|
||||
p = "userpass"
|
||||
self.client.login(username="staffuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/domainrequest/{}/change/".format(_domain_request.pk),
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure the page loaded, and that we're on the right page
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, _domain_request.requested_domain.name)
|
||||
|
||||
# Test if the page has the right CISA region
|
||||
expected_html = '<div class="flex-container margin-top-2">' '<span">CISA Region: 2</span>' "</div>"
|
||||
# Remove whitespace from expected_html
|
||||
expected_html = "".join(expected_html.split())
|
||||
|
||||
# Remove whitespace from response content
|
||||
response_content = "".join(response.content.decode().split())
|
||||
|
||||
# Check if response contains expected_html
|
||||
self.assertIn(expected_html, response_content)
|
||||
|
||||
def tearDown(self):
|
||||
super().tearDown()
|
||||
Domain.objects.all().delete()
|
||||
|
|
63
src/registrar/views/utility/generic_helper.py
Normal file
63
src/registrar/views/utility/generic_helper.py
Normal file
|
@ -0,0 +1,63 @@
|
|||
"""This file contains general purpose helpers that don't belong in any specific location"""
|
||||
|
||||
|
||||
def get_region(state):
|
||||
regions = {
|
||||
"CT": 1,
|
||||
"ME": 1,
|
||||
"MA": 1,
|
||||
"NH": 1,
|
||||
"RI": 1,
|
||||
"VT": 1,
|
||||
"NJ": 2,
|
||||
"NY": 2,
|
||||
"PR": 2,
|
||||
"VI": 2,
|
||||
"DE": 3,
|
||||
"DC": 3,
|
||||
"MD": 3,
|
||||
"PA": 3,
|
||||
"VA": 3,
|
||||
"WV": 3,
|
||||
"AL": 4,
|
||||
"FL": 4,
|
||||
"GA": 4,
|
||||
"KY": 4,
|
||||
"MS": 4,
|
||||
"NC": 4,
|
||||
"SC": 4,
|
||||
"TN": 4,
|
||||
"IL": 5,
|
||||
"IN": 5,
|
||||
"MI": 5,
|
||||
"MN": 5,
|
||||
"OH": 5,
|
||||
"WI": 5,
|
||||
"AR": 6,
|
||||
"LA": 6,
|
||||
"NM": 6,
|
||||
"OK": 6,
|
||||
"TX": 6,
|
||||
"IA": 7,
|
||||
"KS": 7,
|
||||
"MO": 7,
|
||||
"NE": 7,
|
||||
"CO": 8,
|
||||
"MT": 8,
|
||||
"ND": 8,
|
||||
"SD": 8,
|
||||
"UT": 8,
|
||||
"WY": 8,
|
||||
"AZ": 9,
|
||||
"CA": 9,
|
||||
"HI": 9,
|
||||
"NV": 9,
|
||||
"GU": 9,
|
||||
"AS": 9,
|
||||
"MP": 9,
|
||||
"AK": 10,
|
||||
"ID": 10,
|
||||
"OR": 10,
|
||||
"WA": 10,
|
||||
}
|
||||
return regions.get(state.upper(), None)
|
Loading…
Add table
Add a link
Reference in a new issue