1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-02-12 03:01:17 +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

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