Skip to content

Commit

Permalink
feat: content role checks to permission checks
Browse files Browse the repository at this point in the history
  • Loading branch information
hsinkoff committed Jan 12, 2024
1 parent b908907 commit 396876f
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from common.djangoapps.student.auth import user_has_role
from common.djangoapps.student.roles import CourseBetaTesterRole

from openedx.core.djangoapps.course_roles.data import CourseRolesPermission

from ...data import ScheduleData, ScheduleItemData, UserCourseOutlineData
from .base import OutlineProcessor

Expand Down Expand Up @@ -60,7 +62,13 @@ def load_data(self, full_course_outline):
course_usage_key = self.course_key.make_usage_key('course', 'course')
self._course_start = self.keys_to_schedule_fields[course_usage_key].get('start')
self._course_end = self.keys_to_schedule_fields[course_usage_key].get('end')
self._is_beta_tester = user_has_role(self.user, CourseBetaTesterRole(self.course_key))
# TODO: remove role checks once course_roles is fully impelented and data is migrated
self._is_beta_tester = (
user_has_role(self.user, CourseBetaTesterRole(self.course_key)) or
self.user.has_perm(CourseRolesPermission.VIEW_ALL_PUBLISHED_CONTENT.perm_name) or
self.user.has_perm(CourseRolesPermission.VIEW_LIVE_PUBLISHED_CONTENT.perm_name)
)


def inaccessible_sequences(self, full_course_outline):
"""
Expand Down

0 comments on commit 396876f

Please sign in to comment.