Skip to content

Commit

Permalink
feat: upgrading simple api to drf compatible.
Browse files Browse the repository at this point in the history
  • Loading branch information
awais786 committed Jul 31, 2024
1 parent 480dc75 commit 51f8201
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions lms/djangoapps/instructor/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,29 +232,6 @@ def wrapped(*args, **kwargs):
return decorator


def verify_course_permission(permission):
"""
Decorator with argument that requires a specific permission of the requesting
user. If the requirement is not satisfied, returns an
HttpResponseForbidden (403).
Assumes that request is in self.
Assumes that course_id is in kwargs['course_id'].
"""
def decorator(func):
def wrapped(self, *args, **kwargs):
request = self.request
course = get_course_by_id(CourseKey.from_string(kwargs['course_id']))

if request.user.has_perm(permission, course):
return func(self, *args, **kwargs)
else:
return HttpResponseForbidden()

return wrapped

return decorator


def require_sales_admin(func):
"""
Decorator for checking sales administrator access before executing an HTTP endpoint. This decorator
Expand Down Expand Up @@ -2398,11 +2375,11 @@ class ListEntranceExamInstructorTasks(APIView):
BearerAuthenticationAllowInactiveUser,
SessionAuthenticationAllowInactiveUser,
)
permission_classes = (IsAuthenticated,)
permission_classes = (IsAuthenticated, permissions.InstructorPermission)
permission_name = permissions.SHOW_TASKS
http_method_names = ['post']

@method_decorator(ensure_csrf_cookie)
@verify_course_permission(permissions.SHOW_TASKS)
@method_decorator(cache_control(no_cache=True, no_store=True, must_revalidate=True))
def post(self, request, course_id):
"""
Expand Down

0 comments on commit 51f8201

Please sign in to comment.