admin: fix policy testing form not showing the correct result

This commit is contained in:
Jens Langhammer 2020-05-28 21:50:43 +02:00
parent df8995deed
commit 270739a45a
3 changed files with 2 additions and 3 deletions

View file

@ -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)

View file

@ -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."))

View file

@ -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) => {