From 0a2acd8751ff783c8550a24364c87f78088150de Mon Sep 17 00:00:00 2001
From: Jonathan Weth <git@jonathanweth.de>
Date: Thu, 20 Aug 2020 16:36:14 +0200
Subject: [PATCH] Check permission of lesson documentations in week view

---
 .../alsijil/class_register/week_view.html     | 59 ++++++++++---------
 1 file changed, 31 insertions(+), 28 deletions(-)

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 d0761f810..d0f4d7994 100644
--- a/aleksis/apps/alsijil/templates/alsijil/class_register/week_view.html
+++ b/aleksis/apps/alsijil/templates/alsijil/class_register/week_view.html
@@ -65,38 +65,41 @@
                 </thead>
                 <tbody>
                 {% for period in periods %}
-                  <tr>
-                    <td class="center-align">
-                      {% include "alsijil/partials/lesson_status_icon.html" with period=period %}
-                    </td>
-                    <td class="tr-link">
-                      <a class="tr-link" href="{% url 'lesson_by_week_and_period' week.year week.week period.id %}">
-                        {{ period.period.period }}.
-                      </a>
-                    </td>
-                    {% if not group %}
+                  {% has_perm "alsijil.view_lessondocumentation" user period as can_view_lesson_documentation %}
+                  {% if can_view_lesson_documentation %}
+                    <tr>
+                      <td class="center-align">
+                        {% include "alsijil/partials/lesson_status_icon.html" with period=period %}
+                      </td>
+                      <td class="tr-link">
+                        <a class="tr-link" href="{% url 'lesson_by_week_and_period' week.year week.week period.id %}">
+                          {{ period.period.period }}.
+                        </a>
+                      </td>
+                      {% if not group %}
+                        <td>
+                          <a class="tr-link" href="{% url 'lesson_by_week_and_period' week.year week.week period.id %}">
+                            {{ period.lesson.group_names }}
+                          </a>
+                        </td>
+                      {% endif %}
                       <td>
                         <a class="tr-link" href="{% url 'lesson_by_week_and_period' week.year week.week period.id %}">
-                          {{ period.lesson.group_names }}
+                          {{ period.get_subject.name }}
                         </a>
                       </td>
-                    {% endif %}
-                    <td>
-                      <a class="tr-link" href="{% url 'lesson_by_week_and_period' week.year week.week period.id %}">
-                        {{ period.get_subject.name }}
-                      </a>
-                    </td>
-                    <td>
-                      <a class="tr-link" href="{% url 'lesson_by_week_and_period' week.year week.week period.id %}">
-                        {{ period.get_teacher_names }}
-                      </a>
-                    </td>
-                    <td>
-                      <a class="tr-link" href="{% url 'lesson_by_week_and_period' week.year week.week period.id %}">
-                        {{ period.get_lesson_documentation.topic }}
-                      </a>
-                    </td>
-                  </tr>
+                      <td>
+                        <a class="tr-link" href="{% url 'lesson_by_week_and_period' week.year week.week period.id %}">
+                          {{ period.get_teacher_names }}
+                        </a>
+                      </td>
+                      <td>
+                        <a class="tr-link" href="{% url 'lesson_by_week_and_period' week.year week.week period.id %}">
+                          {{ period.get_lesson_documentation.topic }}
+                        </a>
+                      </td>
+                    </tr>
+                  {% endif %}
                 {% endfor %}
                 </tbody>
               </table>
-- 
GitLab