Browse Source

Refatora cruds da app sessao para usar novo Crud

pull/675/head
LeandroRoberto 8 years ago
parent
commit
35e5d50c4e
  1. 2
      sapl/crispy_layout_mixin.py
  2. 28
      sapl/crud/base.py
  3. 2
      sapl/parlamentares/views.py
  4. 1
      sapl/sessao/models.py
  5. 12
      sapl/sessao/urls.py
  6. 187
      sapl/sessao/views.py
  7. 2
      sapl/templates/sessao/mesa.html

2
sapl/crispy_layout_mixin.py

@ -150,7 +150,7 @@ class CrispyLayoutFormMixin:
in the first fieldset of the layout. in the first fieldset of the layout.
''' '''
obj = self.crud if hasattr(self, 'crud') else self obj = self.crud if hasattr(self, 'crud') else self
if hasattr(obj, 'list_field_names'): if hasattr(obj, 'list_field_names') and obj.list_field_names:
return obj.list_field_names return obj.list_field_names
rows = self.get_layout()[0][1:] rows = self.get_layout()[0][1:]
return [fieldname for row in rows for fieldname, __ in row] return [fieldname for row in rows for fieldname, __ in row]

28
sapl/crud/base.py

@ -668,7 +668,9 @@ class CrudDetailView(PermissionRequiredContainerCrudMixin,
for i, name in enumerate(self.list_field_names_set)] for i, name in enumerate(self.list_field_names_set)]
def get_object(self, queryset=None): def get_object(self, queryset=None):
if hasattr(self, 'object'):
return self.object return self.object
return DetailView.get_object(self, queryset=queryset)
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
self.object = self.model.objects.get(pk=kwargs.get('pk')) self.object = self.model.objects.get(pk=kwargs.get('pk'))
@ -680,7 +682,10 @@ class CrudDetailView(PermissionRequiredContainerCrudMixin,
def get_queryset(self): def get_queryset(self):
obj = self.crud if hasattr(self, 'crud') else self obj = self.crud if hasattr(self, 'crud') else self
if hasattr(obj, 'model_set') and obj.model_set:
queryset = getattr(self.object, obj.model_set).all() queryset = getattr(self.object, obj.model_set).all()
else:
queryset = super().get_queryset()
if not self.request.user.is_authenticated(): if not self.request.user.is_authenticated():
return queryset return queryset
@ -782,13 +787,6 @@ class CrudDeleteView(PermissionRequiredContainerCrudMixin,
return self.list_url return self.list_url
class DeactivatedMixin(View):
@classmethod
def get_url_regex(cls):
return r'^dummy$'
class Crud: class Crud:
BaseMixin = CrudBaseMixin BaseMixin = CrudBaseMixin
ListView = CrudListView ListView = CrudListView
@ -842,28 +840,16 @@ class Crud:
@classonlymethod @classonlymethod
def build(cls, _model, _help_path, _model_set=None, list_field_names=[]): def build(cls, _model, _help_path, _model_set=None, list_field_names=[]):
def create_class_with_list_field(_list_field_names): def create_class(_list_field_names):
class ModelCrud(cls): class ModelCrud(cls):
model = _model model = _model
model_set = _model_set model_set = _model_set
help_path = _help_path help_path = _help_path
class BaseMixin(cls.BaseMixin):
list_field_names = _list_field_names list_field_names = _list_field_names
return ModelCrud return ModelCrud
def create_class(): ModelCrud = create_class(list_field_names)
class ModelCrud(cls):
model = _model
model_set = _model_set
help_path = _help_path
return ModelCrud
ModelCrud = create_class() if not list_field_names\
else create_class_with_list_field(list_field_names)
ModelCrud.__name__ = '%sCrud' % _model.__name__ ModelCrud.__name__ = '%sCrud' % _model.__name__
return ModelCrud return ModelCrud

2
sapl/parlamentares/views.py

@ -15,7 +15,7 @@ from sapl.comissoes.models import Participacao
from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView, from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView,
CrudDeleteView, CrudDetailView, CrudListView, CrudDeleteView, CrudDetailView, CrudListView,
CrudUpdateView, MasterDetailCrud, CrudAux, CrudUpdateView, MasterDetailCrud, CrudAux,
RP_CHANGE, RP_DETAIL, RP_LIST, DeactivatedMixin, RP_CHANGE, RP_DETAIL, RP_LIST,
CrudBaseForListAndDetailExternalAppView) CrudBaseForListAndDetailExternalAppView)
from sapl.materia.models import Proposicao, Relatoria from sapl.materia.models import Proposicao, Relatoria
from sapl.parlamentares.apps import AppConfig from sapl.parlamentares.apps import AppConfig

1
sapl/sessao/models.py

@ -41,6 +41,7 @@ class Bancada(models.Model):
class Meta: class Meta:
verbose_name = _('Bancada') verbose_name = _('Bancada')
verbose_name_plural = _('Bancadas') verbose_name_plural = _('Bancadas')
ordering = ('-legislatura__numero', )
def __str__(self): def __str__(self):
return self.nome return self.nome

12
sapl/sessao/urls.py

@ -39,6 +39,7 @@ urlpatterns = [
ExpedienteMateriaCrud.get_urls() + ExpedienteMateriaCrud.get_urls() +
MateriaOrdemDiaCrud.get_urls())), MateriaOrdemDiaCrud.get_urls())),
url(r'^sessao/(?P<pk>\d+)/mesa$', MesaView.as_view(), name='mesa'),
url(r'^recuperar-materia/', recuperar_materia), url(r'^recuperar-materia/', recuperar_materia),
url(r'^recuperar-numero-sessao/', recuperar_numero_sessao), url(r'^recuperar-numero-sessao/', recuperar_numero_sessao),
@ -86,17 +87,16 @@ urlpatterns = [
PautaOrdemDetail.as_view(), name='pauta_ordem_detail'), PautaOrdemDetail.as_view(), name='pauta_ordem_detail'),
# Subnav sessão # Subnav sessão
url(r'^(?P<pk>\d+)/expediente$', url(r'^sessao/(?P<pk>\d+)/expediente$',
ExpedienteView.as_view(), name='expediente'), ExpedienteView.as_view(), name='expediente'),
url(r'^(?P<pk>\d+)/presenca$', url(r'^sessao/(?P<pk>\d+)/presenca$',
PresencaView.as_view(), name='presenca'), PresencaView.as_view(), name='presenca'),
url(r'^(?P<pk>\d+)/painel$', url(r'^sessao/(?P<pk>\d+)/painel$',
PainelView.as_view(), name='painel'), PainelView.as_view(), name='painel'),
url(r'^(?P<pk>\d+)/presencaordemdia$', url(r'^sessao/(?P<pk>\d+)/presencaordemdia$',
PresencaOrdemDiaView.as_view(), PresencaOrdemDiaView.as_view(),
name='presencaordemdia'), name='presencaordemdia'),
url(r'^(?P<pk>\d+)/mesa$', MesaView.as_view(), name='mesa'), url(r'^sessao/(?P<pk>\d+)/resumo$',
url(r'^(?P<pk>\d+)/resumo$',
ResumoView.as_view(), name='resumo'), ResumoView.as_view(), name='resumo'),
url(r'^sessao/pesquisar-sessao$', url(r'^sessao/pesquisar-sessao$',
PesquisarSessaoPlenariaView.as_view(), name='pesquisar_sessao'), PesquisarSessaoPlenariaView.as_view(), name='pesquisar_sessao'),

187
sapl/sessao/views.py

@ -3,22 +3,24 @@ from re import sub
from braces.views import PermissionRequiredMixin from braces.views import PermissionRequiredMixin
from django.contrib import messages from django.contrib import messages
from django.contrib.auth.decorators import permission_required
from django.core.exceptions import ObjectDoesNotExist, ValidationError from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.forms.utils import ErrorList from django.forms.utils import ErrorList
from django.http import JsonResponse from django.http import JsonResponse
from django.http.response import HttpResponseRedirect from django.http.response import HttpResponseRedirect
from django.utils.datastructures import MultiValueDictKeyError from django.utils.datastructures import MultiValueDictKeyError
from django.utils.decorators import method_decorator
from django.utils.html import strip_tags from django.utils.html import strip_tags
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.generic import ListView, TemplateView from django.views.generic import ListView, TemplateView
from django.views.generic.detail import DetailView
from django.views.generic.edit import FormMixin from django.views.generic.edit import FormMixin
from django_filters.views import FilterView from django_filters.views import FilterView
from rest_framework import generics from rest_framework import generics
from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView, from sapl.crud.base import (Crud, MasterDetailCrud, make_pagination,
CrudDeleteView, CrudDetailView, CrudListView, CrudAux, RP_CHANGE, RP_DETAIL, RP_LIST,)
CrudUpdateView, MasterDetailCrud, make_pagination)
from sapl.materia.forms import pega_ultima_tramitacao from sapl.materia.forms import pega_ultima_tramitacao
from sapl.materia.models import (Autoria, DocumentoAcessorio, from sapl.materia.models import (Autoria, DocumentoAcessorio,
TipoMateriaLegislativa, Tramitacao) TipoMateriaLegislativa, Tramitacao)
@ -26,6 +28,7 @@ from sapl.materia.views import MateriaLegislativaPesquisaView
from sapl.norma.models import NormaJuridica from sapl.norma.models import NormaJuridica
from sapl.parlamentares.models import (Parlamentar, SessaoLegislativa, from sapl.parlamentares.models import (Parlamentar, SessaoLegislativa,
Legislatura) Legislatura)
from sapl.sessao.apps import AppConfig
from sapl.sessao.serializers import SessaoPlenariaSerializer from sapl.sessao.serializers import SessaoPlenariaSerializer
from sapl.utils import permissao_tb_aux, permissoes_painel, permissoes_sessao from sapl.utils import permissao_tb_aux, permissoes_painel, permissoes_sessao
@ -42,9 +45,23 @@ from .models import (Bancada, Bloco, CargoBancada, CargoMesa,
SessaoPlenariaPresenca, TipoExpediente, SessaoPlenariaPresenca, TipoExpediente,
TipoResultadoVotacao, TipoSessaoPlenaria, VotoParlamentar) TipoResultadoVotacao, TipoSessaoPlenaria, VotoParlamentar)
OrdemDiaCrud = Crud.build(OrdemDia, '') OrdemDiaCrud = Crud.build(OrdemDia, '')
RegistroVotacaoCrud = Crud.build(RegistroVotacao, '') RegistroVotacaoCrud = Crud.build(RegistroVotacao, '')
TipoSessaoCrud = CrudAux.build(TipoSessaoPlenaria, 'tipo_sessao_plenaria')
TipoExpedienteCrud = CrudAux.build(TipoExpediente, 'tipo_expediente')
CargoBancadaCrud = CrudAux.build(CargoBancada, '')
TipoSessaoCrud = CrudAux.build(TipoSessaoPlenaria, 'tipo_sessao_plenaria')
TipoSessaoCrud = CrudAux.build(TipoSessaoPlenaria, 'tipo_sessao_plenaria')
BlocoCrud = CrudAux.build(
Bloco, '', list_field_names=['nome', 'data_criacao', 'partidos'])
BancadaCrud = CrudAux.build(
Bancada, '', list_field_names=['nome', 'legislatura'])
TipoResultadoVotacaoCrud = CrudAux.build(
TipoResultadoVotacao, 'tipo_resultado_votacao')
def reordernar_materias_expediente(request, pk): def reordernar_materias_expediente(request, pk):
expedientes = ExpedienteMateria.objects.filter( expedientes = ExpedienteMateria.objects.filter(
@ -72,77 +89,6 @@ def reordernar_materias_ordem(request, pk):
reverse('sapl.sessao:ordemdia_list', kwargs={'pk': pk})) reverse('sapl.sessao:ordemdia_list', kwargs={'pk': pk}))
class BlocoCrud(Crud):
model = Bloco
help_path = ''
class BaseMixin(CrudBaseMixin):
list_field_names = ['nome', 'data_criacao', 'partidos']
def has_permission(self):
return permissao_tb_aux(self)
class BancadaCrud(Crud):
model = Bancada
help_path = ''
class BaseMixin(CrudBaseMixin):
list_field_names = ['nome', 'legislatura']
def has_permission(self):
return permissao_tb_aux(self)
class ListView(CrudListView):
ordering = 'legislatura'
class CreateView(CrudCreateView):
form_class = BancadaForm
class UpdateView(CrudUpdateView):
form_class = BancadaForm
class TipoSessaoCrud(Crud):
model = TipoSessaoPlenaria
help_path = 'tipo_sessao_plenaria'
class BaseMixin(CrudBaseMixin):
def has_permission(self):
return permissao_tb_aux(self)
class TipoResultadoVotacaoCrud(Crud):
model = TipoResultadoVotacao
help_path = 'tipo_resultado_votacao'
class BaseMixin(CrudBaseMixin):
def has_permission(self):
return permissao_tb_aux(self)
class TipoExpedienteCrud(Crud):
model = TipoExpediente
help_path = 'tipo_expediente'
class BaseMixin(CrudBaseMixin):
def has_permission(self):
return permissao_tb_aux(self)
class CargoBancadaCrud(Crud):
model = CargoBancada
help_path = ''
class BaseMixin(CrudBaseMixin):
def has_permission(self):
return permissao_tb_aux(self)
def abrir_votacao_expediente_view(request, pk, spk): def abrir_votacao_expediente_view(request, pk, spk):
existe_votacao_aberta = ExpedienteMateria.objects.filter( existe_votacao_aberta = ExpedienteMateria.objects.filter(
sessao_plenaria_id=spk, votacao_aberta=True sessao_plenaria_id=spk, votacao_aberta=True
@ -245,7 +191,7 @@ class MateriaOrdemDiaCrud(MasterDetailCrud):
url = reverse('sapl.sessao:abrir_votacao', kwargs={ url = reverse('sapl.sessao:abrir_votacao', kwargs={
'pk': obj.pk, 'spk': obj.sessao_plenaria_id}) 'pk': obj.pk, 'spk': obj.sessao_plenaria_id})
if self.request.user.has_perms(permissoes_sessao()): if self.request.user.has_module_perms(AppConfig.label):
btn_abrir = ''' btn_abrir = '''
Matéria não votada<br /> Matéria não votada<br />
<a href="%s" <a href="%s"
@ -255,7 +201,7 @@ class MateriaOrdemDiaCrud(MasterDetailCrud):
else: else:
obj.resultado = '''Não há resultado''' obj.resultado = '''Não há resultado'''
else: else:
if self.request.user.has_perms(permissoes_sessao()): if self.request.user.has_module_perms(AppConfig.label):
url = '' url = ''
if obj.tipo_votacao == 1: if obj.tipo_votacao == 1:
url = reverse('sapl.sessao:votacaosimbolicaedit', url = reverse('sapl.sessao:votacaosimbolicaedit',
@ -309,7 +255,7 @@ class ExpedienteMateriaCrud(MasterDetailCrud):
list_field_names = ['numero_ordem', 'materia', list_field_names = ['numero_ordem', 'materia',
'observacao', 'resultado'] 'observacao', 'resultado']
class ListView(MasterDetailCrud.ListView): class ListView(Crud.PublicMixin, MasterDetailCrud.ListView):
ordering = ['numero_ordem', 'materia', 'resultado'] ordering = ['numero_ordem', 'materia', 'resultado']
def get_rows(self, object_list): def get_rows(self, object_list):
@ -349,6 +295,7 @@ class ExpedienteMateriaCrud(MasterDetailCrud):
<a href="%s" <a href="%s"
class="btn btn-primary" class="btn btn-primary"
role="button">Abrir Votação</a>''' % (url) role="button">Abrir Votação</a>''' % (url)
obj.resultado = btn_abrir obj.resultado = btn_abrir
else: else:
url = '' url = ''
@ -376,7 +323,6 @@ class ExpedienteMateriaCrud(MasterDetailCrud):
class CreateView(MasterDetailCrud.CreateView): class CreateView(MasterDetailCrud.CreateView):
form_class = ExpedienteMateriaForm form_class = ExpedienteMateriaForm
permission_required = permissoes_sessao()
def get_success_url(self): def get_success_url(self):
return reverse('sapl.sessao:expedientemateria_list', return reverse('sapl.sessao:expedientemateria_list',
@ -384,7 +330,6 @@ class ExpedienteMateriaCrud(MasterDetailCrud):
class UpdateView(MasterDetailCrud.UpdateView): class UpdateView(MasterDetailCrud.UpdateView):
form_class = ExpedienteMateriaForm form_class = ExpedienteMateriaForm
permission_required = permissoes_sessao()
def get_initial(self): def get_initial(self):
self.initial['tipo_materia'] = self.object.materia.tipo.id self.initial['tipo_materia'] = self.object.materia.tipo.id
@ -392,9 +337,6 @@ class ExpedienteMateriaCrud(MasterDetailCrud):
self.initial['ano_materia'] = self.object.materia.ano self.initial['ano_materia'] = self.object.materia.ano
return self.initial return self.initial
class DeleteView(PermissionRequiredMixin, MasterDetailCrud.DeleteView):
permission_required = permissoes_sessao()
class DetailView(MasterDetailCrud.DetailView): class DetailView(MasterDetailCrud.DetailView):
@property @property
@ -406,25 +348,16 @@ class OradorCrud(MasterDetailCrud):
model = '' model = ''
parent_field = 'sessao_plenaria' parent_field = 'sessao_plenaria'
help_path = '' help_path = ''
public = [RP_LIST, RP_DETAIL]
class ListView(MasterDetailCrud.ListView): class ListView(MasterDetailCrud.ListView):
ordering = ['numero_ordem', 'parlamentar'] ordering = ['numero_ordem', 'parlamentar']
class CreateView(MasterDetailCrud.CreateView):
permission_required = permissoes_sessao()
class UpdateView(MasterDetailCrud.UpdateView):
permission_required = permissoes_sessao()
class DeleteView(MasterDetailCrud.DeleteView):
permission_required = permissoes_sessao()
class OradorExpedienteCrud(OradorCrud): class OradorExpedienteCrud(OradorCrud):
model = OradorExpediente model = OradorExpediente
class CreateView(MasterDetailCrud.CreateView): class CreateView(MasterDetailCrud.CreateView):
permission_required = permissoes_sessao()
form_class = OradorExpedienteForm form_class = OradorExpedienteForm
def get_success_url(self): def get_success_url(self):
@ -432,18 +365,13 @@ class OradorExpedienteCrud(OradorCrud):
kwargs={'pk': self.kwargs['pk']}) kwargs={'pk': self.kwargs['pk']})
class UpdateView(MasterDetailCrud.UpdateView): class UpdateView(MasterDetailCrud.UpdateView):
permission_required = permissoes_sessao()
form_class = OradorExpedienteForm form_class = OradorExpedienteForm
class DeleteView(MasterDetailCrud.DeleteView):
permission_required = permissoes_sessao()
class OradorCrud(OradorCrud): class OradorCrud(OradorCrud):
model = Orador model = Orador
class CreateView(MasterDetailCrud.CreateView): class CreateView(MasterDetailCrud.CreateView):
permission_required = permissoes_sessao()
form_class = OradorForm form_class = OradorForm
def get_success_url(self): def get_success_url(self):
@ -451,12 +379,8 @@ class OradorCrud(OradorCrud):
kwargs={'pk': self.kwargs['pk']}) kwargs={'pk': self.kwargs['pk']})
class UpdateView(MasterDetailCrud.UpdateView): class UpdateView(MasterDetailCrud.UpdateView):
permission_required = permissoes_sessao()
form_class = OradorForm form_class = OradorForm
class DeleteView(MasterDetailCrud.DeleteView):
permission_required = permissoes_sessao()
def recuperar_numero_sessao(request): def recuperar_numero_sessao(request):
try: try:
@ -473,22 +397,19 @@ def recuperar_numero_sessao(request):
class SessaoCrud(Crud): class SessaoCrud(Crud):
model = SessaoPlenaria model = SessaoPlenaria
help_path = 'sessao_plenaria' help_path = 'sessao_plenaria'
public = [RP_DETAIL]
class BaseMixin(CrudBaseMixin): class BaseMixin(Crud.BaseMixin):
list_field_names = ['data_inicio', 'legislatura', 'sessao_legislativa', list_field_names = ['data_inicio', 'legislatura', 'sessao_legislativa',
'tipo'] 'tipo']
# FIXME!!!! corrigir referencias no codigo e remover isso!!!!! class CrudDetailView(DetailView):
# fazer com #230
class CrudDetailView(CrudDetailView):
model = SessaoPlenaria model = SessaoPlenaria
help_path = 'sessao_plenaria'
class ListView(CrudListView): class ListView(Crud.ListView):
ordering = ['-data_inicio'] ordering = ['-data_inicio']
class CreateView(CrudCreateView): class CreateView(Crud.CreateView):
permission_required = permissoes_sessao()
def get_initial(self): def get_initial(self):
legislatura = Legislatura.objects.order_by('-numero')[0] legislatura = Legislatura.objects.order_by('-numero')[0]
@ -497,12 +418,6 @@ class SessaoCrud(Crud):
return {'legislatura': legislatura, return {'legislatura': legislatura,
'sessao_legislativa': sessao_legislativa} 'sessao_legislativa': sessao_legislativa}
class UpdateView(CrudUpdateView):
permission_required = permissoes_sessao()
class DeleteView(CrudDeleteView):
permission_required = permissoes_sessao()
class PresencaMixin: class PresencaMixin:
@ -535,18 +450,24 @@ class PresencaMixin:
yield (parlamentar, False) yield (parlamentar, False)
class PresencaView(FormMixin, class PresencaView(FormMixin, PresencaMixin, DetailView):
PresencaMixin,
SessaoCrud.CrudDetailView):
template_name = 'sessao/presenca.html' template_name = 'sessao/presenca.html'
form_class = PresencaForm form_class = PresencaForm
model = SessaoPlenaria model = SessaoPlenaria
@method_decorator(permission_required((
'%s.add_%s' % (
AppConfig.label, SessaoPlenariaPresenca._meta.model_name),
'%s.change_%s' % (
AppConfig.label, SessaoPlenariaPresenca._meta.model_name),
'%s.delete_%s' % (
AppConfig.label, SessaoPlenariaPresenca._meta.model_name),
)))
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
self.object = self.get_object() self.object = self.get_object()
form = self.get_form() form = self.get_form()
if not self.request.user.has_perms(permissoes_sessao()): if not self.request.user.has_module_perms(AppConfig.label):
return self.form_invalid(form) return self.form_invalid(form)
if form.is_valid(): if form.is_valid():
@ -586,12 +507,16 @@ class PainelView(PermissionRequiredMixin, TemplateView):
permission_required = permissoes_painel() permission_required = permissoes_painel()
class PresencaOrdemDiaView(FormMixin, class PresencaOrdemDiaView(FormMixin, PresencaMixin, DetailView):
PresencaMixin,
SessaoCrud.CrudDetailView):
template_name = 'sessao/presenca_ordemdia.html' template_name = 'sessao/presenca_ordemdia.html'
form_class = PresencaForm form_class = PresencaForm
model = SessaoPlenaria
@method_decorator(permission_required((
'%s.add_%s' % (AppConfig.label, PresencaOrdemDia._meta.model_name),
'%s.change_%s' % (AppConfig.label, PresencaOrdemDia._meta.model_name),
'%s.delete_%s' % (AppConfig.label, PresencaOrdemDia._meta.model_name),
)))
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
self.object = self.get_object() self.object = self.get_object()
@ -634,9 +559,10 @@ class PresencaOrdemDiaView(FormMixin,
return reverse('sapl.sessao:presencaordemdia', kwargs={'pk': pk}) return reverse('sapl.sessao:presencaordemdia', kwargs={'pk': pk})
class ListMateriaOrdemDiaView(FormMixin, SessaoCrud.CrudDetailView): class ListMateriaOrdemDiaView(FormMixin, DetailView):
template_name = 'sessao/materia_ordemdia_list.html' template_name = 'sessao/materia_ordemdia_list.html'
form_class = ListMateriaForm form_class = ListMateriaForm
model = SessaoPlenaria
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
self.object = self.get_object() self.object = self.get_object()
@ -673,6 +599,11 @@ class ListMateriaOrdemDiaView(FormMixin, SessaoCrud.CrudDetailView):
return self.render_to_response(context) return self.render_to_response(context)
@method_decorator(permission_required((
'%s.add_%s' % (AppConfig.label, OrdemDia._meta.model_name),
'%s.change_%s' % (AppConfig.label, OrdemDia._meta.model_name),
'%s.delete_%s' % (AppConfig.label, OrdemDia._meta.model_name),
)))
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
self.object = self.get_object() self.object = self.get_object()
context = self.get_context_data(object=self.object) context = self.get_context_data(object=self.object)
@ -737,12 +668,13 @@ class ListMateriaOrdemDiaView(FormMixin, SessaoCrud.CrudDetailView):
return self.get(self, request, args, kwargs) return self.get(self, request, args, kwargs)
class MesaView(PermissionRequiredMixin, FormMixin, SessaoCrud.CrudDetailView): class MesaView(FormMixin, DetailView):
template_name = 'sessao/mesa.html' template_name = 'sessao/mesa.html'
form_class = MesaForm form_class = MesaForm
permission_required = permissoes_sessao() model = SessaoPlenaria
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
self.object = self.get_object() self.object = self.get_object()
context = self.get_context_data(object=self.object) context = self.get_context_data(object=self.object)
@ -762,6 +694,11 @@ class MesaView(PermissionRequiredMixin, FormMixin, SessaoCrud.CrudDetailView):
return self.render_to_response(context) return self.render_to_response(context)
@method_decorator(permission_required((
'%s.add_integrantemesa' % AppConfig.label,
'%s.change_integrantemesa' % AppConfig.label,
'%s.delete_integrantemesa' % AppConfig.label,
)))
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
self.object = self.get_object() self.object = self.get_object()
form = MesaForm(request.POST) form = MesaForm(request.POST)

2
sapl/templates/sessao/mesa.html

@ -20,10 +20,12 @@
</div> </div>
<div class="col-md-4" align="center"> <div class="col-md-4" align="center">
{% if perms.sessao %}
<br /><br /> <br /><br />
{% if view.get_cargos_mesa %}<input type="submit" name="Incluir" Value="Incluir" class="btn btn-primary" />{% endif %} {% if view.get_cargos_mesa %}<input type="submit" name="Incluir" Value="Incluir" class="btn btn-primary" />{% endif %}
<br /><br /> <br /><br />
<input type="submit" name="Excluir" Value="Excluir" class="btn btn-danger" /> <input type="submit" name="Excluir" Value="Excluir" class="btn btn-danger" />
{% endif %}
</div> </div>
{% if view.get_cargos_mesa %} {% if view.get_cargos_mesa %}
<div class="col-md-4"> <div class="col-md-4">

Loading…
Cancel
Save