Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • AlekSIS/onboarding/AlekSIS-App-Lesrooster
  • elumKtrolte/AlekSIS-App-Lesrooster
  • 3caifricarha/AlekSIS-App-Lesrooster
  • 0randpenFtiabo/AlekSIS-App-Lesrooster
  • disclaMcremze/AlekSIS-App-Lesrooster
  • mogamuboun/AlekSIS-App-Lesrooster
  • 1lidisPtheoto/AlekSIS-App-Lesrooster
  • 8exitQconsko/AlekSIS-App-Lesrooster
  • 9scelasOyghe/AlekSIS-App-Lesrooster
  • misraMcaryo/AlekSIS-App-Lesrooster
  • 3mirummocgu/AlekSIS-App-Lesrooster
11 results
Show changes
Showing
with 280 additions and 0 deletions
<div class="card lesson-card">
<div class="card-content">
{% for element in elements %}
{% include "lesrooster/partials/lesson.html" with lesson=element %}
{% endfor %}
</div>
</div>
{{ item.short_name }}{% if not forloop.last %},{% endif %}
{% if groups.count == 1 and groups.0.parent_groups.all and request.site.preferences.lesrooster__use_parent_groups %}
{% include "lesrooster/partials/groups_part.html" with groups=groups.0.parent_groups.all no_collapsible=no_collapsible %}
{% else %}
{% include "lesrooster/partials/groups_part.html" with groups=groups no_collapsible=no_collapsible %}
{% endif %}
{% if groups.count > request.site.preferences.lesrooster__shorten_groups_limit and request.user.person.preferences.lesrooster__shorten_groups and not no_collapsible %}
{% include "components/text_collapsible.html" with template="lesrooster/partials/group.html" qs=groups %}
{% else %}
{% for group in groups %}
{% include "lesrooster/partials/group.html" with item=group %}
{% endfor %}
{% endif %}
{% load i18n %}
<div style="{% include "lesrooster/partials/subject_colour.html" with subject=lesson.subject %}">
<p>
{# Teacher or room > Display classes #}
{% if type.value == "teacher" or type.value == "room" %}
{% if lesson.course.groups %}
{% include "lesrooster/partials/groups.html" with groups=lesson.course.groups.all %}
{% endif %}
{% endif %}
{# Class or room > Display teacher #}
{% if type.value == "room" or type.value == "group" %}
{% include "lesrooster/partials/teachers.html" with teachers=lesson.teachers.all %}
{% endif %}
{# Display subject #}
{% include "lesrooster/partials/subject.html" with subject=lesson.subject %}
{# Teacher or class > Display room #}
{% if type.value == "teacher" or type.value == "group" %}
{% include "lesrooster/partials/rooms.html" with rooms=lesson.rooms.all %}
{% endif %}
</p>
</div>
{% for room in rooms %}
{{ room.short_name }}{% if not forloop.last %},{% endif %}
{% endfor %}
{% load data_helpers %}
<div class="card timetable-title-card">
<div class="card-content">
{# Lesson number #}
<div class="card-title left">
{{ slot.period }}.
</div>
{# Time dimension of lesson #}
<div class="right timetable-time grey-text text-darken-2">
<span>{{ slot.time_start|time }}</span>
<br/>
<span>{{ slot.time_end|time }}</span>
</div>
</div>
</div>
<strong>
{{ subject.short_name }}
</strong>
{% if subject.colour_fg %}
color: {{ subject.colour_fg }};
{% endif %}
{% if subject.colour_bg and subject.colour_bg != subject.colour_fg %}
background-color: {{ subject.colour_bg }};
{% endif %}
{% load i18n %}
<div class="card lesson-card supervision-card">
<div class="card-content">
{% if supervision %}
<div>
<p>
<strong>{% trans "Supervision" %}</strong>
{% include "lesrooster/partials/rooms.html" with rooms=supervision.rooms.all %}
{% include "lesrooster/partials/teachers.html" with teachers=supervision.teachers.all %}
</p>
</div>
{% endif %}
</div>
</div>
{% for teacher in teachers %}
{{ teacher.short_name }}{% if not forloop.last %},{% endif %}
{% endfor %}
{% extends 'core/base_print.html' %}
{% load data_helpers static i18n %}
{% block extra_head %}
<link rel="stylesheet" href="{% static 'css/lesrooster/timetable_print.css' %}">
{% endblock %}
{% block page_title %}
{% trans "Timetable" %} <i>{{ el.short_name }}</i>
{% endblock %}
{% block content %}
<div class="timetable-plan">
{# Week days #}
<div class="row">
<div class="col s2">
</div>
{% for weekday in weekdays %}
<div class="col s2">
<div class="card timetable-title-card">
<div class="card-content">
<span class="card-title">
{{ weekday.1 }}
</span>
</div>
</div>
</div>
{% endfor %}
</div>
{% for row in timetable %}
<div class="row">
<div class="col s2">
{% if row.type == "period" %}
{% include "lesrooster/partials/slot_time.html" with slot=row.slot %}
{% endif %}
</div>
{% for col in row.cols %}
{# A lesson #}
<div class="col s2">
{% if col.type == "period" %}
{% include "lesrooster/partials/elements.html" with elements=col.col %}
{% else %}
{% include "lesrooster/partials/supervision.html" with supervision=col.col %}
{% endif %}
</div>
{% endfor %}
</div>
{% endfor %}
</div>
<small>{% trans "Validity range" %}: {{ time_grid.validity_range.date_start }}–{{ time_grid.validity_range.date_end }}</small>
{% endblock %}
from django.urls import path
from . import views
urlpatterns = [
path(
"timetable/<int:time_grid>/<str:type_>/<int:pk>/print/",
views.print_timetable,
name="timetable_print",
),
]
from collections import OrderedDict
from typing import Union
from aleksis.apps.chronos.managers import TimetableType
from aleksis.apps.lesrooster.models import BreakSlot, Lesson, Slot, Supervision, TimeGrid
from aleksis.core.models import Group, Person, Room
def build_timetable(
time_grid: TimeGrid,
type_: TimetableType,
obj: Union[Group, Room, Person],
) -> list | None:
"""Build regular timetable for the given time grid."""
slots = Slot.objects.filter(time_grid=time_grid).order_by("weekday", "time_start")
lesson_periods_per_slot = OrderedDict()
supervisions_per_slot = OrderedDict()
slot_map = OrderedDict()
for slot in slots:
lesson_periods_per_slot[slot] = []
supervisions_per_slot[slot] = []
slot_map.setdefault(slot.weekday, []).append(slot)
max_slots_weekday, max_slots = max(slot_map.items(), key=lambda x: len(x[1]))
max_slots = len(max_slots)
# Get matching lessons
lessons = Lesson.objects.filter(bundle__slot_start__time_grid=time_grid).filter_from_type(
type_, obj
)
# Sort lesson periods in a dict
for lesson in lessons:
lesson_periods_per_slot[lesson.bundle.all()[0].slot_start].append(lesson)
# Get matching supervisions
supervisions = Supervision.objects.filter(break_slot__time_grid=time_grid).filter_from_type(
type_, obj
)
for supervision in supervisions:
supervisions_per_slot[supervision.break_slot] = supervision
rows = []
for slot_idx in range(max_slots): # period is period after break
left_slot = slot_map[max_slots_weekday][slot_idx]
if isinstance(left_slot, BreakSlot):
row = {"type": "break", "slot": left_slot}
else:
row = {
"type": "period",
"slot": left_slot,
}
cols = []
for weekday in range(time_grid.weekday_min, time_grid.weekday_max + 1):
if slot_idx > len(slot_map[weekday]) - 1:
continue
actual_slot = slot_map[weekday][slot_idx]
if isinstance(actual_slot, BreakSlot):
col = {"type": "break", "col": supervisions_per_slot.get(actual_slot)}
else:
col = {
"type": "period",
"col": (
lesson_periods_per_slot.get(actual_slot, [])
),
}
cols.append(col)
row["cols"] = cols
rows.append(row)
return rows
from django.http import HttpRequest, HttpResponse, HttpResponseNotFound
from django.shortcuts import get_object_or_404
from rules.contrib.views import permission_required
from aleksis.apps.chronos.managers import TimetableType
from aleksis.apps.chronos.util.chronos_helpers import get_el_by_pk
from aleksis.apps.lesrooster.models import Slot, TimeGrid
from aleksis.apps.lesrooster.util.build import build_timetable
from aleksis.core.util.pdf import render_pdf
@permission_required("chronos.view_timetable_rule", fn=get_el_by_pk)
def print_timetable(
request: HttpRequest,
time_grid: int,
type_: str,
pk: int,
) -> HttpResponse:
"""View a selected timetable for a person, group or room."""
context = {}
time_grid = get_object_or_404(TimeGrid, pk=time_grid)
el = get_el_by_pk(request, type_, pk, prefetch=True)
if isinstance(el, HttpResponseNotFound):
return HttpResponseNotFound()
type_ = TimetableType.from_string(type_)
timetable = build_timetable(time_grid, type_, el)
context["timetable"] = timetable
context["weekdays"] = Slot.WEEKDAY_CHOICES[time_grid.weekday_min : time_grid.weekday_max + 1]
context["time_grid"] = time_grid
context["type"] = type_
context["pk"] = pk
context["el"] = el
return render_pdf(request, "lesrooster/timetable_print.html", context)