diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2023-12-18 16:18:06 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2023-12-18 16:23:11 +0100 |
commit | e538ac34869c0f57f96269376b744923fa4aad9e (patch) | |
tree | 21ab5bb5811ce759d2d070a9e1f7fc1a82255bd4 | |
parent | 0bffd12daeb9dfee4fb8365d0dca645e7e735c8a (diff) | |
download | Ishtar-e538ac34869c0f57f96269376b744923fa4aad9e.tar.bz2 Ishtar-e538ac34869c0f57f96269376b744923fa4aad9e.zip |
🐛 account form: set profile_type to readonly in order to prevent some errors on deletion (refs #5696)
-rw-r--r-- | changelog/en/changelog_2022-06-15.md | 2 | ||||
-rw-r--r-- | changelog/fr/changelog_2023-01-25.md | 1 | ||||
-rw-r--r-- | ishtar_common/forms_common.py | 12 |
3 files changed, 15 insertions, 0 deletions
diff --git a/changelog/en/changelog_2022-06-15.md b/changelog/en/changelog_2022-06-15.md index 436aa4c63..e7f96432f 100644 --- a/changelog/en/changelog_2022-06-15.md +++ b/changelog/en/changelog_2022-06-15.md @@ -3,6 +3,8 @@ v4.0.69 - 2023-12-18 ### Technical ### - values associated with archaeological find for templates: use "base_find_" prefix and simple prefix (#5695) +- account form: on modification set profile_type to readonly in order to prevent some errors on deletion (#5696) + v4.0.68 - 2023-11-30 -------------------- diff --git a/changelog/fr/changelog_2023-01-25.md b/changelog/fr/changelog_2023-01-25.md index 8e79a4cba..036f15f88 100644 --- a/changelog/fr/changelog_2023-01-25.md +++ b/changelog/fr/changelog_2023-01-25.md @@ -3,6 +3,7 @@ v4.0.69 - 2023-12-18 ### Technique ### - valeurs associées au mobilier pour les patrons de documents : utiliser le préfixe "base_find_" et le préfixe simple (#5695) +- formulaire de compte : en modification le type de profil est en lecture seule afin d'éviter certaines erreurs lors de la suppression (#5696) v4.0.68 - 2023-11-30 -------------------- diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index a4a77c8f7..197b5a03c 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -1306,6 +1306,18 @@ class ProfileForm(ManageOldType): FieldType("area", models.Area, is_multiple=True), ] + def __init__(self, *args, **kwargs): + profile_type = None + initial = kwargs.get("initial", None) + if initial and "profile_type" in initial: + profile_type = initial.get("profile_type") + super().__init__(*args, **kwargs) + if profile_type: + self.fields["profile_type"].widget.choices = [ + (k, v) for k, v in self.fields["profile_type"].widget.choices if profile_type == str(k) + ] + self.fields["profile_type"].widget.attrs.update({"readonly": True}) + class ProfileFormsetBase(FormSetWithDeleteSwitches): def clean(self): |