From 9c1253878caa56bd1a1600beb6b25396c70821c6 Mon Sep 17 00:00:00 2001 From: sebastien yaal Date: Tue, 7 Jan 2025 15:58:39 +0000 Subject: [PATCH] Resolve "Impossible to update my password" --- CHANGES.rst | 4 ++++ canaille/core/endpoints/account.py | 2 +- canaille/core/endpoints/forms.py | 11 +++++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 83ecae35..ce8f3397 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,10 @@ Added ^^^^^ - ``--version`` option to the CLI. :pr:`209` +Changed +^^^^^^^ +- fixed a bug on updating user's settings :issue:`206` + [0.0.57] - 2024-12-31 --------------------- diff --git a/canaille/core/endpoints/account.py b/canaille/core/endpoints/account.py index 507a375a..28bb5d8b 100644 --- a/canaille/core/endpoints/account.py +++ b/canaille/core/endpoints/account.py @@ -784,7 +784,7 @@ def profile_settings_edit(editor, edited_user): if hasattr(edited_user, k) and k in available_fields } - data["groups"] = [group.id for group in edited_user.groups] + data["groups"] = edited_user.groups form = build_profile_form( editor.writable_fields & available_fields, diff --git a/canaille/core/endpoints/forms.py b/canaille/core/endpoints/forms.py index 9f700e4f..d8fdb609 100644 --- a/canaille/core/endpoints/forms.py +++ b/canaille/core/endpoints/forms.py @@ -260,10 +260,13 @@ PROFILE_FORM_FIELDS = dict( groups=wtforms.SelectMultipleField( _("Groups"), default=[], - choices=lambda: [ - (group, group.display_name) - for group in Backend.instance.query(models.Group) - ], + choices=lambda: sorted( + [ + (group, group.display_name) + for group in Backend.instance.query(models.Group) + ], + key=lambda group: group[0].id, + ), render_kw={"placeholder": _("users, admins …")}, coerce=IDToModel("Group"), validators=[non_empty_groups],