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

View file

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