Skip to content
Snippets Groups Projects
Verified Commit 85752ec4 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Merge branch 'master' into 51-pdf-export-for-timetables

parents 759e6fbd 48c5e565
No related branches found
No related tags found
1 merge request!77Resolve "PDF export for timetables"
Pipeline #5974 passed
<!-- AlekSIS is developed on EduGit. GitHub only serves as
backup mirror and to help people find the project. If
possible, please submit your merge request on EduGit!
EduGit accepts logins with GitHub accounts.
-->
[ ] I have read the above and have no way to contribute on EduGit
[ ] I understand that GitHub's terms of service exclude young and
learning contributors, but still cannot contribute on EduGit
instead.
......@@ -83,7 +83,7 @@ def lesson_periods_as_teacher(self):
@Person.method
def lessons_on_day(self, day: date):
"""Get all lessons of this person (either as participant or teacher) on the given day."""
return LessonPeriod.objects.on_day(day).filter_from_person(self).order_by("period__period")
return LessonPeriod.objects.order_by("period__period").on_day(day).filter_from_person(self)
@Person.method
......@@ -92,6 +92,10 @@ def _adjacent_lesson(
) -> Union["LessonPeriod", None]:
"""Get next/previous lesson of the person (either as participant or teacher) on the same day."""
daily_lessons = self.lessons_on_day(day)
if not daily_lessons:
return None
ids = list(daily_lessons.values_list("id", flat=True))
index = ids.index(lesson_period.pk)
......
......@@ -19,7 +19,6 @@ from django.utils.translation import gettext_lazy as _
from cache_memoize import cache_memoize
from calendarweek.django import CalendarWeek, i18n_day_abbr_choices_lazy, i18n_day_name_choices_lazy
from colorfield.fields import ColorField
from django_global_request.middleware import get_request
from aleksis.apps.chronos.managers import (
AbsenceQuerySet,
......@@ -515,10 +514,9 @@ class LessonPeriod(ExtensibleModel, WeekAnnotationMixin):
class TimetableWidget(DashboardWidget):
template = "chronos/widget.html"
def get_context(self):
def get_context(self, request):
from aleksis.apps.chronos.util.build import build_timetable # noqa
request = get_request()
context = {"has_plan": True}
wanted_day = TimePeriod.get_next_relevant_day(timezone.now().date(), datetime.now().time())
......
<div class="card lesson-card {% if week_day == active_day %} z-depth-5 active {% endif %}">
<div class="card lesson-card {% if active_day and week_day == active_day %} z-depth-5 active {% endif %}">
<div class="card-content">
{% for element in elements %}
{% if element.label_ == "lesson_period" %}
{% include "chronos/partials/lesson.html" with lesson_period=element %}
{% elif element.label_ == "extra_lesson" %}
{% elif element.label_ == "extra_lesson" and smart %}
{% include "chronos/partials/extra_lesson.html" with extra_lesson=element %}
{% elif element.label_ == "event" %}
{% elif element.label_ == "event" and smart %}
{% include "chronos/partials/event.html" with event=element %}
{% endif %}
{% endfor %}
......
......@@ -12,9 +12,7 @@
class="{% if lesson_period.get_substitution and smart %}lesson-with-sub{% endif %}"
>
<p>
{% if lesson_period.is_hol and smart %}
{# Do nothing #}
{% elif lesson_period.get_substitution and smart %}
{% if lesson_period.get_substitution and smart %}
{% with sub=lesson_period.get_substitution %}
{# SUBSTITUTION #}
{% if type.value == "room" and lesson_period.room != lesson_period.get_room and lesson_period.get_room != el %}
......
{% load i18n %}
<div class="card lesson-card supervision-card">
<div class="card lesson-card supervision-card {% if active_day and week_day == active_day %} z-depth-5 active {% endif %}">
<div class="card-content">
{% if supervision %}
<div style="
......
{# Week days #}
<div class="row">
<div class="col s1">
<div class="col {% if active_day %}s1{% else %}s2{% endif %}">
</div>
{# Show short weekdays on tablets #}
{% for weekday in weekdays_short %}
<div class="col s2 hide-on-large-only">
<div class="card timetable-title-card">
<div class="card timetable-title-card {% if active_day and weekday.date == active_day %} z-depth-5 {% endif %}">
<div class="card-content">
<span class="card-title">
{{ weekday.name }}
......@@ -28,7 +28,7 @@
{# Show long weekdays elsewere #}
{% for weekday in weekdays %}
<div class="col {% if weekday.date == active_day %} s3 {% else %} s2 {% endif %} hide-on-med-only">
<div class="card timetable-title-card {% if weekday.date == active_day %} z-depth-5 {% endif %}">
<div class="card timetable-title-card {% if active_day and weekday.date == active_day %} z-depth-5 {% endif %}">
<div class="card-content">
<span class="card-title">
{{ weekday.name }}
......@@ -51,7 +51,7 @@
{# Lessons #}
{% for row in timetable %}
<div class="row">
<div class="col s1">
<div class="col {% if active_day %}s1{% else %}s2{% endif %}">
{% if row.type == "period" %}
{% include "chronos/partials/period_time.html" with period=row.period periods=periods %}
{% endif %}
......
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