From 3aae3975792bd054e11646d9e7c2d13f47339599 Mon Sep 17 00:00:00 2001 From: Alice Date: Sat, 9 Jun 2018 15:27:49 +0200 Subject: [PATCH] delete book button, some css, filepath --- app/static/css/style.css | 3 ++- app/templates/show_book_detail.html | 2 ++ app/templates/show_books.html | 2 +- app/templates/show_stack_detail_tab.html | 2 +- app/views.py | 28 ++++++++++++------------ 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/app/static/css/style.css b/app/static/css/style.css index 6bc917f..ec32671 100755 --- a/app/static/css/style.css +++ b/app/static/css/style.css @@ -93,7 +93,8 @@ background-color: #E8E8E8!important; .library_table .title_col{ font-size: 20px; - padding-left: 10px; + padding-left: 90px; + padding-right: 20px; } .library_table .author_col{ diff --git a/app/templates/show_book_detail.html b/app/templates/show_book_detail.html index cc2f0f1..a8b29d3 100755 --- a/app/templates/show_book_detail.html +++ b/app/templates/show_book_detail.html @@ -25,6 +25,8 @@

edit +
+ delete {% endblock %} diff --git a/app/templates/show_books.html b/app/templates/show_books.html index fa0580b..1b8a369 100755 --- a/app/templates/show_books.html +++ b/app/templates/show_books.html @@ -35,7 +35,7 @@ Filetype Category Stack - Add to stack + Add to a stack diff --git a/app/templates/show_stack_detail_tab.html b/app/templates/show_stack_detail_tab.html index d074c2c..afa9b30 100644 --- a/app/templates/show_stack_detail_tab.html +++ b/app/templates/show_stack_detail_tab.html @@ -11,7 +11,7 @@

{{ stack.stack_description }}

-

Books in this stack: {% for book in stack.books %} +

Books in this stack: {% for book in stack.books %}

  • {{book.title}}
  • diff --git a/app/views.py b/app/views.py index c32106f..8b18213 100755 --- a/app/views.py +++ b/app/views.py @@ -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: @@ -369,7 +369,7 @@ def show_books(): return render_template ('show_books.html', books=books, form=search) if request.method == 'POST': - newmsg = 'searched for: ' + search.search.data + newmsg = 'searched for: ' + search.search.data # message = search.search.data # newmessage = Chat(message) # db.session.add(newmessage) @@ -422,7 +422,7 @@ def search_results(searchtype, query, viewby): count = results.count() whole = Book.query.count() - percentage = float(count / whole * 100) + percentage = float(count / whole * 100) if search.listview.data: 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) if request.method == 'POST': - newmsg = 'searched for: ' + search.search.data + newmsg = 'searched for: ' + search.search.data socketio.emit('channel-' + str(1), { 'username': 'Search form', 'text': search.search.data, @@ -445,7 +445,7 @@ def search_results(searchtype, query, viewby): db.session.commit() except: db.session.rollback() - + query = search.search.data results = [] 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))) else: return redirect((url_for('search_results', searchtype=search.select.data, query=search.search.data, viewby=viewby))) - + 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)