1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-04-28 09:32:43 +00:00

Update file views.py

This commit is contained in:
thomasl 2025-02-09 15:56:12 +01:00
parent 05e21ed229
commit 9635004520

View File

@ -72,22 +72,15 @@ class UserUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView):
form.fields['email'].required = True
form.fields['email'].help_text = _("This address must be valid.")
#if PermissionBackend.check_perm(self.request, "member.change_profile", context['user_object'].profile):
# context['profile_form'] = self.profile_form(instance=context['user_object'].profile,
# data=self.request.POST if self.request.POST else None)
# if not self.object.profile.report_frequency:
# del context['profile_form'].fields["last_report"]
# Vérification des permissions sur le profil
profile_form = self.profile_form(instance=context['user_object'].profile,
data=self.request.POST if self.request.POST else None)
if not self.object.profile.report_frequency:
del profile_form.fields["last_report"]
# Désactivation des champs non autorisés
fields_to_check = list(profile_form.fields.keys())
# Delete the fields for which the user does not have the permission to modify
for field_name in fields_to_check:
if not PermissionBackend.check_perm(self.request, f"member.change_profile_{field_name}", context['user_object'].profile):
del profile_form.fields[field_name]