From f4b3af0f63bd1de0997839f920dbcfb097e39a13 Mon Sep 17 00:00:00 2001 From: LeandroRoberto Date: Mon, 28 Nov 2016 11:23:13 -0200 Subject: [PATCH] Ajst Autor para trabalhar com username_field de user --- sapl/base/forms.py | 10 +++++++--- sapl/base/views.py | 2 +- sapl/templates/base/layouts.yaml | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/sapl/base/forms.py b/sapl/base/forms.py index 75145bba7..ea30726ae 100644 --- a/sapl/base/forms.py +++ b/sapl/base/forms.py @@ -358,9 +358,13 @@ class AutorForm(ModelForm): u.save() elif self.cleaned_data['action_user'] == 'C': - u = get_user_model().objects.create( - username=self.cleaned_data['username'], - email=self.cleaned_data['email']) + param_username = { + get_user_model().USERNAME_FIELD: self.cleaned_data['username']} + + if get_user_model().USERNAME_FIELD != 'email': + param_username['email'] = self.cleaned_data['email'] + + u = get_user_model().objects.create(**param_username) u.set_password(self.cleaned_data['senha']) # Define usuário como ativo em ambiente de desenvolvimento diff --git a/sapl/base/views.py b/sapl/base/views.py index 4de2da9fc..9d50c7176 100644 --- a/sapl/base/views.py +++ b/sapl/base/views.py @@ -62,7 +62,7 @@ class AutorCrud(CrudAux): help_path = 'autor' class BaseMixin(CrudAux.BaseMixin): - list_field_names = ['tipo', 'nome', 'user__username'] + list_field_names = ['tipo', 'nome', 'user'] class DeleteView(CrudAux.DeleteView): diff --git a/sapl/templates/base/layouts.yaml b/sapl/templates/base/layouts.yaml index be1901b0f..ac9607c3f 100644 --- a/sapl/templates/base/layouts.yaml +++ b/sapl/templates/base/layouts.yaml @@ -27,7 +27,7 @@ TipoAutor: Autor: {% trans 'Autor' %}: - tipo:3 nome - - user:6 cargo + - cargo AutorCreate: {% trans 'Cadastro de Usuários Autores' %}: