1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-02-11 18:51:19 +00:00

Update file views.py

This commit is contained in:
thomasl 2025-02-09 15:39:08 +01:00
parent 6127ced143
commit bcf21507e5

View File

@ -81,20 +81,15 @@ class UserUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView):
# 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)
has_permission = False
# Désactivation des champs non autorisés
for field_name in profile_form.fields:
if PermissionBackend.check_perm(self.request, f"member.change_profile_{field_name}", context['user_object'].profile):
has_permission = True
else:
if not PermissionBackend.check_perm(self.request, f"member.change_profile_{field_name}", context['user_object'].profile):
profile_form.fields[field_name].widget.attrs['disabled'] = True
if has_permission :
context['profile_form'] = profile_form
context['profile_form'] = profile_form
if not self.object.profile.report_frequency:
if not self.object.profile.report_frequency:
del context['profile_form'].fields["last_report"]