Skip to content
Snippets Groups Projects
Verified Commit 53b23d07 authored by Tom Teichler's avatar Tom Teichler :beers:
Browse files

Create django_tables table.

parent 068d3452
No related branches found
No related tags found
No related merge requests found
from django.utils.translation import ugettext_lazy as _
import django_tables2 as tables
from django_tables2.utils import A
class LessonsTable(tables.Table):
class Meta:
attrs = {'class': 'table table-striped table-bordered table-hover table-responsive-xl'}
period__period = tables.Column()
lesson__groups = tables.Column()
lesson_teachers = tables.Column()
lesson_subject = tables.Column()
room = tables.Column()
{% extends "core/base.html" %}
{% load bootstrap4 i18n %}
{% load render_table from django_tables2 %}
{% block page_title %}{% blocktrans %}Lessons{% endblocktrans %}{% endblock %}
{% block content %}
<h2>
{{ day }}
</h2>
{% render_table lessons_table %}
{% endblock %}
......@@ -14,6 +14,7 @@ from biscuit.core.models import Group, Person
from .forms import SelectForm
from .models import LessonPeriod, TimePeriod, Room
from .util import current_week, week_weekday_from_date
from .tables import LessonsTable
@login_required
......@@ -92,11 +93,17 @@ def lessons_day(request: HttpRequest, when: Optional[str] = None) -> HttpRespons
week, weekday = week_weekday_from_date(day)
# Get lessons
lesson_periods = LessonPeriod.objects.filter(
lesson__date_start__lte=day, lesson__date_end__gte=day,
period__weekday=weekday
).all()
# Build table
lesson_table = LessonsTable(lesson_periods)
RequestConfig(request).configure(lesson_table)
context['lesson_table'] = lesson_table
context['day'] = day
context['day_prev'] = day + timedelta(days=-1)
context['day_next'] = day + timedelta(days=1)
......
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