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
No related merge requests found
...@@ -13,6 +13,7 @@ Fixed ...@@ -13,6 +13,7 @@ Fixed
~~~~~ ~~~~~
* The _Delete personal note_ action didn't work due to wrong usage of ``bulk_update``. * 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 `2.0rc4`_ - 2021-08-01
---------------------- ----------------------
......
...@@ -256,11 +256,13 @@ class AssignGroupRoleForm(forms.ModelForm): ...@@ -256,11 +256,13 @@ class AssignGroupRoleForm(forms.ModelForm):
) )
else: else:
persons = persons.filter(member_of__owners=self.request.user.person) 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: if "groups" not in initial:
groups = Group.objects.for_current_school_term_or_all().filter( groups = (
owners=self.request.user.person Group.objects.for_current_school_term_or_all()
.filter(owners=self.request.user.person)
.distinct()
) )
self.fields["groups"].queryset = groups self.fields["groups"].queryset = groups
...@@ -332,7 +334,7 @@ class FilterRegisterObjectForm(forms.Form): ...@@ -332,7 +334,7 @@ class FilterRegisterObjectForm(forms.Form):
| Q(lessons__lesson_periods__substitutions__teachers=person) | Q(lessons__lesson_periods__substitutions__teachers=person)
| Q(events__teachers=person) | Q(events__teachers=person)
| Q(extra_lessons__teachers=person) | Q(extra_lessons__teachers=person)
) ).distinct()
elif not for_person: elif not for_person:
groups = Group.objects.all() groups = Group.objects.all()
self.fields["group"].queryset = groups 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