|
|
@ -1257,30 +1257,25 @@ class TramitacaoCrud(MasterDetailCrud): |
|
|
layout_key = 'TramitacaoUpdate' |
|
|
layout_key = 'TramitacaoUpdate' |
|
|
|
|
|
|
|
|
def form_valid(self, form): |
|
|
def form_valid(self, form): |
|
|
objeto_antigo = Tramitacao.objects.get(pk=self.kwargs['pk']) |
|
|
dict_objeto_antigo = Tramitacao.objects.get(pk=self.kwargs['pk']).__dict__ |
|
|
|
|
|
|
|
|
self.object = form.save() |
|
|
self.object = form.save() |
|
|
objeto_novo = self.object |
|
|
dict_objeto_novo = self.object.__dict__ |
|
|
|
|
|
|
|
|
user = self.request.user |
|
|
user = self.request.user |
|
|
|
|
|
|
|
|
|
|
|
atributos = [ |
|
|
|
|
|
'data_tramitacao', 'unidade_tramitacao_destino_id', 'status_id', 'texto', |
|
|
|
|
|
'data_encaminhamento', 'data_fim_prazo', 'urgente', 'turno' |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
# Se não houve qualquer alteração em um dos dados, mantém o usuário e ip |
|
|
# Se não houve qualquer alteração em um dos dados, mantém o usuário e ip |
|
|
if not( |
|
|
for atributo in atributos: |
|
|
objeto_antigo.data_tramitacao != objeto_novo.data_tramitacao or \ |
|
|
if dict_objeto_antigo[atributo] != dict_objeto_novo[atributo]: |
|
|
objeto_antigo.unidade_tramitacao_destino != objeto_novo.unidade_tramitacao_destino or \ |
|
|
self.object.user = user |
|
|
objeto_antigo.status != objeto_novo.status or \ |
|
|
self.object.ip = get_client_ip(self.request) |
|
|
objeto_antigo.texto != objeto_novo.texto or \ |
|
|
self.object.save() |
|
|
objeto_antigo.data_encaminhamento != objeto_novo.data_encaminhamento or \ |
|
|
break |
|
|
objeto_antigo.data_fim_prazo != objeto_novo.data_fim_prazo or \ |
|
|
|
|
|
objeto_antigo.urgente != objeto_novo.urgente or \ |
|
|
|
|
|
objeto_antigo.turno != objeto_novo.turno |
|
|
|
|
|
): |
|
|
|
|
|
self.object.user = objeto_antigo.user |
|
|
|
|
|
self.object.ip = objeto_antigo.ip |
|
|
|
|
|
else: |
|
|
|
|
|
self.object.user = user |
|
|
|
|
|
self.object.ip = get_client_ip(self.request) |
|
|
|
|
|
self.object.save() |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
try: |
|
|
self.logger.debug("user=" + user.username + ". Tentando enviar Tramitacao (sender={}, post={}, request={}" |
|
|
self.logger.debug("user=" + user.username + ". Tentando enviar Tramitacao (sender={}, post={}, request={}" |
|
|
|