Skip to content

Commit

Permalink
feat: adding CCX support to gradebook API
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjmpb committed Jan 11, 2024
1 parent 63c4db3 commit 0117d5d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lms/djangoapps/grades/rest_api/v1/gradebook_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
from rest_framework.response import Response
from rest_framework.views import APIView

from common.djangoapps.student.auth import has_course_author_access
from common.djangoapps.student.auth import has_course_author_access, is_ccx_course
from common.djangoapps.student.models import CourseAccessRole, CourseEnrollment, CourseMode
from common.djangoapps.student.roles import BulkRoleCache
from common.djangoapps.student.roles import BulkRoleCache, CourseInstructorRole, CourseStaffRole
from common.djangoapps.track.event_transaction_utils import (
create_new_event_transaction_id,
get_event_transaction_id,
Expand Down Expand Up @@ -227,6 +227,13 @@ def _wrapper_view(self, request, course_id, *args, **kwargs):
"""
course_key = CourseKey.from_string(course_id)
if not has_course_author_access(request.user, course_key):
user_has_gradebook_access = any([
CourseStaffRole(course_key).has_user(request.user),
CourseInstructorRole(course_key).has_user(request.user),
])
if is_ccx_course(course_key) and user_has_gradebook_access:
return view(self, request, course_key, *args, **kwargs)

raise DeveloperErrorViewMixin.api_error(
status_code=status.HTTP_403_FORBIDDEN,
developer_message='The requesting user does not have course author permissions.',
Expand Down

0 comments on commit 0117d5d

Please sign in to comment.