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
62a32cda
Commit
62a32cda
authored
Feb 18, 2014
by
zubiar-arbi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add course updates location to loc_mapper on accessing course_info_update_handler
STUD-1248
parent
e3a71b16
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
3 deletions
+54
-3
cms/djangoapps/contentstore/views/course.py
+9
-1
cms/djangoapps/contentstore/views/tests/test_course_updates.py
+45
-2
No files found.
cms/djangoapps/contentstore/views/course.py
View file @
62a32cda
...
@@ -466,7 +466,15 @@ def course_info_update_handler(request, tag=None, package_id=None, branch=None,
...
@@ -466,7 +466,15 @@ def course_info_update_handler(request, tag=None, package_id=None, branch=None,
"""
"""
if
'application/json'
not
in
request
.
META
.
get
(
'HTTP_ACCEPT'
,
'application/json'
):
if
'application/json'
not
in
request
.
META
.
get
(
'HTTP_ACCEPT'
,
'application/json'
):
return
HttpResponseBadRequest
(
"Only supports json requests"
)
return
HttpResponseBadRequest
(
"Only supports json requests"
)
updates_locator
=
BlockUsageLocator
(
package_id
=
package_id
,
branch
=
branch
,
version_guid
=
version_guid
,
block_id
=
block
)
course_location
=
loc_mapper
()
.
translate_locator_to_location
(
CourseLocator
(
package_id
=
package_id
),
get_course
=
True
)
# add location to loc_mapper
updates_locator
=
loc_mapper
()
.
translate_location
(
course_location
.
course_id
,
course_location
.
replace
(
category
=
'course_info'
,
name
=
'updates'
),
False
,
True
)
updates_location
=
loc_mapper
()
.
translate_locator_to_location
(
updates_locator
)
updates_location
=
loc_mapper
()
.
translate_locator_to_location
(
updates_locator
)
if
provided_id
==
''
:
if
provided_id
==
''
:
provided_id
=
None
provided_id
=
None
...
...
cms/djangoapps/contentstore/views/tests/test_course_updates.py
View file @
62a32cda
'''unit tests for course_info views and models.'''
"""
from
contentstore.tests.test_course_settings
import
CourseTestCase
unit tests for course_info views and models.
"""
import
json
import
json
from
contentstore.tests.test_course_settings
import
CourseTestCase
from
xmodule.modulestore
import
Location
from
xmodule.modulestore.django
import
modulestore
,
loc_mapper
from
xmodule.modulestore.django
import
modulestore
,
loc_mapper
from
xmodule.modulestore.locator
import
BlockUsageLocator
class
CourseUpdateTest
(
CourseTestCase
):
class
CourseUpdateTest
(
CourseTestCase
):
...
@@ -142,3 +147,41 @@ class CourseUpdateTest(CourseTestCase):
...
@@ -142,3 +147,41 @@ class CourseUpdateTest(CourseTestCase):
resp
=
self
.
client
.
get_json
(
course_update_url
)
resp
=
self
.
client
.
get_json
(
course_update_url
)
payload
=
json
.
loads
(
resp
.
content
)
payload
=
json
.
loads
(
resp
.
content
)
self
.
assertTrue
(
len
(
payload
)
==
2
)
self
.
assertTrue
(
len
(
payload
)
==
2
)
def
test_post_course_update
(
self
):
"""
Test posting a course update through api on a newly created course updates location map with course_updates
"""
# create a course via the view handler
course_location
=
Location
([
'i4x'
,
'Org_1'
,
'Course_1'
,
'course'
,
'Run_1'
])
course_locator
=
loc_mapper
()
.
translate_location
(
course_location
.
course_id
,
course_location
,
False
,
True
)
self
.
client
.
ajax_post
(
course_locator
.
url_reverse
(
'course'
),
{
'org'
:
course_location
.
org
,
'number'
:
course_location
.
course
,
'display_name'
:
'test course'
,
'run'
:
course_location
.
name
,
}
)
branch
=
u'draft'
version
=
None
block
=
u'updates'
updates_locator
=
BlockUsageLocator
(
package_id
=
course_location
.
course_id
.
replace
(
'/'
,
'.'
),
branch
=
branch
,
version_guid
=
version
,
block_id
=
block
)
# test that user can successfully post on course updates whose location in not added in loc_mapper
content
=
u"Sample update"
payload
=
{
'content'
:
content
,
'date'
:
'January 8, 2013'
}
course_update_url
=
updates_locator
.
url_reverse
(
'course_info_update'
)
resp
=
self
.
client
.
ajax_post
(
course_update_url
,
payload
)
# check that response status is 200 not 400
self
.
assertEqual
(
resp
.
status_code
,
200
)
payload
=
json
.
loads
(
resp
.
content
)
self
.
assertHTMLEqual
(
payload
[
'content'
],
content
)
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