Skip to content
Snippets Groups Projects
Commit 8fae6d26 authored by Hangzhi Yu's avatar Hangzhi Yu
Browse files

Update group and student overviews to show all objects a person has privileges on

parent a32c4988
No related branches found
No related tags found
1 merge request!276Resolve "Allow parent group owners to edit lesson documentations/etc. of courses"
Pipeline #65049 passed with warnings
...@@ -11,6 +11,7 @@ from calendarweek import CalendarWeek ...@@ -11,6 +11,7 @@ from calendarweek import CalendarWeek
from aleksis.apps.alsijil.managers import PersonalNoteQuerySet from aleksis.apps.alsijil.managers import PersonalNoteQuerySet
from aleksis.apps.chronos.models import Event, ExtraLesson, LessonPeriod from aleksis.apps.chronos.models import Event, ExtraLesson, LessonPeriod
from aleksis.core.models import Group, Person from aleksis.core.models import Group, Person
from aleksis.core.util.core_helpers import get_site_preferences
from .models import ExcuseType, ExtraMark, LessonDocumentation, PersonalNote from .models import ExcuseType, ExtraMark, LessonDocumentation, PersonalNote
...@@ -385,8 +386,16 @@ def get_groups_with_lessons(cls: Group): ...@@ -385,8 +386,16 @@ def get_groups_with_lessons(cls: Group):
def get_owner_groups_with_lessons(self: Person): def get_owner_groups_with_lessons(self: Person):
"""Get all groups the person is an owner of and which have related lessons. """Get all groups the person is an owner of and which have related lessons.
Groups which have child groups with related lessons are also included. Groups which have child groups with related lessons are also included, as well as all
child groups of the groups owned by the person with related lessons if the
inherit_privileges_from_parent_group preference is turned on.
""" """
if get_site_preferences()["alsijil__inherit_privileges_from_parent_group"]:
return (
Group.get_groups_with_lessons()
.filter(Q(owners=self) | Q(parent_groups__owners=self))
.distinct()
)
return Group.get_groups_with_lessons().filter(owners=self).distinct() return Group.get_groups_with_lessons().filter(owners=self).distinct()
......
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