canaille-globuzma/canaille/templates/profile_edit.html

188 lines
8 KiB
HTML
Raw Normal View History

2023-03-16 17:39:28 +00:00
{% extends theme('base.html') %}
2023-03-28 18:37:16 +00:00
{% import 'macro/form.html' as fui %}
2023-03-16 17:39:28 +00:00
{%- block title -%}
2023-03-16 17:39:28 +00:00
{% if not edited_user %}
{%- trans %}User creation{% endtrans -%}
{% elif user.user_name == edited_user.user_name %}
{%- trans %}My profile{% endtrans -%}
2023-03-16 17:39:28 +00:00
{% else %}
{%- trans %}User profile edition{% endtrans -%}
2023-03-16 17:39:28 +00:00
{% endif %}
{%- endblock -%}
2023-03-16 17:39:28 +00:00
{% block script %}
<script src="/static/js/confirm.js"></script>
<script src="/static/js/profile.js"></script>
{% endblock %}
{% block submenu %}
<nav class="ui bottom attached two item borderless menu">
<a class="active item" href="{{ url_for('account.profile_edition', username=edited_user.user_name[0]) }}">
2023-03-16 17:39:28 +00:00
<i class="id card icon"></i>
{% trans %}Personal information{% endtrans %}
</a>
<a class="item" href="{{ url_for('account.profile_settings', username=edited_user.user_name[0]) }}">
2023-03-16 17:39:28 +00:00
<i class="tools icon"></i>
{% trans %}Account information{% endtrans %}
</a>
</nav>
{% endblock %}
2023-06-19 16:10:14 +00:00
{% macro render_input(field, noindicator=false) %}
2023-03-16 17:39:28 +00:00
{% set lock_indicator = field.render_kw and ("readonly" in field.render_kw or "disabled" in field.render_kw) %}
{% if not edited_user %}
2023-06-19 16:10:14 +00:00
{{ fui.render_input(field, **kwargs) }}
{% elif edited_user.user_name == user.user_name or lock_indicator or noindicator %}
2023-06-19 16:10:14 +00:00
{{ fui.render_input(field, **kwargs) }}
2023-03-16 17:39:28 +00:00
{% elif field.name in edited_user.write %}
2023-06-19 16:10:14 +00:00
{{ fui.render_input(field, **kwargs) }}
2023-03-16 17:39:28 +00:00
{% elif field.name in edited_user.read %}
2023-06-19 16:10:14 +00:00
{{ fui.render_input(field, indicator_icon="eye", indicator_text=_("This user cannot edit this field"), **kwargs) }}
2023-03-16 17:39:28 +00:00
{% else %}
2023-06-19 16:10:14 +00:00
{{ fui.render_input(field, indicator_icon="eye slash", indicator_text=_("This user cannot see this field"), **kwargs) }}
2023-03-16 17:39:28 +00:00
{% endif %}
{% endmacro %}
{% block content %}
<div class="ui clearing segment">
<h2 class="ui center aligned header">
<div class="content">
{% if user.user_name == edited_user.user_name %}
2023-03-16 17:39:28 +00:00
{% trans %}My profile{% endtrans %}
{% else %}
{% trans %}User profile edition{% endtrans %}
{% endif %}
</div>
<div class="sub header">
{% if user.user_name == edited_user.user_name %}
2023-03-16 17:39:28 +00:00
{% trans %}Edit your personal information{% endtrans %}
{% else %}
{% trans %}Edit information about a user{% endtrans %}
{% endif %}
</div>
</h2>
{% call fui.render_form(form) %}
{% if "photo" in form %}
2023-03-16 17:39:28 +00:00
<div class="ui grid">
<div class="three wide column">
{% block photo_field scoped %}
2023-06-19 16:10:14 +00:00
{{ render_input(form.photo, display=false, class="photo-field") }}
{{ render_input(form.photo_delete, display=false, class="photo-delete-button") }}
{% set photo = edited_user.photo and edited_user.photo[0] %}
2023-03-16 17:39:28 +00:00
<label
class="ui small bordered image photo-content"
for="{{ form.photo.id }}"
2023-03-16 17:39:28 +00:00
title="{{ _("Click to upload a photo") }}"
{% if not photo %}style="display: none;"{% endif %}>
<a class="ui right corner label photo-delete-icon" title="{{ _("Delete the photo") }}">
<i class="times icon"></i>
</a>
<img src="{% if photo %}{{ url_for("account.photo", user_name=edited_user.user_name[0], field="photo") }}{% endif %}" alt="User photo">
2023-03-16 17:39:28 +00:00
</label>
<label
class="ui centered photo-placeholder"
for="{{ form.photo.id }}"
2023-03-16 17:39:28 +00:00
title="{{ _("Click to upload a photo") }}"
{% if photo %}style="display: none;"{% endif %}>
<i class="massive centered portrait icon"></i>
</label>
</div>
{% endblock %}
<div class="thirteen wide column">
{% endif %}
{% if "given_name" in form or "family_name" in form %}
2023-03-16 17:39:28 +00:00
<div class="equal width fields">
{% if "given_name" in form %}
2023-06-19 16:10:14 +00:00
{% block given_name_field scoped %}{{ render_input(form.given_name) }}{% endblock %}
2023-03-16 17:39:28 +00:00
{% endif %}
{% if "family_name" in form %}
2023-06-19 16:10:14 +00:00
{% block sn_field scoped %}{{ render_input(form.family_name) }}{% endblock %}
2023-03-16 17:39:28 +00:00
{% endif %}
</div>
{% endif %}
{% if "display_name" in form %}
2023-06-19 16:10:14 +00:00
{% block display_name_field scoped %}{{ render_input(form.display_name) }}{% endblock %}
2023-03-16 17:39:28 +00:00
{% endif %}
{% if "photo" in form %}</div></div>{% endif %}
2023-03-16 17:39:28 +00:00
2023-06-22 13:14:07 +00:00
{% if "emails" in form %}
{% block emails_field scoped %}{{ render_input(form.emails) }}{% endblock %}
2023-03-16 17:39:28 +00:00
{% endif %}
{% if "phone_number" in form %}
2023-06-19 16:10:14 +00:00
{% block phone_number_field scoped %}{{ render_input(form.phone_number) }}{% endblock %}
2023-03-16 17:39:28 +00:00
{% endif %}
{% if "formatted_address" in form %}
2023-06-19 16:10:14 +00:00
{% block formatted_address_field scoped %}{{ render_input(form.formatted_address) }}{% endblock %}
2023-03-16 17:39:28 +00:00
{% endif %}
{% if "street" in form %}
2023-06-19 16:10:14 +00:00
{% block street_field scoped %}{{ render_input(form.street) }}{% endblock %}
2023-03-16 17:39:28 +00:00
{% endif %}
<div class="equal width fields">
{% if "postal_code" in form %}
2023-06-19 16:10:14 +00:00
{% block postal_code_field scoped %}{{ render_input(form.postal_code) }}{% endblock %}
2023-03-16 17:39:28 +00:00
{% endif %}
{% if "locality" in form %}
2023-06-19 16:10:14 +00:00
{% block locality_field scoped %}{{ render_input(form.locality) }}{% endblock %}
2023-03-16 17:39:28 +00:00
{% endif %}
{% if "region" in form %}
2023-06-19 16:10:14 +00:00
{% block region_field scoped %}{{ render_input(form.region) }}{% endblock %}
2023-03-16 17:39:28 +00:00
{% endif %}
</div>
<div class="equal width fields">
{% if "department" in form %}
2023-06-19 16:10:14 +00:00
{% block department_number_field scoped %}{{ render_input(form.department) }}{% endblock %}
2023-03-16 17:39:28 +00:00
{% endif %}
{% if "employee_number" in form %}
2023-06-19 16:10:14 +00:00
{% block employee_number_field scoped %}{{ render_input(form.employee_number) }}{% endblock %}
2023-03-16 17:39:28 +00:00
{% endif %}
2023-03-17 16:35:05 +00:00
</div>
<div class="equal width fields">
2023-03-16 17:39:28 +00:00
{% if "title" in form %}
2023-06-19 16:10:14 +00:00
{% block title_field scoped %}{{ render_input(form.title) }}{% endblock %}
2023-03-16 17:39:28 +00:00
{% endif %}
{% if "organization" in form %}
2023-06-19 16:10:14 +00:00
{% block organization_field scoped %}{{ render_input(form.organization) }}{% endblock %}
2023-03-17 16:35:05 +00:00
{% endif %}
2023-03-16 17:39:28 +00:00
</div>
{% if "profile_url" in form %}
2023-06-19 16:10:14 +00:00
{% block profile_url_field scoped %}{{ render_input(form.profile_url) }}{% endblock %}
2023-03-16 17:39:28 +00:00
{% endif %}
{% if "preferred_language" in form %}
2023-06-19 16:10:14 +00:00
{% block preferred_language_field scoped %}{{ render_input(form.preferred_language) }}{% endblock %}
2023-03-16 17:39:28 +00:00
{% endif %}
<div class="ui right aligned container">
<div class="ui stackable buttons">
<button type="submit" class="ui right floated primary button" name="action" value="edit" id="edit">
2023-04-27 17:26:01 +00:00
{{ _("Edit") }}
2023-03-16 17:39:28 +00:00
</button>
</div>
</div>
{% endcall %}
2023-03-16 17:39:28 +00:00
</div>
{% endblock %}