From fd00a77f54f37ec759839a289a2b7022634c8d82 Mon Sep 17 00:00:00 2001 From: Eduardo Calil Date: Mon, 20 Jun 2016 11:18:11 -0300 Subject: [PATCH] Finaliza a autenticacao do app parlamentares --- sapl/materia/views.py | 14 +--------- sapl/parlamentares/views.py | 53 ++++++++++++++++++++++++++----------- 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/sapl/materia/views.py b/sapl/materia/views.py index 63107a5af..6fb8f2d8b 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -59,7 +59,6 @@ class OrigemCrud(Crud): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): permission_required = permissoes_materia() - list_field_names = ['nome', 'sigla'] class TipoMateriaCrud(Crud): @@ -68,7 +67,6 @@ class TipoMateriaCrud(Crud): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): permission_required = permissoes_materia() - list_field_names = ['sigla', 'descricao'] class RegimeTramitacaoCrud(Crud): @@ -77,7 +75,6 @@ class RegimeTramitacaoCrud(Crud): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): permission_required = permissoes_materia() - list_field_names = ['descricao'] class TipoDocumentoCrud(Crud): @@ -86,7 +83,6 @@ class TipoDocumentoCrud(Crud): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): permission_required = permissoes_materia() - list_field_names = ['descricao'] class TipoFimRelatoriaCrud(Crud): @@ -95,7 +91,6 @@ class TipoFimRelatoriaCrud(Crud): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): permission_required = permissoes_materia() - list_field_names = ['descricao'] class TipoAutorCrud(Crud): @@ -104,7 +99,6 @@ class TipoAutorCrud(Crud): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): permission_required = permissoes_materia() - list_field_names = ['descricao'] class AutorCrud(Crud): @@ -113,7 +107,6 @@ class AutorCrud(Crud): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): permission_required = permissoes_materia() - list_field_names = ['username', 'tipo', 'nome'] class OrgaoCrud(Crud): @@ -122,8 +115,6 @@ class OrgaoCrud(Crud): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): permission_required = permissoes_materia() - list_field_names = ['nome', 'sigla', 'telefone', - 'unidade_deliberativa'] class TipoProposicaoCrud(Crud): @@ -132,8 +123,6 @@ class TipoProposicaoCrud(Crud): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): permission_required = permissoes_materia() - list_field_names = ['descricao', 'materia_ou_documento', - 'tipo_materia', 'modelo'] class StatusTramitacaoCrud(Crud): @@ -142,7 +131,6 @@ class StatusTramitacaoCrud(Crud): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): permission_required = permissoes_materia() - list_field_names = ['sigla', 'descricao', 'indicador'] class UnidadeTramitacaoCrud(Crud): @@ -195,7 +183,7 @@ class ProposicaoCrud(Crud): return [self._as_row(obj) for obj in object_list] - class DeleteView(PermissionRequiredMixin, MasterDetailCrud.DeleteView): + class DeleteView(PermissionRequiredMixin, CrudDeleteView): permission_required = permissoes_materia() def delete(self, request, *args, **kwargs): diff --git a/sapl/parlamentares/views.py b/sapl/parlamentares/views.py index 1e997b9bf..b2b6b57ce 100644 --- a/sapl/parlamentares/views.py +++ b/sapl/parlamentares/views.py @@ -9,7 +9,7 @@ from django.utils.translation import ugettext_lazy as _ from django.views.generic import FormView from sapl.crud.base import (Crud, CrudCreateView, CrudListView, CrudUpdateView, - CrudBaseMixin) + CrudBaseMixin, CrudDeleteView) from sapl.crud.masterdetail import MasterDetailCrud from .forms import (ComposicaoColigacaoForm, FiliacaoForm, LegislaturaForm, @@ -37,7 +37,6 @@ class CargoMesaCrud(Crud): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): permission_required = permissoes_parlamentares() - list_field_names = ['descricao', 'unico'] class PartidoCrud(Crud): @@ -46,7 +45,6 @@ class PartidoCrud(Crud): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): permission_required = permissoes_parlamentares() - list_field_names = ['nome', 'sigla', 'data_criacao', 'data_extincao'] class SessaoLegislativaCrud(Crud): @@ -55,9 +53,6 @@ class SessaoLegislativaCrud(Crud): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): permission_required = permissoes_parlamentares() - list_field_names = ['numero', 'tipo', 'legislatura', 'data_inicio', - 'data_fim', 'data_inicio_intervalo', - 'data_fim_intervalo'] class TipoDependenteCrud(Crud): @@ -66,7 +61,6 @@ class TipoDependenteCrud(Crud): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): permission_required = permissoes_parlamentares() - list_field_names = ['descricao'] class NivelInstrucaoCrud(Crud): @@ -75,7 +69,6 @@ class NivelInstrucaoCrud(Crud): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): permission_required = permissoes_parlamentares() - list_field_names = ['descricao'] class TipoAfastamentoCrud(Crud): @@ -84,7 +77,6 @@ class TipoAfastamentoCrud(Crud): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): permission_required = permissoes_parlamentares() - list_field_names = ['descricao', 'dispositivo', 'fim_mandato'] class TipoMilitarCrud(Crud): @@ -93,7 +85,6 @@ class TipoMilitarCrud(Crud): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): permission_required = permissoes_parlamentares() - list_field_names = ['descricao'] class MandatoCrud(MasterDetailCrud): @@ -104,6 +95,15 @@ class MandatoCrud(MasterDetailCrud): class ListView(MasterDetailCrud.ListView): ordering = ('-legislatura__data_inicio') + class CreateView(PermissionRequiredMixin, MasterDetailCrud.CreateView): + permission_required = permissoes_parlamentares() + + class UpdateView(PermissionRequiredMixin, MasterDetailCrud.UpdateView): + permission_required = permissoes_parlamentares() + + class DeleteView(PermissionRequiredMixin, MasterDetailCrud.DeleteView): + permission_required = permissoes_parlamentares() + class ColigacaoCrud(Crud): model = Coligacao @@ -112,6 +112,9 @@ class ColigacaoCrud(Crud): class ListView(CrudListView): ordering = ('-legislatura__data_inicio', 'nome') + class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): + permission_required = permissoes_parlamentares() + class ComposicaoColigacaoCrud(MasterDetailCrud): model = ComposicaoColigacao @@ -135,6 +138,9 @@ class ComposicaoColigacaoCrud(MasterDetailCrud): class ListView(MasterDetailCrud.ListView): ordering = '-partido__sigla' + class BaseMixin(PermissionRequiredMixin, MasterDetailCrud.BaseMixin): + permission_required = permissoes_parlamentares() + class LegislaturaCrud(Crud): model = Legislatura @@ -146,17 +152,25 @@ class LegislaturaCrud(Crud): class UpdateView(CrudUpdateView): form_class = LegislaturaForm + class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): + permission_required = permissoes_parlamentares() + class FiliacaoCrud(MasterDetailCrud): model = Filiacao parent_field = 'parlamentar' help_path = '' - class CreateView(MasterDetailCrud.CreateView): + class CreateView(PermissionRequiredMixin, MasterDetailCrud.CreateView): form_class = FiliacaoForm + permission_required = permissoes_parlamentares() - class UpdateView(MasterDetailCrud.UpdateView): + class UpdateView(PermissionRequiredMixin, MasterDetailCrud.UpdateView): form_class = FiliacaoForm + permission_required = permissoes_parlamentares() + + class DeleteView(PermissionRequiredMixin, MasterDetailCrud.DeleteView): + permission_required = permissoes_parlamentares() class ListView(MasterDetailCrud.ListView): ordering = '-data' @@ -166,16 +180,22 @@ class ParlamentarCrud(Crud): model = Parlamentar help_path = '' - class UpdateView(CrudUpdateView): + class UpdateView(PermissionRequiredMixin, CrudUpdateView): form_class = ParlamentarForm + permission_required = permissoes_parlamentares() - class CreateView(CrudCreateView): + class CreateView(PermissionRequiredMixin, CrudCreateView): form_class = ParlamentarCreateForm + permission_required = permissoes_parlamentares() @property def layout_key(self): return 'ParlamentarCreate' + class DeleteView(PermissionRequiredMixin, CrudDeleteView): + form_class = ParlamentarCreateForm + permission_required = permissoes_parlamentares() + class ListView(CrudListView): template_name = "parlamentares/parlamentares_list.html" paginate_by = None @@ -230,11 +250,12 @@ class ParlamentarCrud(Crud): return context -class MesaDiretoraView(FormView): +class MesaDiretoraView(PermissionRequiredMixin, FormView): template_name = "mesa_diretora/mesa_diretora.html" success_url = reverse_lazy('sapl.parlamentares:mesa_diretora') + permission_required = permissoes_parlamentares() - # Essa função avisa quando se pode compor uma Mesa Legislativa) + # Essa função avisa quando se pode compor uma Mesa Legislativa def validation(self, request): mensagem = _("Não há nenhuma Sessão Legislativa cadastrada. \ Só é possível compor uma Mesa Diretora quando há uma Sessão \