Browse Source

ajusta alg definções de permissões em protocolo

pull/781/head
LeandroRoberto 8 years ago
parent
commit
7f59dcf728
  1. 19
      sapl/protocoloadm/migrations/0005_auto_20161027_1741.py
  2. 3
      sapl/protocoloadm/models.py
  3. 21
      sapl/protocoloadm/views.py
  4. 3
      sapl/rules/map_rules.py
  5. 9
      sapl/utils.py

19
sapl/protocoloadm/migrations/0005_auto_20161027_1741.py

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-10-27 17:41
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('protocoloadm', '0004_auto_20161023_1444'),
]
operations = [
migrations.AlterModelOptions(
name='protocolo',
options={'permissions': (('action_anular_protocolo', 'Permissão para Anular Protocolo'),), 'verbose_name': 'Protocolo', 'verbose_name_plural': 'Protocolos'},
),
]

3
sapl/protocoloadm/models.py

@ -153,6 +153,9 @@ class Protocolo(models.Model):
class Meta:
verbose_name = _('Protocolo')
verbose_name_plural = _('Protocolos')
permissions = (
('action_anular_protocolo', _('Permissão para Anular Protocolo')),
)
class StatusTramitacaoAdministrativo(models.Model):

21
sapl/protocoloadm/views.py

@ -12,12 +12,12 @@ from django.views.generic import CreateView, DetailView, FormView, ListView
from django.views.generic.base import TemplateView
from django_filters.views import FilterView
from sapl.base.apps import AppConfig as AppsAppConfig
from sapl.base.models import AppConfig
from sapl.crud.base import Crud, CrudAux, MasterDetailCrud, make_pagination
from sapl.materia.models import TipoMateriaLegislativa
from sapl.protocoloadm.apps import AppConfig
from sapl.utils import (create_barcode, get_client_ip, permissoes_adm,
permissoes_protocoloadm)
permissoes_protocoloadm, permission_required_for_app)
import sapl
from .forms import (AnularProcoloAdmForm, DocumentoAcessorioAdministrativoForm,
DocumentoAdministrativoFilterSet,
@ -28,6 +28,7 @@ from .models import (DocumentoAcessorioAdministrativo, DocumentoAdministrativo,
Protocolo, StatusTramitacaoAdministrativo,
TipoDocumentoAdministrativo, TramitacaoAdministrativo)
TipoDocumentoAdministrativoCrud = CrudAux.build(
TipoDocumentoAdministrativo, '')
@ -44,11 +45,11 @@ DocumentoAcessorioAdministrativoCrud = Crud.build(
class DocumentoAdministrativoMixin:
def has_permission(self):
app_config = AppConfig.objects.last()
app_config = sapl.base.models.AppConfig.objects.last()
if app_config and app_config.documentos_administrativos == 'O':
return True
return self.request.user.has_module_perms(AppsAppConfig.label)
return self.request.user.has_module_perms(sapl.base.models.AppConfig.label)
class DocumentoAdministrativoCrud(Crud):
@ -82,7 +83,7 @@ class ProtocoloPesquisaView(PermissionRequiredMixin, FilterView):
model = Protocolo
filterset_class = ProtocoloFilterSet
paginate_by = 10
permission_required = permissoes_protocoloadm()
permission_required = ('protocoloadm.list_protocolo',)
def get_filterset_kwargs(self, filterset_class):
super(ProtocoloPesquisaView,
@ -143,7 +144,7 @@ class ProtocoloListView(PermissionRequiredMixin, ListView):
context_object_name = 'protocolos'
model = Protocolo
paginate_by = 10
permission_required = permissoes_protocoloadm()
permission_required = ('protocoloadm.list_protocolo',)
def get_queryset(self):
kwargs = self.request.session['kwargs']
@ -204,7 +205,8 @@ class ProtocoloDocumentoView(PermissionRequiredMixin,
f = form.save(commit=False)
try:
numeracao = AppConfig.objects.last().sequencia_numeracao
numeracao = sapl.base.models.AppConfig.objects.last(
).sequencia_numeracao
except AttributeError:
msg = _('É preciso definir a sequencia de ' +
'numeração na tabelas auxiliares!')
@ -326,7 +328,8 @@ class ProtocoloMateriaView(PermissionRequiredMixin, CreateView):
def form_valid(self, form):
try:
numeracao = AppConfig.objects.last().sequencia_numeracao
numeracao = sapl.base.models.AppConfig.objects.last(
).sequencia_numeracao
except AttributeError:
msg = _('É preciso definir a sequencia de ' +
'numeração na tabelas auxiliares!')

3
sapl/rules/map_rules.py

@ -36,7 +36,8 @@ rules_group_administrativo = {
rules_group_protocolo = {
'group': SAPL_GROUP_PROTOCOLO,
'rules': [
(protocoloadm.Protocolo, __base__),
(protocoloadm.Protocolo, __base__ + [
'action_anular_protocolo']),
(protocoloadm.DocumentoAdministrativo, __listdetailchange__),
(protocoloadm.DocumentoAcessorioAdministrativo, __listdetailchange__),

9
sapl/utils.py

@ -1,14 +1,12 @@
import hashlib
import logging
from datetime import date
from functools import wraps
from unicodedata import normalize as unicodedata_normalize
import hashlib
import hashlib
import logging
import logging
import re
import magic
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Button
from django import forms
@ -23,12 +21,13 @@ from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import PermissionDenied, ValidationError
from django.utils.translation import ugettext_lazy as _
from floppyforms import ClearableFileInput
import magic
import magic
from sapl.crispy_layout_mixin import SaplFormLayout, form_actions, to_row
from sapl.settings import BASE_DIR
sapl_logger = logging.getLogger(BASE_DIR.name)

Loading…
Cancel
Save