From 016d2d8c3f514c957bef4c265823aee9d1c1a8e9 Mon Sep 17 00:00:00 2001 From: stvn Date: Mon, 23 Mar 2020 11:28:17 -0700 Subject: [PATCH] Add content_type_gating_enabled flag to courseware API to extend the Learner MFE. --- openedx/core/djangoapps/courseware_api/serializers.py | 1 + openedx/core/djangoapps/courseware_api/views.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/openedx/core/djangoapps/courseware_api/serializers.py b/openedx/core/djangoapps/courseware_api/serializers.py index c8bd318938..f9a70c9f61 100644 --- a/openedx/core/djangoapps/courseware_api/serializers.py +++ b/openedx/core/djangoapps/courseware_api/serializers.py @@ -69,6 +69,7 @@ class CourseInfoSerializer(serializers.Serializer): # pylint: disable=abstract- Compare this with CourseDetailSerializer. """ + content_type_gating_enabled = serializers.BooleanField() course_expired_message = serializers.CharField() effort = serializers.CharField() end = serializers.DateTimeField() diff --git a/openedx/core/djangoapps/courseware_api/views.py b/openedx/core/djangoapps/courseware_api/views.py index bcbd12c6bd..a75e454588 100644 --- a/openedx/core/djangoapps/courseware_api/views.py +++ b/openedx/core/djangoapps/courseware_api/views.py @@ -16,6 +16,7 @@ from lms.djangoapps.courseware.module_render import get_module_by_usage_id from student.models import CourseEnrollment from openedx.core.lib.api.view_utils import DeveloperErrorViewMixin +from openedx.features.content_type_gating.models import ContentTypeGatingConfig from openedx.features.course_duration_limits.access import generate_course_expired_message from xmodule.course_module import COURSE_VISIBILITY_PUBLIC @@ -116,6 +117,12 @@ class CoursewareInformation(RetrieveAPIView): # TODO: TNL-7185 Legacy: Refactor to return the expiration date and format the message in the MFE overview.course_expired_message = generate_course_expired_message(self.request.user, overview) + + course_key = CourseKey.from_string(self.kwargs['course_key_string']) + overview.content_type_gating_enabled = ContentTypeGatingConfig.enabled_for_enrollment( + user=self.request.user, + course_key=course_key, + ) return overview def get_serializer_context(self):