Commit 30e640c9 authored by Dominik George's avatar Dominik George 🍳

Merge branch 'feature/show-announcements-in-timetable-views' into 'master'

Show announcements in timetable views

Closes #63

See merge request !41
parents f899554d edfd5296
from django import forms
from django_select2.forms import ModelSelect2MultipleWidget
from django.utils.translation import gettext_lazy as _
from material import Fieldset
from .models import LessonSubstitution
from aleksis.core.forms import AnnouncementForm
class LessonSubstitutionForm(forms.ModelForm):
......@@ -17,3 +20,6 @@ class LessonSubstitutionForm(forms.ModelForm):
]
)
}
AnnouncementForm.add_node_to_layout(Fieldset(_("Options for timetables"), "show_in_timetables"))
from typing import Optional, Union
from aleksis.core.models import Person, Group
from django.utils.translation import gettext_lazy as _
from jsonstore import BooleanField
from aleksis.core.models import Person, Group, Announcement
from .models import Lesson, LessonPeriod
......@@ -81,3 +84,11 @@ def lesson_periods_as_teacher(self):
"""
return LessonPeriod.objects.filter(lesson__teachers=self)
def for_timetables(cls):
return cls.objects.filter(show_in_timetables=True)
Announcement.class_method(for_timetables)
Announcement.field(show_in_timetables=BooleanField(verbose_name=_("Show announcement in timetable views?")))
......@@ -26,7 +26,7 @@
<div class="row nomargin">
<div class="col m12 s12 l6 xl4">
{# {% include "timetable/hintsinplan.html" %}#}
{% include "core/announcements.html" with announcements=announcements %}
</div>
</div>
......
{% load martortags %}
{% if hints %}
<ul class="collapsible">
<li>
<div class="collapsible-header " style="font-size: 16px;">
<div class="col s12">
<i class="material-icons left">announcement</i>Es gibt {{ hints|length }}
Hinweis{{ hints|pluralize:"e" }} für diesen Tag.
<i class="material-icons right collapsible-trigger"></i>
</div>
</div>
<div class="collapsible-body">
{% for hint in hints %}
<div>
<strong>
{{ hint.classes_formatted }}{% if hint.teachers and hint.classes.all %},{% endif %}
</strong>
{% if hint.teachers %}
<span class="badge new green no-float no-margin">Lehrkräfte</span>
{% endif %}:
{{ hint.text|safe_markdown }}
</div>
{% endfor %}
</div>
</li>
</ul>
{% endif %}
{% load martortags %}
{% if c.hints %}
{% for hint in c.hints %}
<div class="alert primary">
<div>
<strong>
{{ hint.classes_formatted }}{% if hint.teachers and hint.classes.all %}, Lehrkräfte{% endif %}:
</strong>
<i class="material-icons left">announcement</i>
{{ hint.text|safe_markdown }}
</div>
</div>
{% endfor %}
{% endif %}
{% load martortags %}
{% if hints %}
{% for hint in hints %}
<div class="alert primary">
<div>
<em class="right hide-on-small-and-down">Hinweis für {{ hint.from_date|date:"D, d.m." }},
{% if hint.from_date != hint.to_date %}
bis {{ hint.to_date|date:"D, d.m." }}
{% endif %} </em>
<i class="material-icons left">announcement</i>
{{ hint.text|safe_markdown }}
<em class="hide-on-med-and-up">Hinweis für {{ hint.from_date|date:"D, d.m." }},
{% if hint.from_date != hint.to_date %}
bis {{ hint.to_date|date:"D, d.m." }}
{% endif %} </em>
</div>
</div>
{% endfor %}
{% endif %}
{% if hints_b %}
<ul class="collapsible">
<li>
<div class="collapsible-header " style="font-size: 16px;">
<div class="col s12">
<i class="material-icons left">add</i>
Es gibt
{% if hints_b_mode == "week" %}
diese Woche
{% else %}
heute
{% endif %}
{% if hints %}
noch
{% endif %}
{{ hints_b|length }}
{% if hints %}
weitere{{ hints_b|pluralize:"n," }}
{% endif %}
Hinweis{{ hints_b|pluralize:"e" }}.
<i class="material-icons right collapsible-trigger"></i>
</div>
</div>
<div class="collapsible-body">
{% for hint in hints_b %}
{% if not hint.teachers %}
<div>
<strong>
{{ hint.classes_formatted }},
</strong>
{{ hint.from_date|date:"D, d.m." }}{% if hint.from_date != hint.to_date %}, bis
{{ hint.to_date|date:"D, d.m." }}{% endif %}:
{{ hint.text|safe_markdown }}
</div>
{% endif %}
{% endfor %}
</div>
</li>
</ul>
{% endif %}
......@@ -28,7 +28,7 @@
<div class="col s12 m6 l8">
{% include "chronos/partials/headerbox.html" %}
{# {% include "chronos/hintsinsub.html" %}#}
{% include "core/announcements.html" with announcements=announcements show_recipients=1 %}
</div>
<div class="col s12 m6 l4 no-padding">
{% include "chronos/partials/datepicker.html" %}
......
......@@ -16,7 +16,7 @@
{% for day, c in days.items %}
<h4>{% trans "Substitutions" %} {{ c.day|date:"l" }} {{ c.day }}</h4>
{# {% include "timetable/hintsinsubprint.html" %}#}
{% include "core/announcements.html" with announcements=announcements show_recipients=1 %}
{% include "chronos/partials/headerbox.html" with affected_teachers=c.affected_teachers affected_groups=c.affected_groups print=1 %}
......
......@@ -113,7 +113,7 @@
{% endif %}
</div>
{# {% include "chronos/hintsinplan.html" %}#}
{% include "core/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">
......
......@@ -13,7 +13,7 @@ from django.utils.translation import ugettext as _
from django_tables2 import RequestConfig
from aleksis.core.decorators import admin_required
from aleksis.core.models import Person, Group
from aleksis.core.models import Person, Group, Announcement
from aleksis.core.util import messages
from .forms import LessonSubstitutionForm
from .models import LessonPeriod, LessonSubstitution, TimePeriod, Room
......@@ -77,6 +77,7 @@ def my_timetable(
context["day"] = wanted_day
context["periods"] = TimePeriod.get_times_dict()
context["smart"] = True
context["announcements"] = Announcement.for_timetables().on_date(wanted_day).for_person(person)
context["url_prev"], context["url_next"] = TimePeriod.get_prev_next_by_day(
wanted_day, "my_timetable_by_date"
......@@ -167,6 +168,11 @@ def timetable(
"dest": reverse("timetable", args=[type_, pk])
}
if is_smart:
start = wanted_week[TimePeriod.weekday_min]
stop = wanted_week[TimePeriod.weekday_max]
context["announcements"] = Announcement.for_timetables().relevant_for(el).within_days(start, stop)
week_prev = wanted_week - 1
week_next = wanted_week + 1
......@@ -306,6 +312,8 @@ def substitutions(
subs = LessonSubstitution.objects.on_day(day).order_by("lesson_period__lesson__groups", "lesson_period__period")
day_contexts[day]["substitutions"] = subs
day_contexts[day]["announcements"] = Announcement.for_timetables().on_date(day).filter(show_in_timetables=True)
if config.CHRONOS_SUBSTITUTIONS_SHOW_HEADER_BOX:
day_contexts[day]["affected_teachers"] = subs.affected_teachers()
day_contexts[day]["affected_groups"] = subs.affected_groups()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment