From 396876fc051703412c9c557fa8f08803fe348c6b Mon Sep 17 00:00:00 2001 From: hsinkoff <10408711+hsinkoff@users.noreply.github.com> Date: Tue, 2 Jan 2024 16:11:32 +0000 Subject: [PATCH] feat: content role checks to permission checks --- .../learning_sequences/api/processors/schedule.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/openedx/core/djangoapps/content/learning_sequences/api/processors/schedule.py b/openedx/core/djangoapps/content/learning_sequences/api/processors/schedule.py index 7d6e373b43e1..41f3dd07d548 100644 --- a/openedx/core/djangoapps/content/learning_sequences/api/processors/schedule.py +++ b/openedx/core/djangoapps/content/learning_sequences/api/processors/schedule.py @@ -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 @@ -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): """