Skip to content
Snippets Groups Projects
Commit c3b5d5d5 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Merge branch...

Merge branch '182-multipleobjectsreturned-at-app-alsijil-me-get-returned-more-than-one-group-it-returned-18' into 'master'

Resolve "MultipleObjectsReturned at /app/alsijil/me/ - get() returned more than one Group -- it returned 18!"

Closes #182

See merge request AlekSIS/official/AlekSIS-App-Alsijil!222
parents 02b1b695 c4474646
Branches
Tags
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.
Please register or to comment