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

[Lesson] Add next/previous buttons for currently logged in person

To do that, restructure page accordingly
parent 3534d7e6
No related branches found
No related tags found
1 merge request!98Resolve "[Lesson overview] Buttons for switching to next/previous lesson of the currently logged in person"
Pipeline #4161 failed
...@@ -22,3 +22,7 @@ ...@@ -22,3 +22,7 @@
vertical-align: top; vertical-align: top;
height: 109px;} height: 109px;}
} }
.alsijil-top-button {
margin-top: -20px;
}
...@@ -9,55 +9,84 @@ ...@@ -9,55 +9,84 @@
<link rel="stylesheet" href="{% static 'css/alsijil/lesson.css' %}"/> <link rel="stylesheet" href="{% static 'css/alsijil/lesson.css' %}"/>
{% endblock %} {% endblock %}
{% block page_title %} {% block content %}
{% with lesson_period.get_lesson_documentation as lesson_doc %} {% if next_lesson_person or prev_lesson_person %}
<a href="{% url "week_view_by_week" lesson_doc.year lesson_doc.week "group" lesson_period.lesson.groups.all.0.pk %}" <div class="row no-margin">
class="btn-flat primary-color-text waves-light waves-effect"> <div class="col s12 no-padding">
<i class="material-icons left">chevron_left</i> {% trans "Back" %} {# Back to week view #}
</a> {% with lesson_period.get_lesson_documentation as lesson_doc %}
{% endwith %} <a href="{% url "week_view_by_week" lesson_doc.year lesson_doc.week "group" lesson_period.lesson.groups.all.0.pk %}"
{{ day }}, {% blocktrans with period=lesson_period.period.period %}{{ period }}. period{% endblocktrans %} – class="btn primary-color waves-light waves-effect alsijil-top-button">
<i class="material-icons left">chevron_left</i> {% trans "Back to week view" %}
{% for group in lesson_period.get_groups.all %} </a>
<span>{{ group.name }}</span>, {% endwith %}
{% endfor %}
{# Next lesson #}
{{ lesson_period.get_subject.name }}, {% if prev_lesson_person %}
<a class="btn primary waves-effect waves-light alsijil-top-button"
{% for teacher in lesson_period.get_teachers.all %} href="{% url "lesson_by_week_and_period" prev_lesson_person.week.year prev_lesson_person.week.week prev_lesson_person.id %}">
{{ teacher.short_name }} <i class="material-icons left">arrow_back</i>
{% endfor %} {% trans "My previous lesson" %}
</a>
<span class="right"> {% endif %}
{# Previous lesson #}
{% if next_lesson_person %}
<a class="btn primary right waves-effect waves-light alsijil-top-button"
href="{% url "lesson_by_week_and_period" next_lesson_person.week.year next_lesson_person.week.week next_lesson_person.id %}">
<i class="material-icons right">arrow_forward</i>
{% trans "My next lesson" %}
</a>
{% endif %}
</div>
</div>
{% endif %}
<h4>
{{ day }}, {% blocktrans with period=lesson_period.period.period %}{{ period }}. period{% endblocktrans %} –
{% for group in lesson_period.get_groups.all %}
<span>{{ group.name }}</span>,
{% endfor %}
{{ lesson_period.get_subject.name }},
{% for teacher in lesson_period.get_teachers.all %}
{{ teacher.short_name }}
{% endfor %}
<span class="right">
{% include "alsijil/partials/lesson_status_icon.html" with period=lesson_period css_class="medium" %} {% include "alsijil/partials/lesson_status_icon.html" with period=lesson_period css_class="medium" %}
</span> </span>
{% endblock %} </h4>
<br/>
{% block content %}
{% has_perm "alsijil.view_lessondocumentation" user lesson_period as can_view_lesson_documentation %} {% has_perm "alsijil.view_lessondocumentation" user lesson_period as can_view_lesson_documentation %}
{% has_perm "alsijil.edit_lessondocumentation" user lesson_period as can_edit_lesson_documentation %} {% has_perm "alsijil.edit_lessondocumentation" user lesson_period as can_edit_lesson_documentation %}
{% has_perm "alsijil.edit_lesson_personalnote" user lesson_period as can_edit_lesson_personalnote %} {% has_perm "alsijil.edit_lesson_personalnote" user lesson_period as can_edit_lesson_personalnote %}
<div class="row"> <form method="post" class="row">
<div class="col s12"> <p>
<a class="btn-flat left waves-effect waves-light" {% if can_edit_lesson_documentation or can_edit_lesson_personalnote %}
{% include "core/partials/save_button.html" %}
{% endif %}
<a class="btn waves-effect waves-light primary"
href="{% url "lesson_by_week_and_period" prev_lesson.week.year prev_lesson.week.week prev_lesson.id %}"> href="{% url "lesson_by_week_and_period" prev_lesson.week.year prev_lesson.week.week prev_lesson.id %}">
<i class="material-icons left">arrow_back</i> <i class="material-icons left">arrow_back</i>
{% trans "Previous lesson" %} {% blocktrans with subject=lesson_period.get_subject.name %}
Previous {{ subject }} lesson
{% endblocktrans %}
</a> </a>
<a class="btn-flat right waves-effect waves-light" <a class="btn right waves-effect waves-light primary"
href="{% url "lesson_by_week_and_period" next_lesson.week.year next_lesson.week.week next_lesson.id %}"> href="{% url "lesson_by_week_and_period" next_lesson.week.year next_lesson.week.week next_lesson.id %}">
<i class="material-icons right">arrow_forward</i> <i class="material-icons right">arrow_forward</i>
{% trans "Next lesson" %} {% blocktrans with subject=lesson_period.get_subject.name %}
Next {{ subject }} lesson
{% endblocktrans %}
</a> </a>
</div> </p>
</div>
<form method="post">
{% if can_edit_lesson_documentation or can_edit_lesson_personalnote %}
<p>{% include "core/partials/save_button.html" %}</p>
{% endif %}
{% csrf_token %} {% csrf_token %}
...@@ -319,8 +348,26 @@ ...@@ -319,8 +348,26 @@
{% endif %} {% endif %}
</div> </div>
{% if can_edit_lesson_documentation or can_edit_lesson_personalnote %} <p>
<p>{% include "core/partials/save_button.html" %}</p> {% if can_edit_lesson_documentation or can_edit_lesson_personalnote %}
{% endif %} {% include "core/partials/save_button.html" %}
{% endif %}
<a class="btn primary waves-effect waves-light"
href="{% url "lesson_by_week_and_period" prev_lesson.week.year prev_lesson.week.week prev_lesson.id %}">
<i class="material-icons left">arrow_back</i>
{% blocktrans with subject=lesson_period.get_subject.name %}
Previous {{ subject }} lesson
{% endblocktrans %}
</a>
<a class="btn primary right waves-effect waves-light"
href="{% url "lesson_by_week_and_period" next_lesson.week.year next_lesson.week.week next_lesson.id %}">
<i class="material-icons right">arrow_forward</i>
{% blocktrans with subject=lesson_period.get_subject.name %}
Next {{ subject }} lesson
{% endblocktrans %}
</a>
</p>
</form> </form>
{% endblock %} {% endblock %}
...@@ -96,9 +96,14 @@ def lesson( ...@@ -96,9 +96,14 @@ def lesson(
) )
) )
next_lesson = request.user.person.next_lesson(lesson_period, date_of_lesson)
prev_lesson = request.user.person.previous_lesson(lesson_period, date_of_lesson)
context["lesson_period"] = lesson_period context["lesson_period"] = lesson_period
context["week"] = wanted_week context["week"] = wanted_week
context["day"] = wanted_week[lesson_period.period.weekday] context["day"] = wanted_week[lesson_period.period.weekday]
context["next_lesson_person"] = next_lesson
context["prev_lesson_person"] = prev_lesson
# Create or get lesson documentation object; can be empty when first opening lesson # Create or get lesson documentation object; can be empty when first opening lesson
lesson_documentation = lesson_period.get_or_create_lesson_documentation(wanted_week) lesson_documentation = lesson_period.get_or_create_lesson_documentation(wanted_week)
......
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