From 54112e539fc543b5143419f3b536fe0fdbb47d95 Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Fri, 12 Feb 2016 11:50:52 -0200 Subject: [PATCH] Move crud p/ pacote separado e seus testes p/ app --- comissoes/views.py | 2 +- compilacao/views.py | 2 +- sapl/crud.py => crud.py | 0 {sapl/teststubs => crud_tests}/__init__.py | 0 sapl/test_crud.py => crud_tests/test_flux.py | 0 .../urls_for_list_test.py => crud_tests/urls.py | 2 +- lexml/views.py | 2 +- materia/views.py | 15 +++++++-------- norma/views.py | 2 +- painel/views.py | 2 +- parlamentares/views.py | 2 +- protocoloadm/views.py | 5 ++--- sessao/views.py | 4 ++-- 13 files changed, 18 insertions(+), 20 deletions(-) rename sapl/crud.py => crud.py (100%) rename {sapl/teststubs => crud_tests}/__init__.py (100%) rename sapl/test_crud.py => crud_tests/test_flux.py (100%) rename sapl/teststubs/urls_for_list_test.py => crud_tests/urls.py (94%) diff --git a/comissoes/views.py b/comissoes/views.py index 41d819bee..673d9edc8 100644 --- a/comissoes/views.py +++ b/comissoes/views.py @@ -5,9 +5,9 @@ from django.views.generic import ListView from django.views.generic.edit import FormMixin from vanilla import GenericView +from crud import build_crud from materia.models import Tramitacao from parlamentares.models import Filiacao -from sapl.crud import build_crud from .forms import (CadastrarComissaoForm, ComposicaoForm, ParticipacaoCadastroForm) diff --git a/compilacao/views.py b/compilacao/views.py index d9f2cc602..4db80bda0 100644 --- a/compilacao/views.py +++ b/compilacao/views.py @@ -27,7 +27,7 @@ from compilacao.models import (Dispositivo, Nota, TextoArticulado, TipoDispositivo, TipoNota, TipoPublicacao, TipoTextoArticulado, TipoVide, VeiculoPublicacao, Vide) -from sapl.crud import NO_ENTRIES_MSG, build_crud, make_pagination +from crud import NO_ENTRIES_MSG, build_crud, make_pagination DISPOSITIVO_SELECT_RELATED = ( 'tipo_dispositivo', diff --git a/sapl/crud.py b/crud.py similarity index 100% rename from sapl/crud.py rename to crud.py diff --git a/sapl/teststubs/__init__.py b/crud_tests/__init__.py similarity index 100% rename from sapl/teststubs/__init__.py rename to crud_tests/__init__.py diff --git a/sapl/test_crud.py b/crud_tests/test_flux.py similarity index 100% rename from sapl/test_crud.py rename to crud_tests/test_flux.py diff --git a/sapl/teststubs/urls_for_list_test.py b/crud_tests/urls.py similarity index 94% rename from sapl/teststubs/urls_for_list_test.py rename to crud_tests/urls.py index b09a0d13e..1d0ca7991 100644 --- a/sapl/teststubs/urls_for_list_test.py +++ b/crud_tests/urls.py @@ -2,7 +2,7 @@ from django.conf.urls import include, url from comissoes.models import Comissao from comissoes.urls import comissao_url_patterns -from sapl.crud import build_crud +from crud import build_crud crud = build_crud( Comissao, '', [ diff --git a/lexml/views.py b/lexml/views.py index 464b6da3d..b9f0b5a31 100644 --- a/lexml/views.py +++ b/lexml/views.py @@ -1,6 +1,6 @@ from django.utils.translation import ugettext_lazy as _ -from sapl.crud import build_crud +from crud import build_crud from .models import LexmlProvedor, LexmlPublicador diff --git a/materia/views.py b/materia/views.py index 178016862..128176111 100644 --- a/materia/views.py +++ b/materia/views.py @@ -12,12 +12,11 @@ from django.views.generic import ListView from django.views.generic.edit import FormMixin from vanilla.views import GenericView -import sapl from comissoes.models import Comissao, Composicao from compilacao.views import IntegracaoTaView +from crud import build_crud, make_pagination from norma.models import LegislacaoCitada, NormaJuridica, TipoNormaJuridica from parlamentares.models import Partido -from sapl.crud import build_crud from sessao.models import AcompanharMateria from .forms import (AutoriaForm, DespachoInicialForm, DocumentoAcessorioForm, @@ -879,12 +878,12 @@ class RelatoriaView(FormMixin, GenericView): }) else: relatorias = Relatoria.objects.filter( - materia_id=kwargs['pk']).order_by( - '-data_designacao_relator') + materia_id=kwargs['pk']).order_by( + '-data_designacao_relator') localizacao = Tramitacao.objects.filter( - materia=materia).last() + materia=materia).last() comissao = Comissao.objects.get( - id=localizacao.unidade_tramitacao_destino.comissao.id) + id=localizacao.unidade_tramitacao_destino.comissao.id) if form.is_valid(): relatoria = form.save(commit=False) @@ -1251,7 +1250,7 @@ class ProposicaoListView(ListView): paginator = context['paginator'] page_obj = context['page_obj'] - context['page_range'] = sapl.crud.make_pagination( + context['page_range'] = make_pagination( page_obj.number, paginator.num_pages) return context @@ -1434,7 +1433,7 @@ class PesquisaMateriaListView(FormMixin, ListView): paginator = context['paginator'] page_obj = context['page_obj'] - context['page_range'] = sapl.crud.make_pagination( + context['page_range'] = make_pagination( page_obj.number, paginator.num_pages) return context diff --git a/norma/views.py b/norma/views.py index 9a630a515..73ea3206b 100644 --- a/norma/views.py +++ b/norma/views.py @@ -8,8 +8,8 @@ from django.views.generic.edit import FormMixin from vanilla.views import GenericView from compilacao.views import IntegracaoTaView +from crud import build_crud from materia.models import MateriaLegislativa, TipoMateriaLegislativa -from sapl.crud import build_crud from .forms import NormaJuridicaForm from .models import (AssuntoNorma, LegislacaoCitada, NormaJuridica, diff --git a/painel/views.py b/painel/views.py index 65088386b..0c280cfb5 100644 --- a/painel/views.py +++ b/painel/views.py @@ -5,9 +5,9 @@ from django.http import HttpResponse, JsonResponse from django.shortcuts import render from django.utils.translation import ugettext_lazy as _ +from crud import build_crud from painel.models import Painel from parlamentares.models import Filiacao -from sapl.crud import build_crud from sessao.models import (ExpedienteMateria, OrdemDia, PresencaOrdemDia, RegistroVotacao, SessaoPlenaria, SessaoPlenariaPresenca, VotoParlamentar) diff --git a/parlamentares/views.py b/parlamentares/views.py index fc50d1be6..e39b54447 100644 --- a/parlamentares/views.py +++ b/parlamentares/views.py @@ -8,7 +8,7 @@ from django.utils.translation import ugettext_lazy as _ from django.views.generic.edit import FormMixin from vanilla import GenericView -from sapl.crud import build_crud +from crud import build_crud from .forms import (DependenteEditForm, DependenteForm, FiliacaoEditForm, FiliacaoForm, MandatoEditForm, MandatoForm, diff --git a/protocoloadm/views.py b/protocoloadm/views.py index 34156ac95..9e0cc4367 100644 --- a/protocoloadm/views.py +++ b/protocoloadm/views.py @@ -15,8 +15,8 @@ from django.views.generic.edit import FormMixin from vanilla import GenericView import sapl +from crud import build_crud, make_pagination from materia.models import Proposicao, TipoMateriaLegislativa -from sapl.crud import build_crud from sapl.utils import create_barcode from .forms import (AnularProcoloAdmForm, DocumentoAcessorioAdministrativoForm, @@ -118,7 +118,7 @@ class ProtocoloListView(FormMixin, ListView): paginator = context['paginator'] page_obj = context['page_obj'] - context['page_range'] = sapl.crud.make_pagination( + context['page_range'] = make_pagination( page_obj.number, paginator.num_pages) return context @@ -322,7 +322,6 @@ class ComprovanteProtocoloView(TemplateView): numero = self.kwargs['pk'] ano = self.kwargs['ano'] protocolo = Protocolo.objects.get(ano=ano, numero=numero) - # numero is string, padd with zeros left via .zfill() base64_data = create_barcode(numero.zfill(6)) barcode = 'data:image/png;base64,{0}'.format(base64_data) diff --git a/sessao/views.py b/sessao/views.py index d7a0a9c21..0ac58b2c0 100644 --- a/sessao/views.py +++ b/sessao/views.py @@ -11,11 +11,11 @@ from django.views.generic.edit import FormMixin from rest_framework import generics import sapl +from crud import build_crud, make_pagination from materia.models import (Autoria, DocumentoAcessorio, TipoMateriaLegislativa, Tramitacao) from norma.models import NormaJuridica from parlamentares.models import Parlamentar -from sapl.crud import build_crud from sessao.serializers import SessaoPlenariaSerializer from .forms import (AcompanharMateriaForm, ExpedienteForm, ListMateriaForm, @@ -2184,7 +2184,7 @@ class SessaoListView(ListView): paginator = context['paginator'] page_obj = context['page_obj'] - context['page_range'] = sapl.crud.make_pagination( + context['page_range'] = make_pagination( page_obj.number, paginator.num_pages) return context