|
|
@ -165,15 +165,15 @@ def edit_book_by_id(id):
|
|
|
|
flash('No selected file')
|
|
|
|
flash('No selected file')
|
|
|
|
return redirect(request.url)
|
|
|
|
return redirect(request.url)
|
|
|
|
if file and allowed_file(file.filename):
|
|
|
|
if file and allowed_file(file.filename):
|
|
|
|
filename = secure_filename(file.filename)
|
|
|
|
|
|
|
|
allbooks = db.session.query(Book).all()
|
|
|
|
allbooks = db.session.query(Book).all()
|
|
|
|
id = book.id
|
|
|
|
id = book.id
|
|
|
|
new_filename = str(id) +"_"+ filename
|
|
|
|
|
|
|
|
fullpath = os.path.join(app.config['UPLOAD_FOLDER'], new_filename)
|
|
|
|
filename = str(id) + "_" + secure_filename(file.filename)
|
|
|
|
name, file_extension = os.path.splitext(new_filename)
|
|
|
|
fullpath = os.path.join(app.config['UPLOAD_FOLDER'], filename)
|
|
|
|
|
|
|
|
name, file_extension = os.path.splitext(filename)
|
|
|
|
file.save(fullpath)
|
|
|
|
file.save(fullpath)
|
|
|
|
book.cover = get_cover(fullpath, name)
|
|
|
|
book.cover = get_cover(fullpath, name)
|
|
|
|
book.file = new_filename
|
|
|
|
book.file = filename
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
flash('allowed file formats: %s' % ALLOWED_EXTENSIONS)
|
|
|
|
flash('allowed file formats: %s' % ALLOWED_EXTENSIONS)
|
|
|
|
|
|
|
|
|
|
|
@ -211,12 +211,12 @@ def add_book():
|
|
|
|
flash('No selected file')
|
|
|
|
flash('No selected file')
|
|
|
|
return redirect(request.url)
|
|
|
|
return redirect(request.url)
|
|
|
|
if file and allowed_file(file.filename):
|
|
|
|
if file and allowed_file(file.filename):
|
|
|
|
filename = secure_filename(file.filename)
|
|
|
|
|
|
|
|
allbooks = db.session.query(Book).all()
|
|
|
|
allbooks = db.session.query(Book).all()
|
|
|
|
id = len(allbooks)+1
|
|
|
|
id = len(allbooks)+1
|
|
|
|
new_filename = str(id) +"_"+ filename
|
|
|
|
filename = str(id) + "_" + secure_filename(file.filename)
|
|
|
|
fullpath = os.path.join(app.config['UPLOAD_FOLDER'], new_filename)
|
|
|
|
|
|
|
|
name, file_extension = os.path.splitext(new_filename)
|
|
|
|
fullpath = os.path.join(app.config['UPLOAD_FOLDER'], filename)
|
|
|
|
|
|
|
|
name, file_extension = os.path.splitext(filename)
|
|
|
|
file.save(fullpath)
|
|
|
|
file.save(fullpath)
|
|
|
|
cover = get_cover(fullpath, name)
|
|
|
|
cover = get_cover(fullpath, name)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -369,7 +369,7 @@ def show_books():
|
|
|
|
return render_template ('show_books.html', books=books, form=search)
|
|
|
|
return render_template ('show_books.html', books=books, form=search)
|
|
|
|
|
|
|
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
if request.method == 'POST':
|
|
|
|
newmsg = 'searched for: ' + search.search.data
|
|
|
|
newmsg = 'searched for: ' + search.search.data
|
|
|
|
# message = search.search.data
|
|
|
|
# message = search.search.data
|
|
|
|
# newmessage = Chat(message)
|
|
|
|
# newmessage = Chat(message)
|
|
|
|
# db.session.add(newmessage)
|
|
|
|
# db.session.add(newmessage)
|
|
|
@ -422,7 +422,7 @@ def search_results(searchtype, query, viewby):
|
|
|
|
|
|
|
|
|
|
|
|
count = results.count()
|
|
|
|
count = results.count()
|
|
|
|
whole = Book.query.count()
|
|
|
|
whole = Book.query.count()
|
|
|
|
percentage = float(count / whole * 100)
|
|
|
|
percentage = float(count / whole * 100)
|
|
|
|
|
|
|
|
|
|
|
|
if search.listview.data:
|
|
|
|
if search.listview.data:
|
|
|
|
view.append('1')
|
|
|
|
view.append('1')
|
|
|
@ -433,7 +433,7 @@ def search_results(searchtype, query, viewby):
|
|
|
|
return render_template('results_grid.html', books=results, form=search, query=query, books_all=random_order, searchtype=search.select.data, count = count, whole = whole, percentage = percentage)
|
|
|
|
return render_template('results_grid.html', books=results, form=search, query=query, books_all=random_order, searchtype=search.select.data, count = count, whole = whole, percentage = percentage)
|
|
|
|
|
|
|
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
if request.method == 'POST':
|
|
|
|
newmsg = 'searched for: ' + search.search.data
|
|
|
|
newmsg = 'searched for: ' + search.search.data
|
|
|
|
socketio.emit('channel-' + str(1), {
|
|
|
|
socketio.emit('channel-' + str(1), {
|
|
|
|
'username': 'Search form',
|
|
|
|
'username': 'Search form',
|
|
|
|
'text': search.search.data,
|
|
|
|
'text': search.search.data,
|
|
|
@ -445,7 +445,7 @@ def search_results(searchtype, query, viewby):
|
|
|
|
db.session.commit()
|
|
|
|
db.session.commit()
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
db.session.rollback()
|
|
|
|
db.session.rollback()
|
|
|
|
|
|
|
|
|
|
|
|
query = search.search.data
|
|
|
|
query = search.search.data
|
|
|
|
results = []
|
|
|
|
results = []
|
|
|
|
if viewby == '1':
|
|
|
|
if viewby == '1':
|
|
|
@ -453,7 +453,7 @@ def search_results(searchtype, query, viewby):
|
|
|
|
return redirect((url_for('search_results', searchtype=search.select.data, query=search.search.data, viewby=viewby)))
|
|
|
|
return redirect((url_for('search_results', searchtype=search.select.data, query=search.search.data, viewby=viewby)))
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return redirect((url_for('search_results', searchtype=search.select.data, query=search.search.data, viewby=viewby)))
|
|
|
|
return redirect((url_for('search_results', searchtype=search.select.data, query=search.search.data, viewby=viewby)))
|
|
|
|
|
|
|
|
|
|
|
|
if viewby == '2':
|
|
|
|
if viewby == '2':
|
|
|
|
return render_template('results_grid.html', form=search, books=results, books_all=random_order, searchtype=search.select.data, query=query, count = count, whole = whole, percentage = percentage)
|
|
|
|
return render_template('results_grid.html', form=search, books=results, books_all=random_order, searchtype=search.select.data, query=query, count = count, whole = whole, percentage = percentage)
|
|
|
|
|
|
|
|
|
|
|
|