Skip to content
Snippets Groups Projects
Verified Commit c4474646 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Add distinct to permission-related queries in FilterRegisterObjectForm and AssignGroupRoleForm

parent 02b1b695
No related branches found
No related tags found
1 merge request!222Resolve "MultipleObjectsReturned at /app/alsijil/me/ - get() returned more than one Group -- it returned 18!"
Pipeline #26369 passed with warnings
......@@ -13,6 +13,7 @@ Fixed
~~~~~
* The _Delete personal note_ action didn't work due to wrong usage of ``bulk_update``.
* Groups and persons were shown multiple times in some forms due to filtering by permissions.
`2.0rc4`_ - 2021-08-01
----------------------
......
......@@ -256,11 +256,13 @@ class AssignGroupRoleForm(forms.ModelForm):
)
else:
persons = persons.filter(member_of__owners=self.request.user.person)
self.fields["person"].queryset = persons
self.fields["person"].queryset = persons.distinct()
if "groups" not in initial:
groups = Group.objects.for_current_school_term_or_all().filter(
owners=self.request.user.person
groups = (
Group.objects.for_current_school_term_or_all()
.filter(owners=self.request.user.person)
.distinct()
)
self.fields["groups"].queryset = groups
......@@ -332,7 +334,7 @@ class FilterRegisterObjectForm(forms.Form):
| Q(lessons__lesson_periods__substitutions__teachers=person)
| Q(events__teachers=person)
| Q(extra_lessons__teachers=person)
)
).distinct()
elif not for_person:
groups = Group.objects.all()
self.fields["group"].queryset = groups
......
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