Browse Source

HOT-FIX problema com permissão em legislação citada

Foi apresentado na lista GITEC um problema com permissão na aba
Legislação Citada de matérias legislativas. O código removido neste
commit se tornou irrelevante depois que o mapa de regras foi criado (app
rule)
pull/1642/head
LeandroRoberto 7 years ago
parent
commit
2332706ffc
  1. 50
      sapl/materia/views.py
  2. 2
      sapl/rules/apps.py

50
sapl/materia/views.py

@ -959,7 +959,6 @@ class TramitacaoCrud(MasterDetailCrud):
ultima_tramitacao.unidade_tramitacao_destino)] ultima_tramitacao.unidade_tramitacao_destino)]
return context return context
def form_valid(self, form): def form_valid(self, form):
self.object = form.save() self.object = form.save()
@ -1197,55 +1196,6 @@ class LegislacaoCitadaCrud(MasterDetailCrud):
return reverse('%s:%s' % (namespace, self.url_name(suffix)), return reverse('%s:%s' % (namespace, self.url_name(suffix)),
args=args) args=args)
def has_permission(self):
perms = self.get_permission_required()
# Torna a view pública se não possuir conteudo
# no atributo permission_required
return self.request.user.has_module_perms('materia')\
if len(perms) else True
def permission(self, rad):
return '%s%s%s' % ('norma' if rad.endswith('_') else '',
rad,
self.model_name if rad.endswith('_') else '')
@property
def detail_create_url(self):
obj = self.crud if hasattr(self, 'crud') else self
if self.request.user.has_module_perms('materia'):
parent_field = obj.parent_field.split('__')[0]
parent_object = getattr(self.object, parent_field)
root_pk = parent_object.pk
return self.resolve_url(ACTION_CREATE, args=(root_pk,))
return ''
@property
def list_url(self):
return self.resolve_url(ACTION_LIST, args=(self.kwargs['pk'],))\
if self.request.user.has_module_perms('materia') else ''
@property
def create_url(self):
return self.resolve_url(ACTION_CREATE, args=(self.kwargs['pk'],))\
if self.request.user.has_module_perms('materia') else ''
@property
def detail_url(self):
return self.resolve_url(ACTION_DETAIL, args=(self.object.id,))\
if self.request.user.has_module_perms('materia') else ''
@property
def update_url(self):
return self.resolve_url(ACTION_UPDATE, args=(self.kwargs['pk'],))\
if self.request.user.has_module_perms('materia') else ''
@property
def delete_url(self):
return self.resolve_url(ACTION_DELETE, args=(self.object.id,))\
if self.request.user.has_module_perms('materia') else ''
class CreateView(MasterDetailCrud.CreateView): class CreateView(MasterDetailCrud.CreateView):
form_class = LegislacaoCitadaForm form_class = LegislacaoCitadaForm

2
sapl/rules/apps.py

@ -127,7 +127,7 @@ def create_proxy_permissions(
def update_groups(app_config, verbosity=2, interactive=True, def update_groups(app_config, verbosity=2, interactive=True,
using=DEFAULT_DB_ALIAS, cria_usuarios_padrao=False, using=DEFAULT_DB_ALIAS, cria_usuarios_padrao=True,
**kwargs): **kwargs):
if app_config != AppConfig and not isinstance(app_config, AppConfig): if app_config != AppConfig and not isinstance(app_config, AppConfig):

Loading…
Cancel
Save