mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-17 01:57:03 +02:00
More code cleanup
This commit is contained in:
parent
3d0a519ab0
commit
81e5f5f8bb
3 changed files with 11 additions and 21 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue