1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-02-19 06:31:17 +00:00

Some improvements

This commit is contained in:
thomasl 2025-02-13 20:09:45 +01:00
parent 62baad7b69
commit 9e7f7df721
2 changed files with 5 additions and 2 deletions

View File

@ -15,7 +15,6 @@ from django.utils.translation import gettext_lazy as _
from note.models import NoteSpecial, Alias
from note_kfet.inputs import Autocomplete, AmountInput
from permission.models import PermissionMask, Role
from permission.backends import PermissionBackend
from PIL import Image, ImageSequence
from .models import Profile, Club, Membership

View File

@ -79,13 +79,17 @@ class UserUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView):
del profile_form.fields["last_report"]
fields_to_check = list(profile_form.fields.keys())
fields_modifiable = False
# 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):
profile_form.fields[field_name].widget = forms.HiddenInput()
else :
fields_modifiable = True
context['profile_form'] = profile_form
if fields_modifiable :
context['profile_form'] = profile_form
return context