Add responsive design (fix #2)
This commit is contained in:
@@ -246,7 +246,6 @@ def set_postpaid_user_money(user_id: int, money: float):
|
||||
int: The number of rows affected by the update operation.
|
||||
"""
|
||||
|
||||
print(f"set_postpaid_user_money: {user_id}, {money}")
|
||||
_log_transaction(user_id, user_is_postpaid=True, new_money_cent=money, description="Set money manually via Admin UI")
|
||||
t = text("UPDATE users_postpaid SET money = :money WHERE id = :id")
|
||||
with engine.connect() as connection:
|
||||
@@ -466,7 +465,6 @@ def get_last_drink(user_id: int, user_is_postpaid: bool, max_since_seconds: int
|
||||
last_drink_time = last_drink_time.replace(tzinfo=datetime.timezone.utc)
|
||||
if (now - last_drink_time).total_seconds() > max_since_seconds:
|
||||
return None
|
||||
print(f"get_last_drink: user_id={user_id}, user_is_postpaid={user_is_postpaid}, drink_id={drink_id}, timestamp={timestamp}, drink_type={drink_type}")
|
||||
return {"id": drink_id, "timestamp": timestamp, "drink_type": drink_type}
|
||||
|
||||
def revert_last_drink(user_id: int, user_is_postpaid: bool, drink_id: int, drink_cost: int = DRINK_COST):
|
||||
@@ -481,7 +479,6 @@ def revert_last_drink(user_id: int, user_is_postpaid: bool, drink_id: int, drink
|
||||
|
||||
with engine.connect() as connection:
|
||||
# Check if the drink exists
|
||||
print(f"revert_last_drink: user_id={user_id}, user_is_postpaid={user_is_postpaid}, drink_id={drink_id}, drink_cost={drink_cost}")
|
||||
drink_exists = connection.execute(del_t, {"user_id": user_id, "drink_id": drink_id}).rowcount > 0
|
||||
if not drink_exists:
|
||||
raise HTTPException(status_code=404, detail="Drink not found")
|
||||
|
||||
11
main.py
11
main.py
@@ -182,11 +182,7 @@ async def drink(request: Request):
|
||||
if not user_db_id:
|
||||
raise HTTPException(status_code=404, detail="User not found")
|
||||
|
||||
form = await request.form()
|
||||
getraenk = str(form.get("getraenk"))
|
||||
print(f"User {user_authentik['preferred_username']} requested drink: {getraenk}")
|
||||
|
||||
drink_postpaid_user(user_db_id, getraenk)
|
||||
drink_postpaid_user(user_db_id)
|
||||
return RedirectResponse(url="/", status_code=303)
|
||||
|
||||
@app.post("/payup")
|
||||
@@ -329,11 +325,6 @@ def delete_prepaid_user(request: Request, username: str = Form(...)):
|
||||
|
||||
return RedirectResponse(url="/", status_code=303)
|
||||
|
||||
@app.get("/popup_getraenke")
|
||||
async def popup_getraenke():
|
||||
alle_getraenke = ["Wasser", "Cola", "Bier", "Mate", "Saft", "Tee", "Kaffee", "Limo"]
|
||||
return JSONResponse(content={"getraenke": random.sample(alle_getraenke, 4)})
|
||||
|
||||
@app.post("/del_last_drink")
|
||||
def del_last_drink(request: Request):
|
||||
user_db_id = request.session.get("user_db_id")
|
||||
|
||||
@@ -38,9 +38,71 @@ header {
|
||||
background: #23272a;
|
||||
color: #e0e0e0;
|
||||
}
|
||||
input, select, button {
|
||||
input,
|
||||
select,
|
||||
button {
|
||||
background: #23272a;
|
||||
color: #e0e0e0;
|
||||
border-color: #444;
|
||||
}
|
||||
}
|
||||
|
||||
/* Responsive Design */
|
||||
@media (max-width: 600px) {
|
||||
body {
|
||||
max-width: 100vw;
|
||||
padding: 0.5em;
|
||||
}
|
||||
header,
|
||||
main {
|
||||
padding: 0.5em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
h1 {
|
||||
font-size: 1.3em;
|
||||
text-align: center;
|
||||
}
|
||||
table {
|
||||
font-size: 0.95em;
|
||||
width: 100%;
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
}
|
||||
th,
|
||||
td {
|
||||
padding: 0.3em 0.5em !important;
|
||||
word-break: break-word;
|
||||
}
|
||||
form {
|
||||
flex-direction: column !important;
|
||||
gap: 0.5em !important;
|
||||
max-width: 100% !important;
|
||||
}
|
||||
input,
|
||||
select,
|
||||
button,
|
||||
label {
|
||||
width: 100% !important;
|
||||
font-size: 1em !important;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.github-icon-link {
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
}
|
||||
img[alt="Logo"] {
|
||||
height: 36px !important;
|
||||
}
|
||||
#popup {
|
||||
max-width: 98vw !important;
|
||||
left: 50% !important;
|
||||
transform: translate(-50%, -25%) !important;
|
||||
padding: 0.5em !important;
|
||||
}
|
||||
#popup-getraenke button {
|
||||
font-size: 1em !important;
|
||||
padding: 0.5em 0.7em !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,25 +56,17 @@
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="padding: 0.5em 1em">ID</th>
|
||||
<th style="padding: 0.5em 1em">Username</th>
|
||||
<th style="padding: 0.5em 1em">Key</th>
|
||||
<th style="padding: 0.5em 1em">Postpaid_User ID</th>
|
||||
<th style="padding: 0.5em 1em">Money (€)</th>
|
||||
<th style="padding: 0.5em 1em">Activated</th>
|
||||
<th style="padding: 0.5em 1em">last drink</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for prepaid_user_i in prepaid_users_from_curr_user %}
|
||||
<tr{% if prepaid_user_i.money <= 0 %} style="background-color: rgba(179, 6, 44, 0.5)"{% endif %}>
|
||||
<td style="padding: 0.5em 1em">{{ prepaid_user_i.id }}</td>
|
||||
<td style="padding: 0.5em 1em">{{ prepaid_user_i.username }}</td>
|
||||
<td style="padding: 0.5em 1em">{{ prepaid_user_i.user_key }}</td>
|
||||
<td style="padding: 0.5em 1em">{{ prepaid_user_i.postpaid_user_id }}</td>
|
||||
<td style="padding: 0.5em 1em">{{ prepaid_user_i.money / 100 }}</td>
|
||||
<td style="padding: 0.5em 1em">{{ prepaid_user_i.activated }}</td>
|
||||
<td style="padding: 0.5em 1em">{{ prepaid_user_i.last_drink }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{% extends "base.html" %} {% block title %}Startseite{% endblock %} {% block
|
||||
content %}
|
||||
<h2>Willkommen, {{ user.name }}!</h2>
|
||||
<p>Dies ist eine einfache geschützte Seite.</p>
|
||||
<p><strong>Aktueller Kontostand:</strong></p>
|
||||
{% if db_user.money > -5000 %}
|
||||
<div
|
||||
@@ -82,7 +81,7 @@ content %}
|
||||
<input type="hidden" name="drink_type" value="{{ drink }}">
|
||||
<button type="submit"
|
||||
style="display: flex; flex-direction: column; align-items: center; background-color: #00618F; color: #fff; border: none; border-radius: 8px; padding: 0.7em 1.2em; cursor: pointer; min-width: 120px;">
|
||||
<img src="static/drinks/{{ drink|lower|replace(' ', '_') }}.png" alt="{{ drink }}" style="width:48px; height:48px; object-fit:contain; margin-bottom:0.5em;">
|
||||
<img src="/static/drinks/{{ drink|lower|replace(' ', '_') }}.png" alt="{{ drink }}" style="width:48px; height:48px; object-fit:contain; margin-bottom:0.5em;">
|
||||
<span>{{ drink }}</span>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user