search items
This commit is contained in:
parent
9cd05b61d2
commit
6c0badfd55
5 changed files with 58 additions and 9 deletions
|
@ -1,7 +1,6 @@
|
||||||
{% 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-push-1 col-md-4 darker"><!-- Shitty html-->
|
<div class="col-md-push-1 col-md-4 darker"><!-- Shitty html-->
|
||||||
|
@ -15,14 +14,13 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<br/>
|
<br/>
|
||||||
location: <a href="{{ order.location.website }}">{{ order.location.name }}</a><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/>
|
<b>status:</b> {% if order.stoptime %}{{ order.stoptime|countdown }}{% else %}open{% endif %}<br/>
|
||||||
total price: {{ total_price|euro }}
|
total price: {{ total_price|euro }}
|
||||||
</div>
|
</div>
|
||||||
{% if form -%}
|
{% if form -%}
|
||||||
<div class="col-md-push-3 col-md-4 darker">
|
<div class="col-md-push-3 col-md-4 darker">
|
||||||
<h4>Order:</h4>
|
<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>
|
</div>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,9 +1,41 @@
|
||||||
{% extends "layout.html" %}
|
{% extends "layout.html" %}
|
||||||
{% set active_page = "orders" -%}
|
{% set active_page = "orders" -%}
|
||||||
|
|
||||||
{% import "bootstrap/wtf.html" as wtf %}
|
{% import "utils.html" as util %}
|
||||||
{% block container %}
|
|
||||||
|
{% block content %}
|
||||||
<div class="row">
|
<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>
|
</div>
|
||||||
{% endblock %}
|
{% 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 %}
|
9
app/templates/orders_form.html
Normal file
9
app/templates/orders_form.html
Normal 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 %}
|
|
@ -10,3 +10,13 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{%- endmacro %}
|
{%- 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 %}
|
|
@ -31,7 +31,7 @@ def order_create():
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return redirect(url_for('.order', id=order.id))
|
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>')
|
@order_bp.route('/<id>')
|
||||||
|
@ -76,7 +76,7 @@ def order_item_create(id):
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
flash('Ordered %s' % (item.product.name), 'info')
|
flash('Ordered %s' % (item.product.name), 'info')
|
||||||
return redirect(url_for('.order', id=id))
|
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')
|
@order_bp.route('/<order_id>/<item_id>/delete')
|
||||||
def delete_item(order_id, item_id):
|
def delete_item(order_id, item_id):
|
||||||
|
|
Loading…
Reference in a new issue