diff --git a/lms/djangoapps/courseware/courses.py b/lms/djangoapps/courseware/courses.py index 3b6d614f91..27ceb530f3 100644 --- a/lms/djangoapps/courseware/courses.py +++ b/lms/djangoapps/courseware/courses.py @@ -66,7 +66,8 @@ def get_course_by_id(course_key, depth=0): depth: The number of levels of children for the modulestore to cache. None means infinite depth """ - course = modulestore().get_course(course_key, depth=depth) + with modulestore().bulk_operations(course_key): + course = modulestore().get_course(course_key, depth=depth) if course: return course else: diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index 22d95de96c..18013af6dc 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -285,6 +285,11 @@ def index(request, course_id, chapter=None, section=None, return redirect(reverse('dashboard')) request.user = user # keep just one instance of User + with modulestore().bulk_operations(course_key): + return _index_bulk_op(request, user, course_key, chapter, section, position) + + +def _index_bulk_op(request, user, course_key, chapter, section, position): course = get_course_with_access(user, 'load', course_key, depth=2) staff_access = has_access(user, 'staff', course) registered = registered_for_course(course, user)