Indicators on which fields an user can read and write whene editing his profile

This commit is contained in:
Éloi Rivard 2021-12-05 19:45:27 +01:00
parent b218158ef0
commit db08adcb72
6 changed files with 130 additions and 88 deletions

View file

@ -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 %}
<div class="ui
{% if not noindicator and (lock_label or required_label) %}corner labeled{% endif %}
{% if not noindicator and (indicator_icon or lock_indicator or required_indicator) %}corner labeled{% endif %}
{% if icon %}left icon {% endif %}
{% if field.type not in ("BooleanField", "RadioField") %}input{% endif %}
">
@ -32,11 +34,15 @@
{% endif %}
{% if not noindicator %}
{% if lock_label %}
{% if indicator_icon %}
<div class="ui corner label"{% if indicator_text %} title="{{ indicator_text }}"{% endif %}>
<i class="{{ indicator_icon }} icon"></i>
</div>
{% elif lock_indicator %}
<div class="ui corner label" title="{{ _("This field is not editable") }}">
<i class="lock icon"></i>
</div>
{% elif required_label %}
{% elif required_indicator %}
<div class="ui corner label" title="{{ _("This field is required") }}">
<i class="asterisk icon"></i>
</div>

View file

@ -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") }}
<div class="ui right aligned container">
<div class="ui stackable buttons">

View file

@ -5,6 +5,18 @@
<script src="/static/js/confirm.js"></script>
{% 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) %}
<div class="ui basic modal">
@ -59,39 +71,39 @@
class="ui form info{% if user.can_manage_users and edited_user and not edited_user.has_password() %} warning{% endif %}"
>
{#{ sui.render_field(form.csrf_token) }#}
{#{ render_field(form.csrf_token) }#}
<h4 class="ui dividing header">{% trans %}Personal information{% endtrans %}</h4>
<div class="two fields">
{% if "givenName" in form %}
{{ sui.render_field(form.givenName) }}
{{ render_field(form.givenName) }}
{% endif %}
{% if "sn" in form %}
{{ sui.render_field(form.sn) }}
{{ render_field(form.sn) }}
{% endif %}
</div>
{% if "mail" in form %}
{{ sui.render_field(form.mail) }}
{{ render_field(form.mail) }}
{% endif %}
{% if "telephoneNumber" in form %}
{{ sui.render_field(form.telephoneNumber) }}
{{ render_field(form.telephoneNumber) }}
{% endif %}
{% if "employeeNumber" in form %}
{{ sui.render_field(form.employeeNumber) }}
{{ render_field(form.employeeNumber) }}
{% endif %}
{% if "groups" in form %}
{{ sui.render_field(form.groups) }}
{{ render_field(form.groups) }}
{% endif %}
<h4 class="ui dividing header">{% trans %}Account information{% endtrans %}</h4>
{% if "uid" in form %}
{{ sui.render_field(form.uid) }}
{{ render_field(form.uid) }}
{% endif %}
<div class="two fields">
{% if "password1" in form %}
{{ sui.render_field(form.password1) }}
{{ sui.render_field(form.password2) }}
{{ render_field(form.password1, noindicator=true) }}
{{ render_field(form.password2, noindicator=true) }}
{% endif %}
</div>

View file

@ -9,8 +9,8 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: contact@yaal.fr\n"
"POT-Creation-Date: 2021-12-05 18:47+0100\n"
"PO-Revision-Date: 2021-12-05 18:47+0100\n"
"POT-Creation-Date: 2021-12-05 19:40+0100\n"
"PO-Revision-Date: 2021-12-05 19:41+0100\n"
"Last-Translator: Éloi Rivard <eloi@yaal.fr>\n"
"Language: fr_FR\n"
"Language-Team: French - France <equipe@yaal.fr>\n"
@ -515,11 +515,11 @@ msgstr "Page de connexion"
msgid "Send the initialization email"
msgstr "Envoyer le courriel d'initialisation"
#: canaille/templates/fomanticui.html:33
#: canaille/templates/fomanticui.html:38 canaille/templates/fomanticui.html:42
msgid "This field is not editable"
msgstr "Ce champ n'est pas modifiable"
#: canaille/templates/fomanticui.html:37
#: canaille/templates/fomanticui.html:46
msgid "This field is required"
msgstr "Ce champ est requis"
@ -546,7 +546,7 @@ msgstr ""
" "
#: canaille/templates/forgotten-password.html:38
#: canaille/templates/profile.html:119 canaille/templates/profile.html:142
#: canaille/templates/profile.html:133 canaille/templates/profile.html:156
msgid "Send again"
msgstr "Envoyer à nouveau"
@ -567,12 +567,12 @@ msgstr ""
"irrévocable, et toutes les données de cet utilisateur seront supprimées."
#: canaille/templates/admin/client_edit.html:18
#: canaille/templates/group.html:29 canaille/templates/profile.html:25
#: canaille/templates/group.html:29 canaille/templates/profile.html:37
msgid "Cancel"
msgstr "Annuler"
#: canaille/templates/admin/client_edit.html:19
#: canaille/templates/group.html:30 canaille/templates/profile.html:26
#: canaille/templates/group.html:30 canaille/templates/profile.html:38
msgid "Delete"
msgstr "Supprimer"
@ -610,7 +610,7 @@ msgstr "Supprimer le groupe"
msgid "Create group"
msgstr "Créer le groupe"
#: canaille/templates/group.html:79 canaille/templates/profile.html:182
#: canaille/templates/group.html:79 canaille/templates/profile.html:196
msgid "Submit"
msgstr "Valider"
@ -703,11 +703,23 @@ msgstr "Je ne suis pas %(username)s"
msgid "Sign in"
msgstr "Se connecter"
#: canaille/templates/profile.html:13
#: canaille/templates/profile.html:12
msgid "This user can edit this field"
msgstr "Cet utilisateur peut éditer ce champ"
#: canaille/templates/profile.html:14
msgid "This user cannot edit this field"
msgstr "Cet utilisateur ne peut pas éditer ce champ"
#: canaille/templates/profile.html:16
msgid "This user cannot see this field"
msgstr "Cet utilisateur ne peut pas voir ce champ"
#: canaille/templates/profile.html:25
msgid "Account deletion"
msgstr "Suppression d'un compte"
#: canaille/templates/profile.html:18
#: canaille/templates/profile.html:30
msgid ""
"Are you sure you want to delete this user? This action is unrevokable and "
"all the data about this user will be removed."
@ -715,7 +727,7 @@ msgstr ""
"Êtes-vous sûrs de vouloir supprimer cet utilisateur ? Cette action est "
"irrévocable, et toutes les données de cet utilisateur seront supprimées."
#: canaille/templates/profile.html:20
#: canaille/templates/profile.html:32
msgid ""
"Are you sure you want to delete your account? This action is unrevokable and "
"all your data will be removed forever."
@ -723,51 +735,51 @@ msgstr ""
"Êtes-vous sûrs de vouloir supprimer votre compte ? Cette action est "
"irrévocable et toutes vos données seront supprimées pour toujours."
#: canaille/templates/profile.html:35
#: canaille/templates/profile.html:47
msgid "User creation"
msgstr "Nouvel utilisateur"
#: canaille/templates/profile.html:37 canaille/themes/default/base.html:39
#: canaille/templates/profile.html:49 canaille/themes/default/base.html:39
msgid "My profile"
msgstr "Mon profil"
#: canaille/templates/profile.html:39
#: canaille/templates/profile.html:51
msgid "User profile edition"
msgstr "Édition d'un profil utilisateur"
#: canaille/templates/profile.html:45
#: canaille/templates/profile.html:57
msgid "Create a new user account"
msgstr "Création d'un nouveau compte utilisateur"
#: canaille/templates/profile.html:47
#: canaille/templates/profile.html:59
msgid "Edit your personal informations"
msgstr "Éditez vos informations personnelles"
#: canaille/templates/profile.html:49
#: canaille/templates/profile.html:61
msgid "Edit informations about an user"
msgstr "Éditez les informations d'un utilisateur"
#: canaille/templates/profile.html:64
#: canaille/templates/profile.html:78
msgid "Personal information"
msgstr "Informations personnelles"
#: canaille/templates/profile.html:86
#: canaille/templates/profile.html:100
msgid "Account information"
msgstr "Informations sur le compte"
#: canaille/templates/profile.html:104
#: canaille/templates/profile.html:118
msgid "User password is not mandatory"
msgstr "Le mot de passe utilisateur n'est pas requis à la création"
#: canaille/templates/profile.html:106
#: canaille/templates/profile.html:120
msgid "The user password can be set:"
msgstr "Il pourra être renseigné :"
#: canaille/templates/profile.html:108
#: canaille/templates/profile.html:122
msgid "by filling this form;"
msgstr "en remplissant ce formulaire ;"
#: canaille/templates/profile.html:109
#: canaille/templates/profile.html:123
msgid ""
"by sending the user a password initialization mail, after the account "
"creation;"
@ -775,7 +787,7 @@ msgstr ""
"en envoyant un lien d'initialisation de mot de passe, par mail à "
"l'utilisateur, après la création de son compte;"
#: canaille/templates/profile.html:110 canaille/templates/profile.html:133
#: canaille/templates/profile.html:124 canaille/templates/profile.html:147
msgid ""
"or simply waiting for the user to sign-in a first time, and then receive a "
"password initialization mail."
@ -783,40 +795,40 @@ msgstr ""
"ou simplement en attendant la première connexion de l'utilisateur, afin "
"qu'il reçoive un lien d'initialisation de mot de passe par email."
#: canaille/templates/profile.html:123
#: canaille/templates/profile.html:137
msgid "Send email"
msgstr "Envoyer l'email"
#: canaille/templates/profile.html:127
#: canaille/templates/profile.html:141
msgid "This user does not have a password yet"
msgstr "L'utilisateur n'a pas encore de mot de passe"
#: canaille/templates/profile.html:129
#: canaille/templates/profile.html:143
msgid "You can solve this by:"
msgstr "Vous pouvez régler ceci en :"
#: canaille/templates/profile.html:131
#: canaille/templates/profile.html:145
msgid "setting a password using this form;"
msgstr "renseignant un mot de passe via ce formulaire ;"
#: canaille/templates/profile.html:132
#: canaille/templates/profile.html:146
msgid ""
"sending the user a password initialization mail, by clicking this button;"
msgstr ""
"envoyant un lien d'initialisation de mot de passe, par mail à l'utilisateur, "
"en cliquant sur ce bouton;"
#: canaille/templates/profile.html:144
#: canaille/templates/profile.html:158
msgid "Send mail"
msgstr "Envoyer l'email"
#: canaille/templates/admin/mails.html:34 canaille/templates/profile.html:148
#: canaille/templates/admin/mails.html:34 canaille/templates/profile.html:162
#: canaille/templates/reset-password.html:11
#: canaille/templates/reset-password.html:16
msgid "Password reset"
msgstr "Réinitialisation du mot de passe"
#: canaille/templates/profile.html:150
#: canaille/templates/profile.html:164
msgid ""
"If the user has forgotten his password, you can send him a password reset "
"email by clicking this button."
@ -824,19 +836,19 @@ msgstr ""
"Si l'utilisateur a oublié son mot de passe, vous pouvez lui envoyer un email "
"contenant un lien de réinitilisation en cliquant sur ce bouton."
#: canaille/templates/profile.html:162
#: canaille/templates/profile.html:176
msgid "Delete the user"
msgstr "Supprimer l'utilisateur"
#: canaille/templates/profile.html:164
#: canaille/templates/profile.html:178
msgid "Delete my account"
msgstr "Supprimer mon compte"
#: canaille/templates/profile.html:171
#: canaille/templates/profile.html:185
msgid "Impersonate"
msgstr "Prendre l'identité"
#: canaille/templates/profile.html:177 canaille/templates/users.html:18
#: canaille/templates/profile.html:191 canaille/templates/users.html:18
msgid "Invite a user"
msgstr "Inviter un utilisateur"

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2021-12-05 18:47+0100\n"
"POT-Creation-Date: 2021-12-05 19:40+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -493,11 +493,11 @@ msgstr ""
msgid "Send the initialization email"
msgstr ""
#: canaille/templates/fomanticui.html:33
#: canaille/templates/fomanticui.html:38 canaille/templates/fomanticui.html:42
msgid "This field is not editable"
msgstr ""
#: canaille/templates/fomanticui.html:37
#: canaille/templates/fomanticui.html:46
msgid "This field is required"
msgstr ""
@ -518,7 +518,7 @@ msgid ""
msgstr ""
#: canaille/templates/forgotten-password.html:38
#: canaille/templates/profile.html:119 canaille/templates/profile.html:142
#: canaille/templates/profile.html:133 canaille/templates/profile.html:156
msgid "Send again"
msgstr ""
@ -537,12 +537,12 @@ msgid ""
msgstr ""
#: canaille/templates/admin/client_edit.html:18
#: canaille/templates/group.html:29 canaille/templates/profile.html:25
#: canaille/templates/group.html:29 canaille/templates/profile.html:37
msgid "Cancel"
msgstr ""
#: canaille/templates/admin/client_edit.html:19
#: canaille/templates/group.html:30 canaille/templates/profile.html:26
#: canaille/templates/group.html:30 canaille/templates/profile.html:38
msgid "Delete"
msgstr ""
@ -577,7 +577,7 @@ msgstr ""
msgid "Create group"
msgstr ""
#: canaille/templates/group.html:79 canaille/templates/profile.html:182
#: canaille/templates/group.html:79 canaille/templates/profile.html:196
msgid "Submit"
msgstr ""
@ -664,127 +664,139 @@ msgstr ""
msgid "Sign in"
msgstr ""
#: canaille/templates/profile.html:13
#: canaille/templates/profile.html:12
msgid "This user can edit this field"
msgstr ""
#: canaille/templates/profile.html:14
msgid "This user cannot edit this field"
msgstr ""
#: canaille/templates/profile.html:16
msgid "This user cannot see this field"
msgstr ""
#: canaille/templates/profile.html:25
msgid "Account deletion"
msgstr ""
#: canaille/templates/profile.html:18
#: canaille/templates/profile.html:30
msgid ""
"Are you sure you want to delete this user? This action is unrevokable and"
" all the data about this user will be removed."
msgstr ""
#: canaille/templates/profile.html:20
#: canaille/templates/profile.html:32
msgid ""
"Are you sure you want to delete your account? This action is unrevokable "
"and all your data will be removed forever."
msgstr ""
#: canaille/templates/profile.html:35
#: canaille/templates/profile.html:47
msgid "User creation"
msgstr ""
#: canaille/templates/profile.html:37 canaille/themes/default/base.html:39
#: canaille/templates/profile.html:49 canaille/themes/default/base.html:39
msgid "My profile"
msgstr ""
#: canaille/templates/profile.html:39
#: canaille/templates/profile.html:51
msgid "User profile edition"
msgstr ""
#: canaille/templates/profile.html:45
#: canaille/templates/profile.html:57
msgid "Create a new user account"
msgstr ""
#: canaille/templates/profile.html:47
#: canaille/templates/profile.html:59
msgid "Edit your personal informations"
msgstr ""
#: canaille/templates/profile.html:49
#: canaille/templates/profile.html:61
msgid "Edit informations about an user"
msgstr ""
#: canaille/templates/profile.html:64
#: canaille/templates/profile.html:78
msgid "Personal information"
msgstr ""
#: canaille/templates/profile.html:86
#: canaille/templates/profile.html:100
msgid "Account information"
msgstr ""
#: canaille/templates/profile.html:104
#: canaille/templates/profile.html:118
msgid "User password is not mandatory"
msgstr ""
#: canaille/templates/profile.html:106
#: canaille/templates/profile.html:120
msgid "The user password can be set:"
msgstr ""
#: canaille/templates/profile.html:108
#: canaille/templates/profile.html:122
msgid "by filling this form;"
msgstr ""
#: canaille/templates/profile.html:109
#: canaille/templates/profile.html:123
msgid ""
"by sending the user a password initialization mail, after the account "
"creation;"
msgstr ""
#: canaille/templates/profile.html:110 canaille/templates/profile.html:133
#: canaille/templates/profile.html:124 canaille/templates/profile.html:147
msgid ""
"or simply waiting for the user to sign-in a first time, and then receive "
"a password initialization mail."
msgstr ""
#: canaille/templates/profile.html:123
#: canaille/templates/profile.html:137
msgid "Send email"
msgstr ""
#: canaille/templates/profile.html:127
#: canaille/templates/profile.html:141
msgid "This user does not have a password yet"
msgstr ""
#: canaille/templates/profile.html:129
#: canaille/templates/profile.html:143
msgid "You can solve this by:"
msgstr ""
#: canaille/templates/profile.html:131
#: canaille/templates/profile.html:145
msgid "setting a password using this form;"
msgstr ""
#: canaille/templates/profile.html:132
#: canaille/templates/profile.html:146
msgid "sending the user a password initialization mail, by clicking this button;"
msgstr ""
#: canaille/templates/profile.html:144
#: canaille/templates/profile.html:158
msgid "Send mail"
msgstr ""
#: canaille/templates/admin/mails.html:34 canaille/templates/profile.html:148
#: canaille/templates/admin/mails.html:34 canaille/templates/profile.html:162
#: canaille/templates/reset-password.html:11
#: canaille/templates/reset-password.html:16
msgid "Password reset"
msgstr ""
#: canaille/templates/profile.html:150
#: canaille/templates/profile.html:164
msgid ""
"If the user has forgotten his password, you can send him a password reset"
" email by clicking this button."
msgstr ""
#: canaille/templates/profile.html:162
#: canaille/templates/profile.html:176
msgid "Delete the user"
msgstr ""
#: canaille/templates/profile.html:164
#: canaille/templates/profile.html:178
msgid "Delete my account"
msgstr ""
#: canaille/templates/profile.html:171
#: canaille/templates/profile.html:185
msgid "Impersonate"
msgstr ""
#: canaille/templates/profile.html:177 canaille/templates/users.html:18
#: canaille/templates/profile.html:191 canaille/templates/users.html:18
msgid "Invite a user"
msgstr ""