From 270739a45a14e9d994f95d805c9ee8be205bd40c Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 28 May 2020 21:50:43 +0200 Subject: [PATCH] admin: fix policy testing form not showing the correct result --- passbook/admin/forms/policies.py | 2 +- passbook/admin/views/policies.py | 2 +- passbook/flows/templates/flows/shell.html | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/passbook/admin/forms/policies.py b/passbook/admin/forms/policies.py index 27a932eaa..9751260d0 100644 --- a/passbook/admin/forms/policies.py +++ b/passbook/admin/forms/policies.py @@ -9,4 +9,4 @@ class PolicyTestForm(forms.Form): """Form to test policies against user""" user = forms.ModelChoiceField(queryset=User.objects.all()) - context = YAMLField(widget=CodeMirrorWidget()) + context = YAMLField(widget=CodeMirrorWidget(), required=False, initial=dict) diff --git a/passbook/admin/views/policies.py b/passbook/admin/views/policies.py index ab8278544..76196e70e 100644 --- a/passbook/admin/views/policies.py +++ b/passbook/admin/views/policies.py @@ -155,7 +155,7 @@ class PolicyTestView(LoginRequiredMixin, DetailView, PermissionRequiredMixin, Fo proc = PolicyProcess(PolicyBinding(policy=policy), p_request, None) result = proc.execute() - if result: + if result.passing: messages.success(self.request, _("User successfully passed policy.")) else: messages.error(self.request, _("User didn't pass policy.")) diff --git a/passbook/flows/templates/flows/shell.html b/passbook/flows/templates/flows/shell.html index 046f3c685..aa57f7a5d 100644 --- a/passbook/flows/templates/flows/shell.html +++ b/passbook/flows/templates/flows/shell.html @@ -142,7 +142,6 @@ const loadFormCode = () => { const setFormSubmitHandlers = () => { document.querySelectorAll("#flow-body form").forEach(form => { console.log(`Setting action for form ${form}`); - // debugger; form.action = flowBodyUrl; console.log(`Adding handler for form ${form}`); form.addEventListener('submit', (e) => {