Small Refactoring

This commit is contained in:
zandercymatics 2023-08-23 14:07:54 -06:00
parent 6538471091
commit 274e31cc37
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
5 changed files with 40 additions and 33 deletions

View file

@ -6,7 +6,6 @@ from django.http.response import HttpResponseRedirect
from django.urls import reverse
from . import models
logger = logging.getLogger(__name__)
@ -162,7 +161,7 @@ class DomainAdmin(ListHeaderAdmin):
elif EDIT_DOMAIN in request.POST:
# We want to know, globally, when an edit action occurs
request.session["analyst_action"] = "edit"
# Restricts this action to this domain only
# Restricts this action to this domain (pk) only
request.session["analyst_action_location"] = obj.id
return HttpResponseRedirect(reverse("domain", args=(obj.id,)))
@ -179,6 +178,7 @@ class DomainAdmin(ListHeaderAdmin):
extra_context = extra_context or {}
extra_context["domain_id"] = object_id
return super().change_view(
request,
object_id,
@ -186,6 +186,14 @@ class DomainAdmin(ListHeaderAdmin):
extra_context=extra_context,
)
def has_change_permission(self, request, obj=None):
# Fixes a bug wherein users which are only is_staff can access 'change' when GET,
# but cannot access this page when it is a request of type POST.
if request.user.is_staff:
return True
return super().has_change_permission(request, obj)
class ContactAdmin(ListHeaderAdmin):