aboutsummaryrefslogtreecommitdiff
path: root/templates/wallet.html.jinja
diff options
context:
space:
mode:
authorpacien2021-07-29 18:04:48 +0200
committerpacien2021-07-29 18:04:48 +0200
commit57ff25198a82b3f6f413440e4005f0ade8dfb8d8 (patch)
tree817c43e04b3413d773a999c1950e1af43f26c3e2 /templates/wallet.html.jinja
parentf80c19c18eb01ed7e7c6f44cc25535c14659ba20 (diff)
downloaduge_l2_rdbms_python_proto-57ff25198a82b3f6f413440e4005f0ade8dfb8d8.tar.gz
app: render and serve proper web pages
Diffstat (limited to 'templates/wallet.html.jinja')
-rw-r--r--templates/wallet.html.jinja140
1 files changed, 140 insertions, 0 deletions
diff --git a/templates/wallet.html.jinja b/templates/wallet.html.jinja
new file mode 100644
index 0000000..86919e4
--- /dev/null
+++ b/templates/wallet.html.jinja
@@ -0,0 +1,140 @@
1{#
2 UGE / L2 / Intro to relational databases / Python project prototype
3 Author: Pacien TRAN-GIRARD
4 Licence: EUPL-1.2
5#}
6
7{% extends '_base.html.jinja' %}
8
9{% block title %}My wallet{% endblock %}
10
11{% macro format_operation(transaction) %}
12 {% if transaction.operation == 'transfer' %}
13 {% if transaction.amount > 0 %}
14 Transfer from {{ transaction.source }}
15 {% else %}
16 Transfer to {{ transaction.recipient }}
17 {% endif %}
18 {% else %}
19 {{ transaction.operation.capitalize() }}
20 {% endif %}
21{% endmacro %}
22
23{% macro amount_class(transaction) %}
24 {{ 'amount-positive' if transaction.amount > 0 else 'amount-negative'}}
25{% endmacro %}
26
27{% block content %}
28 <div class="pure-g">
29
30 <div class="pure-u-1 pure-u-md-1-3">
31 <h2>Deposit</h2>
32 <form
33 method="post"
34 action="/wallet/deposit"
35 class="pure-form">
36 <fieldset>
37 <input
38 class="pure-input-1-4"
39 type="number"
40 name="amount"
41 min="0.01"
42 step="0.01"
43 placeholder="§"
44 required />
45 <button
46 type="submit"
47 class="pure-button pure-button-primary dark-blue-bg">
48 ⇩ Deposit
49 </button>
50 </fieldset>
51 </form>
52 </div>
53
54 <div class="pure-u-1 pure-u-md-1-3">
55 <h2>Withdraw</h2>
56 <form
57 method="post"
58 action="/wallet/withdraw"
59 class="pure-form">
60 <fieldset>
61 <input
62 class="pure-input-1-4"
63 type="number"
64 name="amount"
65 min="0.01"
66 max="{{ user.balance }}"
67 step="0.01"
68 placeholder="§"
69 required />
70 <button
71 type="submit"
72 class="pure-button pure-button-primary dark-blue-bg">
73 ⇧ Withdraw
74 </button>
75 </fieldset>
76 </form>
77 </div>
78
79 <div class="pure-u-1 pure-u-md-1-3">
80 <h2>Transfer</h2>
81 <form
82 method="post"
83 action="/wallet/transfer"
84 class="pure-form">
85 <fieldset>
86 <input
87 class="pure-input-1-3"
88 type="text"
89 name="recipient"
90 minlength="4"
91 maxlength="16"
92 placeholder="Recipient"
93 required />
94 <input
95 class="pure-input-1-4"
96 type="number"
97 name="amount"
98 min="0.01"
99 max="{{ user.balance }}"
100 step="0.01"
101 placeholder="§"
102 required />
103 <button
104 type="submit"
105 class="pure-button pure-button-primary light-blue-bg">
106 ➤ Send
107 </button>
108 </fieldset>
109 </form>
110 </div>
111
112 </div>
113
114 <h2>Transaction history</h2>
115
116 <table class="pure-table pure-table-striped">
117 <thead>
118 <tr>
119 <th>Date</th>
120 <th>Operation</th>
121 <th class="align-right">Amount</th>
122 </tr>
123 </thead>
124 <tbody>
125 {% for transaction in transactions %}
126 <tr>
127 <td>{{ transaction.datetime.strftime('%Y-%m-%d %H:%M:%S') }}</td>
128 <td>{{ format_operation(transaction) }}</td>
129 <td class="align-right text-bold {{ amount_class(transaction) }}">
130 {{ transaction.amount }} §
131 </td>
132 </tr>
133 {% else %}
134 <tr>
135 <td colspan="3"><em>No past transaction.</em></td>
136 </tr>
137 {% endfor %}
138 </tbody>
139 </table>
140{% endblock %}