From 1b5c5789a75d5a7b8c0aa64575b960a9b614e472 Mon Sep 17 00:00:00 2001 From: Leandro Roberto Date: Sat, 13 Mar 2021 23:35:04 -0300 Subject: [PATCH] =?UTF-8?q?HOT-FIX:=20corrige=20edi=C3=A7=C3=A3o=20simplif?= =?UTF-8?q?icada=20de=20usu=C3=A1rio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/base/forms.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sapl/base/forms.py b/sapl/base/forms.py index 15c4edc10..e56dd7a3b 100644 --- a/sapl/base/forms.py +++ b/sapl/base/forms.py @@ -134,6 +134,7 @@ class UserAdminForm(ModelForm): ('groups', 12), ] + ([('user_permissions', 12)] if not self.granular is None else []) + ) self.helper = SaplFormHelper() @@ -185,11 +186,15 @@ class UserAdminForm(ModelForm): self.instance.set_password(self.cleaned_data['new_password1']) votante = None + permissions = None if self.instance.id: inst_old = get_user_model().objects.get(pk=self.instance.pk) votante = inst_old.groups.filter(name='Votante').first() autor = inst_old.groups.filter(name='Autor').first() + if self.granular is None: + permissions = list(inst_old.user_permissions.all()) + inst_new = super().save(commit) if votante: @@ -198,6 +203,9 @@ class UserAdminForm(ModelForm): if autor: inst_new.groups.add(autor) + if permissions: + inst_new.user_permissions.add(*permissions) + return inst_new def clean(self):