From 3e37f4b4e933c03c74025dbc22d520b3663b6738 Mon Sep 17 00:00:00 2001 From: Tom Teichler <tom.teichler@teckids.org> Date: Mon, 16 Sep 2019 18:20:19 +0200 Subject: [PATCH] Fix raising error. --- biscuit/apps/alsijil/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/biscuit/apps/alsijil/views.py b/biscuit/apps/alsijil/views.py index ffb328ff2..87d1e927f 100644 --- a/biscuit/apps/alsijil/views.py +++ b/biscuit/apps/alsijil/views.py @@ -3,8 +3,9 @@ from datetime import date, datetime, timedelta from typing import Optional from django.contrib.auth.decorators import login_required +from django.core.exceptions import PermissionDenied from django.db.models import Count, Exists, F, OuterRef, Q, Sum -from django.http import Http404, Http403, HttpRequest, HttpResponse +from django.http import Http404, HttpRequest, HttpResponse from django.shortcuts import get_object_or_404, render from django.urls import reverse from django.utils.translation import ugettext as _ @@ -35,8 +36,8 @@ def lesson(request: HttpRequest, year: Optional[int] = None, week: Optional[int] if not lesson_period: raise Http404(_('You either selected an invalid lesson or there is currently no lesson in progress.')) - if lesson_period.lesson.periods.time_start < datetime.now() or lesson_period.lesson.get_calendar_week < CalendarWeek(): - raise Http403(_('You are not allowed to create a lesson documentation for a lesson in the future.')) + if datetime.combine(wanted_week[lesson_period.period.weekday - 1], lesson_period.period.time_start) < datetime.now(): + raise PermissionDenied(_('You are not allowed to create a lesson documentation for a lesson in the future.')) context['lesson_period'] = lesson_period context['week'] = wanted_week -- GitLab