Skip to content

Commit

Permalink
feat: override course api perm to give data researcher progress page …
Browse files Browse the repository at this point in the history
…access
  • Loading branch information
tehreem-sadat committed Jan 7, 2025
1 parent 7f6318c commit 5f3a908
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
8 changes: 8 additions & 0 deletions futurex_openedx_extensions/helpers/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ def ready(self) -> None:
from futurex_openedx_extensions.helpers import \
monkey_patches # pylint: disable=unused-import, import-outside-toplevel
from futurex_openedx_extensions.helpers import signals # pylint: disable=unused-import, import-outside-toplevel

from bridgekeeper import perms
from lms.djangoapps.courseware.rules import HasAccessRule, HasRolesRule
CAN_MASQUARADE_LEARNER_PROGRESS = 'course_home_api.can_masquarade_progress'
if CAN_MASQUARADE_LEARNER_PROGRESS in perms:
del perms[CAN_MASQUARADE_LEARNER_PROGRESS]
perms[CAN_MASQUARADE_LEARNER_PROGRESS] = HasAccessRule('staff') | HasAccessRule('data_researcher')

4 changes: 4 additions & 0 deletions test_utils/edx_platform_mocks_shared/bridgekeeper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""Mock bridgekeeper permission map"""


perms = {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Mocked bridgekeepr lms rules"""


class Rule:
"""Mocked Base class for rules."""
def check(self, user, instance=None):
"""Check if a user satisfies this rule."""
raise NotImplementedError()

def __or__(self, other):
return True


class HasRolesRule(Rule):
def __init__(self, *roles):
self.roles = roles

def check(self, user=None, instance=None):
return True


class HasAccessRule(Rule):
def __init__(self, *roles):
self.roles = roles

def check(self, user=None, instance=None):
return True

0 comments on commit 5f3a908

Please sign in to comment.