From 08c6f05aa01efb68f5a94021c078a50a4485a3a8 Mon Sep 17 00:00:00 2001 From: LeandroRoberto Date: Wed, 2 Aug 2017 13:45:38 -0300 Subject: [PATCH 01/25] Ajst js de psq de autor e bug no queryset dinamico --- sapl/api/forms.py | 13 ++++++++----- sapl/static/js/app.js | 10 +++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/sapl/api/forms.py b/sapl/api/forms.py index 41e40eacf..e4951c1e3 100644 --- a/sapl/api/forms.py +++ b/sapl/api/forms.py @@ -38,17 +38,20 @@ class SaplGenericRelationSearchFilterSet(FilterSet): item.related_query_name(), field[0]) ) - if len(field) == 3 and field[2](qtext) is not None: - q_fs = q_fs | Q(**{'%s__%s%s' % ( - item.related_query_name(), - field[0], - field[1]): qtext if len(field) == 2 else field[2](qtext)}) + # if len(field) == 3 and field[2](qtext) is not + # None: + q_fs = q_fs | Q(**{'%s__%s%s' % ( + item.related_query_name(), + field[0], + field[1]): qtext if len(field) == 2 + else field[2](qtext)}) q = q & q_fs if q: queryset = queryset.filter(q).order_by(*order_by) + print(queryset.query) return queryset diff --git a/sapl/static/js/app.js b/sapl/static/js/app.js index 1afa1eec5..0d311fd48 100644 --- a/sapl/static/js/app.js +++ b/sapl/static/js/app.js @@ -90,11 +90,11 @@ function autorModal() { $("#pesquisar").click(function() { var name_in_query = $("#q").val() - var q_0 = "q_0=nome__icontains" - var q_1 = "q_1=" + name_in_query - query = q_0 + "&" + q_1 + //var q_0 = "q_0=nome__icontains" + //var q_1 = name_in_query + //query = q_1 - $.get("/api/autor?" + query, function(data, status) { + $.get("/api/autor?q=" + name_in_query, function(data, status) { $("#div-resultado").children().remove(); if (data.pagination.total_entries == 0) { $("#selecionar").attr("hidden", "hidden"); @@ -235,4 +235,4 @@ function getCookie(name) { } } return cookieValue; -} \ No newline at end of file +} From ecd48d55ca36754ddaa5102f33180881969e3714 Mon Sep 17 00:00:00 2001 From: LeandroRoberto Date: Thu, 3 Aug 2017 08:36:57 -0300 Subject: [PATCH 02/25] =?UTF-8?q?Desmembra=20buscas=20de=20/api/autor=20em?= =?UTF-8?q?=20views=20espec=C3=ADficas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/api/forms.py | 1 - sapl/api/urls.py | 8 ++++- sapl/api/views.py | 47 ++++++++++++++--------------- sapl/templates/base/autor_form.html | 5 ++- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/sapl/api/forms.py b/sapl/api/forms.py index e4951c1e3..f36b7724f 100644 --- a/sapl/api/forms.py +++ b/sapl/api/forms.py @@ -51,7 +51,6 @@ class SaplGenericRelationSearchFilterSet(FilterSet): if q: queryset = queryset.filter(q).order_by(*order_by) - print(queryset.query) return queryset diff --git a/sapl/api/urls.py b/sapl/api/urls.py index bf9c16c51..7d146e4bb 100644 --- a/sapl/api/urls.py +++ b/sapl/api/urls.py @@ -3,7 +3,8 @@ from django.conf.urls import include, url from rest_framework.routers import DefaultRouter from sapl.api.views import (AutorListView, MateriaLegislativaViewSet, - ModelChoiceView, SessaoPlenariaViewSet) + ModelChoiceView, SessaoPlenariaViewSet, + AutoresPossiveisListView, AutoresProvaveisListView) from .apps import AppConfig @@ -17,6 +18,11 @@ urlpatterns_router = router.urls urlpatterns_api = [ + url(r'^autores-provaveis', + AutoresProvaveisListView.as_view(), name='autores_provaveis_list'), + url(r'^autores-possiveis', + AutoresPossiveisListView.as_view(), name='autores_possiveis_list'), + url(r'^autor', AutorListView.as_view(), name='autor_list'), url(r'^model/(?P\d+)/(?P\d*)$', diff --git a/sapl/api/views.py b/sapl/api/views.py index 7d89b28b0..507551808 100644 --- a/sapl/api/views.py +++ b/sapl/api/views.py @@ -57,14 +57,6 @@ class AutorListView(ListAPIView): de Autores feita pelo django-filter -> processo usado nas pesquisas, o mais usado. - = 2 -> para (value, text) usados geralmente - em combobox, radiobox, checkbox, etc com pesquisa básica - de Autores mas feito para Possíveis Autores armazenados - segundo o ContentType associado ao Tipo de Autor via - relacionamento genérico. - Busca feita sem django-filter processada no get_queryset - -> processo no cadastro de autores para seleção e busca - dos possíveis autores = 3 -> Devolve instancias da classe Autor filtradas pelo django-filter @@ -132,10 +124,8 @@ class AutorListView(ListAPIView): """ TR_AUTOR_CHOICE_SERIALIZER = 1 - TR_CHOICE_SERIALIZER = 2 TR_AUTOR_SERIALIZER = 3 - # FIXME aplicar permissão correta de usuário permission_classes = (IsAuthenticatedOrReadOnly,) queryset = Autor.objects.all() model = Autor @@ -152,7 +142,6 @@ class AutorListView(ListAPIView): assert tr in ( AutorListView.TR_AUTOR_CHOICE_SERIALIZER, - AutorListView.TR_CHOICE_SERIALIZER, AutorListView.TR_AUTOR_SERIALIZER), sapl_logger.info( _("Tipo do Resultado a ser fornecido não existe!")) except: @@ -161,16 +150,7 @@ class AutorListView(ListAPIView): return tr def get(self, request, *args, **kwargs): - """ - desativa o django-filter se a busca for por possiveis autores - parametro tr = TR_CHOICE_SERIALIZER - """ - if self.tr == AutorListView.TR_CHOICE_SERIALIZER: - self.filter_class = None - self.filter_backends = [] - self.serializer_class = ChoiceSerializer - - elif self.tr == AutorListView.TR_AUTOR_SERIALIZER: + if self.tr == AutorListView.TR_AUTOR_SERIALIZER: self.serializer_class = AutorSerializer self.permission_classes = (IsAuthenticated,) @@ -179,12 +159,20 @@ class AutorListView(ListAPIView): return ListAPIView.get(self, request, *args, **kwargs) + +class AutoresProvaveisListView(ListAPIView): + + permission_classes = (IsAuthenticatedOrReadOnly,) + queryset = Autor.objects.all() + model = Autor + + filter_class = None + filter_backends = [] + serializer_class = ChoiceSerializer + def get_queryset(self): queryset = ListAPIView.get_queryset(self) - if self.filter_backends: - return queryset - params = {'content_type__isnull': False} tipo = '' @@ -252,6 +240,17 @@ class AutorListView(ListAPIView): return r +class AutoresPossiveisListView(ListAPIView): + + permission_classes = (IsAuthenticatedOrReadOnly,) + queryset = Autor.objects.all() + model = Autor + + filter_class = AutorChoiceFilterSet + filter_backends = (DjangoFilterBackend, ) + serializer_class = ChoiceSerializer + + class MateriaLegislativaViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet): diff --git a/sapl/templates/base/autor_form.html b/sapl/templates/base/autor_form.html index 62d835c85..ec7ddfe7e 100644 --- a/sapl/templates/base/autor_form.html +++ b/sapl/templates/base/autor_form.html @@ -28,12 +28,11 @@ $(document).ready(function(){ var update_search = function(pk, atualizar=true) { var q = $('#id_q').val(); - var url = '{% url 'sapl.api:autor_list'%}' + var url = '{% url 'sapl.api:autores_provaveis_list'%}' var formData = { 'q' : q, - 'tipo' : pk, - 'tr' : '2' // tipo_resultado = 2 - api fornecerá possíveis Autores + 'tipo' : pk } $.get(url, formData).done(function(data) { active('pesquisa'); From 1b19781012009735fe49c1e957813c90703155a9 Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Tue, 25 Jul 2017 15:58:18 -0300 Subject: [PATCH 03/25] Arruma a data_fim_mandato Signed-off-by: Luciano Almeida --- sapl/legacy/migration.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sapl/legacy/migration.py b/sapl/legacy/migration.py index 8f56f91f1..fc22cf6d4 100644 --- a/sapl/legacy/migration.py +++ b/sapl/legacy/migration.py @@ -661,6 +661,8 @@ def adjust_documentoadministrativo(new, old): def adjust_mandato(new, old): + if old.dat_fim_mandato: + new.data_fim_mandato = old.dat_fim_mandato if not new.data_fim_mandato: legislatura = Legislatura.objects.latest('data_fim') new.data_fim_mandato = legislatura.data_fim From 712b214da265a6994da73749cea38a7eed9fb305 Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Wed, 2 Aug 2017 13:05:15 -0300 Subject: [PATCH 04/25] Arruma problema de parlamentar relacionado inexistente Signed-off-by: Luciano Almeida --- sapl/legacy/migration.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/sapl/legacy/migration.py b/sapl/legacy/migration.py index fc22cf6d4..1e27b36d7 100644 --- a/sapl/legacy/migration.py +++ b/sapl/legacy/migration.py @@ -850,8 +850,21 @@ def adjust_protocolo_depois_salvar(new, old): def adjust_autor(new, old): if old.cod_parlamentar: - new.autor_related = Parlamentar.objects.get(pk=old.cod_parlamentar) + try: + new.autor_related = Parlamentar.objects.get(pk=old.cod_parlamentar) + except Exception: + with reversion.create_revision(): + msg = 'Um parlamentar relacionado de PK [%s] não existia' \ + % old.cod_parlamentar + reversion.set_comment('Stub criado pela migração') + value = make_stub(Parlamentar, old.cod_parlamentar) + descricao = 'stub criado para entrada orfã!' + warn(msg + ' => ' + descricao) + save_relation(value, [], msg, descricao, + eh_stub=True) + new.autor_related = value new.nome = new.autor_related.nome_parlamentar + elif old.cod_comissao: new.autor_related = Comissao.objects.get(pk=old.cod_comissao) new.nome = new.autor_related.nome @@ -859,22 +872,14 @@ def adjust_autor(new, old): if old.col_username: if not get_user_model().objects.filter( username=old.col_username).exists(): - user = get_user_model()( - username=old.col_username, password=12345) + user = get_user_model()(username=old.col_username) + user.set_password(12345) with reversion.create_revision(): user.save() reversion.set_comment('Objeto criado pela migração') grupo_autor = Group.objects.get(name="Autor") user.groups.add(grupo_autor) - if old.cod_parlamentar: - grupo_parlamentar = Group.objects.get(name="Parlamentar") - user.groups.add(grupo_parlamentar) - - new.user = user - else: - new.user = get_user_model().objects.filter( - username=old.col_username)[0] def adjust_comissao(new, old): From c3260a94219dd0ccba7cde8b3fe65b2f8b4db8fe Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Wed, 2 Aug 2017 14:26:03 -0300 Subject: [PATCH 05/25] HOT-FIX: erro de grafia --- sapl/templates/sistema.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapl/templates/sistema.html b/sapl/templates/sistema.html index 72ddb240a..e631d84a8 100644 --- a/sapl/templates/sistema.html +++ b/sapl/templates/sistema.html @@ -3,7 +3,7 @@ {% block base_content %} -

Configuração Gerais

+

Configurações Gerais

From 55bbf8892aa1e989a9852ce376c96c710bd07311 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Wed, 2 Aug 2017 14:29:06 -0300 Subject: [PATCH 06/25] HOT-FIX: tira obrigatoriedade do codigo de casa legislativa --- .../migrations/0005_auto_20170802_1428.py | 20 +++++++++++++++++++ sapl/base/models.py | 5 ++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 sapl/base/migrations/0005_auto_20170802_1428.py diff --git a/sapl/base/migrations/0005_auto_20170802_1428.py b/sapl/base/migrations/0005_auto_20170802_1428.py new file mode 100644 index 000000000..d97c0448b --- /dev/null +++ b/sapl/base/migrations/0005_auto_20170802_1428.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.11 on 2017-08-02 14:28 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('base', '0004_auto_20170714_1838'), + ] + + operations = [ + migrations.AlterField( + model_name='casalegislativa', + name='codigo', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Codigo'), + ), + ] diff --git a/sapl/base/models.py b/sapl/base/models.py index f2f81ab15..eadd8e793 100644 --- a/sapl/base/models.py +++ b/sapl/base/models.py @@ -18,7 +18,10 @@ class CasaLegislativa(models.Model): # TODO ajustar todos os max_length !!!! # cod_casa => id (pk) - codigo = models.CharField(max_length=100, verbose_name=_('Codigo')) + codigo = models.CharField(max_length=100, + blank=True, + null=True, + verbose_name=_('Codigo')) nome = models.CharField(max_length=100, verbose_name=_('Nome')) sigla = models.CharField(max_length=100, verbose_name=_('Sigla')) endereco = models.CharField(max_length=100, verbose_name=_('Endereço')) From 9aacf46d3d1db8a14366c20a09367adcf653bc77 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Wed, 2 Aug 2017 14:40:14 -0300 Subject: [PATCH 07/25] =?UTF-8?q?HOT-FIX=202:=20campos=20CharField=20n?= =?UTF-8?q?=C3=A3o=20podem=20ser=20null=20(facepalm)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/base/models.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sapl/base/models.py b/sapl/base/models.py index eadd8e793..a5e94b321 100644 --- a/sapl/base/models.py +++ b/sapl/base/models.py @@ -20,7 +20,6 @@ class CasaLegislativa(models.Model): codigo = models.CharField(max_length=100, blank=True, - null=True, verbose_name=_('Codigo')) nome = models.CharField(max_length=100, verbose_name=_('Nome')) sigla = models.CharField(max_length=100, verbose_name=_('Sigla')) From 725531794885536df9c145a74f0df345465f06be Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Wed, 2 Aug 2017 14:52:22 -0300 Subject: [PATCH 08/25] =?UTF-8?q?Arruma=20erro=20de=20opera=C3=A7=C3=A3o?= =?UTF-8?q?=20n=C3=A3o=20suportadda=20em=20Protocolo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Luciano Almeida --- sapl/legacy/migration.py | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/sapl/legacy/migration.py b/sapl/legacy/migration.py index 1e27b36d7..61de0854e 100644 --- a/sapl/legacy/migration.py +++ b/sapl/legacy/migration.py @@ -747,17 +747,22 @@ def adjust_normarelacionada(new, old): new.tipo_vinculo = tipo[0] -def adjust_protocolo(new, old): - if new.numero is None and not primeira_vez: - p = ProtocoloLegado.objects.filter( - ano_protocolo=new.ano).aggregate(Max('num_protocolo')) - numero_maximo = p['num_protocolo__max'] - new.numero = 1 if numero_maximo is None else numero_maximo + 1 - primeira_vez.append(True) - if new.numero is None and primeira_vez: - p = Protocolo.objects.filter( - ano=new.ano).aggregate(Max('numero')) - new.numero = p['numero__max'] + 1 +def adjust_protocolo_antes_salvar(new, old): + data_ajuste = date(2014, 11, 13) + + if old.num_protocolo is None and data_ajuste >= old.dat_protocolo: + new.numero = old.pk + + +def adjust_protocolo_depois_salvar(new, old): + if old.num_protocolo is None: + with reversion.create_revision(): + problema = 'Número do protocolo de PK %s é nulo' % new.pk + descricao = 'Número do protocolo alterado para %s!' % new.numero + warn(problema + ' => ' + descricao) + save_relation(obj=new, problema=problema, + descricao=descricao, eh_stub=False) + reversion.set_comment('Número de protocolo teve que ser alterado') def adjust_registrovotacao_antes_salvar(new, old): @@ -837,17 +842,6 @@ def adjust_normajuridica_depois_salvar(new, old): new.assuntos.add(AssuntoNorma.objects.get(pk=pk_assunto)) -def adjust_protocolo_depois_salvar(new, old): - if old.num_protocolo is None: - with reversion.create_revision(): - problema = 'Número do protocolo de PK %s é nulo' % new.pk - descricao = 'Número do protocolo alterado para %s!' % new.numero - warn(problema + ' => ' + descricao) - save_relation(obj=new, problema=problema, - descricao=descricao, eh_stub=False) - reversion.set_comment('Numero de protocolo teve que ser alterado') - - def adjust_autor(new, old): if old.cod_parlamentar: try: @@ -904,7 +898,7 @@ AJUSTE_ANTES_SALVAR = { Parlamentar: adjust_parlamentar, Participacao: adjust_participacao, Proposicao: adjust_proposicao_antes_salvar, - Protocolo: adjust_protocolo, + Protocolo: adjust_protocolo_antes_salvar, RegistroVotacao: adjust_registrovotacao_antes_salvar, TipoAfastamento: adjust_tipoafastamento, TipoProposicao: adjust_tipoproposicao, From bf7c3b1b86929b03b51422e5274d567be0f0d5f4 Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Wed, 2 Aug 2017 15:51:00 -0300 Subject: [PATCH 09/25] =?UTF-8?q?Ajusta=20rela=C3=A7=C3=A3o=20e=20cria?= =?UTF-8?q?=C3=A7=C3=A3o=20de=20protocolos=20inexistentes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Luciano Almeida --- sapl/legacy/migration.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/sapl/legacy/migration.py b/sapl/legacy/migration.py index 61de0854e..8878d3522 100644 --- a/sapl/legacy/migration.py +++ b/sapl/legacy/migration.py @@ -655,9 +655,27 @@ def adjust_acompanhamentomateria(new, old): def adjust_documentoadministrativo(new, old): if new.numero_protocolo: - protocolo = Protocolo.objects.get(numero=new.numero_protocolo, - ano=new.ano) - new.protocolo = protocolo + try: + protocolo = Protocolo.objects.get(numero=new.numero_protocolo, + ano=new.ano) + new.protocolo = protocolo + except Exception: + try: + protocolo = Protocolo.objects.get(numero=new.numero_protocolo, + ano=new.ano+1) + new.protocolo = protocolo + except Exception: + protocolo = mommy.make(Protocolo, numero=new.numero_protocolo, + ano=new.ano) + with reversion.create_revision(): + problema = 'Protocolo Vinculado [numero_protocolo=%s, '\ + 'ano=%s] não existe' % (new.numero_protocolo, + new.ano) + descricao = 'O protocolo inexistente foi criado' + warn(problema + ' => ' + descricao) + save_relation(obj=protocolo, problema=problema, + descricao=descricao, eh_stub=True) + reversion.set_comment('Protocolo não existia.') def adjust_mandato(new, old): From 85ece5b28add46da4af9fddea32cf47950c2c9ef Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Wed, 2 Aug 2017 17:29:11 -0300 Subject: [PATCH 10/25] =?UTF-8?q?Verifica=20rela=C3=A7=C3=A3o=20entre=20pa?= =?UTF-8?q?rlamentares=20e=20autores?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Luciano Almeida --- sapl/legacy/migration.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sapl/legacy/migration.py b/sapl/legacy/migration.py index 8878d3522..b5e16e282 100644 --- a/sapl/legacy/migration.py +++ b/sapl/legacy/migration.py @@ -327,6 +327,9 @@ def obj_desnecessario(obj): if (f.one_to_many or f.one_to_one) and f.auto_created] sem_referencia = not any(rr.related_model.objects.filter( **{rr.field.name: obj}).exists() for rr in relacoes) + if type(obj).__name__ == 'Parlamentar' and sem_referencia and \ + obj.autor.all(): + sem_referencia = False return sem_referencia From 258dec34e7e58d8e5f0df5e64b199bc678e9c766 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Wed, 2 Aug 2017 19:08:47 -0300 Subject: [PATCH 11/25] =?UTF-8?q?Adiciona=20valor=20padr=C3=A3o=20de=20c?= =?UTF-8?q?=C3=B3digo=20de=20casa=20legislativa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0006_auto_20170802_1908.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 sapl/base/migrations/0006_auto_20170802_1908.py diff --git a/sapl/base/migrations/0006_auto_20170802_1908.py b/sapl/base/migrations/0006_auto_20170802_1908.py new file mode 100644 index 000000000..2a3ac7009 --- /dev/null +++ b/sapl/base/migrations/0006_auto_20170802_1908.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.11 on 2017-08-02 22:08 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('base', '0005_auto_20170802_1428'), + ] + + operations = [ + migrations.AlterField( + model_name='casalegislativa', + name='codigo', + field=models.CharField(blank=True, default='', max_length=100, verbose_name='Codigo'), + preserve_default=False, + ), + ] From 3ee05211966f094458f79f7043cf65679ee69fbe Mon Sep 17 00:00:00 2001 From: LeandroRoberto Date: Thu, 3 Aug 2017 10:27:06 -0300 Subject: [PATCH 12/25] Ajst js de psq autor e insere drf base para combos --- sapl/api/forms.py | 11 +++++++++++ sapl/api/urls.py | 4 ++-- sapl/api/views.py | 10 ++++++---- sapl/settings.py | 5 +++-- sapl/static/js/app.js | 7 ++++--- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/sapl/api/forms.py b/sapl/api/forms.py index f36b7724f..59c79feb1 100644 --- a/sapl/api/forms.py +++ b/sapl/api/forms.py @@ -117,3 +117,14 @@ class AutorSearchForFieldFilterSet(AutorChoiceFilterSet): v = '1' if v == 'True' else '0' params[key] = v return queryset.filter(**params).distinct('nome').order_by('nome') + + +class AutoresPossiveisFilterSet(FilterSet): + tipo = MethodFilter() + + class Meta: + model = Autor + fields = ['tipo', ] + + def filter_tipo(self, queryset, value): + return queryset diff --git a/sapl/api/urls.py b/sapl/api/urls.py index 7d146e4bb..314b2b339 100644 --- a/sapl/api/urls.py +++ b/sapl/api/urls.py @@ -18,9 +18,9 @@ urlpatterns_router = router.urls urlpatterns_api = [ - url(r'^autores-provaveis', + url(r'^autor/provaveis', AutoresProvaveisListView.as_view(), name='autores_provaveis_list'), - url(r'^autores-possiveis', + url(r'^autor/possiveis', AutoresPossiveisListView.as_view(), name='autores_possiveis_list'), url(r'^autor', AutorListView.as_view(), name='autor_list'), diff --git a/sapl/api/views.py b/sapl/api/views.py index 507551808..fb84c105e 100644 --- a/sapl/api/views.py +++ b/sapl/api/views.py @@ -9,7 +9,8 @@ from rest_framework.permissions import (AllowAny, IsAuthenticated, IsAuthenticatedOrReadOnly) from rest_framework.viewsets import GenericViewSet, ModelViewSet -from sapl.api.forms import AutorChoiceFilterSet, AutorSearchForFieldFilterSet +from sapl.api.forms import AutorChoiceFilterSet, AutorSearchForFieldFilterSet,\ + AutoresPossiveisFilterSet from sapl.api.serializers import (AutorChoiceSerializer, AutorSerializer, ChoiceSerializer, MateriaLegislativaSerializer, @@ -70,7 +71,7 @@ class AutorListView(ListAPIView): o django-filter é desativado e a busca é feita no model do ContentType associado ao tipo. - - q_0 / q_1 - q_0 faz o código ignorar "q"... + - q_0 / q_1 - q_0 é opcional e quando usado, faz o código ignorar "q"... q_0 -> campos lookup a serem filtrados em qualquer Model que implemente SaplGenericRelation @@ -150,6 +151,7 @@ class AutorListView(ListAPIView): return tr def get(self, request, *args, **kwargs): + if self.tr == AutorListView.TR_AUTOR_SERIALIZER: self.serializer_class = AutorSerializer self.permission_classes = (IsAuthenticated,) @@ -246,9 +248,9 @@ class AutoresPossiveisListView(ListAPIView): queryset = Autor.objects.all() model = Autor - filter_class = AutorChoiceFilterSet + filter_class = AutoresPossiveisFilterSet filter_backends = (DjangoFilterBackend, ) - serializer_class = ChoiceSerializer + serializer_class = AutorChoiceSerializer class MateriaLegislativaViewSet(ListModelMixin, diff --git a/sapl/settings.py b/sapl/settings.py index d6590c5b4..0905edb1b 100644 --- a/sapl/settings.py +++ b/sapl/settings.py @@ -22,6 +22,7 @@ from unipath import Path from .temp_suppress_crispy_form_warnings import \ SUPRESS_CRISPY_FORM_WARNINGS_LOGGING + BASE_DIR = Path(__file__).ancestor(1) PROJECT_DIR = Path(__file__).ancestor(2) @@ -101,7 +102,7 @@ if SOLR_URL: HAYSTACK_CONNECTIONS = { 'default': { 'ENGINE': SEARCH_BACKEND, - SEARCH_URL[0] : SEARCH_URL[1] + SEARCH_URL[0]: SEARCH_URL[1] }, } @@ -200,7 +201,7 @@ MAX_IMAGE_UPLOAD_SIZE = 2 * 1024 * 1024 # 2MB # https://docs.djangoproject.com/en/1.8/topics/i18n/ LANGUAGE_CODE = 'pt-br' LANGUAGES = ( - ('pt-br','Português'), + ('pt-br', 'Português'), ) TIME_ZONE = 'America/Sao_Paulo' diff --git a/sapl/static/js/app.js b/sapl/static/js/app.js index 0d311fd48..697564024 100644 --- a/sapl/static/js/app.js +++ b/sapl/static/js/app.js @@ -58,7 +58,7 @@ function autorModal() { autoOpen: false, modal: true, width: 500, - height: 300, + height: 340, show: { effect: "blind", duration: 500}, @@ -111,11 +111,12 @@ function autorModal() { select.append($("