From 72ee63fc364b0a1239af0646395d891781200fa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ses=C3=B3stris=20Vieira?= Date: Thu, 9 Sep 2021 10:15:23 -0300 Subject: [PATCH] =?UTF-8?q?Adiciona=20informa=C3=A7=C3=B5es=20de=20importa?= =?UTF-8?q?=C3=A7=C3=A3o=20no=20Conv=C3=AAnio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi/apps/convenios/admin.py | 9 ++++-- .../migrations/0016_auto_20210909_0732.py | 26 +++++++++++++++++ sigi/apps/convenios/models.py | 29 ++++++++++++++++++- sigi/apps/convenios/views.py | 5 ++++ 4 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 sigi/apps/convenios/migrations/0016_auto_20210909_0732.py diff --git a/sigi/apps/convenios/admin.py b/sigi/apps/convenios/admin.py index b744c13..328f46f 100644 --- a/sigi/apps/convenios/admin.py +++ b/sigi/apps/convenios/admin.py @@ -58,11 +58,14 @@ class ConvenioAdmin(BaseModelAdmin): {'fields': ('servico_gestao', 'servidor_gestao',)} ), (_(u'Datas'), - {'fields': ('data_retorno_assinatura', 'data_termino_vigencia', - 'data_pub_diario',)} + {'fields': ('data_retorno_assinatura', 'data_termino_vigencia', + 'data_pub_diario',)} ), + (_(u'Gescon'), + {'fields': ('atualizacao_gescon', 'observacao_gescon',)} + ), ) - readonly_fields = ('data_sigi',) + readonly_fields = ('data_sigi', 'atualizacao_gescon', 'observacao_gescon',) actions = ['adicionar_convenios'] inlines = (AnexosInline,) list_display = ('num_convenio', 'casa_legislativa', 'get_uf', diff --git a/sigi/apps/convenios/migrations/0016_auto_20210909_0732.py b/sigi/apps/convenios/migrations/0016_auto_20210909_0732.py new file mode 100644 index 0000000..9c98cbc --- /dev/null +++ b/sigi/apps/convenios/migrations/0016_auto_20210909_0732.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('convenios', '0015_remove_convenio_search_text'), + ] + + operations = [ + migrations.AddField( + model_name='convenio', + name='atualizacao_gescon', + field=models.DateTimeField(null=True, verbose_name='Data de atualiza\xe7\xe3o pelo Gescon', blank=True), + preserve_default=True, + ), + migrations.AddField( + model_name='convenio', + name='observacao_gescon', + field=models.TextField(verbose_name='Observa\xe7\xf5es da atualiza\xe7\xe3o do Gescon', blank=True), + preserve_default=True, + ), + ] diff --git a/sigi/apps/convenios/models.py b/sigi/apps/convenios/models.py index 65e5b56..b4dfc79 100644 --- a/sigi/apps/convenios/models.py +++ b/sigi/apps/convenios/models.py @@ -181,6 +181,15 @@ class Convenio(models.Model): ) conveniada = models.BooleanField(default=False) equipada = models.BooleanField(default=False) + atualizacao_gescon = models.DateTimeField( + _(u"Data de atualização pelo Gescon"), + blank=True, + null=True + ) + observacao_gescon = models.TextField( + _(u"Observações da atualização do Gescon"), + blank=True + ) def get_status(self): if self.status and self.status.cancela: @@ -628,13 +637,18 @@ class Gescon(models.Model): observacao=contrato['objeto'], data_retorno_assinatura=contrato['inicioVigencia'], data_termino_vigencia=contrato['terminoVigencia'], - data_pub_diario=contrato['publicacao'] + data_pub_diario=contrato['publicacao'], + atualizacao_gescon=datetime.now(), + observacao_gescon=_(u"Importado integralmente do" + u"Gescon") ) convenio.save() novos += 1 continue elif chk == 1: convenio = convenios.get() + convenio.atualizacao_gescon = datetime.now() + convenio.observacao_gescon = '' if convenio.casa_legislativa != orgao: self.add_message( _(u"\tO órgao no convênio {url} diverge do que " @@ -647,6 +661,10 @@ class Gescon(models.Model): nome=contrato['nomeFornecedor'] ) ) + convenio.observacao_gescon = _( + u'ERRO: Órgão diverge do Gescon. Não atualizado!' + ) + convenio.save() erros += 1 continue @@ -666,6 +684,9 @@ class Gescon(models.Model): ) ) convenio.num_processo_sf = sigad + convenio.observacao_gescon += _( + u"Número do SIGAD atualizado.\n" + ) alertas += 1 if convenio.num_convenio != numero: @@ -685,10 +706,16 @@ class Gescon(models.Model): ) ) convenio.num_convenio = numero + convenio.observacao_gescon += _( + u"Número do convênio atualizado.\n" + ) alertas += 1 if contrato['objeto'] not in convenio.observacao: convenio.observacao += "\n" + contrato['objeto'] + convenio.observacao_gescon += _( + u"Observação atualizada.\n" + ) convenio.data_sigad = contrato['assinatura'] convenio.data_retorno_assinatura = contrato[ diff --git a/sigi/apps/convenios/views.py b/sigi/apps/convenios/views.py index 61aa3bf..dd21f0e 100644 --- a/sigi/apps/convenios/views.py +++ b/sigi/apps/convenios/views.py @@ -2,6 +2,7 @@ import csv import datetime +from django.http.response import HttpResponseForbidden import ho.pisa as pisa from django.conf import settings from django.core.paginator import Paginator, InvalidPage, EmptyPage @@ -373,7 +374,11 @@ def export_csv(request): return response +@login_required def importar_gescon(request): + if not request.user.is_superuser: + return HttpResponseForbidden() + action = request.GET.get('action', "") gescon = Gescon.load()