From db08adcb72653c128969cfc0e4fd14e0e34613ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89loi=20Rivard?= Date: Sun, 5 Dec 2021 19:45:27 +0100 Subject: [PATCH] Indicators on which fields an user can read and write whene editing his profile --- canaille/templates/fomanticui.html | 18 ++-- canaille/templates/invite.html | 2 +- canaille/templates/profile.html | 32 ++++--- .../translations/fr/LC_MESSAGES/messages.mo | Bin 20569 -> 20837 bytes .../translations/fr/LC_MESSAGES/messages.po | 84 ++++++++++-------- canaille/translations/messages.pot | 82 +++++++++-------- 6 files changed, 130 insertions(+), 88 deletions(-) diff --git a/canaille/templates/fomanticui.html b/canaille/templates/fomanticui.html index 69660ee4..9d313cd3 100644 --- a/canaille/templates/fomanticui.html +++ b/canaille/templates/fomanticui.html @@ -3,7 +3,9 @@ label_visible=true, icon=none, container=true, - noindicator=false + noindicator=false, + indicator_icon=none, + indicator_text=none ) -%} {% if container %} @@ -16,10 +18,10 @@ {{ field.label() }} {% endif %} -{% set lock_label = field.render_kw and ("readonly" in field.render_kw or "disabled" in field.render_kw) %} -{% set required_label = "required" in field.flags %} +{% set lock_indicator = field.render_kw and ("readonly" in field.render_kw or "disabled" in field.render_kw) %} +{% set required_indicator = "required" in field.flags %}
@@ -32,11 +34,15 @@ {% endif %} {% if not noindicator %} - {% if lock_label %} + {% if indicator_icon %} +
+ +
+ {% elif lock_indicator %}
- {% elif required_label %} + {% elif required_indicator %}
diff --git a/canaille/templates/invite.html b/canaille/templates/invite.html index 45533748..b44ffa72 100644 --- a/canaille/templates/invite.html +++ b/canaille/templates/invite.html @@ -73,7 +73,7 @@ {{ form.hidden_tag() if form.hidden_tag }} {{ fui.render_field(form.uid, icon="user") }} {{ fui.render_field(form.mail, icon="mail") }} - {{ fui.render_field(form.groups) }} + {{ fui.render_field(form.groups, icon="users") }}
diff --git a/canaille/templates/profile.html b/canaille/templates/profile.html index bdb1b444..f2b39b12 100644 --- a/canaille/templates/profile.html +++ b/canaille/templates/profile.html @@ -5,6 +5,18 @@ {% endblock %} +{% macro render_field(field, noindicator=false) %} + {% if edited_user.uid == user.uid or noindicator %} + {{ sui.render_field(field) }} + {% elif field.name in edited_user.write %} + {{ sui.render_field(field, noindicator=true) }} + {% elif field.name in edited_user.read %} + {{ sui.render_field(field, indicator_icon="eye", indicator_text=_("This user cannot edit this field")) }} + {% else %} + {{ sui.render_field(field, indicator_icon="eye slash", indicator_text=_("This user cannot see this field")) }} + {% endif %} +{% endmacro %} + {% block content %} {% if self_deletion or (user.can_manage_users and edited_user) %}