Browse Source

Fix #2088 (#2106)

* Corrige erro na exclusão de dispositivo base inicial

* Fix #2088
pull/2100/merge
Leandro Roberto da Silva 7 years ago
committed by Edward
parent
commit
a767cd1545
  1. 9
      sapl/compilacao/models.py
  2. 19
      sapl/compilacao/views.py
  3. 4
      sapl/rules/apps.py

9
sapl/compilacao/models.py

@ -69,8 +69,15 @@ class BaseModel(models.Model):
def save(self, force_insert=False, force_update=False, using=None,
update_fields=None, clean=True):
if clean:
# método clean não pode ser chamado no caso do save que está sendo
# executado é o save de revision_pre_delete_signal
import inspect
funcs = list(filter(lambda x: x == 'revision_pre_delete_signal',
map(lambda x: x[3], inspect.stack())))
if clean and not funcs:
self.clean()
return models.Model.save(
self,
force_insert=force_insert,

19
sapl/compilacao/views.py

@ -15,7 +15,7 @@ from django.db import connection, transaction
from django.db.models import Q
from django.db.utils import IntegrityError
from django.http.response import (HttpResponse, HttpResponseRedirect,
JsonResponse)
JsonResponse, Http404)
from django.shortcuts import get_object_or_404, redirect
from django.utils.dateparse import parse_date
from django.utils.encoding import force_text
@ -51,7 +51,6 @@ from sapl.compilacao.utils import (DISPOSITIVO_SELECT_RELATED,
from sapl.crud.base import Crud, CrudAux, CrudListView, make_pagination
from sapl.settings import BASE_DIR
TipoNotaCrud = CrudAux.build(TipoNota, 'tipo_nota')
TipoVideCrud = CrudAux.build(TipoVide, 'tipo_vide')
TipoPublicacaoCrud = CrudAux.build(TipoPublicacao, 'tipo_publicacao')
@ -211,8 +210,12 @@ class CompMixin(PermissionRequiredMixin):
@property
def ta(self):
try:
ta = TextoArticulado.objects.get(
pk=self.kwargs.get('ta_id', self.kwargs.get('pk', 0)))
except TextoArticulado.DoesNotExist:
raise Http404()
return ta
def get_context_data(self, **kwargs):
@ -1480,12 +1483,18 @@ class ActionDeleteDispositivoMixin(ActionsCommonsMixin):
).first()
data = {}
if base_anterior:
data = self.get_json_for_refresh(base_anterior)
else:
if not base_anterior or base == base.get_raiz():
base_anterior = base.get_nivel_zero_anterior()
if not base_anterior:
base_anterior = base
data = self.get_json_for_refresh(base_anterior)
if base == base_anterior:
data['pk'] = base.pk
self.set_message(data, 'danger', _(
'Base Inicial não pode ser removida!'), modal=True)
else:
if base != base.get_raiz():
data['pai'] = [base.get_raiz().pk]
if ta_base.id != int(self.kwargs['ta_id']):

4
sapl/rules/apps.py

@ -1,15 +1,15 @@
from builtins import LookupError
import django
import reversion
from django.apps import apps
from django.contrib.auth import get_user_model
from django.contrib.auth.management import _get_all_permissions
from django.core import exceptions
from django.db import models, router
from django.db.utils import DEFAULT_DB_ALIAS
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import string_concat
from django.utils.translation import ugettext_lazy as _
import reversion
from sapl.rules import (SAPL_GROUP_ADMINISTRATIVO, SAPL_GROUP_COMISSOES,
SAPL_GROUP_GERAL, SAPL_GROUP_MATERIA, SAPL_GROUP_NORMA,

Loading…
Cancel
Save