@@ -605,25 +605,28 @@ def get(self, request, usage_key_string, *args, **kwargs): # lint-amnesty, pyli
605605 ) if is_preview and staff_access else (
606606 ModuleStoreEnum .Branch .published_only
607607 )
608-
609- with modulestore ().branch_setting (branch_type , usage_key .course_key ):
610- sequence , _ = get_block_by_usage_id (
611- self .request ,
612- str (usage_key .course_key ),
613- str (usage_key ),
614- disable_staff_debug_info = True ,
615- will_recheck_access = True )
616-
617- if not hasattr (sequence , 'get_metadata' ):
618- # Looks like we were asked for metadata on something that is not a sequence (or section).
619- return Response (status = status .HTTP_422_UNPROCESSABLE_ENTITY )
620-
621- view = STUDENT_VIEW
622- if request .user .is_anonymous :
623- view = PUBLIC_VIEW
624-
625- context = {'specific_masquerade' : is_masquerading_as_specific_student (request .user , usage_key .course_key )}
626- return Response (sequence .get_metadata (view = view , context = context ))
608+ _modulestore = modulestore ()
609+ with _modulestore .branch_setting (branch_type , usage_key .course_key ):
610+ with _modulestore .bulk_operations (usage_key .course_key ):
611+ sequence , _ = get_block_by_usage_id (
612+ self .request ,
613+ str (usage_key .course_key ),
614+ str (usage_key ),
615+ disable_staff_debug_info = True ,
616+ will_recheck_access = True )
617+
618+ if not hasattr (sequence , 'get_metadata' ):
619+ # Looks like we were asked for metadata on something that is not a sequence (or section).
620+ return Response (status = status .HTTP_422_UNPROCESSABLE_ENTITY )
621+
622+ view = STUDENT_VIEW
623+ if request .user .is_anonymous :
624+ view = PUBLIC_VIEW
625+
626+ context = {
627+ 'specific_masquerade' : is_masquerading_as_specific_student (request .user , usage_key .course_key )
628+ }
629+ return Response (sequence .get_metadata (view = view , context = context ))
627630
628631
629632class Resume (DeveloperErrorViewMixin , APIView ):
0 commit comments