diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py index 66d56af04..d3ac74afb 100644 --- a/sapl/materia/forms.py +++ b/sapl/materia/forms.py @@ -2788,6 +2788,28 @@ class FichaSelecionaForm(forms.Form): ) +class StatusTramitacaoFilterSet(django_filters.FilterSet): + descricao = django_filters.CharFilter(label=_("Descrição do Status"), lookup_expr="icontains") + + class Meta: + model = StatusTramitacao + fields = ["descricao"] + + def multifield_filter(self, queryset, name, value): + return queryset.filter(Q(sigla__icontains=value) | Q(descricao__icontains=value)) + + def __init__(self, *args, **kwargs): + super(StatusTramitacaoFilterSet, self).__init__(*args, **kwargs) + + row0 = to_row([("descricao", 12)]) + + self.form.helper = SaplFormHelper() + self.form.helper.form_method = "GET" + self.form.helper.layout = Layout( + Fieldset(_("Pesquisa de Status de Tramitacao"), row0, form_actions(label="Pesquisar")) + ) + + class ExcluirTramitacaoEmLote(forms.Form): logger = logging.getLogger(__name__) diff --git a/sapl/materia/urls.py b/sapl/materia/urls.py index 4c6c5166b..12e392ef4 100644 --- a/sapl/materia/urls.py +++ b/sapl/materia/urls.py @@ -25,13 +25,17 @@ from sapl.materia.views import (AcompanhamentoConfirmarView, TipoProposicaoCrud, TramitacaoCrud, TramitacaoEmLoteView, UnidadeTramitacaoCrud, proposicao_texto, recuperar_materia, - ExcluirTramitacaoEmLoteView, RetornarProposicao, + ExcluirTramitacaoEmLoteView, + RetornarProposicao, MateriaPesquisaSimplesView, - DespachoInicialMultiCreateView, get_zip_docacessorios, - get_pdf_docacessorios, configEtiquetaMateriaLegislativaCrud) + DespachoInicialMultiCreateView, + get_zip_docacessorios, get_pdf_docacessorios, + configEtiquetaMateriaLegislativaCrud, + PesquisarStatusTramitacaoView) from sapl.norma.views import NormaPesquisaSimplesView from sapl.protocoloadm.views import ( - FichaPesquisaAdmView, FichaSelecionaAdmView) + FichaPesquisaAdmView, FichaSelecionaAdmView +) from .apps import AppConfig @@ -170,8 +174,16 @@ urlpatterns_sistema = [ url(r'^sistema/materia/unidade-tramitacao/', include(UnidadeTramitacaoCrud.get_urls())), url(r'^sistema/materia/origem/', include(OrigemCrud.get_urls())), - url(r'^sistema/materia/status-tramitacao/', - include(StatusTramitacaoCrud.get_urls())), + + url(r'^sistema/materia/status-tramitacao/', include( + StatusTramitacaoCrud.get_urls() + )), + url( + r'^sistema/materia/pesquisar-status-tramitacao/', + PesquisarStatusTramitacaoView.as_view(), + name="pesquisar_statustramitacao" + ), + url(r'^sistema/materia/orgao/', include(OrgaoCrud.get_urls())), url(r'^sistema/materia/config-etiqueta-materia-legislativas/',configEtiquetaMateriaLegislativaCrud, name="configEtiquetaMateriaLegislativaCrud"), ] diff --git a/sapl/materia/views.py b/sapl/materia/views.py index ef82276c3..da1f21ea3 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -60,14 +60,17 @@ from sapl.utils import (autor_label, autor_modal, gerar_hash_arquivo, get_base_u from .forms import (AcessorioEmLoteFilterSet, AcompanhamentoMateriaForm, AnexadaEmLoteFilterSet, AdicionarVariasAutoriasFilterSet, - compara_tramitacoes_mat, DespachoInicialForm, DocumentoAcessorioForm, - EtiquetaPesquisaForm, ExcluirTramitacaoEmLote, FichaPesquisaForm, + compara_tramitacoes_mat, DespachoInicialForm, + DocumentoAcessorioForm, EtiquetaPesquisaForm, + ExcluirTramitacaoEmLote, FichaPesquisaForm, FichaSelecionaForm, filtra_tramitacao_destino, - filtra_tramitacao_destino_and_status, filtra_tramitacao_status, - MateriaAssuntoForm, MateriaLegislativaFilterSet, MateriaLegislativaForm, + filtra_tramitacao_destino_and_status, + filtra_tramitacao_status, MateriaAssuntoForm, + MateriaLegislativaFilterSet, MateriaLegislativaForm, MateriaSimplificadaForm, PrimeiraTramitacaoEmLoteFilterSet, - ReceberProposicaoForm, RelatoriaForm, TramitacaoEmLoteFilterSet, - TramitacaoEmLoteForm, UnidadeTramitacaoForm) + ReceberProposicaoForm, RelatoriaForm, + TramitacaoEmLoteFilterSet, TramitacaoEmLoteForm, + UnidadeTramitacaoForm, StatusTramitacaoFilterSet) from .models import (AcompanhamentoMateria, Anexada, AssuntoMateria, Autoria, DespachoInicial, DocumentoAcessorio, MateriaAssunto, MateriaLegislativa, Numeracao, Orgao, Origem, Proposicao, RegimeTramitacao, Relatoria, StatusTramitacao, @@ -379,7 +382,70 @@ def recuperar_materia(request): return response -StatusTramitacaoCrud = CrudAux.build(StatusTramitacao, 'status_tramitacao') +class StatusTramitacaoCrud(CrudAux): + model = StatusTramitacao + + class DeleteView(CrudAux.DeleteView): + def get_success_url(self): + return reverse('sapl.materia:pesquisar_statustramitacao') + + +class PesquisarStatusTramitacaoView(FilterView): + model = StatusTramitacao + filterset_class = StatusTramitacaoFilterSet + paginate_by = 10 + + def get_filterset_kwargs(self, filterset_class): + super(PesquisarStatusTramitacaoView, self).get_filterset_kwargs( + filterset_class + ) + + return ({ + "data": self.request.GET or None, + "queryset": self.get_queryset().order_by("sigla").distinct() + }) + + def get_context_data(self, **kwargs): + context = super(PesquisarStatusTramitacaoView, self).get_context_data( + **kwargs + ) + + paginator = context["paginator"] + page_obj = context["page_obj"] + + context.update({ + "page_range": make_pagination( + page_obj.number, paginator.num_pages + ), + "NO_ENTRIES_MSG": "Nenhum status de tramitacao encontrado!", + "title": _("Status de Tramitação") + }) + + return context + + def get(self, request, *args, **kwargs): + super(PesquisarStatusTramitacaoView, self).get(request) + + data = self.filterset.data + + url = '' + + if data: + url = '&' + str(self.request.META["QUERY_STRING"]) + if url.startswith("&page"): + ponto_comeco = url.find("sigla=") - 1 + url = url[ponto_comeco:] + + context = self.get_context_data( + filter=self.filterset, object_list=self.object_list, + filter_url=url, numero_res=len(self.object_list) + ) + + context["show_results"] = show_results_filter_set( + self.request.GET.copy() + ) + + return self.render_to_response(context) class OrgaoCrud(CrudAux): diff --git a/sapl/templates/materia/statustramitacao_detail.html b/sapl/templates/materia/statustramitacao_detail.html new file mode 100644 index 000000000..da309d877 --- /dev/null +++ b/sapl/templates/materia/statustramitacao_detail.html @@ -0,0 +1,14 @@ +{% extends "crud/detail.html" %} +{% load i18n %} +{% load crispy_forms_tags cropping %} + +{% block actions %} +
+ +{% endblock actions %} diff --git a/sapl/templates/materia/statustramitacao_filter.html b/sapl/templates/materia/statustramitacao_filter.html new file mode 100644 index 000000000..5b93f3ee0 --- /dev/null +++ b/sapl/templates/materia/statustramitacao_filter.html @@ -0,0 +1,41 @@ +{% extends "crud/list.html" %} +{% load i18n %} +{% load crispy_forms_tags staticfiles %} + +{% block base_content %} + {% if not show_results %} + {% crispy filter.form %} + {% else %} +Foi encontrado {{ numero_res }} resultado.
+ {% else %} +Foram encontrados {{ numero_res }} resultados.
+ {% endif %} +Sigla | Descricao | Indicador da Tramitacao |
---|---|---|
{{ status.sigla }} | +{{ status.descricao }} | +{{ status.indicador }} | +
{{ NO_ENTRIES_MSG }}
+ {% endif %} + {% endif %} +