11"""
22API function for retrieving course blocks data
33"""
4- from edx_django_utils . cache import RequestCache
4+
55
66import lms .djangoapps .course_blocks .api as course_blocks_api
77from lms .djangoapps .course_blocks .transformers .access_denied_filter import AccessDeniedMessageFilterTransformer
1414from .toggles import HIDE_ACCESS_DENIALS_FLAG
1515from .transformers .blocks_api import BlocksAPITransformer
1616from .transformers .milestones import MilestonesAndSpecialExamsTransformer
17- from .utils import COURSE_API_REQUEST_CACHE_NAMESPACE , REUSABLE_BLOCKS_CACHE_KEY
1817
1918
2019def get_blocks (
@@ -30,7 +29,6 @@ def get_blocks(
3029 block_types_filter = None ,
3130 hide_access_denials = False ,
3231 allow_start_dates_in_future = False ,
33- cache_with_future_dates = False ,
3432):
3533 """
3634 Return a serialized representation of the course blocks.
@@ -63,7 +61,6 @@ def get_blocks(
6361 allow_start_dates_in_future (bool): When True, will allow blocks to be
6462 returned that can bypass the StartDateTransformer's filter to show
6563 blocks with start dates in the future.
66- cache_with_future_dates (bool): When True, will use the block caching logic using RequestCache
6764 """
6865
6966 if HIDE_ACCESS_DENIALS_FLAG .is_enabled ():
@@ -121,10 +118,6 @@ def get_blocks(
121118 ),
122119 ]
123120
124- if cache_with_future_dates :
125- # Include future dates such that get_course_assignments can reuse the block structure from RequestCache
126- allow_start_dates_in_future = True
127-
128121 # transform
129122 blocks = course_blocks_api .get_course_blocks (
130123 user ,
@@ -135,19 +128,6 @@ def get_blocks(
135128 include_has_scheduled_content = include_has_scheduled_content
136129 )
137130
138- if cache_with_future_dates :
139- # Store a copy of the transformed, but still unfiltered, course blocks in RequestCache to be reused
140- # wherever possible for optimization. Copying is required to make sure the cached structure is not mutated
141- # by the filtering below.
142- request_cache = RequestCache (COURSE_API_REQUEST_CACHE_NAMESPACE )
143- request_cache .set (REUSABLE_BLOCKS_CACHE_KEY , blocks .copy ())
144-
145- # Since we included blocks with future start dates in our block structure,
146- # we need to include the 'start' field to filter out such blocks before returning the response.
147- # If 'start' field is not requested, it will be removed from the response.
148- requested_fields = set (requested_fields )
149- requested_fields .add ('start' )
150-
151131 # filter blocks by types
152132 if block_types_filter :
153133 block_keys_to_remove = []
@@ -162,7 +142,7 @@ def get_blocks(
162142 serializer_context = {
163143 'request' : request ,
164144 'block_structure' : blocks ,
165- 'requested_fields' : requested_fields ,
145+ 'requested_fields' : requested_fields or [] ,
166146 }
167147
168148 if return_type == 'dict' :
0 commit comments