add view_ccx_coach_dashboard permission
This commit is contained in:
9
lms/djangoapps/ccx/permissions.py
Normal file
9
lms/djangoapps/ccx/permissions.py
Normal file
@@ -0,0 +1,9 @@
|
||||
"""
|
||||
Permission definitions for the ccx djangoapp
|
||||
"""
|
||||
|
||||
from bridgekeeper import perms
|
||||
from courseware.rules import HasAccessRule
|
||||
|
||||
VIEW_CCX_COACH_DASHBOARD = 'ccx.view_ccx_coach_dashboard'
|
||||
perms[VIEW_CCX_COACH_DASHBOARD] = HasAccessRule('staff')
|
||||
@@ -11,6 +11,8 @@ from courseware.access import has_access
|
||||
from student.roles import CourseCcxCoachRole
|
||||
from xmodule.tabs import CourseTab
|
||||
|
||||
from .permissions import VIEW_CCX_COACH_DASHBOARD
|
||||
|
||||
|
||||
class CcxCourseTab(CourseTab):
|
||||
"""
|
||||
@@ -31,9 +33,7 @@ class CcxCourseTab(CourseTab):
|
||||
# If ccx is not enable do not show ccx coach tab.
|
||||
return False
|
||||
|
||||
is_staff_or_instructor = has_access(user, 'staff', course) or has_access(user, 'instructor', course)
|
||||
if hasattr(course.id, 'ccx') and is_staff_or_instructor:
|
||||
# if user is staff or instructor then he can always see ccx coach tab.
|
||||
if hasattr(course.id, 'ccx') and bool(user.has_perm(VIEW_CCX_COACH_DASHBOARD, course)):
|
||||
return True
|
||||
|
||||
# check if user has coach access.
|
||||
|
||||
@@ -36,6 +36,7 @@ from lms.djangoapps.ccx.overrides import (
|
||||
get_override_for_ccx,
|
||||
override_field_for_ccx
|
||||
)
|
||||
from lms.djangoapps.ccx.permissions import VIEW_CCX_COACH_DASHBOARD
|
||||
from lms.djangoapps.ccx.utils import (
|
||||
add_master_course_staff_to_ccx,
|
||||
assign_staff_role_to_ccx,
|
||||
@@ -90,10 +91,7 @@ def coach_dashboard(view):
|
||||
if not course.enable_ccx:
|
||||
raise Http404
|
||||
else:
|
||||
is_staff = has_access(request.user, 'staff', course)
|
||||
is_instructor = has_access(request.user, 'instructor', course)
|
||||
|
||||
if is_staff or is_instructor:
|
||||
if bool(request.user.has_perm(VIEW_CCX_COACH_DASHBOARD, course)):
|
||||
# if user is staff or instructor then he can view ccx coach dashboard.
|
||||
return view(request, course, ccx)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user