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

Move permission check

parent f0c2b7f0
No related branches found
No related tags found
1 merge request!47Resolve "[TCC planning] Frontend is incredibly slow with large amounts of entries"
Pipeline #196438 failed
...@@ -217,7 +217,14 @@ class Query(graphene.ObjectType): ...@@ -217,7 +217,14 @@ class Query(graphene.ObjectType):
info.context, info.context,
TimeboundCourseConfig.objects.all(), TimeboundCourseConfig.objects.all(),
"validity_range__school_term", "validity_range__school_term",
) )
if not info.context.user.has_perm("lesrooster.view_timeboundcourseconfig_rule"):
course_configs = get_objects_for_user(
info.context.user,
"lesrooster.view_timeboundcourseconfig",
course_configs,
)
subjects = Subject.objects.all().prefetch_related( subjects = Subject.objects.all().prefetch_related(
Prefetch( Prefetch(
......
import time
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
...@@ -67,12 +69,6 @@ class LesroosterExtendedCourseType(CourseType): ...@@ -67,12 +69,6 @@ class LesroosterExtendedCourseType(CourseType):
@staticmethod @staticmethod
def resolve_lr_timebound_course_configs(root, info, **kwargs): def resolve_lr_timebound_course_configs(root, info, **kwargs):
if not info.context.user.has_perm("lesrooster.view_timeboundcourseconfig_rule"):
return get_objects_for_user(
info.context.user,
"lesrooster.view_timeboundcourseconfig",
root.lr_timebound_course_configs.all(),
)
return root.lr_timebound_course_configs.all() return root.lr_timebound_course_configs.all()
......
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