summaryrefslogtreecommitdiff
path: root/app/templates/add_product.html
blob: ad7ea0a8c7fc92b0187acec2b542498fa5f5c320 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
{# -*- mode: jinja2; -*- #}

{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}

{% block content %}

  {% block title %}Add a New Product{% endblock %}

  {% if message %}

    {# the form was submitted and message exists #}
    <p class="lead"><strong>{{ message }}</strong></p>
    {# links #}
    <p><a href="{{ url_for('add_product') }}" class="button">Submit another product.</a></p>
<p><a href="/fapg/home">Return to the index.</a></p>

{% else %}

  {# the form is displayed when template opens via GET not POST #}
  <p class="lead alert alert-primary">Add a new sock to our inventory.</p>
<p class="ml-4"><a href="/fapg/home" class="button">Return to the index.</a></p>
{# 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 %}
      <div class="alert alert-danger alert-dismissible" role="alert">
	<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
	{{ err }}
      </div>
    {% endfor %}
  {% endif %}
{% endwith %}
{# end of flash #}

{# the form, thanks to WTForms #}
{{ wtf.quick_form(form) }}

{% endif %}
{% endblock %}
Copyright 2019--2024 Marius PETER