Browse Source

Fixes #94

pull/126/head
Sesostris Vieira 3 years ago
parent
commit
b1d7e50346
  1. 14
      sigi/apps/convenios/admin.py
  2. 20
      sigi/apps/convenios/migrations/0017_convenio_id_contrato_gescon.py
  3. 17
      sigi/apps/convenios/models.py

14
sigi/apps/convenios/admin.py

@ -62,10 +62,10 @@ class ConvenioAdmin(BaseModelAdmin):
'data_pub_diario',)}
),
(_(u'Gescon'),
{'fields': ('atualizacao_gescon', 'observacao_gescon',)}
{'fields': ('atualizacao_gescon', 'observacao_gescon', 'link_gescon')}
),
)
readonly_fields = ('data_sigi', 'atualizacao_gescon', 'observacao_gescon',)
readonly_fields = ('data_sigi', 'atualizacao_gescon', 'observacao_gescon', 'link_gescon')
actions = ['adicionar_convenios']
inlines = (AnexosInline,)
list_display = ('num_convenio', 'casa_legislativa', 'get_uf',
@ -115,6 +115,16 @@ class ConvenioAdmin(BaseModelAdmin):
link_sigad.short_description = _("Processo no Senado")
link_sigad.allow_tags = True
def link_gescon(self, obj):
if not obj.id_contrato_gescon:
return u""
return (
u"<a href='https://adm.senado.gov.br/gestao-contratos/api/"
u"contratos/buscaTexto/{id}'>https://adm.senado.gov.br/"
u"gestao-contratos/api/{id}</a>").format(id=obj.id_contrato_gescon)
link_gescon.short_description = _("Download PDF do Gescon")
link_gescon.allow_tags = True
def changelist_view(self, request, extra_context=None):
from sigi.apps.convenios.views import normaliza_data
request.GET._mutable = True

20
sigi/apps/convenios/migrations/0017_convenio_id_contrato_gescon.py

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('convenios', '0016_auto_20210909_0732'),
]
operations = [
migrations.AddField(
model_name='convenio',
name='id_contrato_gescon',
field=models.CharField(default=b'', verbose_name='ID do contrato no Gescon', max_length=20, editable=False, blank=True),
preserve_default=True,
),
]

17
sigi/apps/convenios/models.py

@ -71,6 +71,13 @@ class Convenio(models.Model):
max_length=10,
blank=True
)
id_contrato_gescon = models.CharField(
_(u"ID do contrato no Gescon"),
max_length=20,
blank=True,
default="",
editable=False
)
data_sigi = models.DateField(
_(u"data de cadastro no SIGI"),
blank=True,
@ -504,7 +511,7 @@ class Gescon(models.Model):
self.add_message(
_(u"\tErro ao acessar {url}: {errmsg}").format(
url=url,
errmsg=str(e)
errmsg=e.message.decode("utf8")
)
)
continue
@ -734,6 +741,12 @@ class Gescon(models.Model):
'terminoVigencia'
]
convenio.data_pub_diario = contrato['publicacao']
if contrato['codTextoContrato']:
convenio.id_contrato_gescon = contrato[
'codTextoContrato'
]
else:
convenio.id_contrato_gescon = ""
try:
convenio.save()
@ -748,7 +761,7 @@ class Gescon(models.Model):
convenio._meta.model_name),
args=[convenio.id]
),
errmsg=str(e)
errmsg=e.message.decode("utf8")
)
)
erros += 1

Loading…
Cancel
Save