diff --git a/parlamentares/migrations/0019_auto_20160518_1204.py b/parlamentares/migrations/0019_auto_20160518_1204.py new file mode 100644 index 000000000..573a5a3ab --- /dev/null +++ b/parlamentares/migrations/0019_auto_20160518_1204.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.5 on 2016-05-18 15:04 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('parlamentares', '0018_auto_20160510_0943'), + ] + + operations = [ + migrations.AlterModelOptions( + name='legislatura', + options={'ordering': ['-data_inicio'], 'verbose_name': 'Legislatura', 'verbose_name_plural': 'Legislaturas'}, + ), + ] diff --git a/parlamentares/models.py b/parlamentares/models.py index e19670871..b0a2cfc55 100644 --- a/parlamentares/models.py +++ b/parlamentares/models.py @@ -14,6 +14,7 @@ class Legislatura(models.Model): data_eleicao = models.DateField(verbose_name=_('Data Eleição')) class Meta: + ordering = ['-data_inicio'] verbose_name = _('Legislatura') verbose_name_plural = _('Legislaturas') diff --git a/protocoloadm/views.py b/protocoloadm/views.py index 5f874ef78..19e67e9ba 100644 --- a/protocoloadm/views.py +++ b/protocoloadm/views.py @@ -4,7 +4,7 @@ from datetime import date, datetime from braces.views import FormValidMessageMixin from django.core.exceptions import ObjectDoesNotExist from django.core.urlresolvers import reverse -from django.db.models import Max, Q +from django.db.models import Q, Max from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import redirect from django.utils.translation import ugettext_lazy as _ diff --git a/sessao/forms.py b/sessao/forms.py index 64af5caaf..cfca3975a 100644 --- a/sessao/forms.py +++ b/sessao/forms.py @@ -13,7 +13,7 @@ from crispy_layout_mixin import form_actions from materia.models import MateriaLegislativa, TipoMateriaLegislativa from sapl.utils import RANGE_DIAS_MES, RANGE_MESES -from .models import ExpedienteMateria, SessaoPlenaria +from .models import Bancada, ExpedienteMateria, SessaoPlenaria def pega_anos(): @@ -29,6 +29,22 @@ MES_CHOICES = [('', '---------')] + RANGE_MESES DIA_CHOICES = [('', '---------')] + RANGE_DIAS_MES +class BancadaForm(ModelForm): + + class Meta: + model = Bancada + fields = ['legislatura', 'nome', 'partido', 'data_criacao', + 'data_extincao', 'descricao'] + + def clean(self): + if self.cleaned_data['data_extincao']: + if (self.cleaned_data['data_extincao'] < + self.cleaned_data['data_criacao']): + msg = _('Data de extinção não pode ser menor que a de criação') + raise ValidationError(msg) + return self.cleaned_data + + class ExpedienteMateriaForm(ModelForm): tipo_materia = forms.ModelChoiceField( diff --git a/sessao/layouts.yaml b/sessao/layouts.yaml index 117be72f7..63529bf46 100644 --- a/sessao/layouts.yaml +++ b/sessao/layouts.yaml @@ -60,3 +60,14 @@ ExpedienteMateriaDetail: - materia - tipo_votacao - observacao + +Bancada: + Bancada: + - legislatura + - nome partido + - data_criacao data_extincao + - descricao + +CargoBancada: + Cargo de Bancada: + - nome_cargo:8 cargo_unico diff --git a/sessao/migrations/0017_bancada.py b/sessao/migrations/0017_bancada.py new file mode 100644 index 000000000..25770a220 --- /dev/null +++ b/sessao/migrations/0017_bancada.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.5 on 2016-05-17 17:26 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('parlamentares', '0018_auto_20160510_0943'), + ('sessao', '0016_auto_20160404_1409'), + ] + + operations = [ + migrations.CreateModel( + name='Bancada', + 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 Bancada, Bloco, Frente ou Grupo')), + ('data_criacao', models.DateField(blank=True, verbose_name='Data Criação')), + ('data_extincao', models.DateField(blank=True, verbose_name='Data Extinção')), + ('descricao', models.TextField(blank=True, verbose_name='Descrição')), + ('legislatura', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='parlamentares.Legislatura', verbose_name='Legislatura')), + ('partido', models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, to='parlamentares.Partido', verbose_name='Partido')), + ], + options={ + 'verbose_name_plural': 'Bancadas', + 'verbose_name': 'Bancada', + }, + ), + ] diff --git a/sessao/migrations/0018_auto_20160517_1435.py b/sessao/migrations/0018_auto_20160517_1435.py new file mode 100644 index 000000000..849ccad31 --- /dev/null +++ b/sessao/migrations/0018_auto_20160517_1435.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.5 on 2016-05-17 17:35 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('sessao', '0017_bancada'), + ] + + operations = [ + migrations.AlterField( + model_name='bancada', + name='data_criacao', + field=models.DateField(blank=True, null=True, verbose_name='Data Criação'), + ), + migrations.AlterField( + model_name='bancada', + name='data_extincao', + field=models.DateField(blank=True, null=True, verbose_name='Data Extinção'), + ), + migrations.AlterField( + model_name='bancada', + name='partido', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='parlamentares.Partido', verbose_name='Partido'), + ), + ] diff --git a/sessao/migrations/0019_cargobancada.py b/sessao/migrations/0019_cargobancada.py new file mode 100644 index 000000000..44a4db58a --- /dev/null +++ b/sessao/migrations/0019_cargobancada.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.5 on 2016-05-17 17:42 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('sessao', '0018_auto_20160517_1435'), + ] + + operations = [ + migrations.CreateModel( + name='CargoBancada', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('nome_cargo', models.CharField(max_length=80, verbose_name='Cargo de Bancada')), + ('cargo_unico', models.NullBooleanField(choices=[(True, 'Sim'), (False, 'Não')], verbose_name='Cargo Único')), + ], + options={ + 'verbose_name_plural': 'Cargos de Bancada', + 'verbose_name': 'Cargo de Bancada', + }, + ), + ] diff --git a/sessao/migrations/0020_auto_20160517_1450.py b/sessao/migrations/0020_auto_20160517_1450.py new file mode 100644 index 000000000..85004c22f --- /dev/null +++ b/sessao/migrations/0020_auto_20160517_1450.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.5 on 2016-05-17 17:50 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('sessao', '0019_cargobancada'), + ] + + operations = [ + migrations.AlterField( + model_name='cargobancada', + name='cargo_unico', + field=models.CharField(choices=[(True, 'Sim'), (False, 'Não')], default=False, max_length=10, verbose_name='Cargo Único'), + ), + ] diff --git a/sessao/models.py b/sessao/models.py index 6e7e2e86f..249956355 100644 --- a/sessao/models.py +++ b/sessao/models.py @@ -3,11 +3,49 @@ from django.utils.translation import ugettext_lazy as _ from model_utils import Choices from materia.models import MateriaLegislativa -from parlamentares.models import (CargoMesa, Legislatura, Parlamentar, +from parlamentares.models import (CargoMesa, Legislatura, Parlamentar, Partido, SessaoLegislativa) from sapl.utils import YES_NO_CHOICES, restringe_tipos_de_arquivo_txt +class CargoBancada(models.Model): + nome_cargo = models.CharField(max_length=80, + verbose_name=_('Cargo de Bancada')) + cargo_unico = models.CharField( + max_length=10, + verbose_name=_('Cargo Único'), + choices=YES_NO_CHOICES, + default=False) + + class Meta: + verbose_name = _('Cargo de Bancada') + verbose_name_plural = _('Cargos de Bancada') + + def __str__(self): + return self.nome_cargo + + +class Bancada(models.Model): + legislatura = models.ForeignKey(Legislatura, verbose_name=_('Legislatura')) + nome = models.CharField( + max_length=80, + verbose_name=_('Nome da Bancada, Bloco, Frente ou Grupo')) + partido = models.ForeignKey(Partido, blank=True, null=True, + verbose_name=_('Partido')) + data_criacao = models.DateField(blank=True, null=True, + verbose_name=_('Data Criação')) + data_extincao = models.DateField(blank=True, null=True, + verbose_name=_('Data Extinção')) + descricao = models.TextField(blank=True, verbose_name=_('Descrição')) + + class Meta: + verbose_name = _('Bancada') + verbose_name_plural = _('Bancadas') + + def __str__(self): + return self.nome + + class TipoSessaoPlenaria(models.Model): nome = models.CharField(max_length=30, verbose_name=_('Tipo')) quorum_minimo = models.PositiveIntegerField( diff --git a/sessao/urls.py b/sessao/urls.py index 222837042..d075a7e13 100644 --- a/sessao/urls.py +++ b/sessao/urls.py @@ -2,7 +2,8 @@ from django.conf.urls import include, url from django.views.static import serve from sapl import settings -from sessao.views import (EditMateriaOrdemDiaView, ExpedienteMateriaCrud, +from sessao.views import (BancadaCrud, CargoBancadaCrud, + EditMateriaOrdemDiaView, ExpedienteMateriaCrud, ExpedienteView, ListMateriaOrdemDiaView, MateriaOrdemDiaView, MesaView, OradorCrud, OradorExpedienteCrud, PainelView, @@ -45,6 +46,10 @@ urlpatterns = [ include(TipoResultadoVotacaoCrud.get_urls())), url(r'^sistema/sessao-plenaria/tipo-expediente/', include(TipoExpedienteCrud.get_urls())), + url(r'^sistema/bancada/', + include(BancadaCrud.get_urls())), + url(r'^sistema/cargo-bancada/', + include(CargoBancadaCrud.get_urls())), # PAUTA SESSÃO url(r'^pauta-sessao$', diff --git a/sessao/views.py b/sessao/views.py index cd91ca171..680d72369 100644 --- a/sessao/views.py +++ b/sessao/views.py @@ -23,13 +23,13 @@ from norma.models import NormaJuridica from parlamentares.models import Parlamentar from sessao.serializers import SessaoPlenariaSerializer -from .forms import (ExpedienteForm, ExpedienteMateriaForm, ListMateriaForm, - MateriaOrdemDiaForm, MesaForm, PresencaForm, - SessaoPlenariaFilterSet, VotacaoEditForm, VotacaoForm, - VotacaoNominalForm) -from .models import (CargoMesa, ExpedienteMateria, ExpedienteSessao, - IntegranteMesa, MateriaLegislativa, Orador, - OradorExpediente, OrdemDia, PresencaOrdemDia, +from .forms import (BancadaForm, ExpedienteForm, ExpedienteMateriaForm, + ListMateriaForm, MateriaOrdemDiaForm, MesaForm, + 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) @@ -40,6 +40,7 @@ TipoResultadoVotacaoCrud = Crud.build( TipoResultadoVotacao, 'tipo_resultado_votacao') TipoExpedienteCrud = Crud.build(TipoExpediente, 'tipo_expediente') RegistroVotacaoCrud = Crud.build(RegistroVotacao, '') +CargoBancadaCrud = Crud.build(CargoBancada, '') def reordernar_materias_expediente(request, pk): @@ -55,6 +56,23 @@ def reordernar_materias_expediente(request, pk): reverse('sessao:expedientemateria_list', kwargs={'pk': pk})) +class BancadaCrud(Crud): + model = Bancada + help_path = '' + + class BaseMixin(crud.base.CrudBaseMixin): + list_field_names = ['nome', 'legislatura'] + + class ListView(crud.base.CrudListView): + ordering = 'legislatura' + + class CreateView(crud.base.CrudCreateView): + form_class = BancadaForm + + class UpdateView(crud.base.CrudUpdateView): + form_class = BancadaForm + + def abrir_votacao_view(request, pk, spk): existe_votacao_aberta = ExpedienteMateria.objects.filter( sessao_plenaria_id=spk, votacao_aberta=True diff --git a/templates/sistema.html b/templates/sistema.html index ba536ec68..7ae09972d 100644 --- a/templates/sistema.html +++ b/templates/sistema.html @@ -34,8 +34,8 @@