canaille-globuzma/canaille/templates/core/profile_settings.html

191 lines
9.4 KiB
HTML
Raw Normal View History

2024-12-16 17:17:42 +00:00
{# The profile settings template.
Displays the user settings edition form.
:param edited_user: The user that the form will edit.
:type edited_user: :class:`~canaille.core.models.User`
:param form: The user profile edition form. Dynamically built according to the user :attr:`~canaille.core.configuration.ACLSettings.READ` and :attr:`~canaille.core.configuration.ACLSettings.WRITE` permissions. The available fields are those appearing in *READ* and *WRITE*, those only appearing in *READ* are read-only.
:type form: :class:`~flask_wtf.FlaskForm`
:param self_deletion: Whether the editor is allowed to delete the account of the edited user.
:type self_deletion: :class:`bool`
#}
{% extends theme('base.html') %}
2023-03-28 18:37:16 +00:00
{% import 'macro/form.html' as fui %}
2020-10-20 09:44:45 +00:00
{%- block title -%}
{% if user.user_name == edited_user.user_name %}
{%- trans %}My profile{% endtrans -%}
2023-03-10 00:02:36 +00:00
{% else %}
{%- trans %}User profile edition{% endtrans -%}
2023-03-10 00:02:36 +00:00
{% endif %}
{%- endblock -%}
2023-03-10 00:02:36 +00:00
2023-03-15 16:27:32 +00:00
{% block submenu %}
<a class="item" href="{{ url_for('core.account.profile_edition', edited_user=edited_user) }}">
<i class="id card icon"></i>
{% trans %}Personal information{% endtrans %}
</a>
<a class="active item" href="{{ url_for('core.account.profile_settings', edited_user=edited_user) }}">
<i class="tools icon"></i>
{% trans %}Account settings{% endtrans %}
</a>
2023-03-15 16:27:32 +00:00
{% endblock %}
{% macro render_field(field, noindicator=false) %}
{% set lock_indicator = field.render_kw and ("readonly" in field.render_kw or "disabled" in field.render_kw) %}
{% if edited_user.user_name == user.user_name or lock_indicator or noindicator %}
{{ fui.render_field(field, **kwargs) }}
{% elif field.name in edited_user.writable_fields %}
{{ fui.render_field(field, **kwargs) }}
{% elif field.name in edited_user.readable_fields %}
{{ fui.render_field(field, indicator_icon="eye", indicator_text=_("This user cannot edit this field"), **kwargs) }}
{% else %}
{{ fui.render_field(field, indicator_icon="eye slash", indicator_text=_("This user cannot see this field"), **kwargs) }}
{% endif %}
{% endmacro %}
2020-10-20 09:44:45 +00:00
{% block content %}
2021-12-20 22:57:27 +00:00
<div class="ui clearing segment">
<h2 class="ui center aligned header">
<div class="content">
2023-06-30 16:10:16 +00:00
{% trans %}Account settings{% endtrans %}
2021-12-20 22:57:27 +00:00
</div>
<div class="sub header" title="{{ edited_user.created|datetimeformat }}">
{% trans creation_datetime=edited_user.created|dateformat %}Created on {{ creation_datetime }}{% endtrans %}
</div>
2021-12-20 22:57:27 +00:00
</h2>
{% call fui.render_form(form, class_="profile-form info warning") %}
{% if "user_name" in form %}
{% block user_name_field scoped %}{{ render_field(form.user_name) }}{% endblock %}
2021-12-20 22:57:27 +00:00
{% endif %}
2021-12-01 11:19:28 +00:00
{% if features.has_account_lockability and "lock_date" in form and not edited_user.locked %}
{% block lock_date_field scoped %}{{ render_field(form.lock_date) }}{% endblock %}
{% endif %}
2021-12-20 22:57:27 +00:00
{% if "groups" in form %}
{% block groups_field scoped %}{{ render_field(form.groups) }}{% endblock %}
2021-12-20 22:57:27 +00:00
{% endif %}
2021-01-22 17:26:53 +00:00
<h2 class="ui center aligned header">
<div class="content">
{% trans %}Password{% endtrans %}
</div>
</h2>
<div class="ui info message">
{% trans %}
You can change your password here by typing it once it each fields below.
The more a password is long, the more it is strong. A good password is a
long password that you will remember, not a complicated password that your
use for all your accounts.
{% endtrans %}
</div>
2021-12-20 22:57:27 +00:00
{% if "password1" in form %}
{% block password_field scoped %}
<div class="two fields">
{{ render_field(form.password1, noindicator=true) }}
{{ render_field(form.password2, noindicator=true) }}
2021-12-20 22:57:27 +00:00
</div>
{% endblock %}
{% endif %}
2021-12-01 11:19:28 +00:00
2021-12-20 22:57:27 +00:00
{% if user.can_manage_users %}
2023-03-17 08:27:48 +00:00
{% if not edited_user.has_password() %}
2021-12-20 22:57:27 +00:00
<div class="ui message warning visible">
{% if features.has_smtp and edited_user.can_edit_self %}
<button type="submit" name="action" value="password-initialization-mail" class="ui right floated primary button">
2024-03-27 13:06:38 +00:00
{% trans %}Send mail{% endtrans %}
</button>
2021-12-20 22:57:27 +00:00
{% endif %}
<div class="header">
{% trans %}This user does not have a password yet{% endtrans %}
</div>
{% if features.has_smtp and edited_user.can_edit_self %}
2021-12-20 22:57:27 +00:00
<p>{% trans %}You can solve this by:{% endtrans %}</p>
<ul class="ui list">
<li>{% trans %}setting a password using this form;{% endtrans %}</li>
<li>{% trans %}sending the user a password initialization mail, by clicking this button;{% endtrans %}</li>
<li>{% trans %}or simply waiting for the user to sign-in a first time, and then receive a password initialization mail.{% endtrans %}</li>
</ul>
{% else %}
<p>{% trans %}The user will not be able to authenticate unless the password is set{% endtrans %}</p>
{% endif %}
</div>
{% elif features.has_smtp and edited_user.user_name != user.user_name and edited_user.has_password() and edited_user.can_edit_self %}
2021-12-20 22:57:27 +00:00
<div class="ui message info">
<button type="submit" name="action" value="password-reset-mail" class="ui right floated button">
{% trans %}Send mail{% endtrans %}
</button>
2021-12-20 22:57:27 +00:00
<div class="header">
{% trans %}Password reset{% endtrans %}
</div>
<p>{% trans %}If the user has forgotten his password, you can send him a password reset email by clicking this button.{% endtrans %}</p>
</div>
2021-12-01 11:19:28 +00:00
{% endif %}
2021-01-22 17:26:53 +00:00
{% if features.has_account_lockability and edited_user.locked %}
2022-11-01 11:25:21 +00:00
<div class="ui message warning visible">
<button type="submit" name="action" value="unlock" class="ui right floated button">
{% trans %}Unlock{% endtrans %}
</button>
<div class="header">
{% trans %}This user account is locked{% endtrans %}
</div>
<p>
{% trans %}The user won't be able to connect until their account is unlocked.{% endtrans %}
</p>
</div>
{% endif %}
{% endif %}
2020-11-01 10:33:56 +00:00
2021-12-20 22:57:27 +00:00
<div class="ui right aligned container">
<div class="ui stackable buttons">
{% if features.has_otp and user.can_manage_users %}
2024-11-18 13:16:38 +00:00
<button type="submit" class="ui right floated basic negative button confirm" name="action" value="confirm-reset-otp" id="reset-otp" formnovalidate>
{% trans %}Reset one-time password authentication{% endtrans %}
</button>
{% endif %}
{% if features.has_account_lockability and "lock_date" in user.writable_fields and not edited_user.locked %}
<button type="submit" class="ui right floated basic negative button confirm" name="action" value="confirm-lock" id="lock" formnovalidate>
2022-11-01 11:25:21 +00:00
{% trans %}Lock the account{% endtrans %}
</button>
{% endif %}
2023-03-17 08:27:48 +00:00
{% if user.can_manage_users or self_deletion %}
<button type="submit" class="ui right floated basic negative button confirm" name="action" value="confirm-delete" id="delete" formnovalidate>
{% if user.user_name != edited_user.user_name %}
2021-12-20 22:57:27 +00:00
{{ _("Delete the user") }}
{% else %}
{{ _("Delete my account") }}
{% endif %}
</button>
2021-07-01 07:55:40 +00:00
{% endif %}
{% if user.can_impersonate_users and user.identifier != edited_user.identifier and not edited_user.locked %}
<a href="{{ url_for('core.account.impersonate', puppet=edited_user) }}" class="ui right floated basic button" name="action" value="impersonate" id="impersonate" hx-boost="false">
2021-12-20 22:57:27 +00:00
{{ _("Impersonate") }}
</a>
{% endif %}
2021-07-01 07:55:40 +00:00
<button type="submit" class="ui right floated primary button" name="action" value="edit-settings" id="edit-settings">
2023-07-07 08:06:01 +00:00
{{ _("Edit") }}
2021-12-20 22:57:27 +00:00
</button>
2021-07-01 07:55:40 +00:00
2021-12-20 22:57:27 +00:00
</div>
2021-07-01 07:55:40 +00:00
</div>
{% endcall %}
2021-12-20 22:57:27 +00:00
</div>
2020-10-20 09:44:45 +00:00
{% endblock %}