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( ...@@ -193,14 +193,11 @@ def _generate_dicts_for_lesson_periods(
"alsijil__inherit_privileges_from_parent_group" "alsijil__inherit_privileges_from_parent_group"
] ]
for lesson_period in lesson_periods: for lesson_period in lesson_periods:
parent_group_owned_by_person = ( parent_group_owned_by_person = inherit_privileges_preference and (
filter_dict.get("person") Group.objects.filter(
.owner_of.intersection( child_groups__in=Group.objects.filter(lessons__lesson_periods=lesson_period),
Group.objects.filter( owners=filter_dict.get("person"),
child_groups__in=Group.objects.filter(lessons__lesson_periods=lesson_period) ).exists()
)
)
.exists()
) )
for week in weeks: for week in weeks:
day = week[lesson_period.period.weekday] day = week[lesson_period.period.weekday]
...@@ -226,7 +223,7 @@ def _generate_dicts_for_lesson_periods( ...@@ -226,7 +223,7 @@ def _generate_dicts_for_lesson_periods(
if filter_dict.get("person") and ( if filter_dict.get("person") and (
filter_dict.get("person") not in lesson_period.lesson.teachers.all() filter_dict.get("person") not in lesson_period.lesson.teachers.all()
and not sub and not sub
and not (inherit_privileges_preference and parent_group_owned_by_person) and not parent_group_owned_by_person
): ):
continue 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