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

Add views for listing instructions

parent b4f8fb24
No related branches found
No related tags found
1 merge request!215Draft: Resolve "Instructions can be linked to a document as remarks by the group"
Pipeline #24855 passed with warnings
from django.contrib import admin
from .models import Instruction
admin.site.register(Instruction)
......@@ -67,6 +67,17 @@ MENUS = {
),
],
},
{
"name": _("Instructions"),
"url": "instructions",
"icon": "rule_folder",
"validators": [
(
"aleksis.core.util.predicates.permission_validator",
"alsijil.view_instructions_rule",
),
],
},
{
"name": _("Assign group role"),
"url": "assign_group_role_multiple",
......
......@@ -490,6 +490,9 @@ class Instruction(SchoolTermRelatedExtensibleModel):
),
)
def __str__(self):
return self.name
class Meta:
verbose_name = _("Instruction")
verbose_name_plural = _("Instructions")
......
......@@ -308,3 +308,6 @@ view_register_objects_list_predicate = has_person & (
| has_global_perm("core.view_full_register")
)
add_perm("alsijil.view_register_objects_list_rule", view_register_objects_list_predicate)
view_instructions_predicate = has_person
add_perm("alsijil.view_instructions_rule", view_instructions_predicate)
{# -*- engine:django -*- #}
{% extends "core/base.html" %}
{% load i18n %}
{% block browser_title %}{% blocktrans %}Instructions{% endblocktrans %}{% endblock %}
{% block page_title %}{% blocktrans %}Instructions{% endblocktrans %}{% endblock %}
{% block content %}
<ul class="collection">
{% for instruction in instruction_list %}
<li class="collection-item avatar">
<i class="material-icons materialize-circle primary-color">{{ instruction.icon|default:"rule" }}</i>
<span class="title"> {{ instruction.name }}</span>
<a class="btn-flat waves-effect waves-green right" href="{{ instruction.pdf_file.url }}" target="_blank">
<i class="material-icons left">picture_as_pdf</i>
{% trans "Show PDF file with instruction" %}
</a>
</li>
{% endfor %}
</ul>
{% endblock %}
......@@ -101,4 +101,5 @@ urlpatterns = [
name="assign_group_role_multiple",
),
path("all/", views.AllRegisterObjectsView.as_view(), name="all_register_objects"),
path("instructions/", views.InstructionsListView.as_view(), name="instructions"),
]
......@@ -16,7 +16,7 @@ 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
from django.views.generic import DetailView
from django.views.generic import DetailView, ListView
import reversion
from calendarweek import CalendarWeek
......@@ -62,6 +62,7 @@ from .models import (
ExtraMark,
GroupRole,
GroupRoleAssignment,
Instruction,
LessonDocumentation,
PersonalNote,
)
......@@ -1351,3 +1352,11 @@ class AllRegisterObjectsView(PermissionRequiredMixin, View):
if self.action_form.is_valid():
self.action_form.execute()
return render(request, "alsijil/class_register/all_objects.html", context)
class InstructionsListView(PermissionRequiredMixin, ListView):
"""Table of all excuse types."""
model = Instruction
permission_required = "alsijil.view_instructions_rule"
template_name = "alsijil/instruction/list.html"
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