Use bulk operations on get_course_by_id and courseware

This commit is contained in:
Don Mitchell
2014-10-03 17:28:16 -04:00
parent 0c795934c3
commit 0ed4ee32eb
2 changed files with 7 additions and 1 deletions

View File

@@ -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:

View File

@@ -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)