Skip to content
Snippets Groups Projects
Commit 50a89067 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Merge branch...

Merge branch '158-back-button-in-lesson-view-should-redirect-to-the-person-s-week-view' into 'master'

Resolve "Back button in lesson view should redirect to the person's week view"

Closes #158

See merge request !180
parents 517b9a9e c7b7ca93
No related tags found
1 merge request!180Resolve "Back button in lesson view should redirect to the person's week view"
Pipeline #10048 failed
......@@ -14,8 +14,8 @@
<div class="row no-margin">
<div class="col s12 no-padding">
{# Back to week view #}
{% if lesson_documentation %}
<a href="{% url "week_view_by_week" lesson_documentation.calendar_week.year lesson_documentation.calendar_week.week "group" register_object.get_groups.all.0.pk %}"
{% if back_to_week_url %}
<a href="{{ back_to_week_url }}"
class="btn primary-color waves-light waves-effect alsijil-top-button">
<i class="material-icons left">chevron_left</i> {% trans "Back to week view" %}
</a>
......
......@@ -120,7 +120,7 @@
</td>
<td class="tr-link">
<a class="tr-link"
href="{{ register_object.alsijil_url }}">
href="{{ register_object.alsijil_url }}?back={{ back_url }}">
{% if register_object.period %}
{{ register_object.period.period }}.
{% else %}
......@@ -131,7 +131,7 @@
{% if not group %}
<td>
<a class="tr-link"
href="{{ register_object.alsijil_url }}">
href="{{ register_object.alsijil_url }}?back={{ back_url }}">
{% if register_object.lesson %}
{{ register_object.lesson.group_names }}
{% else %}
......@@ -142,7 +142,7 @@
{% endif %}
<td>
<a class="tr-link"
href="{{ register_object.alsijil_url }}">
href="{{ register_object.alsijil_url }}?back={{ back_url }}">
{% if register_object.get_subject %}
{{ register_object.get_subject.name }}
{% elif register_object.subject %}
......@@ -154,25 +154,25 @@
</td>
<td>
<a class="tr-link"
href="{{ register_object.alsijil_url }}">
href="{{ register_object.alsijil_url }}?back={{ back_url }}">
{{ register_object.teacher_names }}
</a>
</td>
<td>
<a class="tr-link"
href="{{ register_object.alsijil_url }}">
href="{{ register_object.alsijil_url }}?back={{ back_url }}">
{% firstof register_object.get_lesson_documentation.topic "–" %}
</a>
</td>
<td>
<a class="tr-link"
href="{{ register_object.alsijil_url }}">
href="{{ register_object.alsijil_url }}?back={{ back_url }}">
{% firstof register_object.get_lesson_documentation.homework "–" %}
</a>
</td>
<td>
<a class="tr-link"
href="{{ register_object.alsijil_url }}">
href="{{ register_object.alsijil_url }}?back={{ back_url }}">
{% firstof register_object.get_lesson_documentation.group_note "–" %}
</a>
</td>
......@@ -195,7 +195,7 @@
{% has_perm "alsijil.view_lessondocumentation" user register_object as can_view_lesson_documentation %}
{% if can_view_lesson_documentation %}
<a class="collection-item avatar"
href="{{ register_object.alsijil_url }}">
href="{{ register_object.alsijil_url }}?back={{ back_url }}">
{% include "alsijil/partials/lesson_status_icon.html" with register_object=register_object css_class="materialize-circle" color_suffix=" " %}
<table class="hide-on-med-and-down">
<tr>
......@@ -278,7 +278,7 @@
</li>
{% endif %}
<li class="collection-item">
{{ register_object.teacher_names }}
{{ register_object.teacher_names }}
</li>
<li class="collection-item">
{{ register_object.get_lesson_documentation.topic }}
......
......@@ -12,6 +12,7 @@ from django.shortcuts import get_object_or_404, redirect, render
from django.urls import reverse, reverse_lazy
from django.utils import timezone
from django.utils.decorators import method_decorator
from django.utils.http import url_has_allowed_host_and_scheme
from django.utils.translation import ugettext as _
from django.views import View
from django.views.decorators.cache import never_cache
......@@ -274,6 +275,22 @@ def register_object(
None, queryset=persons_qs, prefix="personal_notes"
)
back_url = request.GET.get("back", "")
back_url_is_safe = url_has_allowed_host_and_scheme(
url=back_url, allowed_hosts={request.get_host()}, require_https=request.is_secure(),
)
if back_url_is_safe:
context["back_to_week_url"] = back_url
else:
context["back_to_week_url"] = reverse(
"week_view_by_week",
args=[
lesson_documentation.calendar_week.year,
lesson_documentation.calendar_week.week,
"group",
register_object.get_groups().all()[0].pk,
],
)
context["lesson_documentation"] = lesson_documentation
context["lesson_documentation_form"] = lesson_documentation_form
context["personal_note_formset"] = personal_note_formset
......
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