Files
edx-platform/lms/djangoapps/course_api/blocks/utils.py
Muhammad Adeel Tajamul 63b5c841cd fix: blocks v2 will filter discussion xblocks (#31820)
Co-authored-by: adeel.tajamul <adeel.tajamul@arbisoft.com>
2023-03-01 06:25:37 +05:00

23 lines
643 B
Python

"""
Utils for Blocks
"""
from openedx.core.djangoapps.discussions.models import (
DiscussionsConfiguration,
Provider,
)
def filter_discussion_xblocks_from_response(response, course_key):
"""
Removes discussion xblocks if discussion provider is openedx
"""
configuration = DiscussionsConfiguration.get(context_key=course_key)
provider = configuration.provider_type
if provider == Provider.OPEN_EDX:
response.data['blocks'] = {
key: value
for key, value in response.data.get('blocks', {}).items()
if value.get('type') != 'discussion'
}
return response