diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 3c4d2e135..bcc15f37b 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,37 +1,39 @@ -dj-database-url==0.4.1 -django-haystack==2.6.0 -django>=1.10,<1.11 -django-bootstrap3==7.0.1 +django>=1.11,<2.0 +django-bootstrap3==11.0.0 +django-haystack==2.8.1 +django-filter==2.0.0 +djangorestframework==3.9.0 +dj-database-url==0.5.0 django-bower==5.2.0 django-braces==1.9.0 -django-compressor==2.0 -django-crispy-forms==1.6.1 -django-extensions==1.9.8 -django-extra-views==0.11.0 -django-filter==1.0.0 -django-floppyforms==1.6.2 -django-model-utils==3.1.1 -django-sass-processor==0.5.8 -djangorestframework==3.4.0 -easy-thumbnails==2.5 +django-crispy-forms==1.7.2 +django-floppyforms==1.7.0 +django-extra-views==0.12.0 +django-model-utils==3.1.2 +django-sass-processor==0.7.2 +django-reversion==3.0.2 +django-reversion-compare==0.8.6 +django-speedinfo==1.4.0 +django-extensions==2.1.4 django-image-cropping==1.2 -libsass==0.11.1 -psycopg2-binary==2.7.4 -python-decouple==3.0 -pytz==2016.4 +easy-thumbnails==2.5 +libsass==0.17.0 +python-decouple==3.1 +psycopg2-binary==2.7.6.1 pyyaml==4.2b1 -rtyaml==0.0.3 -textract==1.5.0 +pytz==2018.9 +rtyaml==0.0.5 +python-magic==0.4.15 unipath==1.1 +WeasyPrint==44 +gunicorn==19.9.0 + +textract==1.5.0 pysolr==3.6.0 -python-magic==0.4.12 -gunicorn==19.6.0 -django-reversion==2.0.8 -WeasyPrint==0.42 whoosh==2.7.4 -django-speedinfo==1.3.5 -django-reversion-compare==0.8.4 git+git://github.com/interlegis/trml2pdf.git git+git://github.com/jasperlittle/django-rest-framework-docs -git+git://github.com/rubgombar1/django-admin-bootstrapped.git \ No newline at end of file +git+git://github.com/rubgombar1/django-admin-bootstrapped.git + +#django-compressor==2.2 \ No newline at end of file diff --git a/sapl/api/forms.py b/sapl/api/forms.py index fecfbf598..0c8a1889f 100644 --- a/sapl/api/forms.py +++ b/sapl/api/forms.py @@ -6,8 +6,8 @@ from django.forms.widgets import MultiWidget, TextInput from django.utils import timezone from django.utils.translation import ugettext_lazy as _ from django_filters.filters import CharFilter, ModelChoiceFilter, DateFilter +from django_filters.rest_framework.filterset import FilterSet from rest_framework import serializers -from rest_framework.filters import FilterSet from sapl.base.models import Autor, TipoAutor from sapl.parlamentares.models import Legislatura diff --git a/sapl/api/views.py b/sapl/api/views.py index b8cafc1dd..336bb23d7 100644 --- a/sapl/api/views.py +++ b/sapl/api/views.py @@ -1,9 +1,10 @@ import logging + from django.contrib.contenttypes.models import ContentType from django.db.models import Q from django.http import Http404 from django.utils.translation import ugettext_lazy as _ -from rest_framework.filters import DjangoFilterBackend +from django_filters.rest_framework.backends import DjangoFilterBackend from rest_framework.generics import ListAPIView from rest_framework.mixins import ListModelMixin, RetrieveModelMixin from rest_framework.permissions import (AllowAny, IsAuthenticated, @@ -175,7 +176,7 @@ class AutoresProvaveisListView(ListAPIView): serializer_class = ChoiceSerializer def get_queryset(self): - + params = {'content_type__isnull': False} username = self.request.user.username tipo = '' diff --git a/sapl/base/email_utils.py b/sapl/base/email_utils.py index 024045edd..b41c68402 100644 --- a/sapl/base/email_utils.py +++ b/sapl/base/email_utils.py @@ -18,7 +18,7 @@ def load_email_templates(templates, context={}): emails = [] for t in templates: tpl = loader.get_template(t) - email = tpl.render(Context(context)) + email = tpl.render(context) if t.endswith(".html"): email = email.replace('\n', '').replace('\r', '') emails.append(email) diff --git a/sapl/base/templatetags/common_tags.py b/sapl/base/templatetags/common_tags.py index 89f781558..884a6968f 100644 --- a/sapl/base/templatetags/common_tags.py +++ b/sapl/base/templatetags/common_tags.py @@ -1,8 +1,4 @@ -import logging - -from compressor.utils import get_class from django import template -from django.conf import settings from django.template.defaultfilters import stringfilter from sapl.base.models import AppConfig @@ -15,6 +11,15 @@ from sapl.utils import filiacao_data, SEPARADOR_HASH_PROPOSICAO register = template.Library() +def get_class(class_string): + if not hasattr(class_string, '__bases__'): + class_string = str(class_string) + dot = class_string.rindex('.') + mod_name, class_name = class_string[:dot], class_string[dot + 1:] + if class_name: + return getattr(__import__(mod_name, {}, {}, [str('')]), class_name) + + @register.simple_tag def define(arg): return arg @@ -228,7 +233,7 @@ def file_extension(value): def cronometro_to_seconds(value): if not AppConfig.attr('cronometro_' + value): return 0 - + return AppConfig.attr('cronometro_' + value).seconds diff --git a/sapl/crud/base.py b/sapl/crud/base.py index e720b36cd..faa0e1287 100644 --- a/sapl/crud/base.py +++ b/sapl/crud/base.py @@ -1,6 +1,6 @@ import logging + from braces.views import FormMessagesMixin -from compressor.utils.decorators import cached_property from crispy_forms.bootstrap import FieldWithButtons, StrictButton from crispy_forms.helper import FormHelper from crispy_forms.layout import Field, Layout @@ -16,6 +16,7 @@ from django.http.response import Http404 from django.shortcuts import redirect from django.utils.decorators import classonlymethod from django.utils.encoding import force_text +from django.utils.functional import cached_property from django.utils.translation import string_concat from django.utils.translation import ugettext_lazy as _ from django.views.generic import (CreateView, DeleteView, DetailView, ListView, @@ -29,6 +30,7 @@ from sapl.rules.map_rules import (RP_ADD, RP_CHANGE, RP_DELETE, RP_DETAIL, from sapl.settings import BASE_DIR from sapl.utils import normalize + ACTION_LIST, ACTION_CREATE, ACTION_DETAIL, ACTION_UPDATE, ACTION_DELETE = \ 'list', 'create', 'detail', 'update', 'delete' @@ -558,7 +560,8 @@ class CrudListView(PermissionRequiredContainerCrudMixin, ListView): fm = model._meta.get_field(fo) except Exception as e: username = self.request.user.username - self.logger.error("user=" + username + ". " + str(e)) + self.logger.error( + "user=" + username + ". " + str(e)) pass if fm and hasattr(fm, 'related_model')\ @@ -824,7 +827,7 @@ class CrudUpdateView(PermissionRequiredContainerCrudMixin, logger = logging.getLogger(__name__) def form_valid(self, form): - + self.object = form.instance try: self.object.modifier = self.request.user @@ -882,12 +885,12 @@ class CrudDeleteView(PermissionRequiredContainerCrudMixin, error_msg2 += '{} - {}, '.format( i._meta.verbose_name, i ) - error_msg2 = error_msg2[:len(error_msg2)-2] + '.' + error_msg2 = error_msg2[:len(error_msg2) - 2] + '.' error_msg += '' - + username = request.user.username self.logger.error("user=" + username + ". Registro não pode ser removido, pois " - "é referenciado por outros registros: " + error_msg2) + "é referenciado por outros registros: " + error_msg2) messages.add_message(request, messages.ERROR, error_msg) diff --git a/sapl/sessao/forms.py b/sapl/sessao/forms.py index 35d49e277..68f6d3222 100644 --- a/sapl/sessao/forms.py +++ b/sapl/sessao/forms.py @@ -3,7 +3,6 @@ from datetime import datetime from crispy_forms.helper import FormHelper from crispy_forms.layout import HTML, Button, Fieldset, Layout from django import forms -from django.contrib import messages from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ObjectDoesNotExist, ValidationError from django.db import transaction @@ -12,22 +11,21 @@ from django.forms import ModelForm from django.forms.widgets import CheckboxSelectMultiple from django.utils.translation import ugettext_lazy as _ import django_filters -from floppyforms import widgets from sapl.base.models import Autor, TipoAutor from sapl.crispy_layout_mixin import form_actions, to_row, SaplFormLayout from sapl.materia.forms import MateriaLegislativaFilterSet from sapl.materia.models import (MateriaLegislativa, StatusTramitacao, TipoMateriaLegislativa) -from sapl.parlamentares.models import Parlamentar, Legislatura, Mandato +from sapl.parlamentares.models import Parlamentar, Mandato from sapl.utils import (RANGE_DIAS_MES, RANGE_MESES, MateriaPesquisaOrderingFilter, autor_label, autor_modal, timezone, choice_anos_com_sessaoplenaria) from .models import (Bancada, Bloco, ExpedienteMateria, JustificativaAusencia, Orador, OradorExpediente, OrdemDia, PresencaOrdemDia, SessaoPlenaria, - SessaoPlenariaPresenca, TipoJustificativa, TipoResultadoVotacao, - OcorrenciaSessao, RegistroVotacao, RetiradaPauta, TipoRetiradaPauta) + SessaoPlenariaPresenca, TipoResultadoVotacao, + OcorrenciaSessao, RetiradaPauta, TipoRetiradaPauta) MES_CHOICES = RANGE_MESES diff --git a/sapl/settings.py b/sapl/settings.py index 80bf18273..782cbb0f4 100755 --- a/sapl/settings.py +++ b/sapl/settings.py @@ -22,9 +22,6 @@ from dj_database_url import parse as db_url from easy_thumbnails.conf import Settings as thumbnail_settings from unipath import Path -from .temp_suppress_crispy_form_warnings import \ - SUPRESS_CRISPY_FORM_WARNINGS_LOGGING - host = socket.gethostbyname_ex(socket.gethostname())[0] @@ -78,20 +75,24 @@ INSTALLED_APPS = ( 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', - - # more 'django_extensions', + 'djangobower', - 'bootstrap3', # basically for django_admin_bootstrapped + 'bootstrap3', 'crispy_forms', - 'easy_thumbnails', - 'image_cropping', 'floppyforms', - 'haystack', 'sass_processor', + 'rest_framework', + 'django_filters', + + 'easy_thumbnails', + 'image_cropping', + 'reversion', 'reversion_compare', + + 'haystack', 'whoosh', 'speedinfo', @@ -110,7 +111,7 @@ SOLR_URL = config('SOLR_URL', cast=str, default='http://localhost:8983') SOLR_COLLECTION = config('SOLR_COLLECTION', cast=str, default='sapl') if USE_SOLR: - HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor' #enable auto-index + HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor' # enable auto-index SEARCH_BACKEND = 'haystack.backends.solr_backend.SolrEngine' SEARCH_URL = ('URL', '{}/solr/{}'.format(SOLR_URL, SOLR_COLLECTION)) @@ -118,7 +119,7 @@ if USE_SOLR: HAYSTACK_CONNECTIONS = { 'default': { 'ENGINE': SEARCH_BACKEND, - SEARCH_URL[0]: SEARCH_URL[1], + SEARCH_URL[0]: SEARCH_URL[1], 'BATCH_SIZE': 1000, 'TIMEOUT': 60, }, @@ -166,7 +167,7 @@ REST_FRAMEWORK = { "DEFAULT_PAGINATION_CLASS": "sapl.api.pagination.StandardPagination", "DEFAULT_FILTER_BACKENDS": ( "rest_framework.filters.SearchFilter", - "rest_framework.filters.DjangoFilterBackend", + 'django_filters.rest_framework.DjangoFilterBackend', ), } @@ -282,6 +283,7 @@ DAB_FIELD_RENDERER = \ CRISPY_TEMPLATE_PACK = 'bootstrap3' CRISPY_ALLOWED_TEMPLATE_PACKS = 'bootstrap3' CRISPY_FAIL_SILENTLY = not DEBUG +FLOPPY_FORMS_USE_GIS = False BOWER_COMPONENTS_ROOT = PROJECT_DIR.child("bower") BOWER_INSTALLED_APPS = ( @@ -339,6 +341,22 @@ LOGGING = { } } +PASSWORD_HASHERS = [ + 'django.contrib.auth.hashers.PBKDF2PasswordHasher', # default + 'sapl.hashers.ZopeSHA1PasswordHasher', +] + + +def remove_warnings(): + import warnings + warnings.filterwarnings( + 'ignore', module='floppyforms', + message='Unable to import floppyforms.gis' + ) + + +remove_warnings() + def uncaught_exceptions(type, value, error_traceback): import traceback @@ -350,8 +368,3 @@ def uncaught_exceptions(type, value, error_traceback): # captura exceções que não foram tratadas sys.excepthook = uncaught_exceptions - -PASSWORD_HASHERS = [ - 'django.contrib.auth.hashers.PBKDF2PasswordHasher', # default - 'sapl.hashers.ZopeSHA1PasswordHasher', -] diff --git a/sapl/static/styles/app.scss b/sapl/static/styles/app.scss index a0540b8e1..f05189142 100644 --- a/sapl/static/styles/app.scss +++ b/sapl/static/styles/app.scss @@ -451,6 +451,9 @@ nav { overflow-x: auto; } } +.lista-parlamentares .table td { + vertical-align: middle; +} @media (min-width: 1092px) and (max-width: 1199px) { .container { diff --git a/sapl/temp_suppress_crispy_form_warnings.py b/sapl/temp_suppress_crispy_form_warnings.py deleted file mode 100644 index 39105d39e..000000000 --- a/sapl/temp_suppress_crispy_form_warnings.py +++ /dev/null @@ -1,22 +0,0 @@ -import copy -import logging - -from django.utils.log import DEFAULT_LOGGING - -# hack to suppress many annoying warnings from crispy_forms -# Do remove this file and corresponding import in settings -# when crispy_forms is corrected !!! -SUPRESS_CRISPY_FORM_WARNINGS_LOGGING = copy.deepcopy(DEFAULT_LOGGING) -SUPRESS_CRISPY_FORM_WARNINGS_LOGGING['filters']['suppress_deprecated'] = { - '()': 'sapl.temp_suppress_crispy_form_warnings.SuppressDeprecated' -} -SUPRESS_CRISPY_FORM_WARNINGS_LOGGING['handlers']['console']['filters'].append( - 'suppress_deprecated') - - -class SuppressDeprecated(logging.Filter): - - def filter(self, record): - msg = record.getMessage() - return not ('crispy_forms' in msg and - 'RemovedInDjango19Warning' in msg) diff --git a/sapl/templates/parlamentares/parlamentares_list.html b/sapl/templates/parlamentares/parlamentares_list.html index bc3955b06..43627a9ad 100644 --- a/sapl/templates/parlamentares/parlamentares_list.html +++ b/sapl/templates/parlamentares/parlamentares_list.html @@ -21,7 +21,7 @@ {% if not rows %}

{{ NO_ENTRIES_MSG }}

{% else %} -
+
{% blocktrans with verbose_name_plural=view.verbose_name_plural %}Total de {{ verbose_name_plural }}: {{count}}{% endblocktrans %}
@@ -43,7 +43,9 @@ {% for value, href, obj in value_list %} {% if forloop.first %} {% endif %}