Browse Source

Fix #1199 Libera iframe para as telas que precisam (#1204)

* Libera iframe para as telas que precisam

* Melhoria na logica de escolha dos templates
pull/1206/head
Eduardo Calil 8 years ago
committed by Edward
parent
commit
9fa71b7145
  1. 12
      sapl/comissoes/views.py
  2. 3
      sapl/materia/views.py
  3. 49
      sapl/parlamentares/views.py

12
sapl/comissoes/views.py

@ -1,6 +1,7 @@
from django.core.urlresolvers import reverse
from django.db.models import F
from django.views.decorators.clickjacking import xframe_options_exempt
from django.views.generic import ListView
from sapl.crud.base import RP_DETAIL, RP_LIST, Crud, CrudAux, MasterDetailCrud
@ -84,6 +85,17 @@ class ComissaoCrud(Crud):
list_field_names = ['nome', 'sigla', 'tipo', 'data_criacao', 'data_extincao', 'ativa']
ordering = '-ativa', 'sigla'
class ListView(Crud.ListView):
@xframe_options_exempt
def get(self, request, *args, **kwargs):
return super().get(request, *args, **kwargs)
class DetailView(Crud.DetailView):
@xframe_options_exempt
def get(self, request, *args, **kwargs):
return super().get(request, *args, **kwargs)
class MateriasTramitacaoListView(ListView):
template_name = "comissoes/materias_em_tramitacao.html"

3
sapl/materia/views.py

@ -7,7 +7,8 @@ from crispy_forms.layout import HTML
from django.contrib import messages
from django.contrib.auth.decorators import permission_required
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
from django.core.exceptions import (ObjectDoesNotExist,
MultipleObjectsReturned)
from django.core.urlresolvers import reverse
from django.http import HttpResponse, JsonResponse
from django.http.response import Http404, HttpResponseRedirect

49
sapl/parlamentares/views.py

@ -7,6 +7,7 @@ from django.http.response import HttpResponseRedirect
from django.templatetags.static import static
from django.utils.datastructures import MultiValueDictKeyError
from django.utils.translation import ugettext_lazy as _
from django.views.decorators.clickjacking import xframe_options_exempt
from django.views.generic import FormView
from sapl.comissoes.models import Participacao
@ -278,6 +279,22 @@ class LegislaturaCrud(CrudAux):
class UpdateView(CrudAux.UpdateView):
form_class = LegislaturaUpdateForm
class DetailView(CrudAux.DetailView):
def has_permission(self):
return True
@xframe_options_exempt
def get(self, request, *args, **kwargs):
return super().get(request, *args, **kwargs)
class ListView(CrudAux.ListView):
def has_permission(self):
return True
@xframe_options_exempt
def get(self, request, *args, **kwargs):
return super().get(request, *args, **kwargs)
class FiliacaoCrud(MasterDetailCrud):
model = Filiacao
@ -311,9 +328,18 @@ class ParlamentarCrud(Crud):
class DetailView(Crud.DetailView):
def get_template_names(self):
return ['crud/detail.html']\
if self.request.user.has_perm(self.permission(RP_CHANGE))\
else ['parlamentares/parlamentar_perfil_publico.html']
if self.request.user.has_perm(self.permission(RP_CHANGE)):
if 'iframe' not in self.request.GET:
if not self.request.session.get('iframe'):
return ['crud/detail.html']
elif self.request.GET['iframe'] == '0':
return ['crud/detail.html']
return ['parlamentares/parlamentar_perfil_publico.html']
@xframe_options_exempt
def get(self, request, *args, **kwargs):
return super().get(request, *args, **kwargs)
class UpdateView(Crud.UpdateView):
form_class = ParlamentarForm
@ -338,6 +364,10 @@ class ParlamentarCrud(Crud):
template_name = "parlamentares/parlamentares_list.html"
paginate_by = None
@xframe_options_exempt
def get(self, request, *args, **kwargs):
return super().get(request, *args, **kwargs)
def take_legislatura_id(self):
try:
return int(self.request.GET['pk'])
@ -436,10 +466,14 @@ class MesaDiretoraView(FormView):
success_url = reverse_lazy('sapl.parlamentares:mesa_diretora')
def get_template_names(self):
return ['parlamentares/composicaomesa_form.html']\
if self.request.user.has_perm(
'parlamentares.change_composicaomesa')\
else ['parlamentares/public_composicaomesa_form.html']
if self.request.user.has_perm('parlamentares.change_composicaomesa'):
if 'iframe' not in self.request.GET:
if not self.request.session.get('iframe'):
return 'parlamentares/composicaomesa_form.html'
elif self.request.GET['iframe'] == '0':
return 'parlamentares/composicaomesa_form.html'
return 'parlamentares/public_composicaomesa_form.html'
# Essa função avisa quando se pode compor uma Mesa Legislativa
def validation(self, request):
@ -454,6 +488,7 @@ class MesaDiretoraView(FormView):
'legislatura_selecionada': Legislatura.objects.last(),
'cargos_vagos': CargoMesa.objects.all()})
@xframe_options_exempt
def get(self, request, *args, **kwargs):
if (not Legislatura.objects.exists() or

Loading…
Cancel
Save