From c10a45f311f2af63779c07e1f79e62059d5ba4b8 Mon Sep 17 00:00:00 2001 From: Leandro Roberto Date: Thu, 4 Jul 2019 23:09:43 -0300 Subject: [PATCH] HOT-FIX: corrige forma de ler USERNAME_FIELD --- sapl/base/forms.py | 14 ++++++++++---- sapl/rules/apps.py | 13 +------------ 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/sapl/base/forms.py b/sapl/base/forms.py index cdd516000..c0e01c2f0 100644 --- a/sapl/base/forms.py +++ b/sapl/base/forms.py @@ -105,8 +105,11 @@ class UsuarioCreateForm(ModelForm): class Meta: model = get_user_model() - fields = ['username', 'firstname', 'lastname', 'email', - 'password1', 'password2', 'user_active', 'roles'] + fields = [ + get_user_model().USERNAME_FIELD, 'firstname', 'lastname', + 'password1', 'password2', 'user_active', 'roles' + ] + (['email'] + if get_user_model().USERNAME_FIELD != 'email' else []) def clean(self): super().clean() @@ -187,8 +190,11 @@ class UsuarioEditForm(ModelForm): class Meta: model = get_user_model() - fields = ['username', 'email', 'password1', - 'password2', 'user_active', 'roles'] + fields = [ + get_user_model().USERNAME_FIELD, 'password1', + 'password2', 'user_active', 'roles' + ] + (['email'] + if get_user_model().USERNAME_FIELD != 'email' else []) def __init__(self, *args, **kwargs): diff --git a/sapl/rules/apps.py b/sapl/rules/apps.py index 48f8c4a41..601026537 100644 --- a/sapl/rules/apps.py +++ b/sapl/rules/apps.py @@ -88,18 +88,7 @@ def create_proxy_permissions( ctypes.add(ctype) - # FIXME: Retirar try except quando sapl passar a usar django 1.11 - try: - logger.info("_get_all_permissions") - # Função não existe mais em Django 1.11 - # como sapl ainda não foi para Django 1.11 - # esta excessão foi adicionada para caso o - # Sapl esteja rodando em um projeto 1.11 não ocorra erros - _all_perms_of_klass = _get_all_permissions(klass._meta, ctype) - except Exception as e: - logger.error(str(e)) - # Nova função usada em projetos com Django 1.11 e o sapl é uma app - _all_perms_of_klass = _get_all_permissions(klass._meta) + _all_perms_of_klass = _get_all_permissions(klass._meta) for perm in _all_perms_of_klass: searched_perms.append((ctype, perm))