From c34f2aca7d90790bee697f4fa8ea2c4700264588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Cantu=C3=A1ria?= Date: Fri, 3 Jul 2020 16:00:31 -0300 Subject: [PATCH] =?UTF-8?q?3178=20-=20Atualiza=20status=20de=20ativa=C3=A7?= =?UTF-8?q?=C3=A3o=20do=20usu=C3=A1rio=20com=20o=20do=20parlamentar=20vinc?= =?UTF-8?q?ulado=20(#3186)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Atualiza status de ativação do usuário com o do parlamentar vinculado * Realiza mudanças solicitadas --- sapl/parlamentares/forms.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sapl/parlamentares/forms.py b/sapl/parlamentares/forms.py index 448535d40..2f2cd49c3 100755 --- a/sapl/parlamentares/forms.py +++ b/sapl/parlamentares/forms.py @@ -216,6 +216,17 @@ class ParlamentarForm(FileFieldCheckMixin, ModelForm): 'biografia': forms.Textarea( attrs={'id': 'texto-rico'})} + def save(self, commit=True): + parlamentar = super().save() + autor = parlamentar.autor.first() + usuario = autor.user if autor else None + + if autor and usuario: + usuario.is_active = parlamentar.ativo + usuario.save() + + return parlamentar + class ParlamentarFilterSet(django_filters.FilterSet): nome_parlamentar = django_filters.CharFilter(