From 4df78eb0c37c92e0ae3ca4bd694a533dbb6d74c9 Mon Sep 17 00:00:00 2001 From: Darks Date: Tue, 13 Jun 2023 20:02:15 +0200 Subject: [PATCH] account: set markdown editor for signature and bio --- app/routes/account/account.py | 2 ++ app/routes/admin/account.py | 3 +++ app/templates/account/account.html | 13 +++---------- app/templates/admin/edit_account.html | 13 +++---------- app/templates/widgets/editor.html | 6 ++++-- 5 files changed, 15 insertions(+), 22 deletions(-) diff --git a/app/routes/account/account.py b/app/routes/account/account.py index 31720ef..489e169 100644 --- a/app/routes/account/account.py +++ b/app/routes/account/account.py @@ -50,6 +50,8 @@ def edit_account(): flash('Erreur lors de la modification', 'error') else: form.theme.data = current_user.theme or 'default_theme' + form.signature.data = current_user.signature + form.biography.data = current_user.bio return render('account/account.html', scripts=["+scripts/entropy.js"], form=form) diff --git a/app/routes/admin/account.py b/app/routes/admin/account.py index 3cf49d5..9adecbd 100644 --- a/app/routes/admin/account.py +++ b/app/routes/admin/account.py @@ -71,6 +71,9 @@ def adm_edit_account(user_id): return redirect(request.url) else: flash('Erreur lors de la modification', 'error') + else: + form.signature.data = user.signature + form.biography.data = user.bio # Trophies if trophy_form.submit.data: diff --git a/app/templates/account/account.html b/app/templates/account/account.html index 3ec19f2..898ce5f 100644 --- a/app/templates/account/account.html +++ b/app/templates/account/account.html @@ -1,4 +1,5 @@ {% extends "base/base.html" %} +{% import "widgets/editor.html" as widget_editor %} {% set tabtitle = "Gestion du compte" %} @@ -68,18 +69,10 @@ {% endfor %}
- {{ form.signature.label }} - - {% for error in form.signature.errors %} - {{ error }} - {% endfor %} + {{ widget_editor.text_editor(form.signature) }}
- {{ form.biography.label }} - - {% for error in form.biography.errors %} - {{ error }} - {% endfor %} + {{ widget_editor.text_editor(form.biography) }}

Préférences

diff --git a/app/templates/admin/edit_account.html b/app/templates/admin/edit_account.html index 7a7b088..c09c080 100644 --- a/app/templates/admin/edit_account.html +++ b/app/templates/admin/edit_account.html @@ -1,4 +1,5 @@ {% extends "base/base.html" %} +{% import "widgets/editor.html" as widget_editor %} {% set tabtitle = "Administration - Édition du compte de " + user.name %} @@ -81,18 +82,10 @@ {% endfor %}
- {{ form.signature.label }} - - {% for error in form.signature.errors %} - {{ error }} - {% endfor %} + {{ widget_editor.text_editor(form.signature) }}
- {{ form.biography.label }} - - {% for error in form.biography.errors %} - {{ error }} - {% endfor %} + {{ widget_editor.text_editor(form.biography) }}

Préférences

diff --git a/app/templates/widgets/editor.html b/app/templates/widgets/editor.html index 3f51e33..13750cb 100644 --- a/app/templates/widgets/editor.html +++ b/app/templates/widgets/editor.html @@ -1,5 +1,8 @@ {% macro text_editor(field, label=True, autofocus=false) %}
+ + {{ field.label if label }} +
@@ -172,8 +175,7 @@ Aide
- - {{ field.label if label }} + {{ field() }}