admin: fix policy testing form not showing the correct result
This commit is contained in:
parent
df8995deed
commit
270739a45a
|
@ -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)
|
||||
|
|
|
@ -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."))
|
||||
|
|
|
@ -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) => {
|
||||
|
|
Reference in a new issue