(oops, missed these files in last commit)

This commit is contained in:
CocoByte 2024-02-29 15:29:13 -07:00
parent 0eafad3fb6
commit 54711152c1
No known key found for this signature in database
GPG key ID: BBFAA2526384C97F
2 changed files with 15 additions and 15 deletions

View file

@ -1055,7 +1055,7 @@ class DomainRequestAdmin(ListHeaderAdmin):
# Trigger action when a fieldset is changed # Trigger action when a fieldset is changed
def save_model(self, request, obj, form, change): def save_model(self, request, obj, form, change):
if obj and obj.creator.status != models.User.RESTRICTED: if obj and obj.creator.status != models.User.RESTRICTED:
if change: # Check if the application is being edited if change: # Check if the domain request is being edited
# Get the original application from the database # Get the original application from the database
original_obj = models.DomainRequest.objects.get(pk=obj.pk) original_obj = models.DomainRequest.objects.get(pk=obj.pk)
@ -1133,7 +1133,7 @@ class DomainRequestAdmin(ListHeaderAdmin):
def get_readonly_fields(self, request, obj=None): def get_readonly_fields(self, request, obj=None):
"""Set the read-only state on form elements. """Set the read-only state on form elements.
We have 2 conditions that determine which fields are read-only: We have 2 conditions that determine which fields are read-only:
admin user permissions and the application creator's status, so admin user permissions and the domain request creator's status, so
we'll use the baseline readonly_fields and extend it as needed. we'll use the baseline readonly_fields and extend it as needed.
""" """
readonly_fields = list(self.readonly_fields) readonly_fields = list(self.readonly_fields)

View file

@ -767,7 +767,7 @@ class DomainRequestTests(TestWithUser, WebTest):
self.assertEquals(other_contacts_form["other_contacts-has_other_contacts"].value, "False") self.assertEquals(other_contacts_form["other_contacts-has_other_contacts"].value, "False")
def test_submitting_other_contacts_deletes_no_other_contacts_rationale(self): def test_submitting_other_contacts_deletes_no_other_contacts_rationale(self):
"""When a user submits the Other Contacts form with other contacts selected, the application's """When a user submits the Other Contacts form with other contacts selected, the domain request's
no other contacts rationale gets deleted""" no other contacts rationale gets deleted"""
# Application has other contacts by default # Application has other contacts by default
domain_request = completed_domain_request(user=self.user, has_other_contacts=False) domain_request = completed_domain_request(user=self.user, has_other_contacts=False)
@ -815,7 +815,7 @@ class DomainRequestTests(TestWithUser, WebTest):
) )
def test_submitting_no_other_contacts_rationale_deletes_other_contacts(self): def test_submitting_no_other_contacts_rationale_deletes_other_contacts(self):
"""When a user submits the Other Contacts form with no other contacts selected, the application's """When a user submits the Other Contacts form with no other contacts selected, the domain request's
other contacts get deleted for other contacts that exist and are not joined to other objects other contacts get deleted for other contacts that exist and are not joined to other objects
""" """
# Application has other contacts by default # Application has other contacts by default
@ -857,7 +857,7 @@ class DomainRequestTests(TestWithUser, WebTest):
) )
def test_submitting_no_other_contacts_rationale_removes_reference_other_contacts_when_joined(self): def test_submitting_no_other_contacts_rationale_removes_reference_other_contacts_when_joined(self):
"""When a user submits the Other Contacts form with no other contacts selected, the application's """When a user submits the Other Contacts form with no other contacts selected, the domain request's
other contacts references get removed for other contacts that exist and are joined to other objects""" other contacts references get removed for other contacts that exist and are joined to other objects"""
# Populate the database with a domain request that # Populate the database with a domain request that
# has 1 "other contact" assigned to it # has 1 "other contact" assigned to it
@ -928,7 +928,7 @@ class DomainRequestTests(TestWithUser, WebTest):
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id) self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
# Verify that the no_other_contacts_rationale we saved earlier is no longer associated with the application # Verify that the no_other_contacts_rationale we saved earlier is no longer associated with the domain request
domain_request = DomainRequest.objects.get() domain_request = DomainRequest.objects.get()
self.assertEqual( self.assertEqual(
domain_request.other_contacts.count(), domain_request.other_contacts.count(),
@ -1218,7 +1218,7 @@ class DomainRequestTests(TestWithUser, WebTest):
"""When you: """When you:
1. edit an existing contact which is not joined to another model, 1. edit an existing contact which is not joined to another model,
2. then submit, 2. then submit,
The application is linked to the existing contact, and the existing contact updated.""" the domain request is linked to the existing contact, and the existing contact updated."""
# Populate the database with a domain request that # Populate the database with a domain request that
# has 1 "other contact" assigned to it # has 1 "other contact" assigned to it
@ -1299,7 +1299,7 @@ class DomainRequestTests(TestWithUser, WebTest):
"""When you: """When you:
1. edit an existing contact which IS joined to another model, 1. edit an existing contact which IS joined to another model,
2. then submit, 2. then submit,
The application is linked to a new contact, and the new contact is updated.""" the domain request is linked to a new contact, and the new contact is updated."""
# Populate the database with a domain request that # Populate the database with a domain request that
# has 1 "other contact" assigned to it, the other contact is also # has 1 "other contact" assigned to it, the other contact is also
@ -1379,7 +1379,7 @@ class DomainRequestTests(TestWithUser, WebTest):
"""When you: """When you:
1. edit an authorizing official which is not joined to another model, 1. edit an authorizing official which is not joined to another model,
2. then submit, 2. then submit,
The application is linked to the existing ao, and the ao updated.""" the domain request is linked to the existing ao, and the ao updated."""
# Populate the database with a domain request that # Populate the database with a domain request that
# has an authorizing_official (ao) # has an authorizing_official (ao)
@ -1444,7 +1444,7 @@ class DomainRequestTests(TestWithUser, WebTest):
"""When you: """When you:
1. edit an existing authorizing official which IS joined to another model, 1. edit an existing authorizing official which IS joined to another model,
2. then submit, 2. then submit,
The application is linked to a new Contact, and the new Contact is updated.""" the domain request is linked to a new Contact, and the new Contact is updated."""
# Populate the database with a domain request that # Populate the database with a domain request that
# has authorizing official assigned to it, the authorizing offical is also # has authorizing official assigned to it, the authorizing offical is also
@ -1516,7 +1516,7 @@ class DomainRequestTests(TestWithUser, WebTest):
"""When you: """When you:
1. edit a submitter (your contact) which is not joined to another model, 1. edit a submitter (your contact) which is not joined to another model,
2. then submit, 2. then submit,
The application is linked to the existing submitter, and the submitter updated.""" the domain request is linked to the existing submitter, and the submitter updated."""
# Populate the database with a domain request that # Populate the database with a domain request that
# has a submitter # has a submitter
@ -1580,7 +1580,7 @@ class DomainRequestTests(TestWithUser, WebTest):
"""When you: """When you:
1. edit an existing your contact which IS joined to another model, 1. edit an existing your contact which IS joined to another model,
2. then submit, 2. then submit,
The application is linked to a new Contact, and the new Contact is updated.""" the domain request is linked to a new Contact, and the new Contact is updated."""
# Populate the database with a domain request that # Populate the database with a domain request that
# has submitter assigned to it, the submitter is also # has submitter assigned to it, the submitter is also
@ -2214,13 +2214,13 @@ class TestWizardUnlockingSteps(TestWithUser, WebTest):
super().tearDown() super().tearDown()
def test_unlocked_steps_empty_domain_request(self): def test_unlocked_steps_empty_domain_request(self):
"""Test when all fields in the application are empty.""" """Test when all fields in the domain request are empty."""
unlocked_steps = self.wizard.db_check_for_unlocking_steps() unlocked_steps = self.wizard.db_check_for_unlocking_steps()
expected_dict = [] expected_dict = []
self.assertEqual(unlocked_steps, expected_dict) self.assertEqual(unlocked_steps, expected_dict)
def test_unlocked_steps_full_domain_request(self): def test_unlocked_steps_full_domain_request(self):
"""Test when all fields in the application are filled.""" """Test when all fields in the domain request are filled."""
completed_domain_request(status=DomainRequest.DomainRequestStatus.STARTED, user=self.user) completed_domain_request(status=DomainRequest.DomainRequestStatus.STARTED, user=self.user)
# Make a request to the home page # Make a request to the home page
@ -2263,7 +2263,7 @@ class TestWizardUnlockingSteps(TestWithUser, WebTest):
self.fail(f"Expected a redirect, but got a different response: {response}") self.fail(f"Expected a redirect, but got a different response: {response}")
def test_unlocked_steps_partial_domain_request(self): def test_unlocked_steps_partial_domain_request(self):
"""Test when some fields in the application are filled.""" """Test when some fields in the domain request are filled."""
# Create the site and contacts to delete (orphaned) # Create the site and contacts to delete (orphaned)
contact = Contact.objects.create( contact = Contact.objects.create(