Browse Source

Retira config e impl da lib logging no sapl

Foram desativadas as configurações superficiais e imprecisas não
condisentes com o sapl em produção. A impl atual estava causando
dificuldades na migração da versão do django, além disso não estava
tendo mínimo efeito para o mais urgente, registro claro de problemas na
produção.
Uma nova solução deve ser apresentada como tarefa da Issue #52, na qual
tomei a liberdade de adicionar a label 'prioridade alta' e alterar o
Milestone para 3.1... Por que? por não ser uma melhoria para usuário
final e sim uma demanda urgente dos devs e da infra.
pull/2255/head
Leandro Roberto 6 years ago
parent
commit
75c98903be
  1. 14
      sapl/api/views.py
  2. 13
      sapl/base/search_indexes.py
  3. 5
      sapl/base/templatetags/menus.py
  4. 70
      sapl/base/views.py
  5. 7
      sapl/compilacao/apps.py
  6. 8
      sapl/compilacao/views.py
  7. 6
      sapl/crud/base.py
  8. 7
      sapl/settings.py
  9. 18
      sapl/utils.py

14
sapl/api/views.py

@ -1,3 +1,4 @@
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.db.models import Q from django.db.models import Q
from django.http import Http404 from django.http import Http404
@ -19,7 +20,7 @@ from sapl.api.serializers import (AutorChoiceSerializer, AutorSerializer,
from sapl.base.models import Autor, TipoAutor from sapl.base.models import Autor, TipoAutor
from sapl.materia.models import MateriaLegislativa from sapl.materia.models import MateriaLegislativa
from sapl.sessao.models import SessaoPlenaria from sapl.sessao.models import SessaoPlenaria
from sapl.utils import SaplGenericRelation, sapl_logger from sapl.utils import SaplGenericRelation
class ModelChoiceView(ListAPIView): class ModelChoiceView(ListAPIView):
@ -141,17 +142,14 @@ class AutorListView(ListAPIView):
tr = int(self.request.GET.get tr = int(self.request.GET.get
('tr', AutorListView.TR_AUTOR_CHOICE_SERIALIZER)) ('tr', AutorListView.TR_AUTOR_CHOICE_SERIALIZER))
assert tr in ( if tr not in (AutorListView.TR_AUTOR_CHOICE_SERIALIZER,
AutorListView.TR_AUTOR_CHOICE_SERIALIZER, AutorListView.TR_AUTOR_SERIALIZER):
AutorListView.TR_AUTOR_SERIALIZER), sapl_logger.info( return AutorListView.TR_AUTOR_CHOICE_SERIALIZER
_("Tipo do Resultado a ser fornecido não existe!"))
except: except:
return AutorListView.TR_AUTOR_CHOICE_SERIALIZER return AutorListView.TR_AUTOR_CHOICE_SERIALIZER
else: return tr
return tr
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
if self.tr == AutorListView.TR_AUTOR_SERIALIZER: if self.tr == AutorListView.TR_AUTOR_SERIALIZER:
self.serializer_class = AutorSerializer self.serializer_class = AutorSerializer
self.permission_classes = (IsAuthenticated,) self.permission_classes = (IsAuthenticated,)

13
sapl/base/search_indexes.py

@ -1,30 +1,25 @@
import logging
import os.path import os.path
import re import re
import string import string
import textract
from django.db.models import F, Q, Value from django.db.models import F, Q, Value
from django.db.models.fields import TextField from django.db.models.fields import TextField
from django.db.models.fields.files import FieldFile
from django.db.models.functions import Concat from django.db.models.functions import Concat
from django.template import loader from django.template import loader
from haystack.constants import Indexable from haystack.constants import Indexable
from haystack.fields import CharField from haystack.fields import CharField
from haystack.indexes import SearchIndex from haystack.indexes import SearchIndex
from haystack.utils import get_model_ct_tuple from haystack.utils import get_model_ct_tuple
import textract
from textract.exceptions import ExtensionNotSupported from textract.exceptions import ExtensionNotSupported
from sapl.compilacao.models import (STATUS_TA_IMMUTABLE_PUBLIC, from sapl.compilacao.models import (STATUS_TA_IMMUTABLE_PUBLIC,
STATUS_TA_PUBLIC, Dispositivo, STATUS_TA_PUBLIC, Dispositivo)
TextoArticulado)
from sapl.materia.models import DocumentoAcessorio, MateriaLegislativa from sapl.materia.models import DocumentoAcessorio, MateriaLegislativa
from sapl.norma.models import NormaJuridica from sapl.norma.models import NormaJuridica
from sapl.settings import BASE_DIR, SOLR_URL from sapl.settings import SOLR_URL
from sapl.utils import RemoveTag from sapl.utils import RemoveTag
logger = logging.getLogger(BASE_DIR.name)
class TextExtractField(CharField): class TextExtractField(CharField):
@ -68,7 +63,6 @@ class TextExtractField(CharField):
msg = 'Erro inesperado processando arquivo: %s' % ( msg = 'Erro inesperado processando arquivo: %s' % (
arquivo.path) arquivo.path)
print(msg) print(msg)
logger.error(msg)
def file_extractor(self, arquivo): def file_extractor(self, arquivo):
if not os.path.exists(arquivo.path) or \ if not os.path.exists(arquivo.path) or \
@ -89,7 +83,6 @@ class TextExtractField(CharField):
return self.whoosh_extraction(arquivo) return self.whoosh_extraction(arquivo)
except ExtensionNotSupported as e: except ExtensionNotSupported as e:
print(str(e)) print(str(e))
logger.error(str(e))
except Exception as e2: except Exception as e2:
print(str(e2)) print(str(e2))
self.print_error(arquivo) self.print_error(arquivo)

5
sapl/base/templatetags/menus.py

@ -1,9 +1,8 @@
import yaml
from django import template from django import template
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
import yaml
from sapl.utils import sapl_logger
register = template.Library() register = template.Library()
@ -85,7 +84,7 @@ def nav_run(context, path=None):
menu = yaml.load(rendered) menu = yaml.load(rendered)
resolve_urls_inplace(menu, root_pk, rm, context) resolve_urls_inplace(menu, root_pk, rm, context)
except Exception as e: except Exception as e:
sapl_logger.error(_("""Erro na conversão do yaml %s. App: %s. print(_("""Erro na conversão do yaml %s. App: %s.
Erro: Erro:
%s %s
""") % ( """) % (

70
sapl/base/views.py

@ -13,8 +13,8 @@ from django.template import TemplateDoesNotExist
from django.template.loader import get_template from django.template.loader import get_template
from django.utils.encoding import force_bytes from django.utils.encoding import force_bytes
from django.utils.http import urlsafe_base64_decode, urlsafe_base64_encode from django.utils.http import urlsafe_base64_decode, urlsafe_base64_encode
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import string_concat from django.utils.translation import string_concat
from django.utils.translation import ugettext_lazy as _
from django.views.generic import (CreateView, DeleteView, FormView, ListView, from django.views.generic import (CreateView, DeleteView, FormView, ListView,
UpdateView) UpdateView)
from django.views.generic.base import RedirectView, TemplateView from django.views.generic.base import RedirectView, TemplateView
@ -22,16 +22,16 @@ from django_filters.views import FilterView
from haystack.views import SearchView from haystack.views import SearchView
from sapl import settings from sapl import settings
from sapl.audiencia.models import AudienciaPublica, TipoAudienciaPublica
from sapl.base.forms import AutorForm, AutorFormForAdmin, TipoAutorForm from sapl.base.forms import AutorForm, AutorFormForAdmin, TipoAutorForm
from sapl.base.models import Autor, TipoAutor from sapl.base.models import Autor, TipoAutor
from sapl.crud.base import CrudAux, make_pagination
from sapl.audiencia.models import AudienciaPublica, TipoAudienciaPublica
from sapl.comissoes.models import Reuniao, Comissao from sapl.comissoes.models import Reuniao, Comissao
from sapl.crud.base import CrudAux, make_pagination
from sapl.materia.models import (Autoria, MateriaLegislativa, from sapl.materia.models import (Autoria, MateriaLegislativa,
TipoMateriaLegislativa, StatusTramitacao, UnidadeTramitacao) TipoMateriaLegislativa, StatusTramitacao, UnidadeTramitacao)
from sapl.sessao.models import (PresencaOrdemDia, SessaoPlenaria, from sapl.sessao.models import (PresencaOrdemDia, SessaoPlenaria,
SessaoPlenariaPresenca) SessaoPlenariaPresenca)
from sapl.utils import (parlamentares_ativos, sapl_logger, from sapl.utils import (parlamentares_ativos,
show_results_filter_set) show_results_filter_set)
from .forms import (AlterarSenhaForm, CasaLegislativaForm, from .forms import (AlterarSenhaForm, CasaLegislativaForm,
@ -52,9 +52,11 @@ def filtra_url_materias_em_tramitacao(qr, qs, campo_url, local_ou_status):
id_materias = [] id_materias = []
filtro_url = qr[campo_url] filtro_url = qr[campo_url]
if local_ou_status == 'local': if local_ou_status == 'local':
id_materias = [item.id for item in qs if item.tramitacao_set.order_by('-id').first().unidade_tramitacao_destino_id == int(filtro_url)] id_materias = [item.id for item in qs if item.tramitacao_set.order_by(
'-id').first().unidade_tramitacao_destino_id == int(filtro_url)]
elif local_ou_status == 'status': elif local_ou_status == 'status':
id_materias = [item.id for item in qs if item.tramitacao_set.order_by('-id').first().status_id == int(filtro_url)] id_materias = [item.id for item in qs if item.tramitacao_set.order_by(
'-id').first().status_id == int(filtro_url)]
return qs.filter(em_tramitacao=True, id__in=id_materias) return qs.filter(em_tramitacao=True, id__in=id_materias)
@ -193,7 +195,7 @@ class AutorCrud(CrudAux):
send_mail(assunto, mensagem, remetente, destinatario, send_mail(assunto, mensagem, remetente, destinatario,
fail_silently=False) fail_silently=False)
except: except:
sapl_logger.error( print(
_('Erro no envio de email na edição de Autores.')) _('Erro no envio de email na edição de Autores.'))
return url_reverse return url_reverse
@ -243,7 +245,7 @@ class AutorCrud(CrudAux):
send_mail(assunto, mensagem, remetente, destinatario, send_mail(assunto, mensagem, remetente, destinatario,
fail_silently=False) fail_silently=False)
except: except:
sapl_logger.error( print(
_('Erro no envio de email na criação de Autores.')) _('Erro no envio de email na criação de Autores.'))
return url_reverse return url_reverse
@ -267,8 +269,8 @@ class RelatorioAtasView(FilterView):
context['show_results'] = show_results_filter_set(qr) context['show_results'] = show_results_filter_set(qr)
context['periodo'] = ( context['periodo'] = (
self.request.GET['data_inicio_0'] + self.request.GET['data_inicio_0'] +
' - ' + self.request.GET['data_inicio_1']) ' - ' + self.request.GET['data_inicio_1'])
return context return context
@ -384,20 +386,23 @@ class RelatorioHistoricoTramitacaoView(FilterView):
context['show_results'] = show_results_filter_set(qr) context['show_results'] = show_results_filter_set(qr)
context['data_tramitacao'] = (self.request.GET['tramitacao__data_tramitacao_0'] + ' - ' + context['data_tramitacao'] = (self.request.GET['tramitacao__data_tramitacao_0'] + ' - ' +
self.request.GET['tramitacao__data_tramitacao_1']) self.request.GET['tramitacao__data_tramitacao_1'])
if self.request.GET['tipo']: if self.request.GET['tipo']:
tipo = self.request.GET['tipo'] tipo = self.request.GET['tipo']
context['tipo'] = (str(TipoMateriaLegislativa.objects.get(id=tipo))) context['tipo'] = (
str(TipoMateriaLegislativa.objects.get(id=tipo)))
else: else:
context['tipo'] = '' context['tipo'] = ''
if self.request.GET['tramitacao__status']: if self.request.GET['tramitacao__status']:
tramitacao_status = self.request.GET['tramitacao__status'] tramitacao_status = self.request.GET['tramitacao__status']
context['tramitacao__status'] = (str(StatusTramitacao.objects.get(id=tramitacao_status))) context['tramitacao__status'] = (
str(StatusTramitacao.objects.get(id=tramitacao_status)))
else: else:
context['tramitacao__status'] = '' context['tramitacao__status'] = ''
if self.request.GET['tramitacao__unidade_tramitacao_local']: if self.request.GET['tramitacao__unidade_tramitacao_local']:
context['tramitacao__unidade_tramitacao_local'] = \ context['tramitacao__unidade_tramitacao_local'] = \
(str(UnidadeTramitacao.objects.get(id=self.request.GET['tramitacao__unidade_tramitacao_local']))) (str(UnidadeTramitacao.objects.get(
id=self.request.GET['tramitacao__unidade_tramitacao_local'])))
else: else:
context['tramitacao__unidade_tramitacao_destino'] = '' context['tramitacao__unidade_tramitacao_destino'] = ''
@ -424,22 +429,26 @@ class RelatorioDataFimPrazoTramitacaoView(FilterView):
self.request.GET['tramitacao__data_fim_prazo_1']) self.request.GET['tramitacao__data_fim_prazo_1'])
if self.request.GET['tipo']: if self.request.GET['tipo']:
tipo = self.request.GET['tipo'] tipo = self.request.GET['tipo']
context['tipo'] = (str(TipoMateriaLegislativa.objects.get(id=tipo))) context['tipo'] = (
str(TipoMateriaLegislativa.objects.get(id=tipo)))
else: else:
context['tipo'] = '' context['tipo'] = ''
if self.request.GET['tramitacao__status']: if self.request.GET['tramitacao__status']:
tramitacao_status = self.request.GET['tramitacao__status'] tramitacao_status = self.request.GET['tramitacao__status']
context['tramitacao__status'] = (str(StatusTramitacao.objects.get(id=tramitacao_status))) context['tramitacao__status'] = (
str(StatusTramitacao.objects.get(id=tramitacao_status)))
else: else:
context['tramitacao__status'] = '' context['tramitacao__status'] = ''
if self.request.GET['tramitacao__unidade_tramitacao_local']: if self.request.GET['tramitacao__unidade_tramitacao_local']:
context['tramitacao__unidade_tramitacao_local'] = \ context['tramitacao__unidade_tramitacao_local'] = \
(str(UnidadeTramitacao.objects.get(id=self.request.GET['tramitacao__unidade_tramitacao_local']))) (str(UnidadeTramitacao.objects.get(
id=self.request.GET['tramitacao__unidade_tramitacao_local'])))
else: else:
context['tramitacao__unidade_tramitacao_destino'] = '' context['tramitacao__unidade_tramitacao_destino'] = ''
return context return context
class RelatorioReuniaoView(FilterView): class RelatorioReuniaoView(FilterView):
model = Reuniao model = Reuniao
filterset_class = RelatorioReuniaoFilterSet filterset_class = RelatorioReuniaoFilterSet
@ -459,7 +468,7 @@ class RelatorioReuniaoView(FilterView):
if not self.filterset.form.is_valid(): if not self.filterset.form.is_valid():
return context return context
qr = self.request.GET.copy() qr = self.request.GET.copy()
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else '' context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
context['show_results'] = show_results_filter_set(qr) context['show_results'] = show_results_filter_set(qr)
@ -472,6 +481,7 @@ class RelatorioReuniaoView(FilterView):
return context return context
class RelatorioAudienciaView(FilterView): class RelatorioAudienciaView(FilterView):
model = AudienciaPublica model = AudienciaPublica
filterset_class = RelatorioAudienciaFilterSet filterset_class = RelatorioAudienciaFilterSet
@ -505,7 +515,6 @@ class RelatorioAudienciaView(FilterView):
return context return context
class RelatorioMateriasTramitacaoView(FilterView): class RelatorioMateriasTramitacaoView(FilterView):
model = MateriaLegislativa model = MateriaLegislativa
filterset_class = RelatorioMateriasTramitacaoilterSet filterset_class = RelatorioMateriasTramitacaoilterSet
@ -524,9 +533,11 @@ class RelatorioMateriasTramitacaoView(FilterView):
qs = qs.filter(em_tramitacao=True) qs = qs.filter(em_tramitacao=True)
if qr.get('tramitacao__unidade_tramitacao_destino'): if qr.get('tramitacao__unidade_tramitacao_destino'):
qs = filtra_url_materias_em_tramitacao(qr, qs, 'tramitacao__unidade_tramitacao_destino', 'local') qs = filtra_url_materias_em_tramitacao(
qr, qs, 'tramitacao__unidade_tramitacao_destino', 'local')
if qr.get('tramitacao__status'): if qr.get('tramitacao__status'):
qs = filtra_url_materias_em_tramitacao(qr, qs, 'tramitacao__status', 'status') qs = filtra_url_materias_em_tramitacao(
qr, qs, 'tramitacao__status', 'status')
context['object_list'] = qs context['object_list'] = qs
@ -540,17 +551,19 @@ class RelatorioMateriasTramitacaoView(FilterView):
context['ano'] = (self.request.GET['ano']) context['ano'] = (self.request.GET['ano'])
if self.request.GET['tipo']: if self.request.GET['tipo']:
tipo = self.request.GET['tipo'] tipo = self.request.GET['tipo']
context['tipo'] = (str(TipoMateriaLegislativa.objects.get(id=tipo))) context['tipo'] = (
str(TipoMateriaLegislativa.objects.get(id=tipo)))
else: else:
context['tipo'] = '' context['tipo'] = ''
if self.request.GET['tramitacao__status']: if self.request.GET['tramitacao__status']:
tramitacao_status = self.request.GET['tramitacao__status'] tramitacao_status = self.request.GET['tramitacao__status']
context['tramitacao__status'] = (str(StatusTramitacao.objects.get(id=tramitacao_status))) context['tramitacao__status'] = (
str(StatusTramitacao.objects.get(id=tramitacao_status)))
else: else:
context['tramitacao__status'] = '' context['tramitacao__status'] = ''
if self.request.GET['tramitacao__unidade_tramitacao_destino']: if self.request.GET['tramitacao__unidade_tramitacao_destino']:
context['tramitacao__unidade_tramitacao_destino'] = (str(UnidadeTramitacao.objects.get(id= context['tramitacao__unidade_tramitacao_destino'] = (str(UnidadeTramitacao.objects.get(
self.request.GET['tramitacao__unidade_tramitacao_destino']))) id=self.request.GET['tramitacao__unidade_tramitacao_destino'])))
else: else:
context['tramitacao__unidade_tramitacao_destino'] = '' context['tramitacao__unidade_tramitacao_destino'] = ''
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else '' context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
@ -677,7 +690,8 @@ class RelatorioMateriasPorAutorView(FilterView):
context['show_results'] = show_results_filter_set(qr) context['show_results'] = show_results_filter_set(qr)
if self.request.GET['tipo']: if self.request.GET['tipo']:
tipo = int(self.request.GET['tipo']) tipo = int(self.request.GET['tipo'])
context['tipo'] = (str(TipoMateriaLegislativa.objects.get(id=tipo))) context['tipo'] = (
str(TipoMateriaLegislativa.objects.get(id=tipo)))
else: else:
context['tipo'] = '' context['tipo'] = ''
if self.request.GET['autoria__autor']: if self.request.GET['autoria__autor']:
@ -686,8 +700,8 @@ class RelatorioMateriasPorAutorView(FilterView):
else: else:
context['autor'] = '' context['autor'] = ''
context['periodo'] = ( context['periodo'] = (
self.request.GET['data_apresentacao_0'] + self.request.GET['data_apresentacao_0'] +
' - ' + self.request.GET['data_apresentacao_1']) ' - ' + self.request.GET['data_apresentacao_1'])
return context return context

7
sapl/compilacao/apps.py

@ -1,16 +1,13 @@
import logging
from django import apps from django import apps
from django.conf import settings from django.conf import settings
from django.db import connection, models from django.db import connection, models
from django.db.utils import DEFAULT_DB_ALIAS, IntegrityError from django.db.utils import DEFAULT_DB_ALIAS, IntegrityError
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import string_concat from django.utils.translation import string_concat
from django.utils.translation import ugettext_lazy as _
from sapl.settings import BASE_DIR from sapl.settings import BASE_DIR
logger = logging.getLogger(BASE_DIR.name)
class AppConfig(apps.AppConfig): class AppConfig(apps.AppConfig):
name = 'sapl.compilacao' name = 'sapl.compilacao'
@ -42,7 +39,7 @@ class AppConfig(apps.AppConfig):
cursor.execute(line) cursor.execute(line)
except IntegrityError as e: except IntegrityError as e:
if not settings.DEBUG: if not settings.DEBUG:
logger.error( print(
string_concat( string_concat(
_('Ocorreu erro na importação: '), _('Ocorreu erro na importação: '),
line, line,

8
sapl/compilacao/views.py

@ -1,6 +1,5 @@
from collections import OrderedDict from collections import OrderedDict
from datetime import timedelta from datetime import timedelta
import logging
import sys import sys
from braces.views import FormMessagesMixin from braces.views import FormMessagesMixin
@ -11,9 +10,8 @@ from django.contrib.auth.mixins import PermissionRequiredMixin
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.core.signing import Signer from django.core.signing import Signer
from django.core.urlresolvers import reverse, reverse_lazy from django.core.urlresolvers import reverse, reverse_lazy
from django.db import connection, transaction from django.db import transaction
from django.db.models import Q from django.db.models import Q
from django.db.utils import IntegrityError
from django.http.response import (HttpResponse, HttpResponseRedirect, from django.http.response import (HttpResponse, HttpResponseRedirect,
JsonResponse, Http404) JsonResponse, Http404)
from django.shortcuts import get_object_or_404, redirect from django.shortcuts import get_object_or_404, redirect
@ -58,8 +56,6 @@ VeiculoPublicacaoCrud = CrudAux.build(VeiculoPublicacao, 'veiculo_publicacao')
TipoDispositivoCrud = CrudAux.build( TipoDispositivoCrud = CrudAux.build(
TipoDispositivo, 'tipo_dispositivo') TipoDispositivo, 'tipo_dispositivo')
logger = logging.getLogger(BASE_DIR.name)
def choice_models_in_extenal_views(): def choice_models_in_extenal_views():
integrations_view_names = get_integrations_view_names() integrations_view_names = get_integrations_view_names()
@ -119,7 +115,7 @@ class IntegracaoTaView(TemplateView):
tipo_ta.save() tipo_ta.save()
except Exception as e: except Exception as e:
logger.error( print(
string_concat( string_concat(
_('Ocorreu erro na importação do arquivo base dos Tipos de' _('Ocorreu erro na importação do arquivo base dos Tipos de'
'Dispositivos, entre outras informações iniciais.'), 'Dispositivos, entre outras informações iniciais.'),

6
sapl/crud/base.py

@ -1,4 +1,3 @@
import logging
from braces.views import FormMessagesMixin from braces.views import FormMessagesMixin
from compressor.utils.decorators import cached_property from compressor.utils.decorators import cached_property
@ -30,9 +29,6 @@ from sapl.rules.map_rules import (RP_ADD, RP_CHANGE, RP_DELETE, RP_DETAIL,
from sapl.settings import BASE_DIR from sapl.settings import BASE_DIR
from sapl.utils import normalize from sapl.utils import normalize
logger = logging.getLogger(BASE_DIR.name)
ACTION_LIST, ACTION_CREATE, ACTION_DETAIL, ACTION_UPDATE, ACTION_DELETE = \ ACTION_LIST, ACTION_CREATE, ACTION_DETAIL, ACTION_UPDATE, ACTION_DELETE = \
'list', 'create', 'detail', 'update', 'delete' 'list', 'create', 'detail', 'update', 'delete'
@ -583,7 +579,7 @@ class CrudListView(PermissionRequiredContainerCrudMixin, ListView):
# print(ordering) # print(ordering)
except Exception as e: except Exception as e:
logger.error(string_concat(_( print(string_concat(_(
'ERRO: construção da tupla de ordenação.'), str(e))) 'ERRO: construção da tupla de ordenação.'), str(e)))
# print(queryset.query) # print(queryset.query)

7
sapl/settings.py

@ -13,7 +13,6 @@ Quick-start development settings - unsuitable for production
See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
""" """
import logging
from decouple import config from decouple import config
from dj_database_url import parse as db_url from dj_database_url import parse as db_url
@ -300,8 +299,10 @@ FILTERS_HELP_TEXT_FILTER = False
LOGGING = SUPRESS_CRISPY_FORM_WARNINGS_LOGGING LOGGING = SUPRESS_CRISPY_FORM_WARNINGS_LOGGING
# FIXME: gerando problemas na alternancia entre django 1.9.13 e 1.10.8
# Issue 52 https://github.com/interlegis/sapl/issues/52
LOGGING_CONSOLE = config('LOGGING_CONSOLE', default=False, cast=bool) LOGGING_CONSOLE = config('LOGGING_CONSOLE', default=False, cast=bool)
if DEBUG and LOGGING_CONSOLE: """if DEBUG and LOGGING_CONSOLE:
# Descomentar linha abaixo fará com que logs aparecam, inclusive SQL # Descomentar linha abaixo fará com que logs aparecam, inclusive SQL
# LOGGING['handlers']['console']['level'] = 'DEBUG' # LOGGING['handlers']['console']['level'] = 'DEBUG'
LOGGING['loggers']['django']['level'] = 'DEBUG' LOGGING['loggers']['django']['level'] = 'DEBUG'
@ -325,7 +326,7 @@ def excepthook(*args):
logging.getLogger(BASE_DIR.name).error( logging.getLogger(BASE_DIR.name).error(
'Uncaught exception:', exc_info=args) 'Uncaught exception:', exc_info=args)
# sys.excepthook = excepthook # sys.excepthook = excepthook"""
PASSWORD_HASHERS = [ PASSWORD_HASHERS = [

18
sapl/utils.py

@ -1,14 +1,11 @@
from functools import wraps
import hashlib import hashlib
import logging from operator import itemgetter
import os import os
import re import re
import unicodedata
from functools import wraps
from operator import itemgetter
from unicodedata import normalize as unicodedata_normalize from unicodedata import normalize as unicodedata_normalize
import unicodedata
import django_filters
import magic
from crispy_forms.helper import FormHelper from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Button from crispy_forms.layout import HTML, Button
from django import forms from django import forms
@ -21,17 +18,15 @@ from django.core.exceptions import ValidationError
from django.db.models import Q from django.db.models import Q
from django.utils import six, timezone from django.utils import six, timezone
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
import django_filters
from django_filters.filterset import STRICTNESS from django_filters.filterset import STRICTNESS
from easy_thumbnails import source_generators from easy_thumbnails import source_generators
from floppyforms import ClearableFileInput from floppyforms import ClearableFileInput
from reversion.admin import VersionAdmin import magic
from reversion_compare.admin import CompareVersionAdmin from reversion_compare.admin import CompareVersionAdmin
from unipath.path import Path from unipath.path import Path
from sapl.crispy_layout_mixin import SaplFormLayout, form_actions, to_row from sapl.crispy_layout_mixin import SaplFormLayout, form_actions, to_row
from sapl.settings import BASE_DIR
sapl_logger = logging.getLogger(BASE_DIR.name)
def pil_image(source, exif_orientation=False, **options): def pil_image(source, exif_orientation=False, **options):
@ -765,5 +760,6 @@ def RemoveTag(texto):
return textoSaida return textoSaida
def remover_acentos(string): def remover_acentos(string):
return unicodedata.normalize('NFKD', string).encode('ASCII', 'ignore').decode() return unicodedata.normalize('NFKD', string).encode('ASCII', 'ignore').decode()

Loading…
Cancel
Save