remove book from stacks
This commit is contained in:
parent
869ed3f3bb
commit
2d8110585d
@ -4,7 +4,8 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
<h1 class="header">{{ book.title }}</h1>
|
<h1 class="header">{{ book.title }}</h1>
|
||||||
<img class="no_cover" id="{{ book.title }}" src="../uploads/cover/{{ book.cover }}" width="150" onerror="if (this.src != '../static/img/{{ book.cover }}') this.src = '../static/img/default_cover.gif';">
|
<img class="no_cover" id="{{ book.title }}" src="../uploads/cover/{{ book.cover }}" width="150" onerror="if (this.src != '../uploads/cover/{{ book.cover }}') this.src = '../static/img/default_cover.gif';">
|
||||||
|
|
||||||
<p>Author(s): <ul>{% for author in book.authors %}
|
<p>Author(s): <ul>{% for author in book.authors %}
|
||||||
|
|
||||||
<li><a href="{{url_for('show_author_by_id', id=author.id)}}">{{ author.author_name }}</a> </li>
|
<li><a href="{{url_for('show_author_by_id', id=author.id)}}">{{ author.author_name }}</a> </li>
|
||||||
@ -16,6 +17,8 @@
|
|||||||
|
|
||||||
<p>Stack(s): <ul>{% for stack in book.stacks %}
|
<p>Stack(s): <ul>{% for stack in book.stacks %}
|
||||||
<li><a href="{{url_for('show_stack_by_id', id=stack.id)}}">{{ stack.stack_name }}</a>
|
<li><a href="{{url_for('show_stack_by_id', id=stack.id)}}">{{ stack.stack_name }}</a>
|
||||||
|
<p style="font-size: 10px;"><a href='{{url_for('remove_from_stack', stackid=stack.id, bookid=book.id)}}'> Remove from stack</a></p>
|
||||||
|
|
||||||
|
|
||||||
{% endfor %}</ul></p>
|
{% endfor %}</ul></p>
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<p>Books in this stack: {% for book in stack.books %}
|
<p>Books in this stack: {% for book in stack.books %}
|
||||||
|
|
||||||
<li> <a href="{{url_for('show_book_by_id', id=book.id)}}">{{book.title}}</a> </li>
|
<li> <a href="{{url_for('show_book_by_id', id=book.id)}}">{{book.title}}</a> </li>
|
||||||
<img class="no_cover" id="{{ book.title }}" src="../uploads/cover/{{ book.cover }}" width="150" onerror="if (this.src != '../static/img/{{ book.cover }}') this.src = '../static/img/default_cover.gif';">
|
<img class="no_cover" id="{{ book.title }}" src="../uploads/cover/{{ book.cover }}" width="150" onerror="if (this.src != '../uploads/cover/{{ book.cover }}') this.src = '../static/img/default_cover.gif';">
|
||||||
<div class='widget'>
|
<div class='widget'>
|
||||||
<iframe src="../uploads/{{ book.file }}" width="50%" ></iframe>
|
<iframe src="../uploads/{{ book.file }}" width="50%" ></iframe>
|
||||||
</div>
|
</div>
|
||||||
|
11
app/views.py
11
app/views.py
@ -336,6 +336,17 @@ def edit_stack_by_id(id):
|
|||||||
return redirect(url_for('show_stack_by_id', id=id))
|
return redirect(url_for('show_stack_by_id', id=id))
|
||||||
return render_template('edit_stack_detail.html', stack=stack, form=form)
|
return render_template('edit_stack_detail.html', stack=stack, form=form)
|
||||||
|
|
||||||
|
@app.route('/stacks/<int:stackid>/remove/<int:bookid>', methods=['POST', 'GET'])
|
||||||
|
def remove_from_stack(bookid, stackid):
|
||||||
|
book = Book.query.get(bookid)
|
||||||
|
stack = Stack.query.get(stackid)
|
||||||
|
if book not in stack.books:
|
||||||
|
return render_template('show_book_detail.html', book=book)
|
||||||
|
stack.books.remove(book)
|
||||||
|
db.session.commit()
|
||||||
|
return render_template('show_book_detail.html', book=book)
|
||||||
|
|
||||||
|
|
||||||
## search
|
## search
|
||||||
|
|
||||||
@app.route('/books', methods= ['POST','GET'])
|
@app.route('/books', methods= ['POST','GET'])
|
||||||
|
Loading…
Reference in New Issue
Block a user