|
|
|
@ -165,15 +165,15 @@ def edit_book_by_id(id):
|
|
|
|
|
flash('No selected file')
|
|
|
|
|
return redirect(request.url)
|
|
|
|
|
if file and allowed_file(file.filename):
|
|
|
|
|
filename = secure_filename(file.filename)
|
|
|
|
|
allbooks = db.session.query(Book).all()
|
|
|
|
|
id = book.id
|
|
|
|
|
new_filename = str(id) +"_"+ filename
|
|
|
|
|
fullpath = os.path.join(app.config['UPLOAD_FOLDER'], new_filename)
|
|
|
|
|
name, file_extension = os.path.splitext(new_filename)
|
|
|
|
|
|
|
|
|
|
filename = str(id) + "_" + secure_filename(file.filename)
|
|
|
|
|
fullpath = os.path.join(app.config['UPLOAD_FOLDER'], filename)
|
|
|
|
|
name, file_extension = os.path.splitext(filename)
|
|
|
|
|
file.save(fullpath)
|
|
|
|
|
book.cover = get_cover(fullpath, name)
|
|
|
|
|
book.file = new_filename
|
|
|
|
|
book.file = filename
|
|
|
|
|
else:
|
|
|
|
|
flash('allowed file formats: %s' % ALLOWED_EXTENSIONS)
|
|
|
|
|
|
|
|
|
@ -211,12 +211,12 @@ def add_book():
|
|
|
|
|
flash('No selected file')
|
|
|
|
|
return redirect(request.url)
|
|
|
|
|
if file and allowed_file(file.filename):
|
|
|
|
|
filename = secure_filename(file.filename)
|
|
|
|
|
allbooks = db.session.query(Book).all()
|
|
|
|
|
id = len(allbooks)+1
|
|
|
|
|
new_filename = str(id) +"_"+ filename
|
|
|
|
|
fullpath = os.path.join(app.config['UPLOAD_FOLDER'], new_filename)
|
|
|
|
|
name, file_extension = os.path.splitext(new_filename)
|
|
|
|
|
filename = str(id) + "_" + secure_filename(file.filename)
|
|
|
|
|
|
|
|
|
|
fullpath = os.path.join(app.config['UPLOAD_FOLDER'], filename)
|
|
|
|
|
name, file_extension = os.path.splitext(filename)
|
|
|
|
|
file.save(fullpath)
|
|
|
|
|
cover = get_cover(fullpath, name)
|
|
|
|
|
else:
|
|
|
|
|