Commit 361a1243 authored by Ozzieisaacs's avatar Ozzieisaacs

Improvements #828

parent fad62a09
...@@ -132,8 +132,8 @@ ...@@ -132,8 +132,8 @@
// Replace the contents of the form, with the returned html // Replace the contents of the form, with the returned html
if (xhr.status === 422) { if (xhr.status === 422) {
var newHtml = $.parseHTML(xhr.responseText); var newHtml = $.parseHTML(xhr.responseText);
this.replace_form(newHtml); this.$modalBar.text(newHtml[0].data);
this.$modal.modal("hide"); //this.$modal.modal("hide");
} }
// Write the error response to the document. // Write the error response to the document.
else{ else{
......
...@@ -62,7 +62,8 @@ ...@@ -62,7 +62,8 @@
<li> <li>
<form id="form-upload" class="navbar-form" action="{{ url_for('upload') }}" method="post" enctype="multipart/form-data"> <form id="form-upload" class="navbar-form" action="{{ url_for('upload') }}" method="post" enctype="multipart/form-data">
<div class="form-group"> <div class="form-group">
<span class="btn btn-default btn-file">{{_('Upload')}}<input id="btn-upload" name="btn-upload" type="file" multiple></span> <span class="btn btn-default btn-file">{{_('Upload')}}<input id="btn-upload" name="btn-upload"
type="file" accept="{% for format in accept %}.{{format}}{{ ',' if not loop.last }}{% endfor %}" multiple></span>
</div> </div>
</form> </form>
</li> </li>
......
This diff is collapsed.
...@@ -698,7 +698,7 @@ def render_xml_template(*args, **kwargs): ...@@ -698,7 +698,7 @@ def render_xml_template(*args, **kwargs):
# Returns the template for redering and includes the instance name # Returns the template for redering and includes the instance name
def render_title_template(*args, **kwargs): def render_title_template(*args, **kwargs):
return render_template(instance=config.config_calibre_web_title, *args, **kwargs) return render_template(instance=config.config_calibre_web_title, accept=EXTENSIONS_UPLOAD, *args, **kwargs)
@app.before_request @app.before_request
...@@ -3733,13 +3733,10 @@ def upload(): ...@@ -3733,13 +3733,10 @@ def upload():
if '.' in requested_file.filename: if '.' in requested_file.filename:
file_ext = requested_file.filename.rsplit('.', 1)[-1].lower() file_ext = requested_file.filename.rsplit('.', 1)[-1].lower()
if file_ext not in EXTENSIONS_UPLOAD: if file_ext not in EXTENSIONS_UPLOAD:
flash( return Response(_("File extension '%(ext)s' is not allowed to be uploaded to this server",
_("File extension '%(ext)s' is not allowed to be uploaded to this server", ext=file_ext)), 422
ext=file_ext), category="error")
return redirect(url_for('index'))
else: else:
flash(_('File to be uploaded must have an extension'), category="error") return Response(_('File to be uploaded must have an extension')), 422
return redirect(url_for('index'))
# extract metadata from file # extract metadata from file
meta = uploader.upload(requested_file) meta = uploader.upload(requested_file)
...@@ -3758,13 +3755,12 @@ def upload(): ...@@ -3758,13 +3755,12 @@ def upload():
try: try:
os.makedirs(filepath) os.makedirs(filepath)
except OSError: except OSError:
flash(_(u"Failed to create path %(path)s (Permission denied).", path=filepath), category="error") return Response(_(u"Failed to create path %(path)s (Permission denied).", path=filepath)), 422
return redirect(url_for('index'))
try: try:
copyfile(meta.file_path, saved_filename) copyfile(meta.file_path, saved_filename)
except OSError: except OSError:
flash(_(u"Failed to store file %(file)s (Permission denied).", file=saved_filename), category="error") return Response(_(u"Failed to store file %(file)s (Permission denied).", file=saved_filename)), 422
return redirect(url_for('index'))
try: try:
os.unlink(meta.file_path) os.unlink(meta.file_path)
except OSError: except OSError:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment