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
e7088d50
Commit
e7088d50
authored
Jul 02, 2013
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display error message when trying to upload a non-PDF file as a PDF textbook
parent
7506562f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
12 deletions
+9
-12
cms/static/js/views/textbook.js
+7
-10
cms/templates/js/upload-dialog.underscore
+2
-2
No files found.
cms/static/js/views/textbook.js
View file @
e7088d50
...
@@ -269,10 +269,9 @@ CMS.Views.UploadDialog = Backbone.View.extend({
...
@@ -269,10 +269,9 @@ CMS.Views.UploadDialog = Backbone.View.extend({
initialize
:
function
()
{
initialize
:
function
()
{
this
.
template
=
_
.
template
(
$
(
"#upload-dialog-tpl"
).
text
());
this
.
template
=
_
.
template
(
$
(
"#upload-dialog-tpl"
).
text
());
this
.
listenTo
(
this
.
model
,
"change"
,
this
.
render
);
this
.
listenTo
(
this
.
model
,
"change"
,
this
.
render
);
this
.
listenTo
(
this
.
model
,
"invalid"
,
this
.
handleInvalid
);
},
},
render
:
function
()
{
render
:
function
()
{
if
(
!
this
.
model
.
isValid
())
{
return
this
;}
var
isValid
=
this
.
model
.
isValid
()
var
selectedFile
=
this
.
model
.
get
(
'selectedFile'
);
var
selectedFile
=
this
.
model
.
get
(
'selectedFile'
);
var
oldInput
=
this
.
$
(
"input[type=file]"
).
get
(
0
);
var
oldInput
=
this
.
$
(
"input[type=file]"
).
get
(
0
);
this
.
$el
.
html
(
this
.
template
({
this
.
$el
.
html
(
this
.
template
({
...
@@ -287,12 +286,15 @@ CMS.Views.UploadDialog = Backbone.View.extend({
...
@@ -287,12 +286,15 @@ CMS.Views.UploadDialog = Backbone.View.extend({
finished
:
this
.
model
.
get
(
'finished'
),
finished
:
this
.
model
.
get
(
'finished'
),
error
:
this
.
model
.
validationError
error
:
this
.
model
.
validationError
}));
}));
//
i
deally, we'd like to tell the browser to pre-populate the
//
I
deally, we'd like to tell the browser to pre-populate the
// <input type="file"> with the selectedFile if we have one -- but
// <input type="file"> with the selectedFile if we have one -- but
// browser security prohibits that. So instead, we'll swap out the
// browser security prohibits that. So instead, we'll swap out the
// new input (that has no file selected) with the old input (that
// new input (that has no file selected) with the old input (that
// already has the selectedFile selected).
// already has the selectedFile selected). However, we only want to do
if
(
selectedFile
)
{
// this if the selected file is valid: if it isn't, we want to render
// a blank input to prompt the user to upload a different (valid) file.
if
(
selectedFile
&&
isValid
)
{
$
(
oldInput
).
removeClass
(
"error"
);
this
.
$
(
'input[type=file]'
).
replaceWith
(
oldInput
);
this
.
$
(
'input[type=file]'
).
replaceWith
(
oldInput
);
}
}
return
this
;
return
this
;
...
@@ -323,11 +325,6 @@ CMS.Views.UploadDialog = Backbone.View.extend({
...
@@ -323,11 +325,6 @@ CMS.Views.UploadDialog = Backbone.View.extend({
if
(
e
&&
e
.
preventDefault
)
{
e
.
preventDefault
();
}
if
(
e
&&
e
.
preventDefault
)
{
e
.
preventDefault
();
}
return
this
.
hide
().
remove
();
return
this
.
hide
().
remove
();
},
},
handleInvalid
:
function
(
model
,
error
,
options
)
{
model
.
set
({
selectedFile
:
null
});
},
upload
:
function
(
e
)
{
upload
:
function
(
e
)
{
this
.
model
.
set
(
'uploading'
,
true
);
this
.
model
.
set
(
'uploading'
,
true
);
this
.
$
(
"form"
).
ajaxSubmit
({
this
.
$
(
"form"
).
ajaxSubmit
({
...
...
cms/templates/js/upload-dialog.underscore
View file @
e7088d50
...
@@ -11,11 +11,11 @@
...
@@ -11,11 +11,11 @@
<h2 class="title"><%= title %></h2>
<h2 class="title"><%= title %></h2>
<% if(error) {%>
<% if(error) {%>
<div id="upload_error" class="message message-status message-status error is-shown" name="upload_error">
<div id="upload_error" class="message message-status message-status error is-shown" name="upload_error">
<p><%=
error
%></p>
<p><%=
gettext(error.message)
%></p>
</div>
</div>
<% } %>
<% } %>
<p id="dialog-assetupload-description" class="message"><%= message %></p>
<p id="dialog-assetupload-description" class="message"><%= message %></p>
<input type="file" name="file" />
<input type="file" name="file"
<% if(error && error.attributes && error.attributes.selectedFile) {%>class="error"<% } %>
/>
<div class="status-upload">
<div class="status-upload">
...
...
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