|
|
|
@ -666,6 +666,7 @@ class NotasCreateView(NotaMixin, CreateView): |
|
|
|
return super(NotasCreateView, self).get(request, *args, **kwargs) |
|
|
|
|
|
|
|
def post(self, request, *args, **kwargs): |
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
self.object = None |
|
|
|
try: |
|
|
|
ta_id = kwargs.pop('ta_id') |
|
|
|
@ -683,7 +684,9 @@ class NotasCreateView(NotaMixin, CreateView): |
|
|
|
else: |
|
|
|
return self.form_invalid(form) |
|
|
|
except Exception as e: |
|
|
|
logger.error("- " + str(e)) |
|
|
|
print(e) |
|
|
|
logger.error("- Error post.") |
|
|
|
return HttpResponse("error post") |
|
|
|
|
|
|
|
|
|
|
|
@ -760,7 +763,7 @@ class PublicacaoMixin(CompMixin): |
|
|
|
messages.error(request, _( |
|
|
|
'A funcionalidade de %s está desativada para %s.') % ( |
|
|
|
TipoTextoArticulado._meta.get_field( |
|
|
|
'publicacao_func').verbose_name, |
|
|
|
'publicacao_func').verbose_name, |
|
|
|
ta.tipo_ta.descricao)) |
|
|
|
return redirect(reverse('sapl.compilacao:ta_text', |
|
|
|
kwargs={'ta_id': self.kwargs['ta_id']})) |
|
|
|
@ -1518,6 +1521,7 @@ class ActionDeleteDispositivoMixin(ActionsCommonsMixin): |
|
|
|
return data |
|
|
|
|
|
|
|
def remover_dispositivo(self, base, bloco): |
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
base_ordem = base.ordem |
|
|
|
if base.dispositivo_subsequente or base.dispositivo_substituido: |
|
|
|
p = base.dispositivo_substituido |
|
|
|
@ -1543,6 +1547,7 @@ class ActionDeleteDispositivoMixin(ActionsCommonsMixin): |
|
|
|
p.dispositivos_filhos_set.add(d) |
|
|
|
p.save() |
|
|
|
except Exception as e: |
|
|
|
logger.error("- " + str(e)) |
|
|
|
print(e) |
|
|
|
base.delete() |
|
|
|
else: |
|
|
|
@ -1577,6 +1582,8 @@ class ActionDeleteDispositivoMixin(ActionsCommonsMixin): |
|
|
|
dispositivo_pai=base).first() |
|
|
|
|
|
|
|
if not anterior: |
|
|
|
logger.error("- Não é possível excluir este Dispositivo sem" |
|
|
|
" excluir toda a sua estrutura!!!") |
|
|
|
raise Exception( |
|
|
|
_('Não é possível excluir este Dispositivo sem' |
|
|
|
' excluir toda a sua estrutura!!!')) |
|
|
|
@ -1596,6 +1603,9 @@ class ActionDeleteDispositivoMixin(ActionsCommonsMixin): |
|
|
|
|
|
|
|
for candidato in parents: |
|
|
|
if candidato == base: |
|
|
|
logger.error("- Não é possível excluir este " |
|
|
|
"Dispositivo sem " |
|
|
|
"excluir toda a sua estrutura!!!") |
|
|
|
raise Exception( |
|
|
|
_('Não é possível excluir este ' |
|
|
|
'Dispositivo sem ' |
|
|
|
@ -1631,7 +1641,9 @@ class ActionDeleteDispositivoMixin(ActionsCommonsMixin): |
|
|
|
d.rotulo = d.rotulo_padrao() |
|
|
|
break |
|
|
|
else: |
|
|
|
|
|
|
|
logger.error("- Não é possível excluir este " |
|
|
|
"Dispositivo sem " |
|
|
|
"excluir toda a sua estrutura!!!") |
|
|
|
raise Exception( |
|
|
|
_('Não é possível excluir este ' |
|
|
|
'Dispositivo sem ' |
|
|
|
@ -1677,7 +1689,8 @@ class ActionDeleteDispositivoMixin(ActionsCommonsMixin): |
|
|
|
profundidade=profundidade_base) |
|
|
|
irmao.rotulo = irmao.rotulo_padrao() |
|
|
|
irmao.save() |
|
|
|
except: |
|
|
|
except Exception as e: |
|
|
|
logger.error("- " + str(e)) |
|
|
|
break |
|
|
|
|
|
|
|
irmaos = pai_base.dispositivos_filhos_set.\ |
|
|
|
@ -1794,7 +1807,8 @@ class ActionDeleteDispositivoMixin(ActionsCommonsMixin): |
|
|
|
dr.rotulo = dr.rotulo_padrao() |
|
|
|
try: |
|
|
|
dr.save(clean=base != dr) |
|
|
|
except: |
|
|
|
except Exception as e: |
|
|
|
logger.error("- " + str(e)) |
|
|
|
break |
|
|
|
|
|
|
|
# Pode não ser religavável |
|
|
|
@ -1839,6 +1853,7 @@ class ActionDeleteDispositivoMixin(ActionsCommonsMixin): |
|
|
|
class ActionDispositivoCreateMixin(ActionsCommonsMixin): |
|
|
|
|
|
|
|
def allowed_inserts(self, _base=None): |
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
request = self.request |
|
|
|
try: |
|
|
|
base = Dispositivo.objects.get( |
|
|
|
@ -2092,14 +2107,15 @@ class ActionDispositivoCreateMixin(ActionsCommonsMixin): |
|
|
|
return result |
|
|
|
|
|
|
|
except Exception as e: |
|
|
|
logger.error("- " + str(e)) |
|
|
|
print(e) |
|
|
|
|
|
|
|
return {} |
|
|
|
|
|
|
|
def json_set_dvt(self, context): |
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
# Dispositivo de Vigência do Texto Original e de Dpts Alterados |
|
|
|
dvt = Dispositivo.objects.get(pk=self.kwargs['dispositivo_id']) |
|
|
|
|
|
|
|
if dvt.auto_inserido: |
|
|
|
dvt = dvt.dispositivo_pai |
|
|
|
|
|
|
|
@ -2140,6 +2156,8 @@ class ActionDispositivoCreateMixin(ActionsCommonsMixin): |
|
|
|
return data |
|
|
|
except: |
|
|
|
data = {} |
|
|
|
logger.error("- Ocorreu um erro na atualização do " |
|
|
|
"Dispositivo de Vigência") |
|
|
|
self.set_message(data, |
|
|
|
'success', |
|
|
|
_('Ocorreu um erro na atualização do ' |
|
|
|
@ -2156,6 +2174,7 @@ class ActionDispositivoCreateMixin(ActionsCommonsMixin): |
|
|
|
def json_add_next( |
|
|
|
self, |
|
|
|
context, local_add='json_add_next', create_auto_inserts=True): |
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
try: |
|
|
|
|
|
|
|
dp_auto_insert = None |
|
|
|
@ -2427,6 +2446,7 @@ class ActionDispositivoCreateMixin(ActionsCommonsMixin): |
|
|
|
return data |
|
|
|
|
|
|
|
except Exception as e: |
|
|
|
logger.error("- " + str(e)) |
|
|
|
print(e) |
|
|
|
return {} |
|
|
|
|
|
|
|
@ -2586,6 +2606,7 @@ class ActionsEditMixin(ActionDragAndMoveDispositivoAlteradoMixin, |
|
|
|
mudança, porém, após registro de alteração, a mudança de rótulo |
|
|
|
pode ser feita no editor avançado. |
|
|
|
""" |
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
|
|
data = {} |
|
|
|
data.update({'pk': bloco_alteracao.pk, |
|
|
|
@ -2706,6 +2727,7 @@ class ActionsEditMixin(ActionDragAndMoveDispositivoAlteradoMixin, |
|
|
|
_('Dispositivo de Revogação adicionado com sucesso.')) |
|
|
|
|
|
|
|
except Exception as e: |
|
|
|
logger.error("- " + str(e)) |
|
|
|
print(e) |
|
|
|
|
|
|
|
data.update({'pk': ndp.pk, |
|
|
|
@ -3104,6 +3126,7 @@ class DispositivoEdicaoBasicaView(CompMixin, FormMessagesMixin, UpdateView): |
|
|
|
return 'sapl.compilacao:dispositivo_edit' |
|
|
|
|
|
|
|
def run_actions(self, request): |
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
if 'action' in request.GET and\ |
|
|
|
request.GET['action'] == 'atualiza_rotulo': |
|
|
|
try: |
|
|
|
@ -3131,6 +3154,7 @@ class DispositivoEdicaoBasicaView(CompMixin, FormMessagesMixin, UpdateView): |
|
|
|
d.rotulo = d.rotulo_padrao() |
|
|
|
|
|
|
|
except: |
|
|
|
logger.error("- Ocorreu erro na atualização do rótulo.") |
|
|
|
return True, JsonResponse({'message': str( |
|
|
|
_('Ocorreu erro na atualização do rótulo'))}, safe=False) |
|
|
|
return True, JsonResponse({ |
|
|
|
@ -3220,6 +3244,7 @@ class DispositivoDefinidorVigenciaView(CompMixin, FormMessagesMixin, FormView): |
|
|
|
return context |
|
|
|
|
|
|
|
def post(self, request, *args, **kwargs): |
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
self.object = get_object_or_404(Dispositivo, pk=kwargs['pk']) |
|
|
|
|
|
|
|
form = self.get_form() |
|
|
|
@ -3232,7 +3257,8 @@ class DispositivoDefinidorVigenciaView(CompMixin, FormMessagesMixin, FormView): |
|
|
|
d = Dispositivo.objects.get(pk=item) |
|
|
|
self.object.dispositivos_vigencias_set.add(d) |
|
|
|
return self.form_valid(form) |
|
|
|
except: |
|
|
|
except Exception as e: |
|
|
|
logger.error("- " + str(e)) |
|
|
|
return self.form_invalid(form) |
|
|
|
else: |
|
|
|
return self.form_invalid(form) |
|
|
|
@ -3263,6 +3289,7 @@ class DispositivoEdicaoAlteracaoView(CompMixin, FormMessagesMixin, UpdateView): |
|
|
|
kwargs={'ta_id': self.kwargs['ta_id'], 'pk': self.kwargs['pk']}) |
|
|
|
|
|
|
|
def post(self, request, *args, **kwargs): |
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
self.object = get_object_or_404(Dispositivo, pk=kwargs['pk']) |
|
|
|
|
|
|
|
form = self.get_form() |
|
|
|
@ -3270,7 +3297,8 @@ class DispositivoEdicaoAlteracaoView(CompMixin, FormMessagesMixin, UpdateView): |
|
|
|
try: |
|
|
|
with transaction.atomic(): |
|
|
|
return self.form_valid(form) |
|
|
|
except: |
|
|
|
except Exception as e: |
|
|
|
logger.error('- ' + str(e)) |
|
|
|
return self.form_invalid(form) |
|
|
|
else: |
|
|
|
return self.form_invalid(form) |
|
|
|
|