added delete stack

master
Alice 7 years ago
parent 23ad268c0b
commit 2ff2b6e9f0

@ -183,12 +183,12 @@ font-family:'Courier New';
font-size: 12px;
}
.ui-tabs-vertical { width: 55em; }
.ui-tabs-vertical { width: 100em; border-top: 0;}
.ui-tabs-vertical .ui-tabs-nav { padding: .2em .2em .2em .2em; float: left; width: 12em; }
.ui-tabs-vertical .ui-tabs-nav li { clear: left; width: 100%; border-bottom-width: 0 !important; border-right-width: 0 !important; margin: 0 -1px .2em 0; }
.ui-tabs-vertical .ui-tabs-nav li a { display:block; }
.ui-tabs-vertical .ui-tabs-nav li.ui-tabs-active { padding-bottom: 0; padding-right: .1em; border-right-width: 0; background-color: #EEC2C2}
.ui-tabs-vertical .ui-tabs-panel { padding: 1em; float: left; width: 40em; font-size: 12px;}
.ui-tabs-vertical .ui-tabs-nav li.ui-tabs-active { padding-bottom: 0; padding-right: .1em; border-right-width: 0; background-color: #A9A9A9}
.ui-tabs-vertical .ui-tabs-panel { padding: 1em; float: left; width: 50em; font-size: 12px;}
#draggable { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 10px 10px 10px 0; }
#droppable { width: 150px; height: 150px; padding: 0.5em; float: left; margin: 10px; }

@ -2,5 +2,12 @@
{% block main %}
<h1 class="page-header">About</h1>
<p>This an interface to the XPUB Library.</p>
<p>
XPPL is a project aimed at people who are studying the field of media culture, or as we like to call them: knowledge comrades.
<br>
This digital library gathers all the books and articles floating around on PZI shelves and our hard drives and memory sticks, so that they can be shared.
<br>
Its web interface hosts a curated catalogue of books and articles, and its distributed architecture provides instances for uploading and downloading.
<br>
It starts at XPUB, but can go anywhere we want it to.</p>
{% endblock %}

@ -3,7 +3,7 @@
{% block main %}
<div class="container">
<!-- {% from "_formhelpers.html" import render_field %}
{% from "_formhelpers.html" import render_field %}
<h1 class="page-header">Add Stack</h1>
{% with messages = get_flashed_messages() %}
@ -16,7 +16,7 @@
</ul>
</div>
{% endif %}
{% endwith %} -->
{% endwith %}
<form method="POST" action="{{ url_for('add_stack') }}" enctype=multipart/form-data>
{{form.hidden_tag()}}

@ -6,7 +6,7 @@
<h1 class="header">{{ stack.stack_name }}</h1>
<p>Stack description: {{ stack.stack_description }} </p>
<p>{{ stack.stack_description }} </p>
<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>
@ -16,6 +16,9 @@
<br>
<br>
<p>
<a href="{{ url_for('remove_stack_by_id', id=stack.id )}}">Delete</a> </p>
<p><a href="{{url_for('show_stacks')}}">Go back to stacks</p>
</div>

@ -21,10 +21,12 @@
</div>
<br>
<br>
<h1 class="page-header">Build a stack</h1>
<p><a href= {{ url_for('add_stack') }}>Add Stack</a></p>
<h1 class='page-header'><a href= {{ url_for('add_stack') }}>Add Stack</a></h1>
<!--
<div id="draggable" class="ui-widget-content">
<p>List of books</p>
</div>
@ -32,7 +34,7 @@
<div id="droppable" class="ui-widget-header">
<p>Stack</p>
</div>
-->
</div>
{% endblock %}

@ -268,7 +268,7 @@ def add_stack():
form = StackForm()
stacks = db.session.query(Stack).all()
if request.method == 'POST':
if form.validate_on_submit():
stack_name = form.stack_name.data
stack_description = form.stack_description.data
stack = Stack(stack_name, stack_description)
@ -276,7 +276,7 @@ def add_stack():
stack = Stack(stack_name, stack_description)
db.session.add(stack)
stacks = db.session.query(Stack).all()
return redirect(url_for('show_stacks'))
flash("%s stack created" % (stack_name))
return render_template('add_stack.html', stacks=stacks, form=form)
@ -297,6 +297,12 @@ def show_stack_by_id(id, is_tab=False):
else:
return render_template('show_stack_detail_tab.html', stack=stack)
@app.route('/stacks/<int:id>/delete', methods=['POST', 'GET'])
def remove_stack_by_id(id):
Stack.query.filter_by(id=id).delete()
db.session.commit()
return redirect(url_for('show_stacks'))
## search
## search

Loading…
Cancel
Save