diff --git a/aleksis/apps/alsijil/menus.py b/aleksis/apps/alsijil/menus.py index 67c9292b501b793aa459dbf47495c6e77e8164ec..26ec4f9323bcbc33e8cbba54ae016a35e614b912 100644 --- a/aleksis/apps/alsijil/menus.py +++ b/aleksis/apps/alsijil/menus.py @@ -13,6 +13,13 @@ MENUS = { "aleksis.core.util.core_helpers.has_person", ], "submenu": [ + { + "name": _("Coursebook"), + "url": "select_coursebook", + "svg_icon": "mdi:book-education-outline", + "vuetify_icon": "mdi-book-education-outline", + # FIXME: Permissions + }, { "name": _("Current lesson"), "url": "lesson_period", diff --git a/aleksis/apps/alsijil/urls.py b/aleksis/apps/alsijil/urls.py index b06aebd352774727bb6bddca9dec8a0e28846a69..2cbc63fbbbe9932e3f7fb6e312980971a1fc20dc 100644 --- a/aleksis/apps/alsijil/urls.py +++ b/aleksis/apps/alsijil/urls.py @@ -3,6 +3,8 @@ from django.urls import path from . import views urlpatterns = [ + path("coursebook/", views.SelectCoursebookView.as_view(), name="select_coursebook"), + path("coursebook/<int:pk>/", views.CoursebookView.as_view(), name="coursebook"), path("lesson", views.register_object, {"model": "lesson"}, name="lesson_period"), path( "lesson/<int:year>/<int:week>/<int:id_>", diff --git a/aleksis/apps/alsijil/views.py b/aleksis/apps/alsijil/views.py index ff825ebecf995afdc32e4bcd031dd83003a51403..ccb9683216be66b852a3dfbc9fcfbb32902f8875 100644 --- a/aleksis/apps/alsijil/views.py +++ b/aleksis/apps/alsijil/views.py @@ -17,7 +17,7 @@ from django.utils.http import url_has_allowed_host_and_scheme from django.utils.translation import gettext 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, TemplateView import reversion from calendarweek import CalendarWeek @@ -28,7 +28,7 @@ from reversion.views import RevisionMixin from rules.contrib.views import PermissionRequiredMixin, permission_required from aleksis.apps.chronos.managers import TimetableType -from aleksis.apps.chronos.models import Event, ExtraLesson, Holiday, LessonPeriod, TimePeriod +from aleksis.apps.chronos.models import Event, ExtraLesson, Holiday, Lesson, LessonPeriod, TimePeriod from aleksis.apps.chronos.util.build import build_weekdays from aleksis.apps.chronos.util.date import get_weeks_for_year, week_weekday_to_date from aleksis.core.mixins import ( @@ -1349,3 +1349,19 @@ 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 CoursebookView(DetailView): + model = Lesson + template_name = "alsijil/class_register/coursebook.html" + permission_required = "" # FIXME + + +class SelectCoursebookView(TemplateView): + template_name = "alsijil/class_register/select_coursebook.html" + permission_required = "" # FIXME + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context["lessons"] = self.request.user.person.lessons_as_teacher.all() + return context