Merge pull request #23728 from edx/dcs/dashboard
Refactor instructor dashboard access
This commit is contained in:
@@ -343,6 +343,14 @@ class OrgLibraryUserRole(OrgRole):
|
||||
super(OrgLibraryUserRole, self).__init__(self.ROLE, *args, **kwargs)
|
||||
|
||||
|
||||
class OrgDataResearcherRole(OrgRole):
|
||||
"""A Data Researcher"""
|
||||
ROLE = 'data_researcher'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(OrgDataResearcherRole, self).__init__(self.ROLE, *args, **kwargs)
|
||||
|
||||
|
||||
@register_access_role
|
||||
class CourseCreatorRole(RoleBase):
|
||||
"""
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
"""
|
||||
Django rules for student roles
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import rules
|
||||
|
||||
from lms.djangoapps.courseware.access import has_access
|
||||
from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag, WaffleFlag, WaffleFlagNamespace
|
||||
|
||||
from .roles import CourseDataResearcherRole
|
||||
|
||||
# Waffle flag to enable the separate course outline page and full width content.
|
||||
RESEARCHER_ROLE = CourseWaffleFlag(WaffleFlagNamespace(name='instructor'), 'researcher')
|
||||
|
||||
|
||||
@rules.predicate
|
||||
def can_access_reports(user, course_id):
|
||||
"""
|
||||
Returns whether the user can access the course data downloads.
|
||||
"""
|
||||
is_staff = user.is_staff
|
||||
if RESEARCHER_ROLE.is_enabled(course_id):
|
||||
return is_staff or CourseDataResearcherRole(course_id).has_user(user)
|
||||
else:
|
||||
return is_staff or has_access(user, 'staff', course_id)
|
||||
|
||||
rules.add_perm('student.can_research', can_access_reports)
|
||||
Reference in New Issue
Block a user