search items

This commit is contained in:
Feliciaan De Palmenaer 2015-03-29 22:44:26 +02:00
parent 9cd05b61d2
commit 6c0badfd55
5 changed files with 58 additions and 9 deletions

View file

@ -1,7 +1,6 @@
{% extends "layout.html" %}
{% set active_page = "orders" -%}
{% import "bootstrap/wtf.html" as wtf %}
{% block container %}
<div class="row">
<div class="col-md-push-1 col-md-4 darker"><!-- Shitty html-->
@ -15,14 +14,13 @@
{% endif %}
<br/>
location: <a href="{{ order.location.website }}">{{ order.location.name }}</a><br/>
opened on {{ order.starttime }}<br/>
<b>status:</b> {% if order.stoptime %}{{ order.stoptime|countdown }}{% else %}open{% endif %}<br/>
total price: {{ total_price|euro }}
</div>
{% if form -%}
<div class="col-md-push-3 col-md-4 darker">
<h4>Order:</h4>
{{ wtf.quick_form(form, action=url_for('.order_item_create', id=order.id), button_map={'submit_button': 'primary'}, form_type='horizontal') }}
{% include "order_form.html" with context %}
</div>
{%- endif %}
</div>

View file

@ -1,9 +1,41 @@
{% extends "layout.html" %}
{% set active_page = "orders" -%}
{% import "bootstrap/wtf.html" as wtf %}
{% block container %}
{% import "utils.html" as util %}
{% block content %}
<div class="row">
{{ wtf.quick_form(form, action=url, button_map={'submit_button': 'primary'}) }}
<div class="col-md-12">
<form method="post" action="{{ url_for('.order_item_create', id=order.id) }}">
{{ form.csrf_token }}
<div class="form-group {{ 'has-errors' if form.product_id.errors else ''}}">
{{ form.product_id.label(class='control-label') }}
{{ form.product_id(class='form-control select') }}
{{ util.render_form_field_errors(form.product_id) }}
</div>
{% if current_user.is_anonymous() %}
<div class="form-group{{ ' has-error' if form.name.errors }}{{ ' required' if form.name.flags.required }}">
{{ form.name.label(class='control-label') }}
{{ form.name(class='form-control') }}
{{ util.render_form_field_errors(form.name) }}
</div>
{% endif %}
<div class="form-group">
{{ form.submit_button(class='btn btn-primary') }}
</div>
</form>
</div>
</div>
{% endblock %}
{% block styles %}
{{ super() }}
<link href="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0-rc.2/css/select2.min.css" rel="stylesheet" />
{% endblock %}
{% block scripts %}
{{ super() }}
<script src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0-rc.2/js/select2.min.js"></script>
<script type="text/javascript">
$('.select').select2();
</script>
{% endblock %}

View file

@ -0,0 +1,9 @@
{% extends "layout.html" %}
{% set active_page = "orders" -%}
{% import "bootstrap/wtf.html" as wtf %}
{% block container %}
<div class="row">
{{ wtf.quick_form(form, action=url, button_map={'submit_button': 'primary'}) }}
</div>
{% endblock %}

View file

@ -10,3 +10,13 @@
</div>
</div>
{%- endmacro %}
{% macro render_form_field_errors(field) %}
{%- if field.errors %}
{%- for error in field.errors %}
<p class="help-block">{{error}}</p>
{%- endfor %}
{%- elif field.description -%}
<p class="help-block">{{field.description|safe}}</p>
{%- endif %}
{% endmacro %}

View file

@ -31,7 +31,7 @@ def order_create():
db.session.commit()
return redirect(url_for('.order', id=order.id))
return render_template('order_form.html', form=orderForm, url=url_for(".order_create"))
return render_template('orders_form.html', form=orderForm, url=url_for(".order_create"))
@order_bp.route('/<id>')
@ -76,7 +76,7 @@ def order_item_create(id):
db.session.commit()
flash('Ordered %s' % (item.product.name), 'info')
return redirect(url_for('.order', id=id))
return render_template('order_form.html', form=form, url=url_for(".order_item_create", id=id))
return render_template('order_form.html', form=form, order=order)
@order_bp.route('/<order_id>/<item_id>/delete')
def delete_item(order_id, item_id):