Browse Source

Ajst Autor para trabalhar com username_field de user

pull/845/head
LeandroRoberto 8 years ago
parent
commit
f4b3af0f63
  1. 10
      sapl/base/forms.py
  2. 2
      sapl/base/views.py
  3. 2
      sapl/templates/base/layouts.yaml

10
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

2
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):

2
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' %}:

Loading…
Cancel
Save