Skip to content
Snippets Groups Projects
Verified Commit 6676ef2d authored by mirabilos's avatar mirabilos
Browse files

Amend function to be able to limit search to same subject.

Advances #34
parent 6341d76d
No related branches found
No related tags found
No related merge requests found
......@@ -187,11 +187,14 @@ class LessonPeriod(SchoolRelated):
def get_groups(self) -> models.query.QuerySet:
return self.lesson.groups
def next_of_same_groups(self) -> Optional[LessonPeriod]:
def next_of_same_groups(self, same_subject=False) -> Optional[LessonPeriod]:
res = LessonPeriod.objects
# retrieve all LessonPeriods of this group constellation
for group in self.lesson.groups.all():
res = res.filter(lesson__groups__pk=group.pk)
# same subject?
if same_subject:
res = res.filter(lesson__subject=self.lesson.subject)
# sorted by time
res = res.order_by('period__weekday', 'period__period').distinct()
# simple list of their PKs
......
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