|
|
|
@ -129,19 +129,10 @@ def remove_book_by_id(id):
|
|
|
|
|
flash("%s deleted from library" % (title))
|
|
|
|
|
return redirect(url_for('show_books'))
|
|
|
|
|
|
|
|
|
|
@app.route('/potential')
|
|
|
|
|
def htmlpdf():
|
|
|
|
|
paragraphs= ['test title']
|
|
|
|
|
template = 'app/templates/potential_pdf.html'
|
|
|
|
|
html_string = render_template('potential_pdf.html', paragraphs=paragraphs)
|
|
|
|
|
html = HTML(string=html_string)
|
|
|
|
|
html.write_pdf(target='app/uploads/potential2.pdf');
|
|
|
|
|
return render_template('potential_pdf.html', paragraphs=paragraphs)
|
|
|
|
|
|
|
|
|
|
@app.route('/books/<int:id>/edit', methods=['POST', 'GET'])
|
|
|
|
|
def edit_book_by_id(id):
|
|
|
|
|
book_to_edit = Book.query.filter_by(id=id).first()
|
|
|
|
|
user_form = EditForm(title = book_to_edit.title, author =book_to_edit.authors, category = book_to_edit.category, year_published= book_to_edit.year_published)
|
|
|
|
|
user_form = EditForm(title = book_to_edit.title, author =book_to_edit.authors, category = book_to_edit.category, year_published= book_to_edit.year_published, message= book_to_edit.message)
|
|
|
|
|
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
|
if user_form.validate_on_submit():
|
|
|
|
@ -204,6 +195,7 @@ def add_book():
|
|
|
|
|
title = upload_form.title.data
|
|
|
|
|
authors = upload_form.author.data
|
|
|
|
|
category = upload_form.category.data
|
|
|
|
|
message = upload_form.message.data
|
|
|
|
|
year_published = upload_form.year_published.data
|
|
|
|
|
if year_published=="":
|
|
|
|
|
year_published = None
|
|
|
|
@ -248,7 +240,7 @@ def add_book():
|
|
|
|
|
html.write_pdf(target='app/uploads/potential.pdf');
|
|
|
|
|
print ('potential_pdf')
|
|
|
|
|
|
|
|
|
|
book = Book(title, filename, cover, file_extension, category,year_published)
|
|
|
|
|
book = Book(title, filename, cover, file_extension, category, year_published, message)
|
|
|
|
|
db.session.add(book)
|
|
|
|
|
for author in authors:
|
|
|
|
|
author_name = author.get("author_name")
|
|
|
|
|