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
83b7997d
Commit
83b7997d
authored
Jan 08, 2013
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added unit tests and generalized a catch
parent
1708dc40
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
2 deletions
+31
-2
cms/djangoapps/contentstore/course_info_model.py
+1
-1
cms/djangoapps/contentstore/tests/test_course_updates.py
+29
-0
cms/djangoapps/contentstore/views.py
+1
-1
No files found.
cms/djangoapps/contentstore/course_info_model.py
View file @
83b7997d
...
...
@@ -71,7 +71,7 @@ def update_course_updates(location, update, passed_id=None):
# Confirm that root is <ol>, iterate over <li>, pull out <h2> subs and then rest of val
if
course_html_parsed
.
tag
==
'ol'
:
# ??? Should this use the id in the json or in the url or does it matter?
if
passed_id
:
if
passed_id
is
not
None
:
idx
=
get_idx
(
passed_id
)
# idx is count from end of list
course_html_parsed
[
-
idx
]
=
new_html_parsed
...
...
cms/djangoapps/contentstore/tests/test_course_updates.py
0 → 100644
View file @
83b7997d
from
cms.djangoapps.contentstore.tests.test_course_settings
import
CourseTestCase
from
django.core.urlresolvers
import
reverse
import
json
from
cms.djangoapps.contentstore.course_info_model
import
update_course_updates
class
CourseUpdateTest
(
CourseTestCase
):
def
test_course_update
(
self
):
# first get the update to force the creation
url
=
reverse
(
'course_info'
,
kwargs
=
{
'org'
:
self
.
course_location
.
org
,
'course'
:
self
.
course_location
.
course
,
'name'
:
self
.
course_location
.
name
})
self
.
client
.
get
(
url
)
content
=
'<iframe width="560" height="315" src="http://www.youtube.com/embed/RocY-Jd93XU" frameborder="0"></iframe>'
payload
=
{
'content'
:
content
,
'date'
:
'January 8, 2013'
}
# No means to post w/ provided_id missing. django doesn't handle. So, go direct for the create
payload
=
update_course_updates
([
'i4x'
,
self
.
course_location
.
org
,
self
.
course_location
.
course
,
'course_info'
,
"updates"
]
,
payload
)
url
=
reverse
(
'course_info'
,
kwargs
=
{
'org'
:
self
.
course_location
.
org
,
'course'
:
self
.
course_location
.
course
,
'provided_id'
:
payload
[
'id'
]})
self
.
assertHTMLEqual
(
content
,
payload
[
'content'
],
"single iframe"
)
content
+=
'<div>div <p>p</p></div>'
payload
[
'content'
]
=
content
resp
=
self
.
client
.
post
(
url
,
json
.
dumps
(
payload
),
"application/json"
)
self
.
assertHTMLEqual
(
content
,
json
.
loads
(
resp
.
content
)[
'content'
],
"iframe w/ div"
)
cms/djangoapps/contentstore/views.py
View file @
83b7997d
...
...
@@ -991,7 +991,7 @@ def course_info_updates(request, org, course, provided_id=None):
elif
request
.
method
==
'POST'
:
try
:
return
HttpResponse
(
json
.
dumps
(
update_course_updates
(
location
,
request
.
POST
,
provided_id
)),
mimetype
=
"application/json"
)
except
etree
.
XMLSyntaxError
:
except
:
return
HttpResponseBadRequest
(
"Failed to save: malformed html"
,
content_type
=
"text/plain"
)
...
...
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