From 1d63d05c1eeee7871c0078f38a0e22ba3afc7579 Mon Sep 17 00:00:00 2001 From: Lephe Date: Sat, 27 Feb 2021 11:42:29 +0100 Subject: [PATCH] admin: show trophy icons on user editor --- app/routes/admin/account.py | 1 + app/static/css/widgets.css | 5 +++++ app/templates/admin/edit_account.html | 17 +++++++++-------- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/routes/admin/account.py b/app/routes/admin/account.py index 065a48c..17caae0 100644 --- a/app/routes/admin/account.py +++ b/app/routes/admin/account.py @@ -27,6 +27,7 @@ def adm_edit_account(user_id): for t in Trophy.query.all(): setattr(TrophyForm, f't{t.id}', BooleanField(t.name)) + setattr(TrophyForm, "trophies", {f't{t.id}': t for t in Trophy.query.all()}) setattr(TrophyForm, "user_trophies", [f't{t.id}' for t in user.trophies]) trophy_form = TrophyForm(prefix="trophies") diff --git a/app/static/css/widgets.css b/app/static/css/widgets.css index 984b6e3..9276bb3 100644 --- a/app/static/css/widgets.css +++ b/app/static/css/widgets.css @@ -134,6 +134,11 @@ border-left: 1px solid #c5c5c5; } +.trophy.form-disabled { + border-left: 1px solid #c5c5c5; + flex-grow: 1; +} + hr.signature { opacity: 0.2; } diff --git a/app/templates/admin/edit_account.html b/app/templates/admin/edit_account.html index df17371..23f1630 100644 --- a/app/templates/admin/edit_account.html +++ b/app/templates/admin/edit_account.html @@ -107,15 +107,16 @@
{{ trophy_form.hidden_tag() }}

Trophées

-
- {% for id, input in trophy_form.__dict__.items() %} - {% if id[0] == "t" %} -
- {# TODO: add trophies icons #} - {{ input(checked=id in trophies_owned) }} - {{ input.label }} +
+ {% for id, t in trophy_form.trophies.items() %} +
+ {{ trophy_form[id](checked=id in trophies_owned) }} + +
+ {{ t.name }} + {{ t.description }} +
- {% endif %} {% endfor %}
{{ trophy_form.submit(class_="bg-ok") }}