Skip to content
Snippets Groups Projects
Commit 420f07a0 authored by Hangzhi Yu's avatar Hangzhi Yu
Browse files

Add rules&permissions in class register template

parent 45de9a0c
No related branches found
No related tags found
1 merge request!49Resolve "Add rules and permissions"
{# -*- engine:django -*- #} {# -*- engine:django -*- #}
{% extends "core/base.html" %} {% extends "core/base.html" %}
{% load material_form i18n static %} {% load material_form i18n static rules %}
{% block browser_title %}{% blocktrans %}Lesson{% endblocktrans %}{% endblock %} {% block browser_title %}{% blocktrans %}Lesson{% endblocktrans %}{% endblock %}
...@@ -31,7 +31,8 @@ ...@@ -31,7 +31,8 @@
</div> </div>
</div> </div>
{% csrf_token %} {% csrf_token %}
{% 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 %}
<div class="row"> <div class="row">
<div class="col s12 m12 l6 xl8"> <div class="col s12 m12 l6 xl8">
<div class="card"> <div class="card">
...@@ -39,8 +40,28 @@ ...@@ -39,8 +40,28 @@
<span class="card-title"> <span class="card-title">
{% blocktrans %}Lesson documentation{% endblocktrans %} {% blocktrans %}Lesson documentation{% endblocktrans %}
</span> </span>
{% if can_edit_lesson_documentation %}
{% form form=lesson_documentation_form %}{% endform %} {% 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>
</table>
{% endif %}
</div> </div>
</div> </div>
</div> </div>
...@@ -63,6 +84,7 @@ ...@@ -63,6 +84,7 @@
<span class="card-title"> <span class="card-title">
{% blocktrans %}Personal notes{% endblocktrans %} {% blocktrans %}Personal notes{% endblocktrans %}
</span> </span>
{% has_perm "alsijil.edit_personalnote" user lesson_period as can_edit_personalnote %}
{% form form=personal_note_formset.management_form %}{% endform %} {% form form=personal_note_formset.management_form %}{% endform %}
<table class="striped responsive-table alsijil-table"> <table class="striped responsive-table alsijil-table">
...@@ -77,38 +99,73 @@ ...@@ -77,38 +99,73 @@
</thead> </thead>
<tbody> <tbody>
{% for form in personal_note_formset %} {% for form in personal_note_formset %}
<tr> {% if can_edit_personalnote %}
{{ form.id }} <tr>
<td>{{ form.person_name }}{{ form.person_name.value }}</td> {{ form.id }}
<td class="center-align"> <td>{{ form.person_name }}{{ form.person_name.value }}</td>
<label> <td class="center-align">
{{ form.absent }} <label>
<span></span> {{ form.absent }}
</label> <span></span>
</td>
<td>
<div class="input-field">
{{ form.late }}
<label for="{{ form.absent.id_for_label }}">
{% trans "Tardiness (in m)" %}
</label> </label>
</div> </td>
</td> <td>
<td class="center-align"> <div class="input-field">
<label> {{ form.late }}
{{ form.excused }} <label for="{{ form.absent.id_for_label }}">
<span></span> {% trans "Tardiness (in m)" %}
</label> </label>
</td> </div>
<td> </td>
<div class="input-field"> <td class="center-align">
{{ form.remarks }} <label>
<label for="{{ form.absent.id_for_label }}"> {{ form.excused }}
{% trans "Remarks" %} <span></span>
</label> </label>
</div> </td>
</td> <td>
</tr> <div class="input-field">
{{ form.remarks }}
<label for="{{ form.absent.id_for_label }}">
{% trans "Remarks" %}
</label>
</div>
</td>
</tr>
{% else %}
<tr>
{{ form.id }}
<td>{{ form.person_name }}{{ form.person_name.value }}</td>
<td class="center-align">
<label>
{{ form.absent }}
<span></span>
</label>
</td>
<td>
<div class="input-field">
{{ form.late }}
<label for="{{ form.absent.id_for_label }}">
{% trans "Tardiness (in m)" %}
</label>
</div>
</td>
<td class="center-align">
<label>
{{ form.excused }}
<span></span>
</label>
</td>
<td>
<div class="input-field">
{{ form.remarks }}
<label for="{{ form.absent.id_for_label }}">
{% trans "Remarks" %}
</label>
</div>
</td>
</tr>
{% endif %}
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
...@@ -117,10 +174,12 @@ ...@@ -117,10 +174,12 @@
</div> </div>
</div> </div>
<div class="row"> {% if can_edit_lesson_documentation or can_edit_personalnote %}
<div class="col s12"> <div class="row">
{% include "core/partials/save_button.html" %} <div class="col s12">
{% include "core/partials/save_button.html" %}
</div>
</div> </div>
</div> {% endif %}
</form> </form>
{% endblock %} {% endblock %}
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