From 6772c26166f643f3183e3d548a21060817dde6a0 Mon Sep 17 00:00:00 2001 From: Jan-Pieter Baert Date: Fri, 31 Jan 2020 12:25:02 +0100 Subject: [PATCH] Add route to view all orders --- app/templates/orders_all.html | 33 +++++++++++++++++++++++++++++++++ app/views/order.py | 5 +++++ 2 files changed, 38 insertions(+) create mode 100644 app/templates/orders_all.html diff --git a/app/templates/orders_all.html b/app/templates/orders_all.html new file mode 100644 index 0000000..49c1ad6 --- /dev/null +++ b/app/templates/orders_all.html @@ -0,0 +1,33 @@ +{% extends 'layout.html' %} +{% set active_page = "orders" -%} + +{% import "bootstrap/wtf.html" as wtf %} +{% import "utils.html" as util -%} + +{% block container %} +
+
+ {% if orders|count > 0 -%} +

Open orders:

+ {% for order in orders %} + {{ util.render_order(order) }} + {% endfor %} + {% else %} +

There are no orders in the history

+ {%- endif %} +
+
+ +{% endblock %} + +{% block styles -%} + {{ super() }} + + + +{%- endblock %} +{% block scripts -%} + {{ super() }} + + +{%- endblock %} diff --git a/app/views/order.py b/app/views/order.py index f96e848..3900c7b 100644 --- a/app/views/order.py +++ b/app/views/order.py @@ -27,6 +27,11 @@ def orders(form: OrderForm = None) -> str: form.populate() return render_template("orders.html", orders=get_orders(), form=form) +@order_bp.route("/all") +def all_orders() -> str: + "Generate the view of all orders" + # pylint: disable=C0121 + return render_template("orders_all.html", orders=Order.query.filter(Order.public == True).all()) @order_bp.route("/create", methods=["POST"]) @login_required