diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5f4e9ef1335d4f4c08bd56e0a7e7007a183e73f4..e1970a31b69ce3ac4211ce76db5bb6e8e081f023 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 ---------------------- diff --git a/aleksis/apps/alsijil/forms.py b/aleksis/apps/alsijil/forms.py index cb12a4eb86e424167d4301b31fca0a0dd035b625..042b253363a2fa34ab203833e775c4175ebaf162 100644 --- a/aleksis/apps/alsijil/forms.py +++ b/aleksis/apps/alsijil/forms.py @@ -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