admin: show trophy icons on user editor

This commit is contained in:
Lephe 2021-02-27 11:42:29 +01:00
parent f5f1a445ea
commit 1d63d05c1e
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
3 changed files with 15 additions and 8 deletions

View File

@ -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")

View File

@ -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;
}

View File

@ -107,15 +107,16 @@
<form action="{{ url_for('adm_edit_account', user_id=user.id) }}" method="post">
{{ trophy_form.hidden_tag() }}
<h2>Trophées</h2>
<div class="trophies-panel flex-grid fg3">
{% for id, input in trophy_form.__dict__.items() %}
{% if id[0] == "t" %}
<div>
{# TODO: add trophies icons #}
{{ input(checked=id in trophies_owned) }}
{{ input.label }}
<div class="trophies">
{% for id, t in trophy_form.trophies.items() %}
<div class="trophy form-disabled">
{{ trophy_form[id](checked=id in trophies_owned) }}
<img src="{{ url_for('static', filename='images/trophies/'+slugify(t.name))+'.png' }}">
<div>
<em>{{ t.name }}</em>
<span>{{ t.description }}</span>
</div>
</div>
{% endif %}
{% endfor %}
</div>
<div>{{ trophy_form.submit(class_="bg-ok") }}</div>