diff --git a/sapl/legacy/management/__init__.py b/sapl/legacy/management/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/sapl/legacy/management/commands/__init__.py b/sapl/legacy/management/commands/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/sapl/legacy/management/commands/migracao_25_31.py b/sapl/legacy/management/commands/migracao_25_31.py new file mode 100644 index 000000000..199075d44 --- /dev/null +++ b/sapl/legacy/management/commands/migracao_25_31.py @@ -0,0 +1,9 @@ +from django.core.management.base import BaseCommand +from sapl.legacy import migration + + +class Command(BaseCommand): + help = u'Faz a migração de dados do SAPL 2.5 para o SAPL 3.1' + + def handle(self, *args, **options): + migration.migrate() diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py index cce976e88..1d481cce1 100644 --- a/sapl/materia/forms.py +++ b/sapl/materia/forms.py @@ -17,6 +17,7 @@ from sapl.comissoes.models import Comissao from sapl.crispy_layout_mixin import form_actions, to_row from sapl.norma.models import (LegislacaoCitada, NormaJuridica, TipoNormaJuridica) +from sapl.parlamentares.models import Parlamentar from sapl.settings import MAX_DOC_UPLOAD_SIZE from sapl.utils import (RANGE_ANOS, RangeWidgetOverride, autor_label, autor_modal) @@ -190,6 +191,11 @@ class RelatoriaForm(ModelForm): widgets = {'comissao': forms.Select(attrs={'disabled': 'disabled'})} + def __init__(self, *args, **kwargs): + super(RelatoriaForm, self).__init__(*args, **kwargs) + self.fields['parlamentar'].queryset = Parlamentar.objects.filter( + ativo=True).order_by('nome_completo') + def clean(self): cleaned_data = self.cleaned_data 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/norma/migrations/0015_auto_20160929_1635.py b/sapl/norma/migrations/0015_auto_20160929_1635.py new file mode 100644 index 000000000..5ea7f8a1b --- /dev/null +++ b/sapl/norma/migrations/0015_auto_20160929_1635.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-09-29 19:35 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('norma', '0014_merge'), + ] + + operations = [ + migrations.AlterModelOptions( + name='legislacaocitada', + options={'verbose_name': 'Legislação', 'verbose_name_plural': 'Legislações'}, + ), + ] diff --git a/sapl/norma/models.py b/sapl/norma/models.py index 8c47d4c72..c03c4c305 100644 --- a/sapl/norma/models.py +++ b/sapl/norma/models.py @@ -164,8 +164,8 @@ class LegislacaoCitada(models.Model): max_length=3, blank=True, verbose_name=_('Item')) class Meta: - verbose_name = _('Matéria Legislativa') - verbose_name_plural = _('Matérias Legislativas') + verbose_name = _('Legislação') + verbose_name_plural = _('Legislações') class VinculoNormaJuridica(models.Model): diff --git a/sapl/parlamentares/legacy.yaml b/sapl/parlamentares/legacy.yaml index 3130c548f..738656e4e 100644 --- a/sapl/parlamentares/legacy.yaml +++ b/sapl/parlamentares/legacy.yaml @@ -1,4 +1,5 @@ Legislatura: + numero: num_legislatura data_eleicao: dat_eleicao data_fim: dat_fim data_inicio: dat_inicio 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 %} diff --git a/sapl/templates/materia/relatoria_form.html b/sapl/templates/materia/relatoria_form.html new file mode 100644 index 000000000..953557513 --- /dev/null +++ b/sapl/templates/materia/relatoria_form.html @@ -0,0 +1,14 @@ +{% extends "crud/form.html" %} +{% load i18n %} +{% load crispy_forms_tags %} +{% load common_tags %} + +{% block base_content %} + {% if form.comissao.value == 0 %} + + {% else %} + {% crispy form %} + {% endif %} +{% endblock %}