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
b5fd6c90
Commit
b5fd6c90
authored
Dec 18, 2012
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send back error to client if failed to save malformed update and have it
show an alert.
parent
fc2b6f03
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
12 deletions
+13
-12
cms/djangoapps/contentstore/course_info_model.py
+3
-6
cms/djangoapps/contentstore/views.py
+6
-5
cms/static/js/views/course_info_edit.js
+4
-1
No files found.
cms/djangoapps/contentstore/course_info_model.py
View file @
b5fd6c90
...
...
@@ -65,12 +65,9 @@ def update_course_updates(location, update, passed_id=None):
except
etree
.
XMLSyntaxError
:
course_html_parsed
=
etree
.
fromstring
(
"<ol></ol>"
)
try
:
new_html_parsed
=
etree
.
fromstring
(
'<li><h2>'
+
update
[
'date'
]
+
'</h2>'
+
update
[
'content'
]
+
'</li>'
,
etree
.
XMLParser
(
remove_blank_text
=
True
))
except
etree
.
XMLSyntaxError
:
logging
.
debug
(
"Mashing malformed update"
)
new_html_parsed
=
'<li><h2>'
+
update
[
'date'
]
+
'</h2>'
+
update
[
'content'
]
+
'</li>'
# No try/catch b/c failure generates an error back to client
new_html_parsed
=
etree
.
fromstring
(
'<li><h2>'
+
update
[
'date'
]
+
'</h2>'
+
update
[
'content'
]
+
'</li>'
,
etree
.
XMLParser
(
remove_blank_text
=
True
))
# Confirm that root is <ol>, iterate over <li>, pull out <h2> subs and then rest of val
if
course_html_parsed
.
tag
==
'ol'
:
...
...
cms/djangoapps/contentstore/views.py
View file @
b5fd6c90
...
...
@@ -54,6 +54,7 @@ from cms.djangoapps.models.settings.course_details import CourseDetails,\
CourseSettingsEncoder
from
cms.djangoapps.models.settings.course_grading
import
CourseGradingModel
from
cms.djangoapps.contentstore.utils
import
get_modulestore
from
lxml
import
etree
# to install PIL on MacOSX: 'easy_install http://dist.repoze.org/PIL-1.1.6.tar.gz'
...
...
@@ -979,13 +980,13 @@ def course_info_updates(request, org, course, provided_id=None):
if
request
.
method
==
'GET'
:
return
HttpResponse
(
json
.
dumps
(
get_course_updates
(
location
)),
mimetype
=
"application/json"
)
elif
real_method
==
'POST'
:
# new instance (unless django makes PUT a POST): updates are coming as POST. Not sure why.
return
HttpResponse
(
json
.
dumps
(
update_course_updates
(
location
,
request
.
POST
,
provided_id
)),
mimetype
=
"application/json"
)
elif
real_method
==
'PUT'
:
return
HttpResponse
(
json
.
dumps
(
update_course_updates
(
location
,
request
.
POST
,
provided_id
)),
mimetype
=
"application/json"
)
elif
real_method
==
'DELETE'
:
# coming as POST need to pull from Request Header X-HTTP-Method-Override DELETE
return
HttpResponse
(
json
.
dumps
(
delete_course_update
(
location
,
request
.
POST
,
provided_id
)),
mimetype
=
"application/json"
)
elif
request
.
method
==
'POST'
:
try
:
return
HttpResponse
(
json
.
dumps
(
update_course_updates
(
location
,
request
.
POST
,
provided_id
)),
mimetype
=
"application/json"
)
except
etree
.
XMLSyntaxError
:
return
HttpResponse
(
"Failed to save: malformed html"
,
status
=
515
,
content_type
=
"text/plain"
)
@expect_json
...
...
cms/static/js/views/course_info_edit.js
View file @
b5fd6c90
...
...
@@ -99,7 +99,10 @@ CMS.Views.ClassInfoUpdateView = Backbone.View.extend({
var
targetModel
=
this
.
eventModel
(
event
);
targetModel
.
set
({
date
:
this
.
dateEntry
(
event
).
val
(),
content
:
this
.
$codeMirror
.
getValue
()
});
// push change to display, hide the editor, submit the change
targetModel
.
save
();
targetModel
.
save
({},
{
error
:
function
(
model
,
xhr
)
{
// TODO use a standard component
window
.
alert
(
xhr
.
responseText
);
}});
this
.
closeEditor
(
this
);
},
...
...
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