From 4c3e1f579425f7e14d43c381297a035a76b1f4e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Rodrigues?= Date: Tue, 17 Dec 2019 13:01:12 -0300 Subject: [PATCH] =?UTF-8?q?Ordena=C3=A7=C3=A3o=20dos=20cargos=20de=20comis?= =?UTF-8?q?s=C3=A3o=20(#3047)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adiciona id_ordenacao em CargoComissao * Adiciona Ordenação dos Cargos - Tabelas Auxiliares * Adiciona rotas * Adiciona ordenação de cargos de comissão * fix migrations * Add mudança para posição ocupada/livre * Corrige orderings e adiciona link p/ cargo * Adiciona migration * Adiciona comentários * Update sapl/comissoes/forms.py * Update sapl/comissoes/forms.py * Adiciona correções * Refatoração --- sapl/comissoes/forms.py | 6 ++-- .../migrations/0023_auto_20191211_1752.py | 33 +++++++++++++++++++ sapl/comissoes/models.py | 10 ++++-- sapl/comissoes/urls.py | 11 ++++--- sapl/comissoes/views.py | 28 +++++++++------- sapl/templates/comissoes/layouts.yaml | 3 +- 6 files changed, 68 insertions(+), 23 deletions(-) create mode 100644 sapl/comissoes/migrations/0023_auto_20191211_1752.py diff --git a/sapl/comissoes/forms.py b/sapl/comissoes/forms.py index 0c08e17da..92d6695de 100644 --- a/sapl/comissoes/forms.py +++ b/sapl/comissoes/forms.py @@ -15,13 +15,13 @@ from sapl.base.models import Autor, TipoAutor from sapl.comissoes.models import (Comissao, Composicao, DocumentoAcessorio, Participacao, Periodo, Reuniao) -from sapl.crispy_layout_mixin import (form_actions, SaplFormHelper, +from sapl.crispy_layout_mixin import (form_actions, SaplFormHelper, to_row) from sapl.materia.models import MateriaEmTramitacao, PautaReuniao from sapl.parlamentares.models import (Legislatura, Mandato, Parlamentar) -from sapl.utils import (FileFieldCheckMixin, FilterOverridesMetaMixin, - validar_arquivo) +from sapl.utils import (FileFieldCheckMixin, + FilterOverridesMetaMixin, validar_arquivo) class ComposicaoForm(forms.ModelForm): diff --git a/sapl/comissoes/migrations/0023_auto_20191211_1752.py b/sapl/comissoes/migrations/0023_auto_20191211_1752.py new file mode 100644 index 000000000..c96bd9a12 --- /dev/null +++ b/sapl/comissoes/migrations/0023_auto_20191211_1752.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.20 on 2019-12-11 20:52 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('comissoes', '0022_auto_20191120_1440'), + ] + + operations = [ + migrations.AlterModelOptions( + name='cargocomissao', + options={'ordering': ['id_ordenacao'], 'verbose_name': 'Cargo de Comissão', 'verbose_name_plural': 'Cargos de Comissão'}, + ), + migrations.AlterModelOptions( + name='participacao', + options={'ordering': ['-titular', 'cargo__id_ordenacao'], 'verbose_name': 'Participação em Comissão', 'verbose_name_plural': 'Participações em Comissão'}, + ), + migrations.AddField( + model_name='cargocomissao', + name='id_ordenacao', + field=models.PositiveIntegerField(blank=True, null=True, verbose_name='Posição na Ordenação'), + ), + migrations.AlterField( + model_name='cargocomissao', + name='nome', + field=models.CharField(max_length=50, verbose_name='Nome do Cargo'), + ), + ] diff --git a/sapl/comissoes/models.py b/sapl/comissoes/models.py index 4e7c6e2de..8efac2ee6 100644 --- a/sapl/comissoes/models.py +++ b/sapl/comissoes/models.py @@ -121,13 +121,18 @@ class Periodo(models.Model): # PeriodoCompComissao @reversion.register() class CargoComissao(models.Model): - nome = models.CharField(max_length=50, verbose_name=_('Cargo')) + id_ordenacao = models.PositiveIntegerField( + blank=True, null=True, verbose_name=_('Posição na Ordenação'), + ) + nome = models.CharField(max_length=50, verbose_name=_('Nome do Cargo')) unico = models.BooleanField( - choices=YES_NO_CHOICES, verbose_name=_('Único'), default=True) + choices=YES_NO_CHOICES, verbose_name=_('Único'), default=True + ) class Meta: verbose_name = _('Cargo de Comissão') verbose_name_plural = _('Cargos de Comissão') + ordering = ['id_ordenacao'] def __str__(self): return self.nome @@ -180,6 +185,7 @@ class Participacao(models.Model): # ComposicaoComissao class Meta: verbose_name = _('Participação em Comissão') verbose_name_plural = _('Participações em Comissão') + ordering = ['-titular', 'cargo__id_ordenacao'] def __str__(self): return '%s : %s' % (self.cargo, self.parlamentar) diff --git a/sapl/comissoes/urls.py b/sapl/comissoes/urls.py index 5e48ee891..932feaf22 100644 --- a/sapl/comissoes/urls.py +++ b/sapl/comissoes/urls.py @@ -1,8 +1,9 @@ from django.conf.urls import include, url -from sapl.comissoes.views import (CargoCrud, ComissaoCrud, ComposicaoCrud, - DocumentoAcessorioCrud, MateriasTramitacaoListView, ParticipacaoCrud, - PeriodoComposicaoCrud, ReuniaoCrud, TipoComissaoCrud, get_participacoes_comissao, - AdicionaPautaView, RemovePautaView) +from sapl.comissoes.views import (AdicionaPautaView, CargoComissaoCrud, ComissaoCrud, + ComposicaoCrud, DocumentoAcessorioCrud, + MateriasTramitacaoListView, ParticipacaoCrud, + get_participacoes_comissao, PeriodoComposicaoCrud, + RemovePautaView, ReuniaoCrud, TipoComissaoCrud) from .apps import AppConfig @@ -21,7 +22,7 @@ urlpatterns = [ url(r'^comissao/(?P\d+)/pauta/add', AdicionaPautaView.as_view(), name='pauta_add'), url(r'^comissao/(?P\d+)/pauta/remove', RemovePautaView.as_view(), name='pauta_remove'), - url(r'^sistema/comissao/cargo/', include(CargoCrud.get_urls())), + url(r'^sistema/comissao/cargo/', include(CargoComissaoCrud.get_urls())), url(r'^sistema/comissao/periodo-composicao/', include(PeriodoComposicaoCrud.get_urls())), url(r'^sistema/comissao/tipo/', include(TipoComissaoCrud.get_urls())), diff --git a/sapl/comissoes/views.py b/sapl/comissoes/views.py index 4d37d735a..458a9a25f 100644 --- a/sapl/comissoes/views.py +++ b/sapl/comissoes/views.py @@ -1,12 +1,12 @@ import logging -from django.core.urlresolvers import reverse from django.contrib import messages from django.contrib.auth.mixins import PermissionRequiredMixin +from django.core.urlresolvers import reverse from django.db.models import F from django.http.response import HttpResponseRedirect, JsonResponse from django.views.decorators.clickjacking import xframe_options_exempt -from django.views.generic import ListView, CreateView, DeleteView +from django.views.generic import CreateView, DeleteView, FormView, ListView from django.views.generic.base import RedirectView from django.views.generic.detail import DetailView from django.views.generic.edit import FormMixin, UpdateView @@ -19,14 +19,15 @@ from sapl.comissoes.apps import AppConfig from sapl.comissoes.forms import (ComissaoForm, ComposicaoForm, DocumentoAcessorioCreateForm, DocumentoAcessorioEditForm, - ParticipacaoCreateForm, ParticipacaoEditForm, - PautaReuniaoForm, PeriodoForm, ReuniaoForm, - PautaReuniaoFilterSet) -from sapl.crud.base import (RP_DETAIL, RP_LIST, Crud, CrudAux, - MasterDetailCrud, - PermissionRequiredForAppCrudMixin) -from sapl.materia.models import (MateriaLegislativa, Tramitacao, PautaReuniao, - MateriaEmTramitacao) + ParticipacaoCreateForm, + ParticipacaoEditForm, + PautaReuniaoFilterSet, PautaReuniaoForm, + PeriodoForm, ReuniaoForm) +from sapl.crud.base import (Crud, CrudAux, MasterDetailCrud, + PermissionRequiredForAppCrudMixin, RP_DETAIL, + RP_LIST) +from sapl.materia.models import (MateriaEmTramitacao, MateriaLegislativa, + PautaReuniao, Tramitacao) from sapl.utils import show_results_filter_set from .models import (CargoComissao, Comissao, Composicao, DocumentoAcessorio, @@ -46,7 +47,10 @@ def pegar_url_reuniao(pk): url = reverse('sapl.comissoes:reuniao_detail', kwargs={'pk': r_pk}) return url -CargoCrud = CrudAux.build(CargoComissao, 'cargo_comissao') +CargoComissaoCrud = CrudAux.build( + CargoComissao, 'cargo_comissao', + list_field_names=['nome', 'id_ordenacao', 'unico'] +) TipoComissaoCrud = CrudAux.build( TipoComissao, 'tipo_comissao', list_field_names=[ @@ -143,7 +147,7 @@ class ComposicaoCrud(MasterDetailCrud): context['participacao_set'] = Participacao.objects.filter( composicao__pk=context['composicao_pk'] - ).order_by('id') + ).order_by('-titular', 'cargo__id_ordenacao', 'id') return context diff --git a/sapl/templates/comissoes/layouts.yaml b/sapl/templates/comissoes/layouts.yaml index b06fb9ae9..f09a7a0b8 100644 --- a/sapl/templates/comissoes/layouts.yaml +++ b/sapl/templates/comissoes/layouts.yaml @@ -1,7 +1,8 @@ {% load i18n %} + CargoComissao: {% trans 'Cargo de Comissão' %}: - - nome:10 unico + - nome:6 unico id_ordenacao Periodo: {% trans 'Período de composição de Comissão' %}: