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
055ca30c
Commit
055ca30c
authored
Apr 01, 2016
by
Saqib
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #655 from edx-solutions/msaqib52/YONK-279
Update static page detail api to fetch by name
parents
5fb7932b
0e5639e4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
15 deletions
+26
-15
common/lib/xmodule/xmodule/modulestore/tests/factories.py
+4
-1
lms/djangoapps/api_manager/courses/tests.py
+8
-3
lms/djangoapps/api_manager/courses/urls.py
+4
-1
lms/djangoapps/api_manager/courses/views.py
+10
-10
No files found.
common/lib/xmodule/xmodule/modulestore/tests/factories.py
View file @
055ca30c
...
...
@@ -211,6 +211,8 @@ class ItemFactory(XModuleFactory):
:data: (optional): the data for the item
(e.g. XML problem definition for a problem item)
:name: (optional): the name of the item
:display_name: (optional): the display name of the item
:metadata: (optional): dictionary of metadata attributes
...
...
@@ -284,8 +286,9 @@ class ItemFactory(XModuleFactory):
)
course
=
store
.
get_course
(
location
.
course_key
)
name
=
kwargs
.
pop
(
'name'
,
'Static Tab'
)
course
.
tabs
.
append
(
CourseTab
.
load
(
'static_tab'
,
name
=
'Static Tab'
,
url_slug
=
location
.
name
)
CourseTab
.
load
(
'static_tab'
,
name
=
name
,
url_slug
=
location
.
name
)
)
store
.
update_item
(
course
,
user_id
)
...
...
lms/djangoapps/api_manager/courses/tests.py
View file @
055ca30c
...
...
@@ -197,7 +197,8 @@ class CoursesApiTests(ModuleStoreTestCase):
category
=
"static_tab"
,
parent_location
=
self
.
course
.
location
,
data
=
TEST_STATIC_TAB1_CONTENT
,
display_name
=
"syllabus"
display_name
=
"syllabus"
,
name
=
"Static+Tab"
)
self
.
static_tab2
=
ItemFactory
.
create
(
...
...
@@ -882,13 +883,15 @@ class CoursesApiTests(ModuleStoreTestCase):
response
=
self
.
do_get
(
test_uri
)
self
.
assertEqual
(
response
.
status_code
,
404
)
def
test_static_tab_detail_get
(
self
):
test_uri
=
self
.
base_courses_uri
+
'/'
+
self
.
test_course_id
+
'/static_tabs/syllabus'
def
test_static_tab_detail_get_by_name
(
self
):
# get course static tab by tab name
test_uri
=
self
.
base_courses_uri
+
'/'
+
self
.
test_course_id
+
'/static_tabs/Static+Tab'
response
=
self
.
do_get
(
test_uri
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertGreater
(
len
(
response
.
data
),
0
)
tab
=
response
.
data
self
.
assertEqual
(
tab
[
'id'
],
u'syllabus'
)
self
.
assertEqual
(
tab
[
'name'
],
u'Static+Tab'
)
self
.
assertEqual
(
tab
[
'content'
],
self
.
static_tab1
.
data
)
# now try to get syllabus tab contents from cache
...
...
@@ -900,6 +903,8 @@ class CoursesApiTests(ModuleStoreTestCase):
self
.
assertTrue
(
tab_contents
is
not
None
)
self
.
assertEqual
(
tab_contents
,
self
.
static_tab1
.
data
)
def
test_static_tab_detail_get_by_url_slug
(
self
):
# get course static tab by url_slug
test_uri
=
self
.
base_courses_uri
+
'/'
+
self
.
test_course_id
+
'/static_tabs/readings'
response
=
self
.
do_get
(
test_uri
)
self
.
assertEqual
(
response
.
status_code
,
200
)
...
...
lms/djangoapps/api_manager/courses/urls.py
View file @
055ca30c
...
...
@@ -23,7 +23,10 @@ urlpatterns = patterns(
url
(
r'^{0}/groups/(?P<group_id>[0-9]+)$'
.
format
(
COURSE_ID_PATTERN
),
courses_views
.
CoursesGroupsDetail
.
as_view
()),
url
(
r'^{0}/groups/*$'
.
format
(
COURSE_ID_PATTERN
),
courses_views
.
CoursesGroupsList
.
as_view
()),
url
(
r'^{0}/overview/*$'
.
format
(
COURSE_ID_PATTERN
),
courses_views
.
CoursesOverview
.
as_view
()),
url
(
r'^{0}/static_tabs/(?P<tab_id>[a-zA-Z0-9_+\/:-]+)$'
.
format
(
COURSE_ID_PATTERN
),
courses_views
.
CoursesStaticTabsDetail
.
as_view
()),
url
(
r'^{0}/static_tabs/(?P<tab_id>[a-zA-Z0-9_+\/:-]+)$'
.
format
(
COURSE_ID_PATTERN
),
courses_views
.
CoursesStaticTabsDetail
.
as_view
()),
url
(
r'^{0}/static_tabs/(?P<tab_id>[a-zA-Z0-9_+\s\/:-]+)$'
.
format
(
COURSE_ID_PATTERN
),
courses_views
.
CoursesStaticTabsDetail
.
as_view
()),
url
(
r'^{0}/static_tabs/*$'
.
format
(
COURSE_ID_PATTERN
),
courses_views
.
CoursesStaticTabsList
.
as_view
()),
url
(
r'^{0}/completions/*$'
.
format
(
COURSE_ID_PATTERN
),
courses_views
.
CourseModuleCompletionList
.
as_view
(),
name
=
'completion-list'
),
url
(
r'^{0}/projects/*$'
.
format
(
COURSE_ID_PATTERN
),
courses_views
.
CoursesProjectList
.
as_view
(),
name
=
'courseproject-list'
),
...
...
lms/djangoapps/api_manager/courses/views.py
View file @
055ca30c
...
...
@@ -947,19 +947,19 @@ class CoursesStaticTabsDetail(SecureAPIView):
"""
**Use Case**
CoursesStaticTabsDetail returns a c
ollection of custom pages in the
course,
including the page content.
CoursesStaticTabsDetail returns a c
ustom page in the course,
including the page content.
**Example Requests**
GET /api/courses/{course_id}/static_tabs/{tab_id}
GET /api/courses/{course_id}/static_tabs/{tab_url_slug}
GET /api/courses/{course_id}/static_tabs/{tab_name}
**Response Values**
* tabs: The collection of custom pages in the course. Each object in the
collection conains the following keys:
* tab: A custom page in the course. containing following keys:
* id: The
ID
of the custom page.
* id: The
url_slug
of the custom page.
* name: The Display Name of the custom page.
...
...
@@ -975,7 +975,7 @@ class CoursesStaticTabsDetail(SecureAPIView):
return
Response
({},
status
=
status
.
HTTP_404_NOT_FOUND
)
response_data
=
OrderedDict
()
for
tab
in
course_descriptor
.
tabs
:
if
tab
.
type
==
'static_tab'
and
tab
.
url_slug
==
tab_id
:
if
tab
.
type
==
'static_tab'
and
(
tab
.
url_slug
==
tab_id
or
tab
.
name
==
tab_id
)
:
response_data
[
'id'
]
=
tab
.
url_slug
response_data
[
'name'
]
=
tab
.
name
response_data
[
'content'
]
=
_get_static_tab_contents
(
...
...
@@ -983,9 +983,9 @@ class CoursesStaticTabsDetail(SecureAPIView):
course_descriptor
,
tab
)
if
not
response_data
:
return
Response
({},
status
=
status
.
HTTP_404_NOT_FOUND
)
return
Response
(
response_data
,
status
=
status
.
HTTP_200_OK
)
return
Response
(
response_data
,
status
=
status
.
HTTP_200_OK
)
return
Response
(
{},
status
=
status
.
HTTP_404_NOT_FOUND
)
class
CoursesUsersList
(
SecureAPIView
):
...
...
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