diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 80f39dad6..d2df04d3a 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -167,16 +167,14 @@ class DomainAdmin(ListHeaderAdmin): request.session["analyst_action"] = "edit" # Restricts this action to this domain (pk) only request.session["analyst_action_location"] = obj.id - return HttpResponseRedirect(reverse("domain", args=(obj.id,))) return super().response_change(request, obj) def change_view(self, request, object_id): - # If the analyst was recently editing + # If the analyst was recently editing a domain page, + # delete any associated session values if "analyst_action" in request.session: - # delete the session variable del request.session["analyst_action"] - # delete the associated location del request.session["analyst_action_location"] return super().change_view(request, object_id) diff --git a/src/registrar/tests/test_admin.py b/src/registrar/tests/test_admin.py index 35e64582d..84b4535b6 100644 --- a/src/registrar/tests/test_admin.py +++ b/src/registrar/tests/test_admin.py @@ -654,7 +654,7 @@ class DomainSessionVariableTest(TestCase): p = "adminpass" self.client.login(username="superuser", password=p) - dummy_domain_information: DomainInformation = generic_domain_object("information", "session") + dummy_domain_information = generic_domain_object("information", "session") request = self.get_factory_post_edit_domain(dummy_domain_information.domain.pk) self.populate_session_values(request, dummy_domain_information.domain) @@ -663,10 +663,11 @@ class DomainSessionVariableTest(TestCase): def test_session_variables_retain_information(self): """ Checks to see if session variables retain old information """ + p = "adminpass" self.client.login(username="superuser", password=p) - dummy_domain_information_list: [DomainInformation] = multiple_unalphabetical_domain_objects("information") + dummy_domain_information_list = multiple_unalphabetical_domain_objects("information") for item in dummy_domain_information_list: request = self.get_factory_post_edit_domain(item.domain.pk) self.populate_session_values(request, item) @@ -676,22 +677,15 @@ class DomainSessionVariableTest(TestCase): def test_session_variables_concurrent_requests(self): """ Simulates two requests at once """ + p = "adminpass" self.client.login(username="superuser", password=p) - info_first: DomainInformation = generic_domain_object("information", "session") - info_second: DomainInformation = generic_domain_object("information", "session2") + info_first = generic_domain_object("information", "session") + info_second = generic_domain_object("information", "session2") - request_first = self.factory.post( - reverse('admin:registrar_domain_change', args=(info_first.domain.pk,)), - {'_edit_domain': 'true'}, - follow=True - ) - request_second = self.factory.post( - reverse('admin:registrar_domain_change', args=(info_second.domain.pk,)), - {'_edit_domain': 'true'}, - follow=True - ) + request_first = self.get_factory_post_edit_domain(info_first.domain.pk) + request_second = self.get_factory_post_edit_domain(info_second.domain.pk) self.populate_session_values(request_first, info_first.domain) self.populate_session_values(request_second, info_second.domain) diff --git a/src/registrar/views/domain.py b/src/registrar/views/domain.py index 471bd4092..804948ae9 100644 --- a/src/registrar/views/domain.py +++ b/src/registrar/views/domain.py @@ -81,9 +81,7 @@ class DomainOrgNameAddressView(DomainPermissionView, FormMixin): ) # Q: Is there a more efficent way to do this? - # I don't like repeating code across these functions, - # But I can't figure out a way to do this without installing - # middleware... + # It would be ideal if we didn't have to repeat this. if self.request.user.is_staff or self.request.user.is_superuser: # if they are editing from an '/admin' redirect, log their actions self.log_analyst_form_actions(