admin: fix context not being passed correctly to policy test view
This commit is contained in:
parent
ea0ba5ae30
commit
4b24b185f2
|
@ -7,7 +7,6 @@ from django.contrib.auth.mixins import (
|
||||||
PermissionRequiredMixin as DjangoPermissionRequiredMixin,
|
PermissionRequiredMixin as DjangoPermissionRequiredMixin,
|
||||||
)
|
)
|
||||||
from django.contrib.messages.views import SuccessMessageMixin
|
from django.contrib.messages.views import SuccessMessageMixin
|
||||||
from django.db.models import QuerySet
|
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
|
@ -99,7 +98,7 @@ class PolicyTestView(LoginRequiredMixin, DetailView, PermissionRequiredMixin, Fo
|
||||||
template_name = "administration/policy/test.html"
|
template_name = "administration/policy/test.html"
|
||||||
object = None
|
object = None
|
||||||
|
|
||||||
def get_object(self, queryset=None) -> QuerySet:
|
def get_object(self, queryset=None) -> Policy:
|
||||||
return (
|
return (
|
||||||
Policy.objects.filter(pk=self.kwargs.get("pk")).select_subclasses().first()
|
Policy.objects.filter(pk=self.kwargs.get("pk")).select_subclasses().first()
|
||||||
)
|
)
|
||||||
|
@ -118,7 +117,7 @@ class PolicyTestView(LoginRequiredMixin, DetailView, PermissionRequiredMixin, Fo
|
||||||
|
|
||||||
p_request = PolicyRequest(user)
|
p_request = PolicyRequest(user)
|
||||||
p_request.http_request = self.request
|
p_request.http_request = self.request
|
||||||
p_request.context = form.cleaned_data
|
p_request.context = form.cleaned_data.get("context", {})
|
||||||
|
|
||||||
proc = PolicyProcess(PolicyBinding(policy=policy), p_request, None)
|
proc = PolicyProcess(PolicyBinding(policy=policy), p_request, None)
|
||||||
result = proc.execute()
|
result = proc.execute()
|
||||||
|
|
Reference in New Issue