Merge remote-tracking branch 'multiload/master'

pull/473/head
OzzieIsaacs 7 years ago
commit ee5677f376

@ -55,11 +55,20 @@
<ul class="nav navbar-nav navbar-right" id="main-nav"> <ul class="nav navbar-nav navbar-right" id="main-nav">
{% if g.user.is_authenticated or g.user.is_anonymous %} {% if g.user.is_authenticated or g.user.is_anonymous %}
{% if g.user.role_upload() or g.user.role_admin()%} {% if g.user.role_upload() or g.user.role_admin()%}
{% if g.allow_upload %}
<li>
<form id="form-upload-multi" class="navbar-form" action="{{ url_for('upload') }}" method="post" enctype="multipart/form-data">
<div class="form-group">
<span class="btn btn-default btn-file">{{_('Upload')}} multiple books<input id="btn-upload-multi" name="btn-upload" type="file" multiple></span>
</div>
</form>
</li>
{% endif %}
{% if g.allow_upload %} {% if g.allow_upload %}
<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"></span> <span class="btn btn-default btn-file">{{_('Upload')}} a single book<input id="btn-upload" name="btn-upload" type="file"></span>
</div> </div>
</form> </form>
</li> </li>
@ -98,6 +107,14 @@
</div> </div>
{%endif%} {%endif%}
{% endfor %} {% endfor %}
<div id="loader" hidden="true">
<center>
<h3>Uploading...</h3>
<span>please don't refresh the page</span>.
<br />
<img src="{{ url_for('static', filename='img/loader.gif') }}">
</center>
</div>
<div class="container-fluid"> <div class="container-fluid">
<div class="row-fluid"> <div class="row-fluid">
{% if g.user.is_authenticated or g.user.is_anonymous %} {% if g.user.is_authenticated or g.user.is_anonymous %}
@ -226,8 +243,13 @@
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
$("#btn-upload").change(function () { $("#btn-upload").change(function () {
$("#loader").show();
$("#form-upload").submit(); $("#form-upload").submit();
}); });
$("#btn-upload-multi").change(function () {
$("#loader").show();
$("#form-upload-multi").submit();
});
}); });
</script> </script>

@ -3174,10 +3174,10 @@ def upload():
if not config.config_uploading: if not config.config_uploading:
abort(404) abort(404)
# create the function for sorting... # create the function for sorting...
if request.method == 'POST' and 'btn-upload' in request.files:
for requested_file in request.files.getlist("btn-upload"):
db.session.connection().connection.connection.create_function("title_sort", 1, db.title_sort) db.session.connection().connection.connection.create_function("title_sort", 1, db.title_sort)
db.session.connection().connection.connection.create_function('uuid4', 0, lambda: str(uuid4())) db.session.connection().connection.connection.create_function('uuid4', 0, lambda: str(uuid4()))
if request.method == 'POST' and 'btn-upload' in request.files:
requested_file = request.files['btn-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 ALLOWED_EXTENSIONS: if file_ext not in ALLOWED_EXTENSIONS:
@ -3285,17 +3285,16 @@ def upload():
author_names.append(author.name) author_names.append(author.name)
if config.config_use_google_drive: if config.config_use_google_drive:
updateGdriveCalibreFromLocal() updateGdriveCalibreFromLocal()
if len(request.files.getlist("btn-upload")) < 2:
cc = db.session.query(db.Custom_Columns).filter(db.Custom_Columns.datatype.notin_(db.cc_exceptions)).all() cc = db.session.query(db.Custom_Columns).filter(db.Custom_Columns.datatype.notin_(db.cc_exceptions)).all()
if current_user.role_edit() or current_user.role_admin(): if current_user.role_edit() or current_user.role_admin():
return render_title_template('book_edit.html', book=db_book, authors=author_names, cc=cc, return render_title_template('book_edit.html', book=db_book, authors=author_names, cc=cc,title=_(u"edit metadata"))
title=_(u"edit metadata"))
book_in_shelfs = [] book_in_shelfs = []
return render_title_template('detail.html', entry=db_book, cc=cc, title=db_book.title, return render_title_template('detail.html', entry=db_book, cc=cc, title=db_book.title, books_shelfs=book_in_shelfs, )
books_shelfs=book_in_shelfs, ) return redirect(url_for("index"))
else: else:
return redirect(url_for("index")) return redirect(url_for("index"))
def start_gevent(): def start_gevent():
from gevent.wsgi import WSGIServer from gevent.wsgi import WSGIServer
global gevent_server global gevent_server

Loading…
Cancel
Save