Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
af976a0e
Commit
af976a0e
authored
Nov 02, 2016
by
Matthew Piatetsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add JWT auth and hidden flag to course_api
parent
0016d1af
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
1 deletions
+22
-1
lms/djangoapps/course_api/serializers.py
+9
-0
lms/djangoapps/course_api/tests/test_serializers.py
+10
-0
openedx/core/lib/api/view_utils.py
+2
-0
requirements/edx/base.txt
+1
-1
No files found.
lms/djangoapps/course_api/serializers.py
View file @
af976a0e
...
...
@@ -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`
...
...
lms/djangoapps/course_api/tests/test_serializers.py
View file @
af976a0e
...
...
@@ -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'
,
...
...
openedx/core/lib/api/view_utils.py
View file @
af976a0e
...
...
@@ -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
)
...
...
requirements/edx/base.txt
View file @
af976a0e
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment