diff --git a/sigi/apps/casas/admin.py b/sigi/apps/casas/admin.py index a5eb2f7..3685f93 100644 --- a/sigi/apps/casas/admin.py +++ b/sigi/apps/casas/admin.py @@ -374,6 +374,23 @@ class ServicoFilter(admin.SimpleListFilter): return queryset.distinct('municipio__uf__nome', 'nome') +class ServicoAtivoFilter(admin.SimpleListFilter): + title = _(u"Serviço ativo") + parameter_name = 'ativo' + + def lookups(self, request, model_admin): + return ( + ('ativo', _(u"Ativo")), + ('desativado', _(u"Desativado")), + ) + + def queryset(self, request, queryset): + if self.value() is not None: + if self.value() == 'ativo': + queryset = queryset.filter(servico__data_desativacao__isnull=True) + else: + queryset = queryset.filter(servico__data_desativacao__isnull=False) + return queryset @admin.register(Orgao) class OrgaoAdmin(ImageCroppingMixin, BaseModelAdmin): form = OrgaoForm @@ -384,7 +401,7 @@ class OrgaoAdmin(ImageCroppingMixin, BaseModelAdmin): 'get_servicos') list_display_links = ('sigla', 'nome',) list_filter = ('tipo', ('gerentes_interlegis', GerentesInterlegisFilter), - 'municipio__uf__nome', ConvenioFilter, ExcluirConvenioFilter, ServicoFilter, + 'municipio__uf__nome', ConvenioFilter, ServicoAtivoFilter, ExcluirConvenioFilter, ServicoFilter, 'inclusao_digital',) ordering = ('municipio__uf__nome', 'nome') queryset = queryset_ascii diff --git a/sigi/apps/casas/models.py b/sigi/apps/casas/models.py index 29c93e8..1ca27b7 100644 --- a/sigi/apps/casas/models.py +++ b/sigi/apps/casas/models.py @@ -194,6 +194,19 @@ class Orgao(models.Model): return self.funcionario_set.get(setor='presidente') except Funcionario.DoesNotExist: return None + + @property + def contato_interlegis(self): + """ Link para acessar diretamente o contato do presidente da casa + Util para relatorios antigos + """ + try: + if self.funcionario_set.filter(setor='contato_interlegis').count() > 1: + return self.funcionario_set.filter(setor='contato_interlegis')[0] + else: + return self.funcionario_set.get(setor='contato_interlegis') + except Funcionario.DoesNotExist: + return None @property def total_parlamentares(self): diff --git a/sigi/apps/convenios/admin.py b/sigi/apps/convenios/admin.py index 328f46f..971dd1e 100644 --- a/sigi/apps/convenios/admin.py +++ b/sigi/apps/convenios/admin.py @@ -62,15 +62,15 @@ 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', + list_display = ('num_convenio', 'projeto','casa_legislativa', 'get_uf', 'status_convenio', 'link_sigad', 'data_retorno_assinatura', - 'data_termino_vigencia', 'projeto',) + 'data_termino_vigencia',) list_display_links = ('num_convenio', 'casa_legislativa',) list_filter = (('casa_legislativa__gerentes_interlegis', GerentesInterlegisFilter), 'projeto', @@ -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"https://adm.senado.gov.br/" + u"gestao-contratos/api/{id}").format(id=obj.id_contrato_gescon) + link_gescon.short_description = _("Download MINUTA ASSINADA 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 diff --git a/sigi/apps/convenios/migrations/0017_convenio_id_contrato_gescon.py b/sigi/apps/convenios/migrations/0017_convenio_id_contrato_gescon.py new file mode 100644 index 0000000..83bddab --- /dev/null +++ b/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, + ), + ] diff --git a/sigi/apps/convenios/migrations/0018_auto_20211208_1256.py b/sigi/apps/convenios/migrations/0018_auto_20211208_1256.py new file mode 100644 index 0000000..ed6b3c2 --- /dev/null +++ b/sigi/apps/convenios/migrations/0018_auto_20211208_1256.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('convenios', '0017_convenio_id_contrato_gescon'), + ] + + operations = [ + migrations.AlterField( + model_name='convenio', + name='projeto', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='Tipo de Convenio', to='convenios.Projeto'), + preserve_default=True, + ), + ] diff --git a/sigi/apps/convenios/models.py b/sigi/apps/convenios/models.py index cabc724..7e69675 100644 --- a/sigi/apps/convenios/models.py +++ b/sigi/apps/convenios/models.py @@ -57,6 +57,7 @@ class Convenio(models.Model): projeto = models.ForeignKey( Projeto, on_delete=models.PROTECT, + verbose_name=_(u'Tipo de Convenio') ) # numero designado pelo Senado Federal para o convênio num_processo_sf = models.CharField( @@ -71,6 +72,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 +512,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 +742,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 +762,7 @@ class Gescon(models.Model): convenio._meta.model_name), args=[convenio.id] ), - errmsg=str(e) + errmsg=e.message.decode("utf8") ) ) erros += 1 diff --git a/sigi/apps/convenios/reports.py b/sigi/apps/convenios/reports.py index f873f2e..dea94fc 100644 --- a/sigi/apps/convenios/reports.py +++ b/sigi/apps/convenios/reports.py @@ -54,19 +54,19 @@ class ConvenioReport(ReportDefault): ), Label( text=_(u"Projeto"), - left=label_left[5] * cm, + left=label_left[3] * cm, top=label_top + 0.4 * cm, width=2 * cm, ), Label( text=_(u"Data do Convênio"), - left=label_left[3] * cm, + left=label_left[4] * cm, top=label_top, width=2 * cm, ), Label( text=_(u"Data de Publicação"), - left=label_left[4] * cm, + left=label_left[5] * cm, top=label_top, width=2 * cm, ), @@ -100,17 +100,17 @@ class ConvenioReport(ReportDefault): ), ObjectValue( attribute_name='projeto.sigla', - left=label_left[5] * cm + left=label_left[3] * cm ), ObjectValue( attribute_name='data_retorno_assinatura', - left=label_left[3] * cm, + left=label_left[4] * cm, get_value=lambda instance: instance.data_retorno_assinatura.strftime('%d/%m/%Y') if instance.data_retorno_assinatura is not None else '-' ), ObjectValue( attribute_name='data_pub_diario', - left=label_left[4] * cm, + left=label_left[5] * cm, get_value=lambda instance: instance.data_pub_diario.strftime('%d/%m/%Y') if instance.data_pub_diario is not None else '-' ), @@ -163,13 +163,13 @@ class ConvenioReportSemAceite(ConvenioReport): ), Label( text=_(u"Projeto"), - left=label_left[4] * cm, + left=label_left[3] * cm, top=label_top, width=2 * cm, ), Label( text=_(u"Data do Convênio"), - left=label_left[3] * cm, + left=label_left[4] * cm, top=label_top, width=2 * cm, ), @@ -200,11 +200,11 @@ class ConvenioReportSemAceite(ConvenioReport): ), ObjectValue( attribute_name='projeto.sigla', - left=label_left[4], + left=label_left[3], ), ObjectValue( attribute_name='data_retorno_assinatura', - left=label_left[3] * cm, + left=label_left[4] * cm, get_value=lambda instance: instance.data_retorno_assinatura.strftime('%d/%m/%Y') if instance.data_retorno_assinatura is not None else '-' ), diff --git a/sigi/apps/eventos/admin.py b/sigi/apps/eventos/admin.py index 048ce57..198ef32 100644 --- a/sigi/apps/eventos/admin.py +++ b/sigi/apps/eventos/admin.py @@ -23,7 +23,8 @@ from django.contrib import admin from django.db import models from django.http import HttpResponseRedirect from django.utils.translation import ugettext as _ -from sigi.apps.eventos.models import ModeloDeclaracao, Modulo, TipoEvento, Funcao, Evento, Equipe, Convite +from sigi.apps.eventos.models import (ModeloDeclaracao, Modulo, TipoEvento, + Funcao, Evento, Equipe, Convite, Anexo) from sigi.apps.eventos.views import adicionar_eventos_carrinho from sigi.apps.eventos.forms import EventoAdminForm @@ -50,6 +51,10 @@ class ConviteInline(admin.TabularInline): class ModuloInline(admin.TabularInline): model = Modulo +class AnexoInline(admin.TabularInline): + model = Anexo + exclude = ('data_pub',) + @admin.register(Evento) class EventoAdmin(admin.ModelAdmin): form = EventoAdminForm @@ -62,7 +67,7 @@ class EventoAdmin(admin.ModelAdmin): raw_id_fields = ('casa_anfitria', 'municipio',) search_fields = ('nome', 'tipo_evento__nome', 'casa_anfitria__search_text', 'municipio__search_text', 'solicitante') - inlines = (EquipeInline, ConviteInline, ModuloInline) + inlines = (EquipeInline, ConviteInline, ModuloInline, AnexoInline) actions = ['adicionar_eventos', ] def adicionar_eventos(self, request, queryset): diff --git a/sigi/apps/eventos/migrations/0014_auto_20211124_0736.py b/sigi/apps/eventos/migrations/0014_auto_20211124_0736.py new file mode 100644 index 0000000..8c5619d --- /dev/null +++ b/sigi/apps/eventos/migrations/0014_auto_20211124_0736.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import tinymce.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('eventos', '0013_modelodeclaracao'), + ] + + operations = [ + migrations.AlterField( + model_name='modelodeclaracao', + name='texto', + field=tinymce.models.HTMLField(help_text='Use as seguintes marca\xe7\xf5es:', verbose_name='Texto da declara\xe7\xe3o'), + preserve_default=True, + ), + ] diff --git a/sigi/apps/eventos/migrations/0015_anexo.py b/sigi/apps/eventos/migrations/0015_anexo.py new file mode 100644 index 0000000..8dab092 --- /dev/null +++ b/sigi/apps/eventos/migrations/0015_anexo.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import datetime + + +class Migration(migrations.Migration): + + dependencies = [ + ('eventos', '0014_auto_20211124_0736'), + ] + + operations = [ + migrations.CreateModel( + name='Anexo', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('arquivo', models.FileField(max_length=500, upload_to=b'apps/eventos/anexo/arquivo')), + ('descricao', models.CharField(max_length=b'70', verbose_name='descri\xe7\xe3o')), + ('data_pub', models.DateTimeField(default=datetime.datetime.now, verbose_name='data da publica\xe7\xe3o do anexo')), + ('evento', models.ForeignKey(verbose_name='evento', to='eventos.Evento')), + ], + options={ + 'ordering': ('-data_pub',), + }, + bases=(models.Model,), + ), + ] diff --git a/sigi/apps/eventos/models.py b/sigi/apps/eventos/models.py index 9a11315..041fb0e 100644 --- a/sigi/apps/eventos/models.py +++ b/sigi/apps/eventos/models.py @@ -262,8 +262,10 @@ class ModeloDeclaracao(models.Model): ) texto = HTMLField( _(u"Texto da declaração"), - help_text=_(u"Use as seguintes marcações: