From eac5bb765c8d609d3b7eb31316228f8058581796 Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Mon, 16 May 2022 21:11:52 +0200 Subject: Lil fixes. --- app/templates/modules/add-invoice.html | 48 ---------------------------------- app/templates/modules/add-item.html | 2 +- app/templates/modules/invoices.html | 39 ++++++++++++++------------- 3 files changed, 22 insertions(+), 67 deletions(-) delete mode 100644 app/templates/modules/add-invoice.html (limited to 'app/templates') diff --git a/app/templates/modules/add-invoice.html b/app/templates/modules/add-invoice.html deleted file mode 100644 index 92748be..0000000 --- a/app/templates/modules/add-invoice.html +++ /dev/null @@ -1,48 +0,0 @@ -{# -*- mode: web; -*- #} - -{% extends "base.html" %} - - -{% block title %}Add a new invoice{% endblock %} -{% block content %} - -{% if message %} -{# the form was submitted and message exists #} -

{{ item }}

-{# links #} -

Submit another {{ item }}

-

Return to the index

- -{% else %} -{# the form is displayed when template opens via GET not POST #} - -{# show flash - based on WTForms validators see -https://pythonprogramming.net/flash-flask-tutorial/ -get_flashed_messages() exists here because of flash() in the route -function #} - -{% with errors = get_flashed_messages() %} {% if errors %} -{% for err in errors %} - -{% endfor %} -{% endif %} -{% endwith %} -{# end of flash #} - - -{# the form #} -
-
- Add a new {{ item }} to our database. - {% for field in form %} - {{ field.label() }} - {{ field() }}
- {% endfor %} -
-
- -{% endif %} -{% endblock %} diff --git a/app/templates/modules/add-item.html b/app/templates/modules/add-item.html index 356ce9f..4eaee3d 100644 --- a/app/templates/modules/add-item.html +++ b/app/templates/modules/add-item.html @@ -10,7 +10,7 @@
Add a new item to our {{ table }} table. {% for field in form %} - {{ field.label() }} + {{ field.label() }}
{{ field() }}
{% endfor %}
diff --git a/app/templates/modules/invoices.html b/app/templates/modules/invoices.html index 55a4b87..293a45b 100644 --- a/app/templates/modules/invoices.html +++ b/app/templates/modules/invoices.html @@ -13,25 +13,28 @@ Invoices {% block content %} Track your invoices and create new ones here.
+{# Pagination Links #} +{# gotten from https://betterprogramming.pub/simple-flask-pagination-example-4190b12c2e2e #}
-{% for page_num in invoices.iter_pages(left_edge=1, right_edge=1, left_current=1, right_current=2) %} -{% if page_num %} - -{% if invoices.page == page_num %} - - {{ page_num }} - -{% else %} - - {{ page_num }} - -{% endif %} -{% else %} -... -{% endif %} -{% endfor %} + {# Loop through the number of pages to display a link for each #} + {% for page_num in invoices.iter_pages(left_edge=1, right_edge=1, left_current=1, right_current=2) %} + {% if page_num %} + {# Check for the active page and set the link to "Active" #} + {% if invoices.page == page_num %} + + {{ page_num }} + + {% else %} + + {{ page_num }} + + {% endif %} + {% else %} + ... + {% endif %} + {% endfor %}
-- cgit v1.2.3