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

Use ORM annotation to transfer week to table.

Hacka-di-hack!
parent 27a9e13d
No related branches found
No related tags found
No related merge requests found
......@@ -26,8 +26,4 @@ class LessonsTable(tables.Table):
lesson__teachers = tables.Column(accessor='lesson.teacher_names', verbose_name=_('Teachers'))
lesson__subject = tables.Column(accessor='lesson.subject')
room = tables.Column(accessor='room')
edit_substitution = tables.LinkColumn('edit_substitution_by_id', args=[A('id')], text=_('Substitution'))
def __init__(self, week, *args, **kwargs):
self.edit_substitution.args.append(week)
super().__init__(*args, **kwargs)
edit_substitution = tables.LinkColumn('edit_substitution_by_id', args=[A('id'), A('week')], text=_('Substitution'))
......@@ -99,10 +99,10 @@ def lessons_day(request: HttpRequest, when: Optional[str] = None) -> HttpRespons
lesson_periods = LessonPeriod.objects.filter(
lesson__date_start__lte=day, lesson__date_end__gte=day,
period__weekday=weekday
).all()
).annotate(_week=week).all()
# Build table
lessons_table = LessonsTable(week, lesson_periods)
lessons_table = LessonsTable(lesson_periods)
RequestConfig(request).configure(lessons_table)
context['lessons_table'] = lessons_table
......
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