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
0192a04b
Commit
0192a04b
authored
Dec 18, 2012
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed course_info parsing bug.
Addressed some of Christina's review comments.
parent
5709ff34
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
27 deletions
+11
-27
cms/djangoapps/contentstore/course_info_model.py
+7
-24
cms/djangoapps/models/settings/course_details.py
+2
-1
cms/static/js/models/settings/course_details.js
+2
-2
No files found.
cms/djangoapps/contentstore/course_info_model.py
View file @
0192a04b
...
@@ -4,6 +4,7 @@ from xmodule.modulestore.django import modulestore
...
@@ -4,6 +4,7 @@ from xmodule.modulestore.django import modulestore
from
lxml
import
etree
from
lxml
import
etree
import
re
import
re
from
django.http
import
HttpResponseBadRequest
from
django.http
import
HttpResponseBadRequest
import
logging
## TODO store as array of { date, content } and override course_info_module.definition_from_xml
## TODO store as array of { date, content } and override course_info_module.definition_from_xml
## This should be in a class which inherits from XmlDescriptor
## This should be in a class which inherits from XmlDescriptor
...
@@ -65,9 +66,11 @@ def update_course_updates(location, update, passed_id=None):
...
@@ -65,9 +66,11 @@ def update_course_updates(location, update, passed_id=None):
course_html_parsed
=
etree
.
fromstring
(
"<ol></ol>"
)
course_html_parsed
=
etree
.
fromstring
(
"<ol></ol>"
)
try
:
try
:
new_html_parsed
=
etree
.
fromstring
(
update
[
'content'
],
etree
.
XMLParser
(
remove_blank_text
=
True
))
new_html_parsed
=
etree
.
fromstring
(
'<li><h2>'
+
update
[
'date'
]
+
'</h2>'
+
update
[
'content'
]
+
'</li>'
,
etree
.
XMLParser
(
remove_blank_text
=
True
))
except
etree
.
XMLSyntaxError
:
except
etree
.
XMLSyntaxError
:
new_html_parsed
=
None
logging
.
debug
(
"Mashing malformed update"
)
new_html_parsed
=
'<li><h2>'
+
update
[
'date'
]
+
'</h2>'
+
update
[
'content'
]
+
'</li>'
# Confirm that root is <ol>, iterate over <li>, pull out <h2> subs and then rest of val
# Confirm that root is <ol>, iterate over <li>, pull out <h2> subs and then rest of val
if
course_html_parsed
.
tag
==
'ol'
:
if
course_html_parsed
.
tag
==
'ol'
:
...
@@ -75,29 +78,9 @@ def update_course_updates(location, update, passed_id=None):
...
@@ -75,29 +78,9 @@ def update_course_updates(location, update, passed_id=None):
if
passed_id
:
if
passed_id
:
idx
=
get_idx
(
passed_id
)
idx
=
get_idx
(
passed_id
)
# idx is count from end of list
# idx is count from end of list
element
=
course_html_parsed
[
-
idx
]
course_html_parsed
[
-
idx
]
=
new_html_parsed
element
[
0
]
.
text
=
update
[
'date'
]
if
(
len
(
element
)
==
1
):
if
new_html_parsed
is
not
None
:
element
[
0
]
.
tail
=
None
element
.
append
(
new_html_parsed
)
else
:
element
[
0
]
.
tail
=
update
[
'content'
]
else
:
if
new_html_parsed
is
not
None
:
element
[
1
]
=
new_html_parsed
else
:
element
.
pop
(
1
)
element
[
0
]
.
tail
=
update
[
'content'
]
else
:
else
:
element
=
etree
.
Element
(
"li"
)
course_html_parsed
.
insert
(
0
,
new_html_parsed
)
course_html_parsed
.
insert
(
0
,
element
)
date_element
=
etree
.
SubElement
(
element
,
"h2"
)
date_element
.
text
=
update
[
'date'
]
if
new_html_parsed
is
not
None
:
element
.
append
(
new_html_parsed
)
else
:
date_element
.
tail
=
update
[
'content'
]
idx
=
len
(
course_html_parsed
)
idx
=
len
(
course_html_parsed
)
passed_id
=
course_updates
.
location
.
url
()
+
"/"
+
str
(
idx
)
passed_id
=
course_updates
.
location
.
url
()
+
"/"
+
str
(
idx
)
...
...
cms/djangoapps/models/settings/course_details.py
View file @
0192a04b
...
@@ -9,6 +9,7 @@ from util.converters import jsdate_to_time, time_to_date
...
@@ -9,6 +9,7 @@ from util.converters import jsdate_to_time, time_to_date
from
cms.djangoapps.models.settings
import
course_grading
from
cms.djangoapps.models.settings
import
course_grading
from
cms.djangoapps.contentstore.utils
import
update_item
from
cms.djangoapps.contentstore.utils
import
update_item
import
re
import
re
import
logging
class
CourseDetails
:
class
CourseDetails
:
...
@@ -155,7 +156,7 @@ class CourseDetails:
...
@@ -155,7 +156,7 @@ class CourseDetails:
if
keystring_matcher
:
if
keystring_matcher
:
return
keystring_matcher
.
group
(
0
)
return
keystring_matcher
.
group
(
0
)
else
:
else
:
# TODO should this be None or the raw_video? It would be good to at least log this
logging
.
warn
(
"ignoring the content because it doesn't not conform to expected pattern: "
+
raw_video
)
return
None
return
None
@staticmethod
@staticmethod
...
...
cms/static/js/models/settings/course_details.js
View file @
0192a04b
...
@@ -49,7 +49,7 @@ CMS.Models.Settings.CourseDetails = Backbone.Model.extend({
...
@@ -49,7 +49,7 @@ CMS.Models.Settings.CourseDetails = Backbone.Model.extend({
if
(
newattrs
.
end_date
&&
newattrs
.
enrollment_end
&&
newattrs
.
end_date
<
newattrs
.
enrollment_end
)
{
if
(
newattrs
.
end_date
&&
newattrs
.
enrollment_end
&&
newattrs
.
end_date
<
newattrs
.
enrollment_end
)
{
errors
.
enrollment_end
=
"The enrollment end date cannot be after the course end date."
;
errors
.
enrollment_end
=
"The enrollment end date cannot be after the course end date."
;
}
}
if
(
newattrs
.
intro_video
&&
newattrs
.
intro_video
!=
this
.
get
(
'intro_video'
))
{
if
(
newattrs
.
intro_video
&&
newattrs
.
intro_video
!=
=
this
.
get
(
'intro_video'
))
{
if
(
this
.
_videokey_illegal_chars
.
exec
(
newattrs
.
intro_video
))
{
if
(
this
.
_videokey_illegal_chars
.
exec
(
newattrs
.
intro_video
))
{
errors
.
intro_video
=
"Key should only contain letters, numbers, _, or -"
;
errors
.
intro_video
=
"Key should only contain letters, numbers, _, or -"
;
}
}
...
@@ -71,7 +71,7 @@ CMS.Models.Settings.CourseDetails = Backbone.Model.extend({
...
@@ -71,7 +71,7 @@ CMS.Models.Settings.CourseDetails = Backbone.Model.extend({
if
(
_
.
isEmpty
(
newsource
)
&&
!
_
.
isEmpty
(
this
.
get
(
'intro_video'
)))
this
.
save
({
'intro_video'
:
null
});
if
(
_
.
isEmpty
(
newsource
)
&&
!
_
.
isEmpty
(
this
.
get
(
'intro_video'
)))
this
.
save
({
'intro_video'
:
null
});
// TODO remove all whitespace w/in string
// TODO remove all whitespace w/in string
else
{
else
{
if
(
this
.
get
(
'intro_video'
)
!=
newsource
)
this
.
save
(
'intro_video'
,
newsource
);
if
(
this
.
get
(
'intro_video'
)
!=
=
newsource
)
this
.
save
(
'intro_video'
,
newsource
);
}
}
return
this
.
videosourceSample
();
return
this
.
videosourceSample
();
...
...
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