Browse Source

Faz as permissoes do app painel

pull/506/head
Eduardo Calil 9 years ago
parent
commit
8c58818ab7
  1. 13
      sapl/painel/views.py
  2. 20
      scripts/inicializa_grupos_autorizacoes.py

13
sapl/painel/views.py

@ -1,5 +1,6 @@
from datetime import date from datetime import date
from django.contrib.auth.decorators import user_passes_test
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from django.http import HttpResponse, JsonResponse from django.http import HttpResponse, JsonResponse
from django.shortcuts import render from django.shortcuts import render
@ -11,12 +12,18 @@ from sapl.parlamentares.models import Filiacao
from sapl.sessao.models import (ExpedienteMateria, OrdemDia, PresencaOrdemDia, from sapl.sessao.models import (ExpedienteMateria, OrdemDia, PresencaOrdemDia,
RegistroVotacao, SessaoPlenaria, RegistroVotacao, SessaoPlenaria,
SessaoPlenariaPresenca, VotoParlamentar) SessaoPlenariaPresenca, VotoParlamentar)
from sapl.utils import permissoes_painel
from .models import Cronometro from .models import Cronometro
CronometroPainelCrud = Crud.build(Cronometro, '') CronometroPainelCrud = Crud.build(Cronometro, '')
def check_permission(user):
return user.has_perms(permissoes_painel())
@user_passes_test(check_permission)
def controlador_painel(request): def controlador_painel(request):
painel_created = Painel.objects.get_or_create(data_painel=date.today()) painel_created = Painel.objects.get_or_create(data_painel=date.today())
@ -37,23 +44,28 @@ def controlador_painel(request):
return render(request, 'painel/controlador.html', context) return render(request, 'painel/controlador.html', context)
@user_passes_test(check_permission)
def painel_view(request, pk): def painel_view(request, pk):
context = {'head_title': str(_('Painel Plenário')), 'sessao_id': pk} context = {'head_title': str(_('Painel Plenário')), 'sessao_id': pk}
return render(request, 'painel/index.html', context) return render(request, 'painel/index.html', context)
@user_passes_test(check_permission)
def painel_mensagem_view(request): def painel_mensagem_view(request):
return render(request, 'painel/mensagem.html') return render(request, 'painel/mensagem.html')
@user_passes_test(check_permission)
def painel_parlamentar_view(request): def painel_parlamentar_view(request):
return render(request, 'painel/parlamentares.html') return render(request, 'painel/parlamentares.html')
@user_passes_test(check_permission)
def painel_votacao_view(request): def painel_votacao_view(request):
return render(request, 'painel/votacao.html') return render(request, 'painel/votacao.html')
@user_passes_test(check_permission)
def cronometro_painel(request): def cronometro_painel(request):
request.session[request.GET['tipo']] = request.GET['action'] request.session[request.GET['tipo']] = request.GET['action']
return HttpResponse({}) return HttpResponse({})
@ -316,6 +328,7 @@ def get_votos_nominal(response, materia):
return response return response
@user_passes_test(check_permission)
def get_dados_painel(request, pk): def get_dados_painel(request, pk):
sessao = SessaoPlenaria.objects.get(id=pk) sessao = SessaoPlenaria.objects.get(id=pk)
cronometro_discurso = get_cronometro_status(request, 'discurso') cronometro_discurso = get_cronometro_status(request, 'discurso')

20
scripts/inicializa_grupos_autorizacoes.py

@ -17,8 +17,19 @@ def cria_grupos_permissoes():
op_norma = Group.objects.get_or_create(name="Operador de Norma Jurídica") op_norma = Group.objects.get_or_create(name="Operador de Norma Jurídica")
op_materia = Group.objects.get_or_create( op_materia = Group.objects.get_or_create(
name="Operador de Matéria Legislativa") name="Operador de Matéria Legislativa")
op_painel = Group.objects.get_or_create(name="Operador de Painel")
op_autor = Group.objects.get_or_create(name="Autor") op_autor = Group.objects.get_or_create(name="Autor")
op_geral = op_geral[0]
op_prot = op_prot[0]
op_sessao = op_sessao[0]
op_comissao = op_comissao[0]
op_adm = op_adm[0]
op_norma = op_norma[0]
op_materia = op_materia[0]
op_painel = op_painel[0]
op_autor = op_autor[0]
# Base # Base
permissao_add_cl = Permission.objects.get( permissao_add_cl = Permission.objects.get(
@ -76,6 +87,11 @@ def cria_grupos_permissoes():
cts = ContentType.objects.filter(app_label='sessao') cts = ContentType.objects.filter(app_label='sessao')
perms_sessao = list(Permission.objects.filter(content_type__in=cts)) perms_sessao = list(Permission.objects.filter(content_type__in=cts))
# Painel
cts = ContentType.objects.filter(app_label='painel')
perms_painel = list(Permission.objects.filter(content_type__in=cts))
# Autor # Autor
perms_autor = Permission.objects.get(name="Can add Proposição") perms_autor = Permission.objects.get(name="Can add Proposição")
@ -104,6 +120,10 @@ def cria_grupos_permissoes():
for p in perms_materia: for p in perms_materia:
op_materia.permissions.add(p) op_materia.permissions.add(p)
# Configura Permissoes Operador de Painel
for p in perms_painel:
op_painel.permissions.add(p)
# Configura Permissoes Autor # Configura Permissoes Autor
op_autor.permissions.add(perms_autor) op_autor.permissions.add(perms_autor)

Loading…
Cancel
Save