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

Optimize lesson period filtering in _generate_dicts_for_lesson_periods

parent e0572a2a
No related branches found
No related tags found
1 merge request!276Resolve "Allow parent group owners to edit lesson documentations/etc. of courses"
Pipeline #64571 passed with warnings
......@@ -193,14 +193,11 @@ def _generate_dicts_for_lesson_periods(
"alsijil__inherit_privileges_from_parent_group"
]
for lesson_period in lesson_periods:
parent_group_owned_by_person = (
filter_dict.get("person")
.owner_of.intersection(
Group.objects.filter(
child_groups__in=Group.objects.filter(lessons__lesson_periods=lesson_period)
)
)
.exists()
parent_group_owned_by_person = inherit_privileges_preference and (
Group.objects.filter(
child_groups__in=Group.objects.filter(lessons__lesson_periods=lesson_period),
owners=filter_dict.get("person"),
).exists()
)
for week in weeks:
day = week[lesson_period.period.weekday]
......@@ -226,7 +223,7 @@ def _generate_dicts_for_lesson_periods(
if filter_dict.get("person") and (
filter_dict.get("person") not in lesson_period.lesson.teachers.all()
and not sub
and not (inherit_privileges_preference and parent_group_owned_by_person)
and not parent_group_owned_by_person
):
continue
......
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