From 71e04e8bab882327e13bcd1073d7eafdb91a2c9b Mon Sep 17 00:00:00 2001 From: Eduardo Calil Date: Tue, 21 Jun 2016 13:53:44 -0300 Subject: [PATCH] Restringe botoes da tela principal --- sapl/base/urls.py | 4 ++-- sapl/base/views.py | 11 +++++++++++ sapl/parlamentares/views.py | 17 +++++++++++++++-- sapl/templates/base.html | 8 ++++++-- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/sapl/base/urls.py b/sapl/base/urls.py index 9fd6f0dcb..f619423f2 100644 --- a/sapl/base/urls.py +++ b/sapl/base/urls.py @@ -4,13 +4,13 @@ from django.views.generic.base import TemplateView from .apps import AppConfig from .forms import LoginForm -from .views import CasaLegislativaCrud, HelpView +from .views import CasaLegislativaCrud, HelpView, SistemaView app_name = AppConfig.name urlpatterns = [ - url(r'^sistema/', TemplateView.as_view(template_name='sistema.html')), + url(r'^sistema/', SistemaView.as_view()), url(r'^ajuda/(?P\w+)$', HelpView.as_view(), name='help_topic'), url(r'^ajuda/', TemplateView.as_view(template_name='ajuda/index.html'), name='help_base'), diff --git a/sapl/base/views.py b/sapl/base/views.py index cbea94455..f45834d1f 100644 --- a/sapl/base/views.py +++ b/sapl/base/views.py @@ -44,3 +44,14 @@ class HelpView(PermissionRequiredMixin, TemplateView): def get_template_names(self): return ['ajuda/%s.html' % self.kwargs['topic']] + + +class SistemaView(PermissionRequiredMixin, TemplateView): + template_name = 'sistema.html' + permission_required = '' + + def has_perm(self): + if self.request.user.is_superuser: + return True + else: + return False diff --git a/sapl/parlamentares/views.py b/sapl/parlamentares/views.py index 081420ab0..2d24eec0e 100644 --- a/sapl/parlamentares/views.py +++ b/sapl/parlamentares/views.py @@ -19,8 +19,6 @@ from .models import (CargoMesa, Coligacao, ComposicaoColigacao, ComposicaoMesa, NivelInstrucao, Parlamentar, Partido, SessaoLegislativa, SituacaoMilitar, TipoAfastamento, TipoDependente) -DependenteCrud = MasterDetailCrud.build(Dependente, 'parlamentar', '') - class CargoMesaCrud(Crud): model = CargoMesa @@ -78,6 +76,21 @@ class TipoMilitarCrud(Crud): permission_required = permissoes_parlamentares() +class DependenteCrud(MasterDetailCrud): + model = Dependente + parent_field = 'parlamentar' + help_path = '' + + class CreateView(PermissionRequiredMixin, MasterDetailCrud.CreateView): + permission_required = permissoes_parlamentares() + + class UpdateView(PermissionRequiredMixin, MasterDetailCrud.UpdateView): + permission_required = permissoes_parlamentares() + + class DeleteView(PermissionRequiredMixin, MasterDetailCrud.DeleteView): + permission_required = permissoes_parlamentares() + + class MandatoCrud(MasterDetailCrud): model = Mandato parent_field = 'parlamentar' diff --git a/sapl/templates/base.html b/sapl/templates/base.html index 8c5eafc56..276423655 100644 --- a/sapl/templates/base.html +++ b/sapl/templates/base.html @@ -46,13 +46,15 @@ - + {% if user.is_authenticated %} + {% endif %} - + {% if user.is_authenticated %} + {% endif %}