Browse Source

Fix #394

pull/663/head
Eduardo Calil 8 years ago
parent
commit
19706ecbae
  1. 14
      sapl/base/templatetags/common_tags.py
  2. 60
      sapl/protocoloadm/views.py
  3. 5
      sapl/templates/base.html
  4. 10
      sapl/templates/protocoloadm/documentoadministrativo_detail.html
  5. 10
      sapl/templates/protocoloadm/tramitacaoadministrativo_detail.html

14
sapl/base/templatetags/common_tags.py

@ -1,7 +1,9 @@
from compressor.utils import get_class
from django import template
from sapl.base.models import AppConfig
from sapl.parlamentares.models import Filiacao
from sapl.utils import permissoes_adm
register = template.Library()
@ -85,6 +87,18 @@ def get_delete_perm(value, arg):
return perm.__contains__(nome_app + can_delete)
@register.filter
def get_doc_adm_template_perms(user):
app_config = AppConfig.objects.last()
if app_config.documentos_administrativos == 'O':
return True
elif user.has_perms(permissoes_adm()):
return True
else:
return False
@register.filter
def ver_menu_sistema_perm(value):
u = value

60
sapl/protocoloadm/views.py

@ -17,7 +17,8 @@ from django_filters.views import FilterView
import sapl.crud.base
from sapl.base.models import AppConfig
from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView,
CrudDeleteView, CrudListView, CrudUpdateView,
CrudDetailView, CrudDeleteView,
CrudListView, CrudUpdateView,
make_pagination)
from sapl.crud.masterdetail import MasterDetailCrud
from sapl.materia.models import TipoMateriaLegislativa
@ -62,6 +63,30 @@ class DocumentoAdministrativoCrud(Crud):
class DeleteView(PermissionRequiredMixin, CrudDeleteView):
permission_required = permissoes_adm()
class ListView(PermissionRequiredMixin, CrudListView):
permission_required = permissoes_adm()
def has_permission(self):
app_config = AppConfig.objects.last()
if app_config.documentos_administrativos == 'O':
return True
else:
perms = self.get_permission_required()
return self.request.user.has_perms(perms)
class DetailView(PermissionRequiredMixin, CrudDetailView):
permission_required = permissoes_adm()
def has_permission(self):
app_config = AppConfig.objects.last()
if app_config.documentos_administrativos == 'O':
return True
else:
perms = self.get_permission_required()
return self.request.user.has_perms(perms)
class StatusTramitacaoAdministrativoCrud(Crud):
model = StatusTramitacaoAdministrativo
@ -373,6 +398,15 @@ class PesquisarDocumentoAdministrativoView(PermissionRequiredMixin,
paginate_by = 10
permission_required = permissoes_adm()
def has_permission(self):
app_config = AppConfig.objects.last()
if app_config.documentos_administrativos == 'O':
return True
else:
perms = self.get_permission_required()
return self.request.user.has_perms(perms)
def get_filterset_kwargs(self, filterset_class):
super(PesquisarDocumentoAdministrativoView,
self).get_filterset_kwargs(filterset_class)
@ -574,6 +608,9 @@ class TramitacaoAdmCrud(MasterDetailCrud):
form_class = TramitacaoAdmEditForm
permission_required = permissoes_adm()
class DeleteView(PermissionRequiredMixin, MasterDetailCrud.DeleteView):
permission_required = permissoes_adm()
class ListView(PermissionRequiredMixin, MasterDetailCrud.ListView):
permission_required = permissoes_adm()
@ -582,6 +619,27 @@ class TramitacaoAdmCrud(MasterDetailCrud):
kwargs = {self.crud.parent_field: self.kwargs['pk']}
return qs.filter(**kwargs).order_by('-id')
def has_permission(self):
app_config = AppConfig.objects.last()
if app_config.documentos_administrativos == 'O':
return True
else:
perms = self.get_permission_required()
return self.request.user.has_perms(perms)
class DetailView(PermissionRequiredMixin, MasterDetailCrud.DetailView):
permission_required = permissoes_adm()
def has_permission(self):
app_config = AppConfig.objects.last()
if app_config.documentos_administrativos == 'O':
return True
else:
perms = self.get_permission_required()
return self.request.user.has_perms(perms)
def get_nome_autor(request):
nome_autor = ''

5
sapl/templates/base.html

@ -62,16 +62,19 @@
{# <li class="nav__sub-item"><a class="nav__sub-link" href="{% url 'sapl.materia:proposicao' %}">Proposições</a></li> #}
</ul>
</li>
{% endif %}
{% if user|get_doc_adm_template_perms %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Documentos Administrativos <span class="caret"></span></a>
<ul class="dropdown-menu">
<li class="nav__sub-item"><a class="nav__sub-link" href="{% url 'sapl.protocoloadm:pesq_doc_adm' %}">Pesquisar Documento Administrativo</a></li>
</ul>
</li>
{% endif %}
<li class="dropdown">
{% endif %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Atividade Legislativa <span class="caret"></span></a>

10
sapl/templates/protocoloadm/documentoadministrativo_detail.html

@ -1,9 +1,15 @@
{% extends "crud/detail.html" %}
{% load i18n %}
{% block actions %}
{% load common_tags %}
<div class="actions btn-group pull-right" role="group">
<a href="{% url 'sapl.protocoloadm:tramitacaoadministrativo_list' object.pk %}" class="btn btn-default">{% trans 'Tramitações' %}</a>
<a href="{{ view.update_url }}" class="btn btn-default">{% trans 'Editar' %}</a>
<a href="{{ view.delete_url }}" class="btn btn-default">{% trans 'Excluir' %}</a>
{% if perms|get_change_perm:view %}
<a href="{{ view.update_url }}" class="btn btn-default">{% trans 'Editar' %}</a>
{% endif %}
{% if perms|get_delete_perm:view %}
<a href="{{ view.delete_url }}" class="btn btn-default">{% trans 'Excluir' %}</a>
{% endif %}
</div>
{% endblock actions %}

10
sapl/templates/protocoloadm/tramitacaoadministrativo_detail.html

@ -1,9 +1,15 @@
{% extends "crud/detail.html" %}
{% load i18n %}
{% block actions %}
{% load common_tags %}
<div class="actions btn-group pull-right" role="group">
<a href="{% url 'protocoloadm:documentoadministrativo_detail' root_pk %}" class="btn btn-default">{% trans 'Início' %}</a>
<a href="{{ view.update_url }}" class="btn btn-default">{% trans 'Editar' %}</a>
<a href="{{ view.delete_url }}" class="btn btn-default">{% trans 'Excluir' %}</a>
{% if perms|get_change_perm:view %}
<a href="{{ view.update_url }}" class="btn btn-default">{% trans 'Editar' %}</a>
{% endif %}
{% if perms|get_delete_perm:view %}
<a href="{{ view.delete_url }}" class="btn btn-default">{% trans 'Excluir' %}</a>
{% endif %}
</div>
{% endblock actions %}
Loading…
Cancel
Save