From 458f65395e871479a49cffd7d831b1b52e0e5f60 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Thu, 29 Sep 2016 14:49:34 -0300 Subject: [PATCH] Fix #659 --- sapl/materia/urls.py | 4 ++- sapl/materia/views.py | 14 ++++++++++- .../materia/materialegislativa_form.html | 25 +++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 sapl/templates/materia/materialegislativa_form.html diff --git a/sapl/materia/urls.py b/sapl/materia/urls.py index 8ffe63f86..5da2305bb 100644 --- a/sapl/materia/urls.py +++ b/sapl/materia/urls.py @@ -19,7 +19,7 @@ from sapl.materia.views import (AcompanhamentoConfirmarView, TipoDocumentoCrud, TipoFimRelatoriaCrud, TipoMateriaCrud, TipoProposicaoCrud, TramitacaoCrud, TramitacaoEmLoteView, - UnidadeTramitacaoCrud) + UnidadeTramitacaoCrud, recuperar_materia) from .apps import AppConfig @@ -36,6 +36,8 @@ urlpatterns = [ RelatoriaCrud.get_urls() + DocumentoAcessorioCrud.get_urls())), + url(r'^materia/recuperar-materia', recuperar_materia), + url(r'''^confirmar/(?P[0-9A-Za-z_\-]+)/ (?P[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})$''', ConfirmarEmailView.as_view(), name='confirmar_email'), diff --git a/sapl/materia/views.py b/sapl/materia/views.py index 2b639fafa..0425c6b15 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -13,6 +13,7 @@ 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 import JsonResponse from django.http.response import HttpResponseRedirect from django.shortcuts import redirect from django.template import Context, loader @@ -54,10 +55,21 @@ from .models import (AcompanhamentoMateria, Anexada, Autor, Autoria, TipoFimRelatoria, TipoMateriaLegislativa, TipoProposicao, Tramitacao, UnidadeTramitacao) - AnexadaCrud = Crud.build(Anexada, '') +def recuperar_materia(request): + tipo = TipoMateriaLegislativa.objects.get(pk=request.GET['tipo']) + materia = MateriaLegislativa.objects.filter(tipo=tipo).last() + if materia: + response = JsonResponse({'numero': materia.numero + 1, + 'ano': datetime.now().year}) + else: + response = JsonResponse({'numero': 1, 'ano': datetime.now().year}) + + return response + + class OrigemCrud(Crud): model = Origem help_path = 'origem' diff --git a/sapl/templates/materia/materialegislativa_form.html b/sapl/templates/materia/materialegislativa_form.html new file mode 100644 index 000000000..7cb127605 --- /dev/null +++ b/sapl/templates/materia/materialegislativa_form.html @@ -0,0 +1,25 @@ +{% extends "crud/form.html" %} +{% load i18n %} +{% load crispy_forms_tags %} +{% load common_tags %} + +{% block extra_js %} + + + +{% endblock %}