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
783e4b22
Commit
783e4b22
authored
Nov 07, 2013
by
Zubair Afzal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show error on invalid html in course handout edit + Added tests
STUD-293
parent
bc4ebfdc
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
98 additions
and
19 deletions
+98
-19
cms/djangoapps/contentstore/features/course-updates.feature
+14
-0
cms/djangoapps/contentstore/features/course-updates.py
+29
-0
cms/static/coffee/spec/views/course_info_spec.coffee
+20
-0
cms/static/js/views/course_info_handout.js
+29
-17
cms/static/js/views/course_info_helper.js
+4
-1
cms/templates/js/course_info_handouts.underscore
+2
-1
No files found.
cms/djangoapps/contentstore/features/course-updates.feature
View file @
783e4b22
...
@@ -76,3 +76,17 @@ Feature: CMS.Course updates
...
@@ -76,3 +76,17 @@ Feature: CMS.Course updates
Then
I see the handout
"/c4x/MITx/999/asset/modified.jpg"
Then
I see the handout
"/c4x/MITx/999/asset/modified.jpg"
And
when I reload the page
And
when I reload the page
Then
I see the handout
"/c4x/MITx/999/asset/modified.jpg"
Then
I see the handout
"/c4x/MITx/999/asset/modified.jpg"
Scenario
:
Users cannot save handouts with bad html until edit or update it properly
Given
I have opened a new course in Studio
And
I go to the course updates page
When
I modify the handout to
"<p><a href=>[LINK TEXT]</a></p>"
Then
I see the handout error text
And
I see handout save button disabled
When I edit the handout to "<p><a href='https
:
//www.google.com.pk/'>home</a></p>"
Then
I see handout save button re-enabled
When
I save handout edit
# Can only do partial text matches because of the quotes with in quotes (and regexp step matching).
Then I see the handout "https
:
//www.google.com.pk/"
And
when I reload the page
Then I see the handout "https
:
//www.google.com.pk/"
cms/djangoapps/contentstore/features/course-updates.py
View file @
783e4b22
...
@@ -90,6 +90,35 @@ def check_handout(_step, handout):
...
@@ -90,6 +90,35 @@ def check_handout(_step, handout):
assert
handout
in
world
.
css_html
(
handout_css
)
assert
handout
in
world
.
css_html
(
handout_css
)
@step
(
u'I see the handout error text'
)
def
check_handout_error
(
_step
):
handout_error_css
=
'div#handout_error'
assert
world
.
css_has_class
(
handout_error_css
,
'is-shown'
)
@step
(
u'I see handout save button disabled'
)
def
check_handout_error
(
_step
):
handout_save_button
=
'form.edit-handouts-form a.save-button'
assert
world
.
css_has_class
(
handout_save_button
,
'is-disabled'
)
@step
(
u'I edit the handout to "([^"]*)"$'
)
def
edit_handouts
(
_step
,
text
):
type_in_codemirror
(
0
,
text
)
@step
(
u'I see handout save button re-enabled'
)
def
check_handout_error
(
_step
):
handout_save_button
=
'form.edit-handouts-form a.save-button'
assert
not
world
.
css_has_class
(
handout_save_button
,
'is-disabled'
)
@step
(
u'I save handout edit'
)
def
check_handout_error
(
_step
):
save_css
=
'a.save-button'
world
.
css_click
(
save_css
)
def
change_text
(
text
):
def
change_text
(
text
):
type_in_codemirror
(
0
,
text
)
type_in_codemirror
(
0
,
text
)
save_css
=
'a.save-button'
save_css
=
'a.save-button'
...
...
cms/static/coffee/spec/views/course_info_spec.coffee
View file @
783e4b22
...
@@ -196,3 +196,22 @@ define ["js/views/course_info_handout", "js/views/course_info_update", "js/model
...
@@ -196,3 +196,22 @@ define ["js/views/course_info_handout", "js/views/course_info_update", "js/model
@
handoutsEdit
.
$el
.
find
(
'.edit-button'
).
click
()
@
handoutsEdit
.
$el
.
find
(
'.edit-button'
).
click
()
expect
(
@
handoutsEdit
.
$codeMirror
.
getValue
().
trim
()).
toEqual
(
'/static/fromServer.jpg'
)
expect
(
@
handoutsEdit
.
$codeMirror
.
getValue
().
trim
()).
toEqual
(
'/static/fromServer.jpg'
)
it
"can open course handouts with bad html on edit"
,
->
# Enter some bad html in handouts section, verifying that the
# model/handoutform opens when "Edit" is clicked
@
model
=
new
ModuleInfo
({
id
:
'handouts-id'
,
data
:
'<p><a href="[URL OF FILE]>[LINK TEXT]</a></p>'
})
@
handoutsEdit
=
new
CourseInfoHandoutsView
({
el
:
$
(
'#course-handouts-view'
),
model
:
@
model
,
base_asset_url
:
'base-asset-url/'
});
@
handoutsEdit
.
render
()
expect
(
$
(
'.edit-handouts-form'
).
is
(
':hidden'
)).
toEqual
(
true
)
@
handoutsEdit
.
$el
.
find
(
'.edit-button'
).
click
()
expect
(
@
handoutsEdit
.
$codeMirror
.
getValue
()).
toEqual
(
'<p><a href="[URL OF FILE]>[LINK TEXT]</a></p>'
)
expect
(
$
(
'.edit-handouts-form'
).
is
(
':hidden'
)).
toEqual
(
false
)
\ No newline at end of file
cms/static/js/views/course_info_handout.js
View file @
783e4b22
...
@@ -30,6 +30,7 @@ define(["backbone", "underscore", "codemirror", "js/views/feedback_notification"
...
@@ -30,6 +30,7 @@ define(["backbone", "underscore", "codemirror", "js/views/feedback_notification"
model
:
this
.
model
model
:
this
.
model
}))
}))
);
);
$
(
'.handouts-content'
).
html
(
this
.
model
.
get
(
'data'
));
this
.
$preview
=
this
.
$el
.
find
(
'.handouts-content'
);
this
.
$preview
=
this
.
$el
.
find
(
'.handouts-content'
);
this
.
$form
=
this
.
$el
.
find
(
".edit-handouts-form"
);
this
.
$form
=
this
.
$el
.
find
(
".edit-handouts-form"
);
this
.
$editor
=
this
.
$form
.
find
(
'.handouts-content-editor'
);
this
.
$editor
=
this
.
$form
.
find
(
'.handouts-content-editor'
);
...
@@ -50,32 +51,43 @@ define(["backbone", "underscore", "codemirror", "js/views/feedback_notification"
...
@@ -50,32 +51,43 @@ define(["backbone", "underscore", "codemirror", "js/views/feedback_notification"
},
},
onSave
:
function
(
event
)
{
onSave
:
function
(
event
)
{
this
.
model
.
set
(
'data'
,
this
.
$codeMirror
.
getValue
());
$
(
'#handout_error'
).
removeClass
(
'is-shown'
);
var
saving
=
new
NotificationView
.
Mini
({
$
(
'.save-button'
).
removeClass
(
'is-disabled'
);
title
:
gettext
(
'Saving…'
)
if
(
$
(
'.CodeMirror-lines'
).
find
(
'.cm-error'
).
length
==
0
){
});
this
.
model
.
set
(
'data'
,
this
.
$codeMirror
.
getValue
());
saving
.
show
();
var
saving
=
new
NotificationView
.
Mini
({
this
.
model
.
save
({},
{
title
:
gettext
(
'Saving…'
)
success
:
function
()
{
});
saving
.
hide
();
saving
.
show
();
}
this
.
model
.
save
({},
{
});
success
:
function
()
{
this
.
render
();
saving
.
hide
();
this
.
$form
.
hide
();
}
this
.
closeEditor
();
});
this
.
render
();
analytics
.
track
(
'Saved Course Handouts'
,
{
this
.
$form
.
hide
();
'course'
:
course_location_analytics
this
.
closeEditor
();
});
analytics
.
track
(
'Saved Course Handouts'
,
{
'course'
:
course_location_analytics
});
}
else
{
$
(
'#handout_error'
).
addClass
(
'is-shown'
);
$
(
'.save-button'
).
addClass
(
'is-disabled'
);
event
.
preventDefault
();
}
},
},
onCancel
:
function
(
event
)
{
onCancel
:
function
(
event
)
{
$
(
'#handout_error'
).
removeClass
(
'is-shown'
);
$
(
'.save-button'
).
removeClass
(
'is-disabled'
);
this
.
$form
.
hide
();
this
.
$form
.
hide
();
this
.
closeEditor
();
this
.
closeEditor
();
},
},
closeEditor
:
function
()
{
closeEditor
:
function
()
{
$
(
'#handout_error'
).
removeClass
(
'is-shown'
);
$
(
'.save-button'
).
removeClass
(
'is-disabled'
);
this
.
$form
.
hide
();
this
.
$form
.
hide
();
ModalUtils
.
hideModalCover
();
ModalUtils
.
hideModalCover
();
this
.
$form
.
find
(
'.CodeMirror'
).
remove
();
this
.
$form
.
find
(
'.CodeMirror'
).
remove
();
...
...
cms/static/js/views/course_info_helper.js
View file @
783e4b22
...
@@ -6,7 +6,10 @@ define(["codemirror", "utility"],
...
@@ -6,7 +6,10 @@ define(["codemirror", "utility"],
var
$codeMirror
=
CodeMirror
.
fromTextArea
(
textArea
,
{
var
$codeMirror
=
CodeMirror
.
fromTextArea
(
textArea
,
{
mode
:
"text/html"
,
mode
:
"text/html"
,
lineNumbers
:
true
,
lineNumbers
:
true
,
lineWrapping
:
true
lineWrapping
:
true
,
onChange
:
function
()
{
$
(
'.save-button'
).
removeClass
(
'is-disabled'
);
}
});
});
$codeMirror
.
setValue
(
content
);
$codeMirror
.
setValue
(
content
);
$codeMirror
.
clearHistory
();
$codeMirror
.
clearHistory
();
...
...
cms/templates/js/course_info_handouts.underscore
View file @
783e4b22
...
@@ -3,12 +3,13 @@
...
@@ -3,12 +3,13 @@
<h2 class="title">Course Handouts</h2>
<h2 class="title">Course Handouts</h2>
<%if (model.get('data') != null) { %>
<%if (model.get('data') != null) { %>
<div class="handouts-content">
<div class="handouts-content">
<%= model.get('data') %>
</div>
</div>
<% } else {%>
<% } else {%>
<p>${_("You have no handouts defined")}</p>
<p>${_("You have no handouts defined")}</p>
<% } %>
<% } %>
<form class="edit-handouts-form" style="display: block;">
<form class="edit-handouts-form" style="display: block;">
<div class="message message-status error" name="handout_html_error" id="handout_error"><%=gettext("There is invalid code in your content. Please check to make sure it is valid HTML.")%></div>
<div class="row">
<div class="row">
<textarea class="handouts-content-editor text-editor"></textarea>
<textarea class="handouts-content-editor text-editor"></textarea>
</div>
</div>
...
...
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