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
e3c38e5d
Commit
e3c38e5d
authored
Apr 19, 2014
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get course static tabs API methods
parent
812b0be5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
3 deletions
+76
-3
lms/djangoapps/api_manager/courses_urls.py
+3
-1
lms/djangoapps/api_manager/courses_views.py
+71
-0
lms/djangoapps/courseware/views.py
+2
-2
No files found.
lms/djangoapps/api_manager/courses_urls.py
View file @
e3c38e5d
...
...
@@ -14,5 +14,7 @@ urlpatterns = patterns(
url
(
r'^(?P<course_id>[a-zA-Z0-9/_:]+)/groups/*$'
,
'courses_groups_list'
),
url
(
r'^(?P<course_id>[a-zA-Z0-9/_:]+)/overview$'
,
'course_overview'
),
url
(
r'^(?P<course_id>[a-zA-Z0-9/_:]+)/updates$'
,
'course_updates'
),
url
(
r'^(?P<course_id>[a-zA-Z0-9/_:]+)$'
,
'courses_detail'
),
url
(
r'^(?P<course_id>[^/]+/[^/]+/[^/]+)/static_tabs/(?P<tab_id>[a-zA-Z0-9/_:]+)$'
,
'static_tab_detail'
),
url
(
r'^(?P<course_id>[^/]+/[^/]+/[^/]+)/static_tabs$'
,
'static_tabs_list'
),
url
(
r'^(?P<course_id>[^/]+/[^/]+/[^/]+)$'
,
'courses_detail'
),
)
lms/djangoapps/api_manager/courses_views.py
View file @
e3c38e5d
...
...
@@ -17,6 +17,7 @@ from xmodule.modulestore.django import modulestore
from
xmodule.modulestore
import
Location
,
InvalidLocationError
from
courseware.courses
import
get_course_about_section
,
get_course_info_section
from
courseware.views
import
get_static_tab_contents
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -481,3 +482,73 @@ def course_updates(request, course_id):
return
Response
({},
status
=
status
.
HTTP_404_NOT_FOUND
)
return
Response
(
response_data
)
@api_view
([
'GET'
])
@permission_classes
((
ApiKeyHeaderPermission
,))
def
static_tabs_list
(
request
,
course_id
):
"""
GET returns an array of Static Tabs inside of a course
"""
store
=
modulestore
()
response_data
=
OrderedDict
()
try
:
course_module
=
store
.
get_course
(
course_id
)
if
not
course_module
:
return
Response
({},
status
=
status
.
HTTP_404_NOT_FOUND
)
tabs
=
[]
for
tab
in
course_module
.
tabs
:
if
tab
.
type
==
'static_tab'
:
tab_data
=
OrderedDict
()
tab_data
[
'id'
]
=
tab
.
url_slug
tab_data
[
'name'
]
=
tab
.
name
if
request
.
GET
.
get
(
'detail'
)
and
request
.
GET
.
get
(
'detail'
)
in
[
'True'
,
'true'
]:
tab_data
[
'content'
]
=
get_static_tab_contents
(
request
,
course_module
,
tab
,
wrap_xmodule_display
=
False
)
tabs
.
append
(
tab_data
)
response_data
[
'tabs'
]
=
tabs
except
InvalidLocationError
:
return
Response
({},
status
=
status
.
HTTP_404_NOT_FOUND
)
return
Response
(
response_data
)
@api_view
([
'GET'
])
@permission_classes
((
ApiKeyHeaderPermission
,))
def
static_tab_detail
(
request
,
course_id
,
tab_id
):
"""
GET returns an array of Static Tabs inside of a course
"""
store
=
modulestore
()
response_data
=
OrderedDict
()
try
:
course_module
=
store
.
get_course
(
course_id
)
if
not
course_module
:
return
Response
({},
status
=
status
.
HTTP_404_NOT_FOUND
)
for
tab
in
course_module
.
tabs
:
if
tab
.
type
==
'static_tab'
and
tab
.
url_slug
==
tab_id
:
response_data
[
'id'
]
=
tab
.
url_slug
response_data
[
'name'
]
=
tab
.
name
response_data
[
'content'
]
=
get_static_tab_contents
(
request
,
course_module
,
tab
,
wrap_xmodule_display
=
False
)
except
InvalidLocationError
:
return
Response
({},
status
=
status
.
HTTP_404_NOT_FOUND
)
if
not
response_data
:
return
Response
({},
status
=
status
.
HTTP_404_NOT_FOUND
)
return
Response
(
response_data
)
lms/djangoapps/courseware/views.py
View file @
e3c38e5d
...
...
@@ -773,7 +773,7 @@ def notification_image_for_tab(course_tab, user, course):
return
None
def
get_static_tab_contents
(
request
,
course
,
tab
):
def
get_static_tab_contents
(
request
,
course
,
tab
,
wrap_xmodule_display
=
True
):
"""
Returns the contents for the given static tab
"""
...
...
@@ -788,7 +788,7 @@ def get_static_tab_contents(request, course, tab):
course
.
id
,
request
.
user
,
modulestore
()
.
get_instance
(
course
.
id
,
loc
),
depth
=
0
)
tab_module
=
get_module
(
request
.
user
,
request
,
loc
,
field_data_cache
,
course
.
id
,
static_asset_path
=
course
.
static_asset_path
request
.
user
,
request
,
loc
,
field_data_cache
,
course
.
id
,
static_asset_path
=
course
.
static_asset_path
,
wrap_xmodule_display
=
wrap_xmodule_display
)
logging
.
debug
(
'course_module = {0}'
.
format
(
tab_module
))
...
...
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