|
|
@ -172,7 +172,7 @@ def remove_book_by_id(id):
|
|
|
|
@app.route('/books/<int:id>/edit', methods=['POST', 'GET'])
|
|
|
|
@app.route('/books/<int:id>/edit', methods=['POST', 'GET'])
|
|
|
|
def edit_book_by_id(id):
|
|
|
|
def edit_book_by_id(id):
|
|
|
|
book_to_edit = Book.query.filter_by(id=id).first()
|
|
|
|
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, message= book_to_edit.message)
|
|
|
|
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, sameness=book_to_edit.sameness, gender=book_to_edit.gender, diversity=book_to_edit.diversity, who=book_to_edit.who)
|
|
|
|
|
|
|
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
if request.method == 'POST':
|
|
|
|
if user_form.validate_on_submit():
|
|
|
|
if user_form.validate_on_submit():
|
|
|
@ -182,6 +182,11 @@ def edit_book_by_id(id):
|
|
|
|
category = user_form.category.data
|
|
|
|
category = user_form.category.data
|
|
|
|
year_published = user_form.year_published.data
|
|
|
|
year_published = user_form.year_published.data
|
|
|
|
message = user_form.message.data
|
|
|
|
message = user_form.message.data
|
|
|
|
|
|
|
|
sameness = user_form.sameness.data
|
|
|
|
|
|
|
|
gender = user_form.gender.data
|
|
|
|
|
|
|
|
diversity = user_form.diversity.data
|
|
|
|
|
|
|
|
who = user_form.who.data
|
|
|
|
|
|
|
|
|
|
|
|
if year_published=="":
|
|
|
|
if year_published=="":
|
|
|
|
year_published = None
|
|
|
|
year_published = None
|
|
|
|
book = Book.query.filter_by(id=id).first()
|
|
|
|
book = Book.query.filter_by(id=id).first()
|
|
|
@ -189,6 +194,10 @@ def edit_book_by_id(id):
|
|
|
|
book.category = category
|
|
|
|
book.category = category
|
|
|
|
book.year_published = year_published
|
|
|
|
book.year_published = year_published
|
|
|
|
book.message = message
|
|
|
|
book.message = message
|
|
|
|
|
|
|
|
book.sameness = sameness
|
|
|
|
|
|
|
|
book.gender = gender
|
|
|
|
|
|
|
|
book.diversity = diversity
|
|
|
|
|
|
|
|
book.who = who
|
|
|
|
|
|
|
|
|
|
|
|
#authors update
|
|
|
|
#authors update
|
|
|
|
book.authors.clear()
|
|
|
|
book.authors.clear()
|
|
|
@ -258,7 +267,6 @@ def add_book():
|
|
|
|
sameness = upload_form.sameness.data
|
|
|
|
sameness = upload_form.sameness.data
|
|
|
|
gender = upload_form.gender.data
|
|
|
|
gender = upload_form.gender.data
|
|
|
|
diversity = upload_form.diversity.data
|
|
|
|
diversity = upload_form.diversity.data
|
|
|
|
time = upload_form.time.data
|
|
|
|
|
|
|
|
who = upload_form.who.data
|
|
|
|
who = upload_form.who.data
|
|
|
|
|
|
|
|
|
|
|
|
if year_published=="":
|
|
|
|
if year_published=="":
|
|
|
@ -308,9 +316,8 @@ def add_book():
|
|
|
|
html_string = render_template('potential_pdf.html', pbooks = pbooks)
|
|
|
|
html_string = render_template('potential_pdf.html', pbooks = pbooks)
|
|
|
|
html = HTML(string=html_string)
|
|
|
|
html = HTML(string=html_string)
|
|
|
|
html.write_pdf(target='app/uploads/potential.pdf');
|
|
|
|
html.write_pdf(target='app/uploads/potential.pdf');
|
|
|
|
print ('potential_pdf')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
book = Book(title, filename, cover, file_extension, category, year_published, message, sameness, diversity, gender, who, time)
|
|
|
|
book = Book(title, filename, cover, file_extension, category, year_published, message, sameness, diversity, gender, who)
|
|
|
|
db.session.add(book)
|
|
|
|
db.session.add(book)
|
|
|
|
for author in authors:
|
|
|
|
for author in authors:
|
|
|
|
author_name = author.get("author_name")
|
|
|
|
author_name = author.get("author_name")
|
|
|
@ -667,17 +674,32 @@ def import_csv():
|
|
|
|
print("allreadyexists")
|
|
|
|
print("allreadyexists")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
cover = ''
|
|
|
|
cover = ''
|
|
|
|
if row['file']:
|
|
|
|
if row['file'] == '':
|
|
|
|
|
|
|
|
file = 'potential.pdf'
|
|
|
|
|
|
|
|
# file_extension = '.pdf'
|
|
|
|
|
|
|
|
# ptitle = row['title']
|
|
|
|
|
|
|
|
# pbook = Potential(ptitle)
|
|
|
|
|
|
|
|
# db.session.add(pbook)
|
|
|
|
|
|
|
|
# db.session.commit()
|
|
|
|
|
|
|
|
# pbooks = Potential.query.all()
|
|
|
|
|
|
|
|
# template = 'app/templates/potential_pdf.html'
|
|
|
|
|
|
|
|
# html_string = render_template('potential_pdf.html', pbooks = pbooks)
|
|
|
|
|
|
|
|
# html = HTML(string=html_string)
|
|
|
|
|
|
|
|
# html.write_pdf(target='app/uploads/potential.pdf')
|
|
|
|
|
|
|
|
# print ('writing to potential_pdf')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
fullpath = os.path.join(app.config['UPLOAD_FOLDER'], row['file'])
|
|
|
|
fullpath = os.path.join(app.config['UPLOAD_FOLDER'], row['file'])
|
|
|
|
name, file_extension = os.path.splitext(row['file'])
|
|
|
|
name, file_extension = os.path.splitext(row['file'])
|
|
|
|
print ('get_cover', fullpath, name)
|
|
|
|
print ('get_cover', fullpath, name)
|
|
|
|
cover = get_cover(fullpath, name)
|
|
|
|
cover = get_cover(fullpath, name)
|
|
|
|
|
|
|
|
file = str(id) + "_" + row['file']
|
|
|
|
|
|
|
|
|
|
|
|
if row['year_published']:
|
|
|
|
if row['year_published']:
|
|
|
|
year_published = int(row['year_published'])
|
|
|
|
year_published = int(row['year_published'])
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
year_published = None;
|
|
|
|
year_published = None;
|
|
|
|
book = Book(row['title'], row['file'], cover, row['fileformat'], row['category'],year_published, None, None, None, None, None, None)
|
|
|
|
book = Book(row['title'], file, cover, row['fileformat'], row['category'],year_published, None, None, None, None, None)
|
|
|
|
book.scapeX = float(row['scapeX'])
|
|
|
|
book.scapeX = float(row['scapeX'])
|
|
|
|
book.scapeY = float(row['scapeY'])
|
|
|
|
book.scapeY = float(row['scapeY'])
|
|
|
|
|
|
|
|
|
|
|
|