diff --git a/lms/djangoapps/course_api/serializers.py b/lms/djangoapps/course_api/serializers.py index bcd5806fb3..51a394d86a 100644 --- a/lms/djangoapps/course_api/serializers.py +++ b/lms/djangoapps/course_api/serializers.py @@ -72,10 +72,19 @@ class CourseSerializer(serializers.Serializer): # pylint: disable=abstract-meth start_type = serializers.CharField() pacing = serializers.CharField() mobile_available = serializers.BooleanField() + hidden = serializers.SerializerMethodField() # 'course_id' is a deprecated field, please use 'id' instead. course_id = serializers.CharField(source='id', read_only=True) + def get_hidden(self, course_overview): + """ + Get the representation for SerializerMethodField `hidden` + Represents whether course is hidden in LMS + """ + catalog_visibility = course_overview.catalog_visibility + return catalog_visibility in ['about', 'none'] + def get_blocks_url(self, course_overview): """ Get the representation for SerializerMethodField `blocks_url` diff --git a/lms/djangoapps/course_api/tests/test_serializers.py b/lms/djangoapps/course_api/tests/test_serializers.py index 50373d32fc..928a81e5cb 100644 --- a/lms/djangoapps/course_api/tests/test_serializers.py +++ b/lms/djangoapps/course_api/tests/test_serializers.py @@ -68,6 +68,7 @@ class TestCourseSerializer(CourseApiFactoryMixin, ModuleStoreTestCase): 'effort': u'6 hours', 'pacing': 'instructor', 'mobile_available': False, + 'hidden': False, # 'course_id' is a deprecated field, please use 'id' instead. 'course_id': u'edX/toy/2012_Fall', @@ -97,6 +98,15 @@ class TestCourseSerializer(CourseApiFactoryMixin, ModuleStoreTestCase): result = self._get_result(course) self.assertDictEqual(result, self.expected_data) + def test_hidden(self): + course = self.create_course( + course=u'custom', + start=datetime(2015, 3, 15), + catalog_visibility=u'none' + ) + result = self._get_result(course) + self.assertEqual(result['hidden'], True) + def test_advertised_start(self): course = self.create_course( course=u'custom', diff --git a/openedx/core/lib/api/view_utils.py b/openedx/core/lib/api/view_utils.py index 4eeffab4ae..02a838735f 100644 --- a/openedx/core/lib/api/view_utils.py +++ b/openedx/core/lib/api/view_utils.py @@ -13,6 +13,7 @@ from rest_framework.response import Response from rest_framework.mixins import RetrieveModelMixin, UpdateModelMixin from rest_framework.generics import GenericAPIView +from edx_rest_framework_extensions.authentication import JwtAuthentication from openedx.core.lib.api.authentication import ( SessionAuthenticationAllowInactiveUser, OAuth2AuthenticationAllowInactiveUser, @@ -93,6 +94,7 @@ def view_auth_classes(is_user=False, is_authenticated=True): If is_user is True, also requires username in URL matches the request user. """ func_or_class.authentication_classes = ( + JwtAuthentication, OAuth2AuthenticationAllowInactiveUser, SessionAuthenticationAllowInactiveUser ) diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt index bc1fa0cd4d..fdf79f22b8 100644 --- a/requirements/edx/base.txt +++ b/requirements/edx/base.txt @@ -41,7 +41,7 @@ django==1.8.16 djangorestframework-jwt==1.8.0 djangorestframework-oauth==1.1.0 edx-ccx-keys==0.2.1 -edx-drf-extensions==0.5.1 +edx-drf-extensions==1.2.1 edx-lint==0.4.3 edx-django-oauth2-provider==1.1.4 edx-django-sites-extensions==2.1.1