diff --git a/aleksis/apps/alsijil/static/css/alsijil/alsijil.css b/aleksis/apps/alsijil/static/css/alsijil/alsijil.css index e3ca3bf017f0549701a2be7c02f0b6be8a7d3f88..892df4810b80f1d6cac589b6997f35b4deeb4fbf 100644 --- a/aleksis/apps/alsijil/static/css/alsijil/alsijil.css +++ b/aleksis/apps/alsijil/static/css/alsijil/alsijil.css @@ -7,3 +7,31 @@ table a.tr-link { width: inherit; height: inherit; } + +.collapsible-icon-right { + align-self: end; + flex-grow: 100; + text-align: right!important; +} + +@media only screen and (min-width: 1201px) { + .hide-on-extra-large-only { + display: none; + } +} + +@media only screen and (max-width: 1200px) { + .show-on-extra-large { + display: none; + } +} + +@media only screen and (max-width: 600px) { + .collection .collection-item.avatar { + padding-left: 20px; + } + .collection .collection-item.avatar:not(.circle-clipper) > .circle { + position: relative; + margin-bottom: 10px; + } +} diff --git a/aleksis/apps/alsijil/static/css/alsijil/lesson.css b/aleksis/apps/alsijil/static/css/alsijil/lesson.css index 6d57c7e9910063dc8dfe359c643e65765cb6ad9c..9847ea0f035ef8988eab156d746229d1799b9c44 100644 --- a/aleksis/apps/alsijil/static/css/alsijil/lesson.css +++ b/aleksis/apps/alsijil/static/css/alsijil/lesson.css @@ -10,6 +10,11 @@ text-decoration: line-through; } +.alsijil-tardiness-text{ + vertical-align: super; +} + + @media only screen and (max-width : 992px) { table.responsive-table.alsijil-table th, table.responsive-table.alsijil-table td { diff --git a/aleksis/apps/alsijil/templates/alsijil/class_register/lesson.html b/aleksis/apps/alsijil/templates/alsijil/class_register/lesson.html index b83cd7e951ff46c55820ce88266fdc1617fec847..5f8ba67a9904999b8be2ed74f0f454f8ad28e54c 100644 --- a/aleksis/apps/alsijil/templates/alsijil/class_register/lesson.html +++ b/aleksis/apps/alsijil/templates/alsijil/class_register/lesson.html @@ -1,6 +1,6 @@ {# -*- engine:django -*- #} {% extends "core/base.html" %} -{% load week_helpers material_form_internal material_form i18n static rules %} +{% load week_helpers material_form_internal material_form i18n static rules time_helpers %} {% block browser_title %}{% blocktrans %}Lesson{% endblocktrans %}{% endblock %} @@ -10,6 +10,12 @@ {% endblock %} {% block page_title %} + {% with lesson_period.get_lesson_documentation as lesson_doc %} + <a href="{% url "week_view_by_week" lesson_doc.year lesson_doc.week "group" lesson_period.lesson.groups.all.0.pk %}" + class="btn-flat primary-color-text waves-light waves-effect"> + <i class="material-icons left">chevron_left</i> {% trans "Back" %} + </a> + {% endwith %} {{ day }}, {% blocktrans with period=lesson_period.period.period %}{{ period }}. period{% endblocktrans %} – {% for group in lesson_period.get_groups.all %} @@ -66,6 +72,12 @@ <a href="#personal-notes">{% trans "Personal notes" %}</a> </li> {% endif %} + {% has_perm "alsijil.view_lessondocumentation" user lesson_period.prev as can_view_prev_lesson_documentation %} + {% if lesson_period.prev.get_lesson_documentation and can_view_prev_lesson_documentation %} + <li class="tab"> + <a href="#previous-lesson">{% trans "Previous lesson" %}</a> + </li> + {% endif %} <li class="tab"> <a href="#version-history">{% trans "Change history" %}</a> </li> @@ -73,11 +85,52 @@ </div> <div class="col s12" id="lesson-documentation"> - {% with prev_doc=prev_lesson.get_lesson_documentation absences=prev_lesson.get_absences tardinesses=prev_lesson.get_tardinesses extra_marks=prev_lesson.get_extra_marks %} + <div class="card"> + <div class="card-content"> + <span class="card-title"> + {% blocktrans %}Lesson documentation{% endblocktrans %} + </span> + + {% if can_edit_lesson_documentation %} + {% form form=lesson_documentation_form %}{% endform %} + {% elif can_view_lesson_documentation %} + <table> + <tr> + <th> + {% trans "Lesson topic" %} + </th> + <td> + {{ lesson_documentation.topic }} + </td> + </tr> + <tr> + <th> + {% trans "Homework" %} + </th> + <td> + {{ lesson_documentation.homework }} + </td> + </tr> + <tr> + <th> + {% trans "Group note" %} + </th> + <td> + {{ lesson_documentation.group_note }} + </td> + </tr> + </table> + {% endif %} + </div> + </div> + </div> + + {% with prev_lesson=lesson_period.prev prev_doc=prev_lesson.get_lesson_documentation %} + {% with absences=prev_lesson.get_absences tardinesses=prev_lesson.get_tardinesses extra_marks=prev_lesson.get_extra_marks %} {% has_perm "alsijil.view_lessondocumentation" user prev_lesson as can_view_prev_lesson_documentation %} {% if prev_doc and can_view_prev_lesson_documentation %} {% weekday_to_date prev_lesson.week prev_lesson.period.weekday as prev_date %} - + <div class="col s12" id="previous-lesson"> <div class="card"> <div class="card-content"> <span class="card-title"> @@ -140,46 +193,7 @@ </div> {% endif %} {% endwith %} - - <div class="card"> - <div class="card-content"> - <span class="card-title"> - {% blocktrans %}Lesson documentation{% endblocktrans %} - </span> - - {% if can_edit_lesson_documentation %} - {% form form=lesson_documentation_form %}{% endform %} - {% elif can_view_lesson_documentation %} - <table> - <tr> - <th> - {% trans "Lesson topic" %} - </th> - <td> - {{ lesson_documentation.topic }} - </td> - </tr> - <tr> - <th> - {% trans "Homework" %} - </th> - <td> - {{ lesson_documentation.homework }} - </td> - </tr> - <tr> - <th> - {% trans "Group note" %} - </th> - <td> - {{ lesson_documentation.group_note }} - </td> - </tr> - </table> - {% endif %} - </div> - </div> - </div> + {% endwith %} {% if not lesson_period.get_substitution.cancelled or not request.site.preferences.alsijil__block_personal_notes_for_cancelled %} <div class="col s12" id="personal-notes"> @@ -263,16 +277,23 @@ {% else %} <tr> <td>{{ form.person_name.value }}</td> - <td>{{ form.absent.value }}</td> - <td>{{ form.late.value }}</td> - <td>{{ form.excused.value }}</td> - <td>{{ form.excuse_type.value }}</td> + <td><i class="material-icons center">{{ form.absent.value|yesno:"check,clear" }}</i></td> + <td> + <i class="material-icons center">{{ form.late.value|yesno:"check,clear" }}</i> + <span class="alsijil-tardiness-text"> + {% if form.late.value %}{{ form.late.value|to_time|time:"i\m" }}{% endif %} + </span> + </td> + <td><i class="material-icons center">{{ form.excused.value|yesno:"check,clear" }}</i></td> + <td>{% firstof form.excuse_type.value "–" %}</td> <td> {% for extra_mark in form.extra_marks.value %} {{ extra_mark }}{% if not forloop.last %},{% endif %} + {% empty %} + – {% endfor %} </td> - <td>{{ form.remarks.value }}</td> + <td>{% firstof form.remarks.value "–" %}</td> </tr> {% endif %} {% endfor %} @@ -295,10 +316,10 @@ </div> </div> {% endif %} - </div> + </div> - {% if can_edit_lesson_documentation or can_edit_lesson_personalnote %} - <p>{% include "core/partials/save_button.html" %}</p> - {% endif %} + {% if can_edit_lesson_documentation or can_edit_lesson_personalnote %} + <p>{% include "core/partials/save_button.html" %}</p> + {% endif %} </form> {% endblock %} diff --git a/aleksis/apps/alsijil/templates/alsijil/class_register/person.html b/aleksis/apps/alsijil/templates/alsijil/class_register/person.html index efb5179adbc622ab80c47802d2230eb57a19b679..be40b8e2376da7409c7697a4d3bb901aa5c27fc7 100644 --- a/aleksis/apps/alsijil/templates/alsijil/class_register/person.html +++ b/aleksis/apps/alsijil/templates/alsijil/class_register/person.html @@ -9,6 +9,13 @@ {% block page_title %} + {% has_perm "alsijil.view_my_students" user as has_students %} + {% if has_students %} + <a href="{% url "my_students" %}" + class="btn-flat primary-color-text waves-light waves-effect"> + <i class="material-icons left">chevron_left</i> {% trans "Back" %} + </a> + {% endif %} {% blocktrans with person=person %} Class register overview for {{ person }} {% endblocktrans %} @@ -59,8 +66,9 @@ {% endif %} </li> {% empty %} - <li class="collection-item flow-text"> - {% trans "There are unexcused lessons." %} + <li class="collection-item avatar valign-wrapper"> + <i class="material-icons left circle green white-text">check</i> + <span class="title">{% trans "There are no unexcused lessons." %}</span> </li> {% endfor %} </ul> diff --git a/aleksis/apps/alsijil/templates/alsijil/class_register/week_view.html b/aleksis/apps/alsijil/templates/alsijil/class_register/week_view.html index de7c30ecd010294cc05e37a1aa58e27c519036f4..8d51886fa49bef5aebfee12f43fbc71d6292384d 100644 --- a/aleksis/apps/alsijil/templates/alsijil/class_register/week_view.html +++ b/aleksis/apps/alsijil/templates/alsijil/class_register/week_view.html @@ -1,7 +1,7 @@ {# -*- engine:django -*- #} {% extends "core/base.html" %} -{% load material_form i18n week_helpers static data_helpers rules %} +{% load material_form i18n week_helpers static data_helpers rules time_helpers %} {% block browser_title %}{% blocktrans %}Week view{% endblocktrans %}{% endblock %} @@ -42,10 +42,16 @@ {% if lesson_periods %} <div class="row"> - <div class="col s12 m7"> + <div class="col s12"> + <ul class="tabs"> + <li class="tab col s6"><a class="active" href="#week-overview">{% trans "Lesson documentations" %}</a></li> + <li class="tab col s6"><a class="active" href="#personal-notes">{% trans "Personal notes" %}</a></li> + </ul> + </div> + <div class="col s12" id="week-overview"> {% regroup lesson_periods by period.get_weekday_display as periods_by_day %} {% for weekday, periods in periods_by_day %} - <div class="card"> + <div class="card show-on-extra-large"> <div class="card-content"> {% weekday_to_date week periods.0.period.weekday as current_date %} <span class="card-title"> @@ -62,6 +68,8 @@ <th>{% blocktrans %}Subject{% endblocktrans %}</th> <th>{% blocktrans %}Teachers{% endblocktrans %}</th> <th>{% blocktrans %}Lesson topic{% endblocktrans %}</th> + <th>{% blocktrans %}Homework{% endblocktrans %}</th> + <th>{% blocktrans %}Group note{% endblocktrans %}</th> </tr> </thead> <tbody> @@ -96,9 +104,19 @@ </td> <td> <a class="tr-link" href="{% url 'lesson_by_week_and_period' week.year week.week period.id %}"> - {{ period.get_lesson_documentation.topic }} + {% firstof period.get_lesson_documentation.topic "–" %} </a> </td> + <td> + <a class="tr-link" href="{% url 'lesson_by_week_and_period' week.year week.week period.id %}"> + {% firstof period.get_lesson_documentation.homework "–" %} + </a> + </td> + <td> + <a class="tr-link" href="{% url 'lesson_by_week_and_period' week.year week.week period.id %}"> + {% firstof period.get_lesson_documentation.group_note "–" %} + </a> + </td> </tr> {% endif %} {% endfor %} @@ -106,9 +124,98 @@ </table> </div> </div> + <ul class="collapsible hide-on-extra-large-only"> + <li class=""> + {% weekday_to_date week periods.0.period.weekday as current_date %} + <div class="collapsible-header flow-text"> + {{ weekday }}, {{ current_date }} <i class="material-icons collapsible-icon-right">expand_more</i> + </div> + <div class="collapsible-body"> + <div class="collection"> + {% for period in periods %} + {% has_perm "alsijil.view_lessondocumentation" user period as can_view_lesson_documentation %} + {% if can_view_lesson_documentation %} + <a class="collection-item avatar" + href="{% url 'lesson_by_week_and_period' week.year week.week period.id %}"> + {% include "alsijil/partials/lesson_status_icon.html" with period=period css_class="circle" color_suffix=" " %} + <table class="hide-on-med-and-down"> + <tr> + <th>{% trans "Subject" %}</th> + <td>{{ period.period.period }}. {{ period.get_subject.name }}</td> + </tr> + {% if not group %} + <tr> + <th>{% trans "Group" %}</th> + <td>{{ period.lesson.group_names }}</td> + </tr> + {% endif %} + <tr> + <th>{% trans "Teachers" %}</th> + <td>{{ period.lesson.teacher_names }}</td> + </tr> + <tr> + <th>{% trans "Lesson topic" %}</th> + <td>{% firstof period.get_lesson_documentation.topic "–" %}</td> + </tr> + {% with period.get_lesson_documentation as lesson_documentation %} + {% if lesson_documentation.homework %} + <tr> + <th>{% trans "Homework" %}</th> + <td>{% firstof period.get_lesson_documentation.homework "–" %}</td> + </tr> + {% endif %} + {% if lesson_documentation.group_note %} + <tr> + <th>{% trans "Group note" %}</th> + <td>{% firstof period.get_lesson_documentation.group_note "–" %}</td> + </tr> + {% endif %} + {% endwith %} + </table> + <div class="hide-on-large-only"> + <ul class="collection"> + <li class="collection-item"> + {{ period.period.period }}. {{ period.get_subject.name }} + </li> + {% if not group %} + <li class="collection-item"> + + {{ period.lesson.group_names }} + + </li> + {% endif %} + <li class="collection-item"> + {{ period.lesson.teacher_names }} + </li> + <li class="collection-item"> + {{ period.get_lesson_documentation.topic }} + </li> + {% with period.get_lesson_documentation as lesson_documentation %} + {% if lesson_documentation.homework %} + <li class="collection-item"> + <strong>{% trans "Homework" %}</strong> + {% firstof period.get_lesson_documentation.homework "–" %} + </li> + {% endif %} + {% if lesson_documentation.group_note %} + <li class="collection-item"> + <strong>{% trans "Group note" %}</strong> + {% firstof period.get_lesson_documentation.group_note "–" %} + </li> + {% endif %} + {% endwith %} + </ul> + </div> + </a> + {% endif %} + {% endfor %} + </div> + </div> + </li> + </ul> {% endfor %} </div> - <div class="col s12 m5"> + <div class="col s12" id="personal-notes"> <div class="card"> <div class="card-content"> <span class="card-title"> @@ -128,7 +235,7 @@ ({{ person.person.unexcused_count }} {% trans "unexcused" %}) </p> <p class="card-text"> - {% trans "Summed up tardiness" %}: {{ person.person.tardiness_sum }}' + {% trans "Summed up tardiness" %}: {% firstof person.person.tardiness_sum|to_time|time:"H\h i\m" "–" %} </p> {% for extra_mark in extra_marks %} <p class="card-text"> diff --git a/aleksis/apps/alsijil/templates/alsijil/partials/lesson_status_icon.html b/aleksis/apps/alsijil/templates/alsijil/partials/lesson_status_icon.html index 57b71b661994baf0f2b37a71678098d564cc88ed..4ad4aa8251059cbe5453f24ca5e00cd6a4490bd2 100644 --- a/aleksis/apps/alsijil/templates/alsijil/partials/lesson_status_icon.html +++ b/aleksis/apps/alsijil/templates/alsijil/partials/lesson_status_icon.html @@ -3,18 +3,18 @@ {% now_datetime as now_dt %} {% if period.has_documentation %} - <i class="material-icons green-text tooltipped {{ css_class }}" data-position="bottom" data-tooltip="{% trans "Data complete" %}" title="{% trans "Data complete" %}">check_circle</i> + <i class="material-icons green{% firstof color_suffix "-text"%} tooltipped {{ css_class }}" data-position="bottom" data-tooltip="{% trans "Data complete" %}" title="{% trans "Data complete" %}">check_circle</i> {% else %} {% period_to_time_start week period.period as time_start %} {% period_to_time_end week period.period as time_end %} {% if period.get_substitution.cancelled %} - <i class="material-icons red-text tooltipped {{ css_class }}" data-position="bottom" data-tooltip="{% trans "Lesson cancelled" %}" title="{% trans "Lesson cancelled" %}">cancel</i> + <i class="material-icons red{% firstof color_suffix "-text"%} tooltipped {{ css_class }}" data-position="bottom" data-tooltip="{% trans "Lesson cancelled" %}" title="{% trans "Lesson cancelled" %}">cancel</i> {% elif now_dt > time_end %} - <i class="material-icons red-text tooltipped {{ css_class }}" data-position="bottom" data-tooltip="{% trans "Missing data" %}" title="{% trans "Missing data" %}">history</i> + <i class="material-icons red{% firstof color_suffix "-text"%} tooltipped {{ css_class }}" data-position="bottom" data-tooltip="{% trans "Missing data" %}" title="{% trans "Missing data" %}">history</i> {% elif now_dt > time_start and now_dt < time_end %} - <i class="material-icons orange-text tooltipped {{ css_class }}" data-position="bottom" data-tooltip="{% trans "Pending" %}" title="{% trans "Pending" %}">more_horiz</i> + <i class="material-icons orange{% firstof color_suffix "-text"%} tooltipped {{ css_class }}" data-position="bottom" data-tooltip="{% trans "Pending" %}" title="{% trans "Pending" %}">more_horiz</i> {% elif period.get_substitution %} - <i class="material-icons orange-text tooltipped {{ css_class }}" data-position="bottom" data-tooltip="{% trans "Substitution" %}" title="{% trans "Substitution" %}">update</i> + <i class="material-icons orange{% firstof color_suffix "-text"%} tooltipped {{ css_class }}" data-position="bottom" data-tooltip="{% trans "Substitution" %}" title="{% trans "Substitution" %}">update</i> {% endif %} {% endif %} diff --git a/aleksis/apps/alsijil/templatetags/__init__.py b/aleksis/apps/alsijil/templatetags/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/aleksis/apps/alsijil/templatetags/time_helpers.py b/aleksis/apps/alsijil/templatetags/time_helpers.py new file mode 100644 index 0000000000000000000000000000000000000000..00aedad7fee98b2b0d303f63f927fbe722317651 --- /dev/null +++ b/aleksis/apps/alsijil/templatetags/time_helpers.py @@ -0,0 +1,14 @@ +from django import template + +import datetime + +register = template.Library() + + +@register.filter("to_time") +def get_time_from_minutes(minutes: int) -> datetime.timedelta: + """Get a time object from a number of minutes.""" + delta = datetime.timedelta(minutes=(minutes or 0)) + time_obj = (datetime.datetime.min + delta).time() + + return time_obj