Browse Source

trophies: fix checked boxes in account editor after trophy removal (#16)

Up to now, after removing a trophy the box would still be checked
in the template immediately following the form subsmission, because
the list of user trophies was generated before the deletion.

Delaying the generation until template rendering time solves this
problem by selecting trophies after the deletion.
undefined
Lephe 3 months ago
parent
commit
74ed3bd8e6
2 changed files with 1 additions and 2 deletions
  1. 0
    1
      app/routes/admin/account.py
  2. 1
    1
      app/templates/admin/edit_account.html

+ 0
- 1
app/routes/admin/account.py View File

@@ -21,7 +21,6 @@ def adm_edit_account(user_id):

for t in Trophy.query.all():
setattr(TrophyForm, f't{t.id}', BooleanField(t.name))
setattr(TrophyForm, "user_trophies", [f't{t.id}' for t in user.trophies])
trophy_form = TrophyForm(prefix="trophies")

if form.submit.data:

+ 1
- 1
app/templates/admin/edit_account.html View File

@@ -99,7 +99,7 @@
{% if id[0] == "t" %}
<div>
{# TODO: add trophies icons #}
{{ input(checked=id in trophy_form.user_trophies) }}
{{ input(checked=id in user.trophies) }}
{{ input.label }}
</div>
{% endif %}

Loading…
Cancel
Save