Implement Prepaid user functionality: add login, drink handling, and money management features; update templates for user interaction

This commit is contained in:
2025-05-17 15:45:58 +02:00
parent 1fb1b27480
commit 4ee1d99224
7 changed files with 334 additions and 12 deletions

View File

@@ -91,6 +91,76 @@
Add User
</button>
</form>
<p>Füge bestehendem Prepaid-User Geld hinzu:</p>
<form
method="post"
action="/add_money_prepaid_user"
style="
display: flex;
gap: 1em;
align-items: center;
margin-bottom: 1em;
background: var(--hellgrau);
padding: 1em;
border-radius: 8px;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
max-width: 600px;
"
>
<label
for="addmoney-username"
style="margin: 0 0.5em 0 0; font-weight: bold"
>Username:</label
>
<select
id="addmoney-username"
name="username"
required
style="
padding: 0.5em;
border: 1px solid #ccc;
border-radius: 4px;
"
>
{% for db_user in db_users_prepaid %}
<option value="{{ db_user.username }}">
{{ db_user.username }}
</option>
{% endfor %}
</select>
<label
for="addmoney-money"
style="margin: 0 0.5em 0 0; font-weight: bold"
>Amount (€):</label
>
<input
id="addmoney-money"
type="number"
name="money"
placeholder="Money"
step="0.01"
required
style="
padding: 0.5em;
border: 1px solid #ccc;
border-radius: 4px;
width: 100px;
"
/>
<button
type="submit"
style="
padding: 0.5em 1em;
background: rgb(0, 97, 143);
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
"
>
Add Money
</button>
</form>
{% endif %}
{% if 'Fachschaft Admins' in user.groups %}
<h2>Admin Interface</h2>
@@ -393,6 +463,57 @@
{% endif %}
</tbody>
</table>
<p>(De-)Activate User</p>
<form
method="post"
action="/toggle_activated_user_prepaid"
style="
display: flex;
gap: 1em;
align-items: center;
margin-bottom: 1em;
background: var(--hellgrau);
padding: 1em;
border-radius: 8px;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
max-width: 600px;
"
>
<label
for="activate-username"
style="margin: 0 0.5em 0 0; font-weight: bold"
>Username:</label
>
<select
id="activate-username"
name="username"
required
style="
padding: 0.5em;
border: 1px solid #ccc;
border-radius: 4px;
"
>
{% for db_user in db_users_prepaid %}
<option value="{{ db_user.username }}">
{{ db_user.username }}
</option>
{% endfor %}
</select>
<button
type="submit"
style="
padding: 0.5em 1em;
background: rgb(0, 97, 143);
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
"
>
Toggle Activation
</button>
</form>
{% endif %} {% endif %}
</main>
</body>

View File

@@ -72,4 +72,39 @@ content %}
</button>
</form>
</div>
{% endif %} {% endif %} {% endblock %}
{% endif %} {% endif %}
{% if user.prepaid %}
<div style="display: flex; justify-content: center; text-align: center">
<form method="post" action="/drink_prepaid">
<button
type="submit"
style="
background-color: rgb(165, 171, 82);
color: rgb(255, 255, 255);
font-size: 1.5em;
padding: 0.75em 2em;
border: none;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(40, 167, 69, 0.15);
cursor: pointer;
transition: background 0.2s;
"
>
Getränk abziehen
</button>
</form>
</div>
<p>Deine aktuelle Ansprechperson ist:</p>
<div
style="
text-align: center;
font-size: 2em;
color: var(--goetheblau);
margin: 0.5em 0;
"
>
ID {{ db_user.postpaid_user_id }}
</div>
{% endif %}
{% endblock %}

View File

@@ -1,7 +1,6 @@
{% extends "base.html" %} {% block title %}Login{% endblock %} {% block content
%}
<h2>Login</h2>
<h2>Postpaid-Liste:</h2>
<!-- SSO-Button -->
<div
style="
@@ -30,6 +29,52 @@
</button>
</form>
</div>
<h2>Prepaid-Liste:</h2>
<div
style="
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
"
>
<form method="post" action="/login/prepaid">
<label
for="prepaid_user_key"
style="margin: 0 0.5em 0 0; font-weight: bold"
>Prepaid Key:</label>
<input
id="prepaid-user-key"
type="text"
name="prepaid_user_key"
placeholder="Prepaid Key"
style="
padding: 12px;
border: 1px solid #ccc;
border-radius: 6px;
font-size: 1em;
width: 300px;
margin-bottom: 1em;
"
/>
<button
type="submit"
style="
padding: 12px 28px;
background-color: #1976d2;
color: #fff;
border: none;
border-radius: 6px;
font-size: 1.1em;
cursor: pointer;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
transition: background 0.2s;
"
>
📜 Prepaid-Liste
</button>
</form>
</div>
<!-- WebAuthn-Button -->
<!-- <form method="get" action="/login/webauthn">