Skip to content

Commit

Permalink
FIXUP refactoring coursemodulepermission
Browse files Browse the repository at this point in the history
  • Loading branch information
markkuriekkinen committed Sep 21, 2022
1 parent 9943e44 commit 5687486
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions course/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
FilterBackend,
)
from exercise.cache.points import CachedPoints
from exercise.models import BaseExercise
from exercise.models import BaseExercise, LearningObject
from exercise.submission_models import Submission
from userprofile.models import GraderUser, UserProfile
from .models import (
Course,
CourseModule,
CourseInstance,
)
from exercise.models import LearningObject


class JWTObjectPermission(Permission):
Expand Down Expand Up @@ -249,12 +248,14 @@ def has_object_permission(self, request: HttpRequest, view: Any, module: CourseM
if module.status == CourseModule.STATUS.HIDDEN:
return False

#if this isn't an enrollment question and the module hasn't opened yet
if (
not (hasattr(view, 'exercise')
and view.exercise.status in (LearningObject.STATUS.ENROLLMENT, LearningObject.STATUS.ENROLLMENT_EXTERNAL))
and not module.is_after_open()
):
# Enrollment questionnaires are not affected by the module opening time.
if hasattr(view, 'exercise') and view.exercise.status in (
LearningObject.STATUS.ENROLLMENT,
LearningObject.STATUS.ENROLLMENT_EXTERNAL,
):
return True

if not module.is_after_open():
# FIXME: use format from django settings
self.error_msg(
_('MODULE_PERMISSION_ERROR_NOT_OPEN_YET -- {date}'),
Expand Down

0 comments on commit 5687486

Please sign in to comment.