From 39101b003ac50086c05755151657417d844709ec Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Fri, 16 Sep 2016 11:15:34 -0300 Subject: [PATCH 1/7] Cria tela de Frente --- sapl/parlamentares/migrations/0025_frente.py | 30 +++++++++++++++++++ .../migrations/0026_auto_20160916_1034.py | 20 +++++++++++++ sapl/parlamentares/models.py | 28 +++++++++++++++++ sapl/parlamentares/urls.py | 11 ++++--- sapl/parlamentares/views.py | 23 +++++++++++++- sapl/templates/parlamentares/layouts.yaml | 7 +++++ 6 files changed, 114 insertions(+), 5 deletions(-) create mode 100644 sapl/parlamentares/migrations/0025_frente.py create mode 100644 sapl/parlamentares/migrations/0026_auto_20160916_1034.py diff --git a/sapl/parlamentares/migrations/0025_frente.py b/sapl/parlamentares/migrations/0025_frente.py new file mode 100644 index 000000000..1ba6cdb15 --- /dev/null +++ b/sapl/parlamentares/migrations/0025_frente.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-09-16 13:25 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('parlamentares', '0024_merge'), + ] + + operations = [ + migrations.CreateModel( + name='Frente', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('nome', models.CharField(max_length=80, verbose_name='Nome da Frente')), + ('data_criacao', models.DateField(verbose_name='Data Criação')), + ('data_extincao', models.DateField(blank=True, verbose_name='Data Dissolução')), + ('descricao', models.TextField(blank=True, verbose_name='Descrição')), + ('parlamentares', models.ManyToManyField(blank=True, to='parlamentares.Parlamentar', verbose_name='Parlamentares')), + ], + options={ + 'verbose_name': 'Frente', + 'verbose_name_plural': 'Frentes', + }, + ), + ] diff --git a/sapl/parlamentares/migrations/0026_auto_20160916_1034.py b/sapl/parlamentares/migrations/0026_auto_20160916_1034.py new file mode 100644 index 000000000..fecddb39a --- /dev/null +++ b/sapl/parlamentares/migrations/0026_auto_20160916_1034.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-09-16 13:34 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('parlamentares', '0025_frente'), + ] + + operations = [ + migrations.AlterField( + model_name='frente', + name='data_extincao', + field=models.DateField(blank=True, null=True, verbose_name='Data Dissolução'), + ), + ] diff --git a/sapl/parlamentares/models.py b/sapl/parlamentares/models.py index 735fc447f..67039a107 100644 --- a/sapl/parlamentares/models.py +++ b/sapl/parlamentares/models.py @@ -409,3 +409,31 @@ class ComposicaoMesa(models.Model): return _('%(parlamentar)s - %(cargo)s') % { 'parlamentar': self.parlamentar, 'cargo': self.cargo } + + +class Frente(models.Model): + ''' + * Uma frente agrupa vários parlamentares + * Cada parlamentar pode fazer parte de uma ou mais frentes + * Uma frente pode existir por mais de uma legislatura? + ''' + nome = models.CharField( + max_length=80, + verbose_name=_('Nome da Frente')) + parlamentares = models.ManyToManyField(Parlamentar, + blank=True, + verbose_name=_('Parlamentares')) + data_criacao = models.DateField(verbose_name=_('Data Criação')) + data_extincao = models.DateField( + blank=True, null=True, verbose_name=_('Data Dissolução')) + descricao = models.TextField(blank=True, verbose_name=_('Descrição')) + + class Meta: + verbose_name = _('Frente') + verbose_name_plural = _('Frentes') + + def get_parlamentares(self): + return Parlamentar.objects.filter(ativo=True) + + def __str__(self): + return self.nome diff --git a/sapl/parlamentares/urls.py b/sapl/parlamentares/urls.py index 09bc8bf3f..26304d3d8 100644 --- a/sapl/parlamentares/urls.py +++ b/sapl/parlamentares/urls.py @@ -2,9 +2,10 @@ from django.conf.urls import include, url from sapl.parlamentares.views import (CargoMesaCrud, ColigacaoCrud, ComposicaoColigacaoCrud, DependenteCrud, - FiliacaoCrud, LegislaturaCrud, - MandatoCrud, MesaDiretoraView, - NivelInstrucaoCrud, ParlamentarCrud, + FiliacaoCrud, FrenteCrud, + LegislaturaCrud, MandatoCrud, + MesaDiretoraView, NivelInstrucaoCrud, + ParlamentarCrud, ParticipacaoParlamentarCrud, PartidoCrud, ProposicaoParlamentarCrud, RelatoriaParlamentarCrud, @@ -24,10 +25,12 @@ urlpatterns = [ ProposicaoParlamentarCrud.get_urls() + RelatoriaParlamentarCrud.get_urls() )), + url(r'^sistema/coligacao/', include(ColigacaoCrud.get_urls() + ComposicaoColigacaoCrud.get_urls())), - + url(r'^sistema/frente/', + include(FrenteCrud.get_urls())), url(r'^sistema/parlamentar/legislatura/', include(LegislaturaCrud.get_urls())), url(r'^sistema/parlamentar/tipo-dependente/', diff --git a/sapl/parlamentares/views.py b/sapl/parlamentares/views.py index fda746e0e..93f95e46c 100644 --- a/sapl/parlamentares/views.py +++ b/sapl/parlamentares/views.py @@ -20,11 +20,32 @@ from sapl.utils import permissao_tb_aux, permissoes_parlamentares from .forms import (ComposicaoColigacaoForm, FiliacaoForm, LegislaturaForm, ParlamentarCreateForm, ParlamentarForm) from .models import (CargoMesa, Coligacao, ComposicaoColigacao, ComposicaoMesa, - Dependente, Filiacao, Legislatura, Mandato, + Dependente, Filiacao, Frente, Legislatura, Mandato, NivelInstrucao, Parlamentar, Partido, SessaoLegislativa, SituacaoMilitar, TipoAfastamento, TipoDependente) +class FrenteCrud(Crud): + model = Frente + help_path = '' + + class CreateView(PermissionRequiredMixin, CrudCreateView): + permission_required = permissoes_parlamentares() + + # def get_initial(self): + # return {'parlamentares': Parlamentar.objects.filter(ativo=True)} + + # class UpdateView(PermissionRequiredMixin, CrudUpdateView): + # permission_required = permissoes_parlamentares() + # + # def get_initial(self): + # initial = self.initial.copy() + # if self.object.materia: + # initial['parlamentares'] = Parlamentar.object.filter( + # ativo=True) + # return initial + + class RelatoriaParlamentarCrud(MasterDetailCrud): model = Relatoria parent_field = 'parlamentar' diff --git a/sapl/templates/parlamentares/layouts.yaml b/sapl/templates/parlamentares/layouts.yaml index 24a0aab86..f455a593e 100644 --- a/sapl/templates/parlamentares/layouts.yaml +++ b/sapl/templates/parlamentares/layouts.yaml @@ -91,3 +91,10 @@ SituacaoMilitar: ComposicaoColigacao: {% trans 'Nome do Partido' %}: - partido + +Frente: + {% trans 'Frente' %}: + - nome + - data_criacao data_extincao + - parlamentares + - descricao From 4912f7d320967b668012ace39412fe417f5ab11d Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Fri, 16 Sep 2016 12:05:54 -0300 Subject: [PATCH 2/7] Filtra parlamentares por ativo e adiciona link de frente em sistema --- sapl/parlamentares/forms.py | 16 ++++++++++++-- sapl/parlamentares/migrations/0027_merge.py | 16 ++++++++++++++ sapl/parlamentares/views.py | 24 +++++++++------------ sapl/templates/sistema.html | 13 ++++++++++- 4 files changed, 52 insertions(+), 17 deletions(-) create mode 100644 sapl/parlamentares/migrations/0027_merge.py diff --git a/sapl/parlamentares/forms.py b/sapl/parlamentares/forms.py index fe21aeb2c..f618c4421 100644 --- a/sapl/parlamentares/forms.py +++ b/sapl/parlamentares/forms.py @@ -8,8 +8,8 @@ from django.forms import ModelForm from django.utils.translation import ugettext_lazy as _ from floppyforms.widgets import ClearableFileInput -from .models import (ComposicaoColigacao, Filiacao, Legislatura, Mandato, - Parlamentar) +from .models import (ComposicaoColigacao, Filiacao, Frente, Legislatura, + Mandato, Parlamentar) class ImageThumbnailFileInput(ClearableFileInput): @@ -175,3 +175,15 @@ class ComposicaoColigacaoForm(ModelForm): if self.errors: return self.errors return self.cleaned_data + + +class FrenteForm(ModelForm): + + def __init__(self, *args, **kwargs): + super(FrenteForm, self).__init__(*args, **kwargs) + self.fields['parlamentares'].queryset = Parlamentar.objects.filter( + ativo=True).order_by('nome_completo') + + class Meta: + model = Frente + fields = '__all__' diff --git a/sapl/parlamentares/migrations/0027_merge.py b/sapl/parlamentares/migrations/0027_merge.py new file mode 100644 index 000000000..f71a6160b --- /dev/null +++ b/sapl/parlamentares/migrations/0027_merge.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-09-16 14:44 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('parlamentares', '0026_auto_20160916_1034'), + ('parlamentares', '0025_auto_20160916_1030'), + ] + + operations = [ + ] diff --git a/sapl/parlamentares/views.py b/sapl/parlamentares/views.py index 93f95e46c..11e0bb481 100644 --- a/sapl/parlamentares/views.py +++ b/sapl/parlamentares/views.py @@ -17,8 +17,8 @@ from sapl.crud.masterdetail import MasterDetailCrud from sapl.materia.models import Proposicao, Relatoria from sapl.utils import permissao_tb_aux, permissoes_parlamentares -from .forms import (ComposicaoColigacaoForm, FiliacaoForm, LegislaturaForm, - ParlamentarCreateForm, ParlamentarForm) +from .forms import (ComposicaoColigacaoForm, FiliacaoForm, FrenteForm, + LegislaturaForm, ParlamentarCreateForm, ParlamentarForm) from .models import (CargoMesa, Coligacao, ComposicaoColigacao, ComposicaoMesa, Dependente, Filiacao, Frente, Legislatura, Mandato, NivelInstrucao, Parlamentar, Partido, SessaoLegislativa, @@ -29,21 +29,17 @@ class FrenteCrud(Crud): model = Frente help_path = '' + class BaseMixin(CrudBaseMixin): + permission_required = permissoes_parlamentares() + list_field_names = ['nome', 'data_criacao', 'parlamentares'] + class CreateView(PermissionRequiredMixin, CrudCreateView): permission_required = permissoes_parlamentares() + form_class = FrenteForm - # def get_initial(self): - # return {'parlamentares': Parlamentar.objects.filter(ativo=True)} - - # class UpdateView(PermissionRequiredMixin, CrudUpdateView): - # permission_required = permissoes_parlamentares() - # - # def get_initial(self): - # initial = self.initial.copy() - # if self.object.materia: - # initial['parlamentares'] = Parlamentar.object.filter( - # ativo=True) - # return initial + class UpdateView(PermissionRequiredMixin, CrudUpdateView): + permission_required = permissoes_parlamentares() + form_class = FrenteForm class RelatoriaParlamentarCrud(MasterDetailCrud): diff --git a/sapl/templates/sistema.html b/sapl/templates/sistema.html index cc28d831d..3ea597111 100644 --- a/sapl/templates/sistema.html +++ b/sapl/templates/sistema.html @@ -7,6 +7,7 @@ +

Módulo Parlamentares

@@ -18,12 +19,14 @@
+

Módulo Mesa Diretora

+

Módulo Comissões

+

Módulo Bancadas

+

Módulo Proposições

+

Módulo Matéria Legislativa

@@ -57,12 +64,14 @@
+

Módulo Normas Jurídicas

+

Módulo Sessão Plenária

+

Módulo LexML

+

Módulo Administrativo

From 6e92bbceb441ada8a37698804b7517353f6c0e05 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Fri, 16 Sep 2016 12:13:59 -0300 Subject: [PATCH 3/7] Adiciona listagem das frentes que parlamentar participa --- sapl/parlamentares/forms.py | 2 ++ sapl/parlamentares/urls.py | 8 ++++---- sapl/parlamentares/views.py | 6 ++++++ sapl/templates/parlamentares/subnav.yaml | 2 ++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/sapl/parlamentares/forms.py b/sapl/parlamentares/forms.py index f618c4421..20350ef07 100644 --- a/sapl/parlamentares/forms.py +++ b/sapl/parlamentares/forms.py @@ -183,6 +183,8 @@ class FrenteForm(ModelForm): super(FrenteForm, self).__init__(*args, **kwargs) self.fields['parlamentares'].queryset = Parlamentar.objects.filter( ativo=True).order_by('nome_completo') + self.fields['parlamentares'].label = _('Parlamentares \ + (Mantenha CTRL pressionado para selecionar vários)') class Meta: model = Frente diff --git a/sapl/parlamentares/urls.py b/sapl/parlamentares/urls.py index 26304d3d8..34fb8b0fe 100644 --- a/sapl/parlamentares/urls.py +++ b/sapl/parlamentares/urls.py @@ -3,9 +3,9 @@ from django.conf.urls import include, url from sapl.parlamentares.views import (CargoMesaCrud, ColigacaoCrud, ComposicaoColigacaoCrud, DependenteCrud, FiliacaoCrud, FrenteCrud, - LegislaturaCrud, MandatoCrud, - MesaDiretoraView, NivelInstrucaoCrud, - ParlamentarCrud, + FrenteParlamentarCrud, LegislaturaCrud, + MandatoCrud, MesaDiretoraView, + NivelInstrucaoCrud, ParlamentarCrud, ParticipacaoParlamentarCrud, PartidoCrud, ProposicaoParlamentarCrud, RelatoriaParlamentarCrud, @@ -23,7 +23,7 @@ urlpatterns = [ FiliacaoCrud.get_urls() + MandatoCrud.get_urls() + ParticipacaoParlamentarCrud.get_urls() + ProposicaoParlamentarCrud.get_urls() + - RelatoriaParlamentarCrud.get_urls() + RelatoriaParlamentarCrud.get_urls() + FrenteParlamentarCrud.get_urls() )), url(r'^sistema/coligacao/', diff --git a/sapl/parlamentares/views.py b/sapl/parlamentares/views.py index 11e0bb481..c856e6a03 100644 --- a/sapl/parlamentares/views.py +++ b/sapl/parlamentares/views.py @@ -25,6 +25,12 @@ from .models import (CargoMesa, Coligacao, ComposicaoColigacao, ComposicaoMesa, SituacaoMilitar, TipoAfastamento, TipoDependente) +class FrenteParlamentarCrud(MasterDetailCrud): + model = Frente + parent_field = 'parlamentares' + help_path = '' + + class FrenteCrud(Crud): model = Frente help_path = '' diff --git a/sapl/templates/parlamentares/subnav.yaml b/sapl/templates/parlamentares/subnav.yaml index 286e0fc9d..eeccf4533 100644 --- a/sapl/templates/parlamentares/subnav.yaml +++ b/sapl/templates/parlamentares/subnav.yaml @@ -13,3 +13,5 @@ url: proposicao_list - title: {% trans 'Relatorias' %} url: relatoria_list +- title: {% trans 'Frentes' %} + url: frente_list From 5c114c33d1c972b99dc9158cd8a06c8914fe292f Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Fri, 16 Sep 2016 12:41:56 -0300 Subject: [PATCH 4/7] =?UTF-8?q?Cria=20m=C3=A9todo=20separado=20para=20list?= =?UTF-8?q?agem=20de=20frentes=20no=20parlamentar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/parlamentares/urls.py | 13 ++++++++----- sapl/parlamentares/views.py | 21 ++++++++++++++------- sapl/templates/parlamentares/frentes.html | 21 +++++++++++++++++++++ sapl/templates/parlamentares/subnav.yaml | 2 +- 4 files changed, 44 insertions(+), 13 deletions(-) create mode 100644 sapl/templates/parlamentares/frentes.html diff --git a/sapl/parlamentares/urls.py b/sapl/parlamentares/urls.py index 34fb8b0fe..70af2200a 100644 --- a/sapl/parlamentares/urls.py +++ b/sapl/parlamentares/urls.py @@ -2,10 +2,10 @@ from django.conf.urls import include, url from sapl.parlamentares.views import (CargoMesaCrud, ColigacaoCrud, ComposicaoColigacaoCrud, DependenteCrud, - FiliacaoCrud, FrenteCrud, - FrenteParlamentarCrud, LegislaturaCrud, - MandatoCrud, MesaDiretoraView, - NivelInstrucaoCrud, ParlamentarCrud, + FiliacaoCrud, FrenteCrud, FrenteList, + LegislaturaCrud, MandatoCrud, + MesaDiretoraView, NivelInstrucaoCrud, + ParlamentarCrud, ParticipacaoParlamentarCrud, PartidoCrud, ProposicaoParlamentarCrud, RelatoriaParlamentarCrud, @@ -23,9 +23,12 @@ urlpatterns = [ FiliacaoCrud.get_urls() + MandatoCrud.get_urls() + ParticipacaoParlamentarCrud.get_urls() + ProposicaoParlamentarCrud.get_urls() + - RelatoriaParlamentarCrud.get_urls() + FrenteParlamentarCrud.get_urls() + RelatoriaParlamentarCrud.get_urls() )), + url(r'^parlamentar/(?P\d+)/frente$', + FrenteList.as_view(), name="frent_list"), + url(r'^sistema/coligacao/', include(ColigacaoCrud.get_urls() + ComposicaoColigacaoCrud.get_urls())), diff --git a/sapl/parlamentares/views.py b/sapl/parlamentares/views.py index c856e6a03..440fa98da 100644 --- a/sapl/parlamentares/views.py +++ b/sapl/parlamentares/views.py @@ -7,7 +7,7 @@ from django.core.urlresolvers import reverse, reverse_lazy from django.shortcuts import redirect from django.utils.datastructures import MultiValueDictKeyError from django.utils.translation import ugettext_lazy as _ -from django.views.generic import FormView +from django.views.generic import FormView, ListView from sapl.comissoes.models import Participacao from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView, @@ -25,10 +25,17 @@ from .models import (CargoMesa, Coligacao, ComposicaoColigacao, ComposicaoMesa, SituacaoMilitar, TipoAfastamento, TipoDependente) -class FrenteParlamentarCrud(MasterDetailCrud): +class FrenteList(ListView): model = Frente - parent_field = 'parlamentares' - help_path = '' + paginate_by = 10 + template_name = 'parlamentares/frentes.html' + + def get_queryset(self): + return Frente.objects.filter(parlamentares__in=[self.kwargs['pk']]) + + def get_context_data(self, **kwargs): + return {'root_pk': self.kwargs['pk'], + 'object_list': self.get_queryset()} class FrenteCrud(Crud): @@ -36,15 +43,15 @@ class FrenteCrud(Crud): help_path = '' class BaseMixin(CrudBaseMixin): - permission_required = permissoes_parlamentares() list_field_names = ['nome', 'data_criacao', 'parlamentares'] + def has_permission(self): + return permissao_tb_aux(self) + class CreateView(PermissionRequiredMixin, CrudCreateView): - permission_required = permissoes_parlamentares() form_class = FrenteForm class UpdateView(PermissionRequiredMixin, CrudUpdateView): - permission_required = permissoes_parlamentares() form_class = FrenteForm diff --git a/sapl/templates/parlamentares/frentes.html b/sapl/templates/parlamentares/frentes.html new file mode 100644 index 000000000..5a7ae3f9e --- /dev/null +++ b/sapl/templates/parlamentares/frentes.html @@ -0,0 +1,21 @@ +{% extends "crud/list.html" %} +{% load i18n %} +{% load crispy_forms_tags %} + +{% block base_content %} + {% if object_list|length == 0 %} +

Nenhuma frente encontrada.

+ {% else %} + + + + + + {% for frente in object_list %} + + {% endfor %} + +
Frentes
{{ frente.nome }}
+ {% endif %} + {% include "paginacao.html" %} +{% endblock %} diff --git a/sapl/templates/parlamentares/subnav.yaml b/sapl/templates/parlamentares/subnav.yaml index eeccf4533..986ab377d 100644 --- a/sapl/templates/parlamentares/subnav.yaml +++ b/sapl/templates/parlamentares/subnav.yaml @@ -14,4 +14,4 @@ - title: {% trans 'Relatorias' %} url: relatoria_list - title: {% trans 'Frentes' %} - url: frente_list + url: From d348ca069921503550668e8214a7f363062d6620 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Fri, 16 Sep 2016 12:52:40 -0300 Subject: [PATCH 5/7] Conserta url para frente de parlamentares --- sapl/parlamentares/views.py | 6 ++++-- sapl/templates/parlamentares/subnav.yaml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sapl/parlamentares/views.py b/sapl/parlamentares/views.py index 440fa98da..0fabc8361 100644 --- a/sapl/parlamentares/views.py +++ b/sapl/parlamentares/views.py @@ -34,8 +34,10 @@ class FrenteList(ListView): return Frente.objects.filter(parlamentares__in=[self.kwargs['pk']]) def get_context_data(self, **kwargs): - return {'root_pk': self.kwargs['pk'], - 'object_list': self.get_queryset()} + context = super(FrenteList, self).get_context_data(**kwargs) + context['root_pk'] = self.kwargs['pk'] + context['object_list'] = self.get_queryset() + return context class FrenteCrud(Crud): diff --git a/sapl/templates/parlamentares/subnav.yaml b/sapl/templates/parlamentares/subnav.yaml index 986ab377d..6463640d8 100644 --- a/sapl/templates/parlamentares/subnav.yaml +++ b/sapl/templates/parlamentares/subnav.yaml @@ -14,4 +14,4 @@ - title: {% trans 'Relatorias' %} url: relatoria_list - title: {% trans 'Frentes' %} - url: + url: frent_list From 5c884e1345fd41de3c122b399d299fcc9c1d97e0 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Mon, 19 Sep 2016 09:03:41 -0300 Subject: [PATCH 6/7] Cria model Bloco --- sapl/sessao/migrations/0024_bloco.py | 30 ++++++++++++++++++++++++++++ sapl/sessao/models.py | 22 ++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 sapl/sessao/migrations/0024_bloco.py diff --git a/sapl/sessao/migrations/0024_bloco.py b/sapl/sessao/migrations/0024_bloco.py new file mode 100644 index 000000000..5af326429 --- /dev/null +++ b/sapl/sessao/migrations/0024_bloco.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-09-19 12:03 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('sessao', '0023_auto_20160915_1405'), + ] + + operations = [ + migrations.CreateModel( + name='Bloco', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('nome', models.CharField(max_length=80, verbose_name='Nome do Bloco')), + ('data_criacao', models.DateField(blank=True, null=True, verbose_name='Data Criação')), + ('data_extincao', models.DateField(blank=True, null=True, verbose_name='Data Dissolução')), + ('descricao', models.TextField(blank=True, verbose_name='Descrição')), + ('bancadas', models.ManyToManyField(blank=True, to='sessao.Bancada', verbose_name='Bancadas')), + ], + options={ + 'verbose_name_plural': 'Blocos', + 'verbose_name': 'Bloco', + }, + ), + ] diff --git a/sapl/sessao/models.py b/sapl/sessao/models.py index 6cfc4f06e..8f29bc99d 100644 --- a/sapl/sessao/models.py +++ b/sapl/sessao/models.py @@ -321,3 +321,25 @@ class SessaoPlenariaPresenca(models.Model): verbose_name = _('Presença em Sessão Plenária') verbose_name_plural = _('Presenças em Sessões Plenárias') ordering = ['parlamentar__nome_parlamentar'] + + +class Bloco(models.Model): + ''' + * blocos podem existir por mais de uma legislatura + ''' + nome = models.CharField( + max_length=80, verbose_name=_('Nome do Bloco')) + bancadas = models.ManyToManyField( + Bancada, blank=True, verbose_name=_('Bancadas')) + data_criacao = models.DateField( + blank=True, null=True, verbose_name=_('Data Criação')) + data_extincao = models.DateField( + blank=True, null=True, verbose_name=_('Data Dissolução')) + descricao = models.TextField(blank=True, verbose_name=_('Descrição')) + + class Meta: + verbose_name = _('Bloco') + verbose_name_plural = _('Blocos') + + def __str__(self): + return self.nome From 26141274a881b0c48cc96867e4ac433a34165d1b Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Mon, 19 Sep 2016 09:11:59 -0300 Subject: [PATCH 7/7] Cria view para Bloco --- sapl/sessao/urls.py | 9 ++++++--- sapl/sessao/views.py | 23 +++++++++++++++++------ sapl/templates/sessao/layouts.yaml | 7 +++++++ sapl/templates/sistema.html | 3 ++- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/sapl/sessao/urls.py b/sapl/sessao/urls.py index 0c1a5c424..16231d881 100644 --- a/sapl/sessao/urls.py +++ b/sapl/sessao/urls.py @@ -2,9 +2,10 @@ from django.conf.urls import include, url from sapl.sessao.views import (AdicionarVariasMateriasExpediente, AdicionarVariasMateriasOrdemDia, BancadaCrud, - CargoBancadaCrud, ExpedienteMateriaCrud, - ExpedienteView, MateriaOrdemDiaCrud, MesaView, - OradorCrud, OradorExpedienteCrud, PainelView, + BlocoCrud, CargoBancadaCrud, + ExpedienteMateriaCrud, ExpedienteView, + MateriaOrdemDiaCrud, MesaView, OradorCrud, + OradorExpedienteCrud, PainelView, PautaExpedienteDetail, PautaOrdemDetail, PautaSessaoDetailView, PautaSessaoListView, PesquisarSessaoPlenariaView, @@ -55,6 +56,8 @@ urlpatterns = [ include(TipoExpedienteCrud.get_urls())), url(r'^sistema/bancada/', include(BancadaCrud.get_urls())), + url(r'^sistema/bloco/', + include(BlocoCrud.get_urls())), url(r'^sistema/cargo-bancada/', include(CargoBancadaCrud.get_urls())), url(r'^sessao/(?P\d+)/adicionar-varias-materias-expediente/', diff --git a/sapl/sessao/views.py b/sapl/sessao/views.py index d4f06f615..b51000a2e 100644 --- a/sapl/sessao/views.py +++ b/sapl/sessao/views.py @@ -32,12 +32,12 @@ from .forms import (AdicionarVariasMateriasFilterSet, BancadaForm, MesaForm, OrdemDiaForm, PresencaForm, SessaoPlenariaFilterSet, VotacaoEditForm, VotacaoForm, VotacaoNominalForm) -from .models import (Bancada, CargoBancada, CargoMesa, ExpedienteMateria, - ExpedienteSessao, IntegranteMesa, MateriaLegislativa, - Orador, OradorExpediente, OrdemDia, PresencaOrdemDia, - RegistroVotacao, SessaoPlenaria, SessaoPlenariaPresenca, - TipoExpediente, TipoResultadoVotacao, TipoSessaoPlenaria, - VotoParlamentar) +from .models import (Bancada, Bloco, CargoBancada, CargoMesa, + ExpedienteMateria, ExpedienteSessao, IntegranteMesa, + MateriaLegislativa, Orador, OradorExpediente, OrdemDia, + PresencaOrdemDia, RegistroVotacao, SessaoPlenaria, + SessaoPlenariaPresenca, TipoExpediente, + TipoResultadoVotacao, TipoSessaoPlenaria, VotoParlamentar) OrdemDiaCrud = Crud.build(OrdemDia, '') RegistroVotacaoCrud = Crud.build(RegistroVotacao, '') @@ -69,6 +69,17 @@ def reordernar_materias_ordem(request, pk): reverse('sapl.sessao:ordemdia_list', kwargs={'pk': pk})) +class BlocoCrud(Crud): + model = Bloco + help_path = '' + + class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): + list_field_names = ['nome', 'data_criacao', 'bancadas'] + + def has_permission(self): + return permissao_tb_aux(self) + + class BancadaCrud(Crud): model = Bancada help_path = '' diff --git a/sapl/templates/sessao/layouts.yaml b/sapl/templates/sessao/layouts.yaml index a99e224f8..b92333de1 100644 --- a/sapl/templates/sessao/layouts.yaml +++ b/sapl/templates/sessao/layouts.yaml @@ -70,3 +70,10 @@ Bancada: CargoBancada: {% trans 'Cargo de Bancada' %}: - nome_cargo:8 cargo_unico + +Bloco: + {% trans 'Bloco' %}: + - nome + - data_criacao data_extincao + - bancadas + - descricao diff --git a/sapl/templates/sistema.html b/sapl/templates/sistema.html index 3ea597111..e625d3a9e 100644 --- a/sapl/templates/sistema.html +++ b/sapl/templates/sistema.html @@ -40,7 +40,8 @@