From 6b9eca7fd88d92363e7f6eea6959159750e7e087 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Wed, 14 Sep 2016 16:15:53 -0300 Subject: [PATCH] =?UTF-8?q?Inicia=20tela=20de=20pesquisa=20de=20mat=C3=A9r?= =?UTF-8?q?ias?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/materia/forms.py | 31 +++++++++ sapl/materia/urls.py | 8 ++- sapl/materia/views.py | 55 +++++++++++++++- sapl/templates/materia/acessorio_lote.html | 73 ++++++++++++++++++++++ 4 files changed, 162 insertions(+), 5 deletions(-) create mode 100644 sapl/templates/materia/acessorio_lote.html diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py index 851dd51ba..4ef42e922 100644 --- a/sapl/materia/forms.py +++ b/sapl/materia/forms.py @@ -755,3 +755,34 @@ class AutorForm(ModelForm): u.groups.add(grupo) return autor + + +class AcessorioEmLoteFilterSet(django_filters.FilterSet): + + filter_overrides = {models.DateField: { + 'filter_class': django_filters.DateFromToRangeFilter, + 'extra': lambda f: { + 'label': '%s (%s)' % (f.verbose_name, _('Inicial - Final')), + 'widget': RangeWidgetOverride} + }} + + class Meta: + model = MateriaLegislativa + fields = ['tipo', 'data_apresentacao'] + + def __init__(self, *args, **kwargs): + super(AcessorioEmLoteFilterSet, self).__init__(*args, **kwargs) + + self.filters['tipo'].label = 'Tipo de Matéria' + self.filters['data_apresentacao'].label = 'Data (Inicial - Final)' + self.form.fields['tipo'].required = True + self.form.fields['data_apresentacao'].required = True + + row1 = to_row([('tipo', 12)]) + row2 = to_row([('data_apresentacao', 12)]) + + self.form.helper = FormHelper() + self.form.helper.form_method = 'GET' + self.form.helper.layout = Layout( + Fieldset(_('Documentos Acessórios em Lote'), + row1, row2, form_actions(save_label='Pesquisar'))) diff --git a/sapl/materia/urls.py b/sapl/materia/urls.py index a0584d94d..10bbbe08d 100644 --- a/sapl/materia/urls.py +++ b/sapl/materia/urls.py @@ -5,8 +5,9 @@ from sapl.materia.views import (AcompanhamentoConfirmarView, AcompanhamentoMateriaView, AnexadaCrud, AutorCrud, AutoriaCrud, ConfirmarEmailView, ConfirmarProposicao, DespachoInicialCrud, - DocumentoAcessorioCrud, LegislacaoCitadaCrud, - MateriaLegislativaCrud, + DocumentoAcessorioCrud, + DocumentoAcessorioEmLoteView, + LegislacaoCitadaCrud, MateriaLegislativaCrud, MateriaLegislativaPesquisaView, MateriaTaView, NumeracaoCrud, OrgaoCrud, OrigemCrud, ProposicaoCrud, ProposicaoDevolvida, @@ -86,4 +87,7 @@ urlpatterns = [ url(r'^materia/(?P\d+)/acompanhar-excluir$', AcompanhamentoExcluirView.as_view(), name='acompanhar_excluir'), + + url(r'^acessorio-em-lote', DocumentoAcessorioEmLoteView.as_view(), + name='acessorio_em_lote'), ] diff --git a/sapl/materia/views.py b/sapl/materia/views.py index 4f7966118..3ddd1e946 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -4,7 +4,6 @@ from string import ascii_letters, digits from crispy_forms.helper import FormHelper from crispy_forms.layout import HTML, Button -from django.db.models import Q from django.conf import settings from django.contrib import messages from django.contrib.auth.mixins import PermissionRequiredMixin @@ -13,6 +12,7 @@ from django.contrib.auth.tokens import default_token_generator from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist from django.core.mail import send_mail from django.core.urlresolvers import reverse +from django.db.models import Q from django.http.response import HttpResponseRedirect from django.shortcuts import redirect from django.template import Context, loader @@ -34,8 +34,9 @@ from sapl.utils import (autor_label, autor_modal, gerar_hash_arquivo, get_base_url, permissao_tb_aux, permissoes_autor, permissoes_materia, permissoes_protocoloadm) -from .forms import (AcompanhamentoMateriaForm, AnexadaForm, AutorForm, - AutoriaForm, ConfirmarProposicaoForm, DespachoInicialForm, +from .forms import (AcessorioEmLoteFilterSet, AcompanhamentoMateriaForm, + AnexadaForm, AutorForm, AutoriaForm, + ConfirmarProposicaoForm, DespachoInicialForm, DocumentoAcessorioForm, LegislacaoCitadaForm, MateriaLegislativaFilterSet, NumeracaoForm, ProposicaoForm, ReceberProposicaoForm, RelatoriaForm, TramitacaoForm, @@ -1246,3 +1247,51 @@ def do_envia_email_tramitacao(request, materia): enviar_emails(sender, recipients, messages) return None + + +class DocumentoAcessorioEmLoteView(PermissionRequiredMixin, FilterView): + filterset_class = AcessorioEmLoteFilterSet + template_name = 'materia/acessorio_lote.html' + + def get_context_data(self, **kwargs): + context = super(DocumentoAcessorioEmLoteView, + self).get_context_data(**kwargs) + + context['title'] = _('Documentos Acessórios em Lote') + qr = self.request.GET.copy() + context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else '' + return context + + # def post(self, request, *args, **kwargs): + # marcadas = request.POST.getlist('materia_id') + # + # for m in marcadas: + # try: + # tipo_votacao = request.POST['tipo_votacao_%s' % m] + # except MultiValueDictKeyError: + # msg = _('Formulário Inválido. Você esqueceu de selecionar ' + + # 'o tipo de votação de %s' % + # MateriaLegislativa.objects.get(id=m)) + # messages.add_message(request, messages.ERROR, msg) + # return self.get(request, self.kwargs) + # + # if tipo_votacao: + # lista_materias_expediente = ExpedienteMateria.objects.filter( + # sessao_plenaria_id=self.kwargs[ + # 'pk']) + # + # materia = MateriaLegislativa.objects.get(id=m) + # + # expediente = ExpedienteMateria() + # expediente.sessao_plenaria_id = self.kwargs['pk'] + # expediente.materia_id = materia.id + # if lista_materias_expediente: + # posicao = lista_materias_expediente.last().numero_ordem + 1 + # expediente.numero_ordem = posicao + # else: + # expediente.numero_ordem = 1 + # expediente.data_ordem = datetime.now() + # expediente.tipo_votacao = request.POST['tipo_votacao_%s' % m] + # expediente.save() + # + # return self.get(request, self.kwargs) diff --git a/sapl/templates/materia/acessorio_lote.html b/sapl/templates/materia/acessorio_lote.html new file mode 100644 index 000000000..7c5493455 --- /dev/null +++ b/sapl/templates/materia/acessorio_lote.html @@ -0,0 +1,73 @@ +{% extends "crud/detail.html" %} +{% load i18n crispy_forms_tags %} +{% block actions %}{% endblock %} +{% block sections_nav %}{% endblock %} +{% block detail_content %} + + {% if not filter_url %} + {% crispy filter.form %} + {% endif %} + + +{% endblock detail_content %}