Skip to content
Snippets Groups Projects
Unverified Commit 4145b4f0 authored by bickelj's avatar bickelj Committed by GitHub
Browse files

Let non-Staff (e.g. Admin) do batch determination (#3796)

When an Admin who otherwise could make determinations on submissions
does a batch determination then it should succeed. This commit allows it
to succeed or throws a permissions error otherwise.

Issue #3793 Batch determination `KeyError` for non-Staff user
parent 90703c45
No related branches found
No related tags found
1 merge request!76Merge up to 5.6.0
...@@ -132,7 +132,8 @@ class BaseBatchDeterminationForm(BaseDeterminationForm, forms.Form): ...@@ -132,7 +132,8 @@ class BaseBatchDeterminationForm(BaseDeterminationForm, forms.Form):
widget=forms.ModelMultipleChoiceField.hidden_widget, widget=forms.ModelMultipleChoiceField.hidden_widget,
) )
author = forms.ModelChoiceField( author = forms.ModelChoiceField(
queryset=User.objects.staff(), # Permissions should be handled by the view rather than the QuerySet here.
queryset=User.objects.active(),
widget=forms.ModelChoiceField.hidden_widget, widget=forms.ModelChoiceField.hidden_widget,
required=True, required=True,
) )
...@@ -569,7 +570,8 @@ class BatchDeterminationForm(StreamBaseForm, forms.Form, metaclass=FormMixedMeta ...@@ -569,7 +570,8 @@ class BatchDeterminationForm(StreamBaseForm, forms.Form, metaclass=FormMixedMeta
widget=forms.ModelMultipleChoiceField.hidden_widget, widget=forms.ModelMultipleChoiceField.hidden_widget,
) )
author = forms.ModelChoiceField( author = forms.ModelChoiceField(
queryset=User.objects.staff(), # Permissions should be handled by the view rather than the QuerySet here.
queryset=User.objects.active(),
widget=forms.ModelChoiceField.hidden_widget, widget=forms.ModelChoiceField.hidden_widget,
required=True, required=True,
) )
...@@ -627,7 +629,8 @@ class BatchDeterminationForm(StreamBaseForm, forms.Form, metaclass=FormMixedMeta ...@@ -627,7 +629,8 @@ class BatchDeterminationForm(StreamBaseForm, forms.Form, metaclass=FormMixedMeta
def _post_clean(self): def _post_clean(self):
submissions = self.cleaned_data["submissions"].undetermined() submissions = self.cleaned_data["submissions"].undetermined()
data = { data = {
field: self.cleaned_data[field] # If one of these keys is not set, we should get a validation error on the page rather than `KeyError`.
field: self.cleaned_data.get(field)
for field in ["author", "form_data", "outcome"] for field in ["author", "form_data", "outcome"]
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment