Adds new api to return block metadata which includes index_dictionary. Reason for new api instead of adding it to course blocks API: data like index_dictionary are too large for the cache used by course/blocks transformers API.
63 lines
1.7 KiB
Python
63 lines
1.7 KiB
Python
"""
|
|
Course Block API URLs
|
|
"""
|
|
|
|
|
|
from django.conf import settings
|
|
from django.urls import path, re_path
|
|
|
|
from .views import BlockMetadataView, BlocksInCourseView, BlocksView
|
|
|
|
urlpatterns = [
|
|
# This endpoint requires the usage_key for the starting block.
|
|
re_path(
|
|
fr'^v1/blocks/{settings.USAGE_KEY_PATTERN}',
|
|
BlocksView.as_view(),
|
|
kwargs={'hide_access_denials': True},
|
|
name="blocks_in_block_tree"
|
|
),
|
|
|
|
# This endpoint is an alternative to the above, but requires course_id as a parameter.
|
|
path(
|
|
'v1/blocks/',
|
|
BlocksInCourseView.as_view(),
|
|
kwargs={'hide_access_denials': True},
|
|
name="blocks_in_course"
|
|
),
|
|
# This endpoint requires the usage_key
|
|
re_path(
|
|
fr'^v1/block_metadata/{settings.USAGE_KEY_PATTERN}',
|
|
BlockMetadataView.as_view(),
|
|
name="blocks_metadata"
|
|
),
|
|
|
|
# This endpoint requires the usage_key for the starting block.
|
|
re_path(
|
|
fr'^v2/blocks/{settings.USAGE_KEY_PATTERN}',
|
|
BlocksView.as_view(),
|
|
name="blocks_in_block_tree"
|
|
),
|
|
|
|
# This endpoint is an alternative to the above, but requires course_id as a parameter.
|
|
path(
|
|
'v2/blocks/',
|
|
BlocksInCourseView.as_view(),
|
|
name="blocks_in_course"
|
|
),
|
|
|
|
# This endpoint requires the usage_key
|
|
re_path(
|
|
fr'^v2/block_metadata/{settings.USAGE_KEY_PATTERN}',
|
|
BlockMetadataView.as_view(),
|
|
name="blocks_metadata"
|
|
),
|
|
]
|
|
|
|
if getattr(settings, 'PROVIDER_STATES_URL', None):
|
|
from .tests.pacts.views import provider_state
|
|
urlpatterns.append(path(
|
|
'pact/provider_states/',
|
|
provider_state,
|
|
name='provider-state-view'
|
|
))
|