diff --git a/aleksis/apps/chronos/templates/chronos/timetable_print.html b/aleksis/apps/chronos/templates/chronos/timetable_print.html new file mode 100644 index 0000000000000000000000000000000000000000..eb0d3e165bd64459ae5f0c8e98cac81af9566bac --- /dev/null +++ b/aleksis/apps/chronos/templates/chronos/timetable_print.html @@ -0,0 +1,182 @@ +{# -*- engine:django -*- #} + +{% extends 'core/base.html' %} + +{% load data_helpers static i18n %} + +{% block extra_head %} + <link rel="stylesheet" href="{% static 'css/chronos/timetable.css' %}"> +{% endblock %} + +{% block browser_title %}{% blocktrans %}Timetable{% endblocktrans %}{% endblock %} +{% block content %} + + {% if smart %} + <script type="text/javascript" src="{% static "js/helper.js" %}"></script> + {{ week_select|json_script:"week_select" }} + <script type="text/javascript" src="{% static "js/chronos/week_select.js" %}"></script> + {% endif %} + + <div class="row no-margin"> + <div class="col s8 m6 l8 xl9"> + <h4> + {% trans "Timetable" %} <i>{{ el }}</i> + </h4> + + {# Show class teacher and deputy class teacher #} + {% if type.value == "group" and el.owners.all %} + <h5>{% trans "Group teachers:" %} + {% for teacher in el.owners.all %} + <span data-position="bottom" class="tooltipped" + data-tooltip="{{ teacher }}"> + <a href="{% url "timetable" "teacher" teacher.pk %}"> + {{ teacher.short_name }}</a></span>{% if not forloop.last %},{% endif %} + {% endfor %} + </h5> + {% endif %} + </div> + {# Show print button only if not on mobile #} + <div class="col s4 m6 l4 xl3 right align-right no-print"> + <a class="waves-effect waves-teal btn-flat btn-flat-medium right hide-on-small-and-down" id="print"> + <i class="material-icons center">print</i> + </a> + </div> + </div> + <div class="row"> + {% if smart %} + {# Show if smart #} + {# Toggle button to regular and smart plan badge #} + <div class="row s12 m6 left"> + <span class="badge new primary-color left smart-plan-badge">{% trans "SMART PLAN" %}</span> + + <a class="waves-effect waves-light btn-flat no-print" + href="{% url "timetable_regular" type.value pk "regular" %}"> + <i class="material-icons left">slideshow</i> + {% trans "Show regular timetable" %} + </a> + </div> + + {# Week select #} + {% include "chronos/partials/week_select.html" with wanted_week=week %} + + {% else %} + {# Show if regular #} + <a class="waves-effect waves-light btn-flat no-print" + href="{% url "timetable" type.value pk %}"> + <i class="material-icons left">slideshow</i> + {% trans "Show SMART PLAN" %} + </a> + {% endif %} + </div> + + {% include "core/partials/announcements.html" with announcements=announcements show_interval=1 %} + + {# show full timetable on tablets, laptops and pcs #} + <div class="timetable-plan hide-on-small-and-down"> + + {# Week days #} + <div class="row"> + <div class="col s2"> + + </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-content"> + <span class="card-title"> + {{ weekday.name }} + </span> + {% if smart %} + {{ weekday.date }} + {% if weekday.holiday %} + <br/>{% include "chronos/partials/holiday.html" with holiday=weekday.holiday %} + {% endif %} + {% endif %} + </div> + </div> + </div> + {% endfor %} + + {# Show long weekdays elsewere #} + {% for weekday in weekdays %} + <div class="col s2 hide-on-med-only"> + <div class="card timetable-title-card"> + <div class="card-content"> + <span class="card-title"> + {{ weekday.name }} + </span> + {% if smart %} + {{ weekday.date }} + {% if weekday.holiday %} + <br/>{% include "chronos/partials/holiday.html" with holiday=weekday.holiday %} + {% endif %} + {% endif %} + </div> + </div> + </div> + {% endfor %} + </div> + + {# Lessons #} + {% for row in timetable %} + <div class="row"> + <div class="col s2"> + {% if row.type == "period" %} + {% include "chronos/partials/period_time.html" with period=row.period periods=periods %} + {% endif %} + </div> + + {% for col in row.cols %} + {# A lesson #} + <div class="col s2"> + {% if row.type == "period" %} + {% include "chronos/partials/elements.html" with elements=col %} + {% else %} + {% include "chronos/partials/supervision.html" with supervision=col %} + {% endif %} + </div> + {% endfor %} + </div> + {% endfor %} + </div> + + {# show 5 seperate ones on mobiles #} + <div class="timetable-plan hide-on-med-and-up"> + {% for weekday in weekdays %} + <div class="card timetable-mobile-title-card"> + <div class="card-content"> + <span class="card-title"> + {{ weekday.name }} + </span> + {% if smart %} + {{ weekday.date }} + {% if weekday.holiday %} + <br/>{% include "chronos/partials/holiday.html" with holiday=weekday.holiday %} + {% endif %} + {% endif %} + </div> + </div> + {% for row in timetable %} + <div class="row"> + <div class="col s4"> + {% include "chronos/partials/period_time.html" with period=row.period periods=periods %} + </div> + + {% for col in row.cols %} + {% if forloop.counter0 == weekday.key %} + <div class="col s8"> + {# A lesson #} + {% if row.type == "period" %} + {% include "chronos/partials/elements.html" with elements=col %} + {% else %} + {% include "chronos/partials/supervision.html" with supervision=col %} + {% endif %} + </div> + {% endif %} + {% endfor %} + </div> + {% endfor %} + {% endfor %} + </div> +{% endblock %} diff --git a/aleksis/apps/chronos/urls.py b/aleksis/apps/chronos/urls.py index 666183ec6a43d80b897b05643288a77ee8b615b7..22e97b8a6202424f9fc4d4596e15ed99f1713f91 100644 --- a/aleksis/apps/chronos/urls.py +++ b/aleksis/apps/chronos/urls.py @@ -19,6 +19,17 @@ urlpatterns = [ path( "timetable/<str:type_>/<int:pk>/<str:regular>/", views.timetable, name="timetable_regular", ), + path("timetable/<str:type_>/<int:pk>/<str:print_plan>/", views.timetable, name="timetable_print"), + path( + "timetable/<str:type_>/<int:pk>/<int:year>/<int:week>/<str:print_plan>/", + views.timetable, + name="timetable_by_week_print", + ), + path( + "timetable/<str:type_>/<int:pk>/<str:regular>/<str:print_plan>/", + views.timetable, + name="timetable_regular_print", + ), path("lessons/", views.lessons_day, name="lessons_day"), path( "lessons/<int:year>/<int:month>/<int:day>/", views.lessons_day, name="lessons_day_by_date", diff --git a/aleksis/apps/chronos/views.py b/aleksis/apps/chronos/views.py index d4b275cfe0e5b0f40e4f72970d81da4f0d876dc1..0629dd5e2426b4efcd9c2354e99dadbe848487ad 100644 --- a/aleksis/apps/chronos/views.py +++ b/aleksis/apps/chronos/views.py @@ -124,6 +124,7 @@ def timetable( year: Optional[int] = None, week: Optional[int] = None, regular: Optional[str] = None, + print_plan: Optional[str] = None, ) -> HttpResponse: """View a selected timetable for a person, group or room.""" context = {} @@ -185,6 +186,8 @@ def timetable( "timetable_by_week", args=[type_.value, pk, week_next.year, week_next.week] ) + if print_plan == "print": + return render(request, "chronos/timetable_print.html", context) return render(request, "chronos/timetable.html", context)