Commit 1840fe7f by Nimisha Asthagiri

Mobile API: use bulk_operation context manager.

parent 46f64305
...@@ -5,11 +5,13 @@ Common utility methods and decorators for Mobile APIs. ...@@ -5,11 +5,13 @@ Common utility methods and decorators for Mobile APIs.
import functools import functools
from opaque_keys.edx.keys import CourseKey
from courseware.courses import get_course_with_access
from rest_framework import permissions from rest_framework import permissions
from rest_framework.authentication import OAuth2Authentication, SessionAuthentication from rest_framework.authentication import OAuth2Authentication, SessionAuthentication
from opaque_keys.edx.keys import CourseKey
from xmodule.modulestore.django import modulestore
from courseware.courses import get_course_with_access
def mobile_course_access(depth=0, verify_enrolled=True): def mobile_course_access(depth=0, verify_enrolled=True):
""" """
...@@ -25,6 +27,7 @@ def mobile_course_access(depth=0, verify_enrolled=True): ...@@ -25,6 +27,7 @@ def mobile_course_access(depth=0, verify_enrolled=True):
Raises 404 if access to course is disallowed. Raises 404 if access to course is disallowed.
""" """
course_id = CourseKey.from_string(kwargs.pop('course_id')) course_id = CourseKey.from_string(kwargs.pop('course_id'))
with modulestore().bulk_operations(course_id):
course = get_course_with_access( course = get_course_with_access(
request.user, request.user,
'load_mobile' if verify_enrolled else 'load_mobile_no_enrollment_check', 'load_mobile' if verify_enrolled else 'load_mobile_no_enrollment_check',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment