Create order from order page

This commit is contained in:
Feliciaan De Palmenaer 2015-03-27 23:24:41 +01:00
parent 424af3e2cb
commit 070dc241a9
2 changed files with 9 additions and 6 deletions

View file

@ -1,9 +1,10 @@
{% extends 'layout.html' %}
{% set active_page = "orders" -%}
{% import "bootstrap/wtf.html" as wtf %}
{% block container %}
<div class="row">
<div class="col-md-7">
<div class="col-md-5">
<h3>Open orders:</h3>
<ul>
{% for order in orders %}
@ -11,8 +12,9 @@
{% endfor %}
</ul>
</div>
<div class="col-md-push-2">
<a class="btn btn-large btn-default" href="{{ url_for('order_create') }}">Create new order</a>
<div class="col-md-push-1 col-md-6">
{{ wtf.quick_form(form, action=url_for('order_create'), button_map={'submit_button': 'primary'}, form_type='horizontal') }}
</div>
</div>
</div>
{% endblock %}

View file

@ -45,8 +45,7 @@ def order_create():
orderForm.populate_obj(order)
db.session.add(order)
db.session.commit()
print(order.id)
return redirect(url_for('home'))
return redirect(url_for('order', id=order.id))
return render_template('order_form.html', form=orderForm)
@ -54,7 +53,9 @@ def order_create():
@login_required
def orders():
orders = Order.query.filter((Order.stoptime > datetime.now()) | (Order.stoptime == None)).all()
return render_template('orders.html', orders=orders)
orderForm = OrderForm()
orderForm.populate()
return render_template('orders.html', orders=orders, form=orderForm)
if app.debug: # add route information