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

Rename get_instance_by_pk and document it better

parent 3d5d957c
No related branches found
No related tags found
1 merge request!49Resolve "Add rules and permissions"
Pipeline #4071 failed
......@@ -38,14 +38,14 @@ def get_lesson_period_by_pk(
return lesson_period
def get_instance_by_pk(
def get_timetable_instance_by_pk(
request: HttpRequest,
year: Optional[int] = None,
week: Optional[int] = None,
type_: Optional[str] = None,
id_: Optional[int] = None,
):
"""Get Instance object by given type and id or the current person."""
"""Get timetable object (teacher, room or group) by given type and id or the current person."""
if type_ and id_:
return get_el_by_pk(request, type_, id_)
elif hasattr(request, "user") and hasattr(request.user, "person"):
......
......@@ -34,7 +34,7 @@ from .forms import (
)
from .models import ExcuseType, ExtraMark, LessonDocumentation, PersonalNote
from .tables import ExcuseTypeTable, ExtraMarkTable
from .util.alsijil_helpers import get_instance_by_pk, get_lesson_period_by_pk
from .util.alsijil_helpers import get_lesson_period_by_pk, get_timetable_instance_by_pk
@permission_required("alsijil.view_lesson", fn=get_lesson_period_by_pk)
......@@ -162,7 +162,7 @@ def lesson(
return render(request, "alsijil/class_register/lesson.html", context)
@permission_required("alsijil.view_week", fn=get_instance_by_pk)
@permission_required("alsijil.view_week", fn=get_timetable_instance_by_pk)
def week_view(
request: HttpRequest,
year: Optional[int] = None,
......@@ -177,7 +177,7 @@ def week_view(
else:
wanted_week = CalendarWeek()
instance = get_instance_by_pk(request, year, week, type_, id_)
instance = get_timetable_instance_by_pk(request, year, week, type_, id_)
lesson_periods = LessonPeriod.objects.in_week(wanted_week).annotate(
has_documentation=Exists(
......
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