Browse Source

Resolve alguns problemas apontados pelo Leandro

pull/505/head
Eduardo Calil 9 years ago
committed by LeandroRoberto
parent
commit
134c22b1c0
  1. 8
      sapl/comissoes/views.py
  2. 2
      sapl/materia/views.py
  3. 4
      sapl/parlamentares/models.py
  4. 21
      sapl/parlamentares/views.py
  5. 2
      sapl/sessao/views.py
  6. 2
      sapl/templates/base.html
  7. 8
      sapl/templates/mesa_diretora/mesa_diretora.html
  8. 4
      sapl/utils.py

8
sapl/comissoes/views.py

@ -95,7 +95,7 @@ class ParticipacaoCrud(MasterDetailCrud):
def cancel_url(self):
return pegar_url_composicao(self.kwargs['pk'])
class BaseMixin(PermissionRequiredMixin, CrudBaseMixin):
class BaseMixin(PermissionRequiredMixin, MasterDetailCrud.BaseMixin):
permission_required = permissoes_comissoes()
list_field_names = ['composicao', 'parlamentar', 'cargo']
@ -114,13 +114,13 @@ class ComposicaoCrud(MasterDetailCrud):
context['participacoes'] = composicao.participacao_set.all()
return self.render_to_response(context)
class CreateView(PermissionRequiredMixin, MasterDetailCrud.DetailView):
class CreateView(PermissionRequiredMixin, MasterDetailCrud.CreateView):
permission_required = permissoes_comissoes()
class UpdateView(PermissionRequiredMixin, MasterDetailCrud.DetailView):
class UpdateView(PermissionRequiredMixin, MasterDetailCrud.UpdateView):
permission_required = permissoes_comissoes()
class DeleteView(PermissionRequiredMixin, MasterDetailCrud.DetailView):
class DeleteView(PermissionRequiredMixin, MasterDetailCrud.DeleteView):
permission_required = permissoes_comissoes()

2
sapl/materia/views.py

@ -233,7 +233,7 @@ class RelatoriaCrud(MasterDetailCrud):
permission_required = permissoes_materia()
form_class = RelatoriaForm
class DeleteView(PermissionRequiredMixin, CrudDeleteView):
class DeleteView(PermissionRequiredMixin, MasterDetailCrud.DeleteView):
permission_required = permissoes_materia()

4
sapl/parlamentares/models.py

@ -40,7 +40,9 @@ class SessaoLegislativa(models.Model):
('E', 'extraordinaria', _('Extraordinária')),
)
legislatura = models.ForeignKey(Legislatura, verbose_name=Legislatura)
legislatura = models.ForeignKey(
Legislatura,
verbose_name=Legislatura._meta.verbose_name)
numero = models.PositiveIntegerField(verbose_name=_('Número'))
tipo = models.CharField(
max_length=1, verbose_name=_('Tipo'), choices=TIPO_SESSAO_CHOICES)

21
sapl/parlamentares/views.py

@ -1,5 +1,8 @@
from django.contrib import messages
from django.contrib.auth.decorators import user_passes_test
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from django.core.urlresolvers import reverse_lazy
from django.shortcuts import redirect
from django.utils.datastructures import MultiValueDictKeyError
@ -264,10 +267,20 @@ class ParlamentarCrud(Crud):
return context
class MesaDiretoraView(PermissionRequiredMixin, FormView):
def check_permission_mesa(request):
lista_permissoes = []
cts = ContentType.objects.filter(app_label='parlamentares')
cts = cts.filter(model__icontains='mesa')
perms = list(Permission.objects.filter(content_type__in=cts))
for p in perms:
lista_permissoes.append('parlamentares.' + p.codename)
return request.user.has_perms(set(lista_permissoes))
class MesaDiretoraView(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
def validation(self, request):
@ -317,7 +330,7 @@ class MesaDiretoraView(PermissionRequiredMixin, FormView):
})
def post(self, request, *args, **kwargs):
if 'Incluir' in request.POST:
if 'Incluir' in request.POST and check_permission_mesa(request):
if (not Legislatura.objects.all() or
not SessaoLegislativa.objects.all()):
@ -334,7 +347,7 @@ class MesaDiretoraView(PermissionRequiredMixin, FormView):
return redirect('sapl.parlamentares:mesa_diretora')
elif 'Excluir' in request.POST:
elif 'Excluir' in request.POST and check_permission_mesa(request):
if (not Legislatura.objects.all() or
not SessaoLegislativa.objects.all()):

2
sapl/sessao/views.py

@ -314,7 +314,7 @@ class PresencaMixin:
class PresencaView(PermissionRequiredMixin,
FormMixin,
PresencaMixin,
SessaoCrud.DetailView):
SessaoCrud.CrudDetailView):
template_name = 'sessao/presenca.html'
form_class = PresencaForm
model = SessaoPlenaria

2
sapl/templates/base.html

@ -54,7 +54,7 @@
<li class="nav__sub-item"><a class="nav__sub-link" href="{% url 'sapl.parlamentares:parlamentar_list' %}">Parlamentares</a></li>
</ul>
</li>
{% if user.is_authenticated %}
{% if perms.protocoloadm %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Protocolo <span class="caret"></span></a>
<ul class="dropdown-menu">

8
sapl/templates/mesa_diretora/mesa_diretora.html

@ -47,10 +47,16 @@
<div class="col-md-4" align="center">
<br /><br />
{% if cargos_vagos %} <input type="submit" name="Incluir" Value="Incluir" class="btn btn-primary" /> {% endif %}
{% if cargos_vagos %}
{% if perms.parlamentares.add_cargomesa or perms.parlamentares.add_composicaomesa %}
<input type="submit" name="Incluir" Value="Incluir" class="btn btn-primary" />
{% endif %}
{% endif %}
<br />
<br />
{% if perms.parlamentares.add_cargomesa or perms.parlamentares.add_composicaomesa %}
<input type="submit" name="Excluir" Value="Excluir" class="btn btn-danger" />
{% endif %}
</div>
{% if cargos_vagos %}

4
sapl/utils.py

@ -261,8 +261,8 @@ def permissoes_parlamentares():
def permissoes_protocoloadm():
lista_permissoes = []
cts = ContentType.objects.filter(app_label='protocoloadm')
perms_protocolo = list(Permission.objects.filter(content_type__in=cts))
perms_protocolo = Permission.objects.filter(
group__name='Operador de Protocolo')
for p in perms_protocolo:
lista_permissoes.append('protocoloadm.' + p.codename)
return set(lista_permissoes)

Loading…
Cancel
Save