feat: add profile edit

Profile page at /profile with first name, last name, display name, telephone and mobile read from AD and shown with the username and e-mail. Only changed fields are written through the directory adapter in one transaction with the audit entry (field names only); numbers are accepted in any common notation and stored as +country code and digits; names are required. Plain-language errors per field, German text and tests; review findings logged in the plan.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FocPJ75XPma7TcuYEMy8zm
This commit is contained in:
Ebbe Baß
2026-10-19 09:03:24 +02:00
co-authored by Claude Sonnet 5.5
parent ae4b30ec22
commit 3fd8f27127
14 changed files with 1055 additions and 5 deletions
@@ -0,0 +1,7 @@
{% load i18n %}
<div class="field{% if field.errors %} has-error{% endif %}">
<label for="{{ field.id_for_label }}">{{ label }}</label>
<input type="{{ input_type|default:'text' }}" name="{{ field.html_name }}" id="{{ field.id_for_label }}" value="{{ field.value|default_if_none:'' }}" autocomplete="{{ autocomplete }}" maxlength="{{ max_length }}"{% if required %} required{% endif %}{% if field.errors %} aria-invalid="true"{% endif %} aria-describedby="{{ field.id_for_label }}-hint{% if field.errors %} {{ field.id_for_label }}-error{% endif %}">
{% if hint %}<p class="hint" id="{{ field.id_for_label }}-hint">{{ hint }}</p>{% else %}<span id="{{ field.id_for_label }}-hint"></span>{% endif %}
{% if field.errors %}<div id="{{ field.id_for_label }}-error">{% for error in field.errors %}<p class="error">{{ error }}</p>{% endfor %}</div>{% endif %}
</div>
+54
View File
@@ -0,0 +1,54 @@
{% extends "base.html" %}
{% load i18n %}
{% block title %}{% trans "Profile" %}{% endblock %}
{% block content %}
<h1>{% trans "Profile" %}</h1>
<p class="lead">{% trans "These details are stored in your account. Changes apply to every service that uses it." %}</p>
{% if notice == "saved" %}
<div class="notice success" role="status">
<p>{% trans "Your changes were saved." %}</p>
</div>
{% elif notice == "unchanged" %}
<div class="notice" role="status">
<p>{% trans "Nothing to change." %}</p>
</div>
{% endif %}
{% if form.errors %}
<div class="error-summary" role="alert" tabindex="-1" data-focus-on-load>
<p><strong>{% trans "Your changes were not saved." %}</strong></p>
<ul>
{% for error in form.non_field_errors %}<li>{{ error }}</li>{% endfor %}
{% for field in form %}{% for error in field.errors %}
<li><a href="#{{ field.id_for_label }}">{{ error }}</a></li>
{% endfor %}{% endfor %}
</ul>
</div>
{% endif %}
{% if details %}
<dl class="card details">
<dt>{% trans "User name" %}</dt>
<dd>{{ details.username }}</dd>
<dt>{% trans "E-mail address" %}</dt>
<dd>{% if details.mail %}{{ details.mail }}{% else %}&ndash;{% endif %}</dd>
</dl>
{% endif %}
<form method="post" action="{% url 'profile' %}" class="card" data-busy-on-submit novalidate>
{% csrf_token %}
{% trans "For example +49 171 123456. A number that starts with 0 is read as German." as phone_hint %}
{% for item in fields %}
{% if item.field.name == "first_name" %}
{% include "profile/_text_field.html" with field=item.field label=item.label max_length=item.max_length autocomplete="given-name" required=True %}
{% elif item.field.name == "last_name" %}
{% include "profile/_text_field.html" with field=item.field label=item.label max_length=item.max_length autocomplete="family-name" required=True %}
{% elif item.field.name == "display_name" %}
{% include "profile/_text_field.html" with field=item.field label=item.label max_length=item.max_length autocomplete="name" required=True %}
{% else %}
{% include "profile/_text_field.html" with field=item.field label=item.label max_length=item.max_length autocomplete="tel" input_type="tel" hint=phone_hint %}
{% endif %}
{% endfor %}
<p class="actions">
<button type="submit" class="primary"><span class="spinner" aria-hidden="true"></span>{% trans "Save changes" %}</button>
<a class="button" href="{% url 'home' %}">{% trans "Cancel" %}</a>
</p>
</form>
{% endblock %}
@@ -0,0 +1,10 @@
{% extends "base.html" %}
{% load i18n %}
{% block title %}{% trans "Result unclear" %}{% endblock %}
{% block content %}
<h1>{% trans "Result unclear" %}</h1>
<div class="notice" role="alert">
<p>{% trans "Your details may have been changed, but the portal could not finish. Please open your profile and check them. If they are wrong, contact the administrator." %}</p>
</div>
<p><a class="button" href="{% url 'profile' %}">{% trans "Back to the profile" %}</a></p>
{% endblock %}