@ -505,6 +505,8 @@ def upload_single_file(request, book, book_id):
requested_file = request . files [ ' btn-upload-format ' ]
requested_file = request . files [ ' btn-upload-format ' ]
# check for empty request
# check for empty request
if requested_file . filename != ' ' :
if requested_file . filename != ' ' :
if not current_user . role_upload ( ) :
abort ( 403 )
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 constants . EXTENSIONS_UPLOAD and ' ' not in constants . EXTENSIONS_UPLOAD :
if file_ext not in constants . EXTENSIONS_UPLOAD and ' ' not in constants . EXTENSIONS_UPLOAD :
@ -555,9 +557,9 @@ def upload_single_file(request, book, book_id):
WorkerThread . add ( current_user . nickname , TaskUpload (
WorkerThread . add ( current_user . nickname , TaskUpload (
" <a href= \" " + url_for ( ' web.show_book ' , book_id = book . id ) + " \" > " + uploadText + " </a> " ) )
" <a href= \" " + url_for ( ' web.show_book ' , book_id = book . id ) + " \" > " + uploadText + " </a> " ) )
return uploader . process (
return uploader . process (
saved_filename , * os . path . splitext ( requested_file . filename ) ,
saved_filename , * os . path . splitext ( requested_file . filename ) ,
rarExecutable = config . config_rarfile_location )
rarExecutable = config . config_rarfile_location )
def upload_cover ( request , book ) :
def upload_cover ( request , book ) :
@ -565,6 +567,8 @@ def upload_cover(request, book):
requested_file = request . files [ ' btn-upload-cover ' ]
requested_file = request . files [ ' btn-upload-cover ' ]
# check for empty request
# check for empty request
if requested_file . filename != ' ' :
if requested_file . filename != ' ' :
if not current_user . role_upload ( ) :
abort ( 403 )
ret , message = helper . save_cover ( requested_file , book . path )
ret , message = helper . save_cover ( requested_file , book . path )
if ret is True :
if ret is True :
return True
return True
@ -645,13 +649,16 @@ def edit_book(book_id):
error = helper . update_dir_stucture ( edited_books_id , config . config_calibre_dir , input_authors [ 0 ] )
error = helper . update_dir_stucture ( edited_books_id , config . config_calibre_dir , input_authors [ 0 ] )
if not error :
if not error :
if to_save [ " cover_url " ] :
if " cover_url " in to_save :
result , error = helper . save_cover_from_url ( to_save [ " cover_url " ] , book . path )
if to_save [ " cover_url " ] :
if result is True :
if not current_user . role_upload ( ) :
book . has_cover = 1
return " " , ( 403 )
modif_date = True
result , error = helper . save_cover_from_url ( to_save [ " cover_url " ] , book . path )
else :
if result is True :
flash ( error , category = " error " )
book . has_cover = 1
modif_date = True
else :
flash ( error , category = " error " )
# Add default series_index to book
# Add default series_index to book
modif_date | = edit_book_series_index ( to_save [ " series_index " ] , book )
modif_date | = edit_book_series_index ( to_save [ " series_index " ] , book )