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