diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py index e1fda4119..7c0b6d8c8 100644 --- a/sapl/materia/forms.py +++ b/sapl/materia/forms.py @@ -29,7 +29,8 @@ from sapl.compilacao.models import (STATUS_TA_IMMUTABLE_PUBLIC, STATUS_TA_PRIVATE) from sapl.crispy_layout_mixin import (SaplFormLayout, form_actions, to_column, to_row) -from sapl.materia.models import (MateriaLegislativa, RegimeTramitacao, +from sapl.materia.models import (AssuntoMateria, MateriaAssunto, + MateriaLegislativa, RegimeTramitacao, TipoDocumento, TipoProposicao) from sapl.norma.models import (LegislacaoCitada, NormaJuridica, TipoNormaJuridica) @@ -493,6 +494,10 @@ class MateriaLegislativaFilterSet(django_filters.FilterSet): label=u'Em tramitação', choices=em_tramitacao) + materiaassunto__assunto = django_filters.ModelChoiceFilter( + queryset=AssuntoMateria.objects.all(), + label=_('Assunto da Matéria')) + o = MateriaPesquisaOrderingFilter() class Meta: @@ -509,6 +514,7 @@ class MateriaLegislativaFilterSet(django_filters.FilterSet): 'local_origem_externa', 'tramitacao__unidade_tramitacao_destino', 'tramitacao__status', + 'materiaassunto__assunto', 'em_tramitacao', ] @@ -551,6 +557,8 @@ class MateriaLegislativaFilterSet(django_filters.FilterSet): [('em_tramitacao', 6), ('o', 6)]) row9 = to_row( + [('materiaassunto__assunto', 12)]) + row10 = to_row( [('ementa', 12)]) self.form.helper = FormHelper() @@ -560,7 +568,7 @@ class MateriaLegislativaFilterSet(django_filters.FilterSet): row1, row2, row3, HTML(autor_label), HTML(autor_modal), - row4, row5, row6, row7, row8, row9, + row4, row5, row6, row7, row8, row9, row10, form_actions(save_label='Pesquisar')) ) @@ -1430,3 +1438,12 @@ class ConfirmarProposicaoForm(ProposicaoForm): conteudo_gerado.save() return self.instance + + +class MateriaAssuntoForm(ModelForm): + + class Meta: + model = MateriaAssunto + fields = ['materia', 'assunto'] + + widgets = {'materia': forms.HiddenInput()} diff --git a/sapl/materia/migrations/0003_auto_20170403_1505.py b/sapl/materia/migrations/0003_auto_20170403_1505.py new file mode 100644 index 000000000..fcd7b8eb0 --- /dev/null +++ b/sapl/materia/migrations/0003_auto_20170403_1505.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2017-04-03 15:05 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('materia', '0002_auto_20170330_1513'), + ] + + operations = [ + migrations.AlterField( + model_name='assuntomateria', + name='assunto', + field=models.CharField(max_length=50, verbose_name='Assunto'), + ), + migrations.AlterField( + model_name='assuntomateria', + name='dispositivo', + field=models.CharField(blank=True, max_length=200, null=True, verbose_name='Descrição do Dispositivo Legal'), + ), + ] diff --git a/sapl/materia/models.py b/sapl/materia/models.py index 2f3ee70c3..aed36d3df 100644 --- a/sapl/materia/models.py +++ b/sapl/materia/models.py @@ -307,8 +307,14 @@ class Anexada(models.Model): @reversion.register() class AssuntoMateria(models.Model): - assunto = models.CharField(max_length=200) - dispositivo = models.CharField(max_length=50) + assunto = models.CharField( + max_length=50, + verbose_name=_('Assunto')) + dispositivo = models.CharField( + max_length=200, + null=True, + blank=True, + verbose_name=_('Descrição do Dispositivo Legal')) class Meta: verbose_name = _('Assunto de Matéria') @@ -414,8 +420,14 @@ class DocumentoAcessorio(models.Model): @reversion.register() class MateriaAssunto(models.Model): # TODO M2M ?? - assunto = models.ForeignKey(AssuntoMateria, on_delete=models.PROTECT) - materia = models.ForeignKey(MateriaLegislativa, on_delete=models.PROTECT) + assunto = models.ForeignKey( + AssuntoMateria, + on_delete=models.PROTECT, + verbose_name=_('Assunto')) + materia = models.ForeignKey( + MateriaLegislativa, + on_delete=models.PROTECT, + verbose_name=_('Matéria')) class Meta: verbose_name = _('Relação Matéria - Assunto') diff --git a/sapl/materia/urls.py b/sapl/materia/urls.py index 9f774a3d3..1de8cd689 100644 --- a/sapl/materia/urls.py +++ b/sapl/materia/urls.py @@ -4,11 +4,13 @@ from sapl.materia.views import (AcompanhamentoConfirmarView, AcompanhamentoExcluirView, AcompanhamentoMateriaView, AdicionarVariasAutorias, AnexadaCrud, + AssuntoMateriaCrud, AutoriaCrud, ConfirmarProposicao, CriarProtocoloMateriaView, DespachoInicialCrud, DocumentoAcessorioCrud, DocumentoAcessorioEmLoteView, - LegislacaoCitadaCrud, MateriaLegislativaCrud, + LegislacaoCitadaCrud, MateriaAssuntoCrud, + MateriaLegislativaCrud, MateriaLegislativaPesquisaView, MateriaTaView, NumeracaoCrud, OrgaoCrud, OrigemCrud, PrimeiraTramitacaoEmLoteView, ProposicaoCrud, @@ -31,6 +33,7 @@ urlpatterns_materia = [ AnexadaCrud.get_urls() + AutoriaCrud.get_urls() + DespachoInicialCrud.get_urls() + + MateriaAssuntoCrud.get_urls() + NumeracaoCrud.get_urls() + LegislacaoCitadaCrud.get_urls() + TramitacaoCrud.get_urls() + @@ -97,6 +100,8 @@ urlpatterns_proposicao = [ ] urlpatterns_sistema = [ + url(r'^sistema/assunto-materia', + include(AssuntoMateriaCrud.get_urls())), url(r'^sistema/proposicao/tipo/', include(TipoProposicaoCrud.get_urls())), url(r'^sistema/materia/tipo/', include(TipoMateriaCrud.get_urls())), diff --git a/sapl/materia/views.py b/sapl/materia/views.py index e8331e469..305b4b7b0 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -43,19 +43,24 @@ from sapl.utils import (TURNO_TRAMITACAO_CHOICES, YES_NO_CHOICES, autor_label, from .forms import (AcessorioEmLoteFilterSet, AcompanhamentoMateriaForm, AdicionarVariasAutoriasFilterSet, DespachoInicialForm, - DocumentoAcessorioForm, MateriaLegislativaFilterSet, + DocumentoAcessorioForm, + MateriaAssuntoForm, MateriaLegislativaFilterSet, MateriaSimplificadaForm, PrimeiraTramitacaoEmLoteFilterSet, ReceberProposicaoForm, RelatoriaForm, TramitacaoEmLoteFilterSet, filtra_tramitacao_destino, filtra_tramitacao_destino_and_status, filtra_tramitacao_status) -from .models import (AcompanhamentoMateria, Anexada, Autoria, DespachoInicial, - DocumentoAcessorio, MateriaLegislativa, Numeracao, Orgao, +from .models import (AssuntoMateria, AcompanhamentoMateria, + Anexada, Autoria, DespachoInicial, + DocumentoAcessorio, MateriaLegislativa, + MateriaAssunto, Numeracao, Orgao, Origem, Proposicao, RegimeTramitacao, Relatoria, StatusTramitacao, TipoDocumento, TipoFimRelatoria, TipoMateriaLegislativa, TipoProposicao, Tramitacao, UnidadeTramitacao) +AssuntoMateriaCrud = Crud.build(AssuntoMateria, 'assunto_materia') + OrigemCrud = Crud.build(Origem, '') TipoMateriaCrud = CrudAux.build( @@ -1110,6 +1115,31 @@ class AnexadaCrud(MasterDetailCrud): return 'AnexadaDetail' +class MateriaAssuntoCrud(MasterDetailCrud): + model = MateriaAssunto + parent_field = 'materia' + help_path = '' + public = [RP_LIST, RP_DETAIL] + + class BaseMixin(MasterDetailCrud.BaseMixin): + list_field_names = ['assunto', 'materia'] + + class CreateView(MasterDetailCrud.CreateView): + form_class = MateriaAssuntoForm + + def get_initial(self): + self.initial['materia'] = self.kwargs['pk'] + return self.initial + + class UpdateView(MasterDetailCrud.UpdateView): + form_class = MateriaAssuntoForm + + def get_initial(self): + self.initial['materia'] = self.get_object().materia + self.initial['assunto'] = self.get_object().assunto + return self.initial + + class MateriaLegislativaCrud(Crud): model = MateriaLegislativa help_path = 'materia_legislativa' diff --git a/sapl/norma/migrations/0002_auto_20170403_1505.py b/sapl/norma/migrations/0002_auto_20170403_1505.py new file mode 100644 index 000000000..002aa0e11 --- /dev/null +++ b/sapl/norma/migrations/0002_auto_20170403_1505.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2017-04-03 15:05 +from __future__ import unicode_literals + +from django.db import migrations, models +import sapl.utils + + +class Migration(migrations.Migration): + + dependencies = [ + ('norma', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='normajuridica', + name='texto_integral', + field=models.FileField(blank=True, null=True, upload_to=sapl.utils.texto_upload_path, validators=[sapl.utils.restringe_tipos_de_arquivo_txt], verbose_name='Texto Integral'), + ), + ] diff --git a/sapl/templates/materia/layouts.yaml b/sapl/templates/materia/layouts.yaml index 99b91afa3..6045d61d9 100644 --- a/sapl/templates/materia/layouts.yaml +++ b/sapl/templates/materia/layouts.yaml @@ -36,6 +36,16 @@ MateriaLegislativa: - indexacao - observacao +AssuntoMateria: + {% trans 'Assunto de Matéria Legislativa' %}: + - assunto + - dispositivo + +MateriaAssunto: + {% trans 'Assuntos da Matéria' %}: + - assunto + - materia + Anexada: {% trans 'Matéria Anexada' %}: - tipo numero ano diff --git a/sapl/templates/materia/subnav.yaml b/sapl/templates/materia/subnav.yaml index d59930cc4..c2ea4cd71 100644 --- a/sapl/templates/materia/subnav.yaml +++ b/sapl/templates/materia/subnav.yaml @@ -3,6 +3,8 @@ url: materialegislativa_detail - title: {% trans 'Anexada' %} url: anexada_list +- title: {% trans 'Assunto' %} + url: materiaassunto_list - title: {% trans 'Autoria' %} url: autoria_list - title: {% trans 'Despacho Inicial' %} diff --git a/sapl/templates/sistema.html b/sapl/templates/sistema.html index cc6cddfc0..99b9c7062 100644 --- a/sapl/templates/sistema.html +++ b/sapl/templates/sistema.html @@ -64,6 +64,7 @@
+