|
|
|
@ -469,6 +469,8 @@ def upload_single_file(request, book, book_id):
|
|
|
|
|
requested_file = request.files['btn-upload-format']
|
|
|
|
|
# check for empty request
|
|
|
|
|
if requested_file.filename != '':
|
|
|
|
|
if not current_user.role_upload():
|
|
|
|
|
abort(403)
|
|
|
|
|
if '.' in requested_file.filename:
|
|
|
|
|
file_ext = requested_file.filename.rsplit('.', 1)[-1].lower()
|
|
|
|
|
if file_ext not in constants.EXTENSIONS_UPLOAD and '' not in constants.EXTENSIONS_UPLOAD:
|
|
|
|
@ -529,6 +531,8 @@ def upload_cover(request, book):
|
|
|
|
|
requested_file = request.files['btn-upload-cover']
|
|
|
|
|
# check for empty request
|
|
|
|
|
if requested_file.filename != '':
|
|
|
|
|
if not current_user.role_upload():
|
|
|
|
|
abort(403)
|
|
|
|
|
ret, message = helper.save_cover(requested_file, book.path)
|
|
|
|
|
if ret is True:
|
|
|
|
|
return True
|
|
|
|
@ -609,6 +613,8 @@ def edit_book(book_id):
|
|
|
|
|
|
|
|
|
|
if not error:
|
|
|
|
|
if to_save["cover_url"]:
|
|
|
|
|
if not current_user.role_upload() and to_save["cover_url"] != "":
|
|
|
|
|
return "", (403)
|
|
|
|
|
result, error = helper.save_cover_from_url(to_save["cover_url"], book.path)
|
|
|
|
|
if result is True:
|
|
|
|
|
book.has_cover = 1
|
|
|
|
|