diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 4619552..b6ec1b1 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -8,3 +8,4 @@ psycopg2==2.9.3 django-bootstrap5==21.3 Pillow==9.0.0 django-localflavor==3.1 +requests==2.27.1 \ No newline at end of file diff --git a/sigi/apps/convenios/admin.py b/sigi/apps/convenios/admin.py index 6a9dc1e..387695c 100644 --- a/sigi/apps/convenios/admin.py +++ b/sigi/apps/convenios/admin.py @@ -1,35 +1,23 @@ -# -*- coding: utf-8 -*- from django.contrib import admin from django.http import HttpResponse, HttpResponseRedirect from django.utils.translation import gettext as _ -from geraldo.generators import PDFGenerator - +from django.utils.safestring import mark_safe from sigi.apps.convenios.models import (Projeto, StatusConvenio, TipoSolicitacao, Convenio, EquipamentoPrevisto, Anexo, Tramitacao, Gescon) -from sigi.apps.convenios.reports import ConvenioReport -from sigi.apps.convenios.views import adicionar_convenios_carrinho +# from sigi.apps.convenios.reports import ConvenioReport +# from sigi.apps.convenios.views import adicionar_convenios_carrinho from sigi.apps.utils import queryset_ascii -from sigi.apps.utils.base_admin import BaseModelAdmin from sigi.apps.servidores.models import Servidor from sigi.apps.casas.admin import GerentesInterlegisFilter -# class TramitacaoInline(admin.TabularInline): -# model = Tramitacao -# extra = 1 - class AnexosInline(admin.TabularInline): model = Anexo extra = 2 exclude = ['data_pub', ] -# class EquipamentoPrevistoInline(admin.TabularInline): -# model = EquipamentoPrevisto -# extra = 2 -# raw_id_fields = ('equipamento',) - -class AnexoAdmin(BaseModelAdmin): +class AnexoAdmin(admin.ModelAdmin): date_hierarchy = 'data_pub' exclude = ['data_pub', ] list_display = ('arquivo', 'descricao', 'data_pub', 'convenio') @@ -44,7 +32,8 @@ class AcompanhaFilter(admin.filters.RelatedFieldListFilter): convenio__isnull=False).order_by('nome_completo').distinct() self.lookup_choices = [(x.id, x) for x in servidores] -class ConvenioAdmin(BaseModelAdmin): +@admin.register(Convenio) +class ConvenioAdmin(admin.ModelAdmin): change_list_template = 'convenios/change_list.html' fieldsets = ( (None, @@ -65,8 +54,9 @@ class ConvenioAdmin(BaseModelAdmin): {'fields': ('atualizacao_gescon', 'observacao_gescon', 'link_gescon')} ), ) - readonly_fields = ('data_sigi', 'atualizacao_gescon', 'observacao_gescon', 'link_gescon') - actions = ['adicionar_convenios'] + readonly_fields = ('data_sigi', 'atualizacao_gescon', 'observacao_gescon', + 'link_gescon') + # actions = ['adicionar_convenios'] inlines = (AnexosInline,) list_display = ('num_convenio', 'projeto','casa_legislativa', 'get_uf', 'status_convenio', 'link_sigad', 'data_retorno_assinatura', @@ -76,7 +66,6 @@ class ConvenioAdmin(BaseModelAdmin): GerentesInterlegisFilter), 'projeto', 'casa_legislativa__tipo', 'conveniada','equipada', 'casa_legislativa__municipio__uf',) - #date_hierarchy = 'data_adesao' ordering = ('casa_legislativa', '-data_retorno_assinatura') raw_id_fields = ('casa_legislativa',) get_queryset = queryset_ascii @@ -102,28 +91,24 @@ class ConvenioAdmin(BaseModelAdmin): label = r"warning" else: label = r"info" - - return '
{status}
'.format(label=label, status=status) + return mark_safe(f'{status}
') status_convenio.short_description = _("Status do convênio") - status_convenio.allow_tags = True def link_sigad(self, obj): if obj.pk is None: return "" - return obj.get_sigad_url() - + return mark_safe(obj.get_sigad_url()) link_sigad.short_description = _("Processo no Senado") - link_sigad.allow_tags = True def link_gescon(self, obj): if not obj.id_contrato_gescon: return "" - return ( - "https://adm.senado.gov.br/" - "gestao-contratos/api/{id}").format(id=obj.id_contrato_gescon) + return mark_safe( + f"" + f"https://adm.senado.gov.br/gestao-contratos/api/" + f"{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 @@ -143,28 +128,28 @@ class ConvenioAdmin(BaseModelAdmin): extra_context={'query_str': '?' + request.META['QUERY_STRING']} ) - def relatorio(self, request, queryset): - # queryset.order_by('casa_legislativa__municipio__uf') - response = HttpResponse(content_type='application/pdf') - report = ConvenioReport(queryset=queryset) - report.generate_by(PDFGenerator, filename=response) - return response - relatorio.short_description = _('Exportar convênios selecionados para PDF') - - def adicionar_convenios(self, request, queryset): - if 'carrinho_convenios' in request.session: - q1 = len(request.session['carrinho_convenios']) - else: - q1 = 0 - adicionar_convenios_carrinho(request, queryset=queryset) - q2 = len(request.session['carrinho_convenios']) - quant = q2 - q1 - if quant: - self.message_user(request, str(q2 - q1) + _(" Convênios adicionados no carrinho")) - else: - self.message_user(request, _("Os Convênios selecionados já foram adicionadas anteriormente")) - return HttpResponseRedirect('.') - adicionar_convenios.short_description = _("Armazenar convênios no carrinho para exportar") + # def relatorio(self, request, queryset): + # # queryset.order_by('casa_legislativa__municipio__uf') + # response = HttpResponse(content_type='application/pdf') + # report = ConvenioReport(queryset=queryset) + # report.generate_by(PDFGenerator, filename=response) + # return response + # relatorio.short_description = _('Exportar convênios selecionados para PDF') + + # def adicionar_convenios(self, request, queryset): + # if 'carrinho_convenios' in request.session: + # q1 = len(request.session['carrinho_convenios']) + # else: + # q1 = 0 + # adicionar_convenios_carrinho(request, queryset=queryset) + # q2 = len(request.session['carrinho_convenios']) + # quant = q2 - q1 + # if quant: + # self.message_user(request, str(q2 - q1) + _(" Convênios adicionados no carrinho")) + # else: + # self.message_user(request, _("Os Convênios selecionados já foram adicionadas anteriormente")) + # return HttpResponseRedirect('.') + # adicionar_convenios.short_description = _("Armazenar convênios no carrinho para exportar") def get_actions(self, request): actions = super(ConvenioAdmin, self).get_actions(request) @@ -172,12 +157,12 @@ class ConvenioAdmin(BaseModelAdmin): del actions['delete_selected'] return actions - def lookup_allowed(self, lookup, value): - return super(ConvenioAdmin, self).lookup_allowed(lookup, value) or \ - lookup in ['casa_legislativa__municipio__uf__codigo_ibge__exact'] - + # def lookup_allowed(self, lookup, value): + # return super(ConvenioAdmin, self).lookup_allowed(lookup, value) or \ + # lookup in ['casa_legislativa__municipio__uf__codigo_ibge__exact'] -class EquipamentoPrevistoAdmin(BaseModelAdmin): +@admin.register(EquipamentoPrevisto) +class EquipamentoPrevistoAdmin(admin.ModelAdmin): list_display = ('convenio', 'equipamento', 'quantidade') list_display_links = ('convenio', 'equipamento') ordering = ('convenio', 'equipamento') @@ -193,5 +178,3 @@ class GesconAdmin(admin.ModelAdmin): admin.site.register(Projeto) admin.site.register(StatusConvenio) admin.site.register(TipoSolicitacao) -admin.site.register(Convenio, ConvenioAdmin) -admin.site.register(EquipamentoPrevisto, EquipamentoPrevistoAdmin) \ No newline at end of file diff --git a/sigi/apps/convenios/apps.py b/sigi/apps/convenios/apps.py new file mode 100644 index 0000000..71da54e --- /dev/null +++ b/sigi/apps/convenios/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig +from django.utils.translation import gettext_lazy as _ + +class ConveniosConfig(AppConfig): + name = 'sigi.apps.convenios' + verbose_name = _('convênios') diff --git a/sigi/apps/convenios/migrations/0001_initial.py b/sigi/apps/convenios/migrations/0001_initial.py index ca538b7..19bd5f4 100644 --- a/sigi/apps/convenios/migrations/0001_initial.py +++ b/sigi/apps/convenios/migrations/0001_initial.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations @@ -45,7 +44,7 @@ class Migration(migrations.Migration): ('observacao', models.CharField(max_length=100, null=True, blank=True)), ('conveniada', models.BooleanField(default=False)), ('equipada', models.BooleanField(default=False)), - ('casa_legislativa', models.ForeignKey(verbose_name='Casa Legislativa', to='casas.CasaLegislativa')), + ('casa_legislativa', models.ForeignKey(verbose_name='Casa Legislativa', to='casas.CasaLegislativa', on_delete=models.CASCADE)), ], options={ 'ordering': ('id',), @@ -59,8 +58,8 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('quantidade', models.PositiveSmallIntegerField(default=1)), - ('convenio', models.ForeignKey(verbose_name='conv\xeanio', to='convenios.Convenio')), - ('equipamento', models.ForeignKey(to='inventario.Equipamento')), + ('convenio', models.ForeignKey(verbose_name='conv\xeanio', to='convenios.Convenio', on_delete=models.CASCADE)), + ('equipamento', models.ForeignKey(to='inventario.Equipamento', on_delete=models.CASCADE)), ], options={ 'verbose_name': 'equipamento previsto', @@ -85,7 +84,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('data', models.DateField()), ('observacao', models.CharField(max_length=b'512', null=True, verbose_name='observa\xe7\xe3o', blank=True)), - ('convenio', models.ForeignKey(verbose_name='conv\xeanio', to='convenios.Convenio')), + ('convenio', models.ForeignKey(verbose_name='conv\xeanio', to='convenios.Convenio', on_delete=models.CASCADE)), ], options={ 'verbose_name_plural': 'Tramita\xe7\xf5es', @@ -106,19 +105,19 @@ class Migration(migrations.Migration): migrations.AddField( model_name='tramitacao', name='unid_admin', - field=models.ForeignKey(verbose_name='Unidade Administrativa', to='convenios.UnidadeAdministrativa'), + field=models.ForeignKey(verbose_name='Unidade Administrativa', to='convenios.UnidadeAdministrativa', on_delete=models.CASCADE), preserve_default=True, ), migrations.AddField( model_name='convenio', name='projeto', - field=models.ForeignKey(to='convenios.Projeto'), + field=models.ForeignKey(to='convenios.Projeto', on_delete=models.CASCADE), preserve_default=True, ), migrations.AddField( model_name='anexo', name='convenio', - field=models.ForeignKey(verbose_name='conv\xeanio', to='convenios.Convenio'), + field=models.ForeignKey(verbose_name='conv\xeanio', to='convenios.Convenio', on_delete=models.CASCADE), preserve_default=True, ), ] diff --git a/sigi/apps/convenios/migrations/0002_convenio_duracao.py b/sigi/apps/convenios/migrations/0002_convenio_duracao.py index 7422d00..7314354 100644 --- a/sigi/apps/convenios/migrations/0002_convenio_duracao.py +++ b/sigi/apps/convenios/migrations/0002_convenio_duracao.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations diff --git a/sigi/apps/convenios/migrations/0003_auto_20210406_1945.py b/sigi/apps/convenios/migrations/0003_auto_20210406_1945.py index 1fd1c84..d241f52 100644 --- a/sigi/apps/convenios/migrations/0003_auto_20210406_1945.py +++ b/sigi/apps/convenios/migrations/0003_auto_20210406_1945.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations @@ -15,7 +14,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='convenio', name='casa_legislativa', - field=models.ForeignKey(verbose_name='Casa Legislativa', to='casas.Orgao'), + field=models.ForeignKey(verbose_name='Casa Legislativa', to='casas.Orgao', on_delete=models.CASCADE), preserve_default=True, ), ] diff --git a/sigi/apps/convenios/migrations/0004_auto_20210407_1928.py b/sigi/apps/convenios/migrations/0004_auto_20210407_1928.py index 184bd66..0b64bea 100644 --- a/sigi/apps/convenios/migrations/0004_auto_20210407_1928.py +++ b/sigi/apps/convenios/migrations/0004_auto_20210407_1928.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations @@ -42,7 +41,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='convenio', name='casa_legislativa', - field=models.ForeignKey(verbose_name='\xf3rg\xe3o conveniado', to='casas.Orgao'), + field=models.ForeignKey(verbose_name='\xf3rg\xe3o conveniado', to='casas.Orgao', on_delete=models.CASCADE), preserve_default=True, ), migrations.AlterField( diff --git a/sigi/apps/convenios/migrations/0005_auto_20210409_0842.py b/sigi/apps/convenios/migrations/0005_auto_20210409_0842.py index aa0a6d3..78d1385 100644 --- a/sigi/apps/convenios/migrations/0005_auto_20210409_0842.py +++ b/sigi/apps/convenios/migrations/0005_auto_20210409_0842.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations diff --git a/sigi/apps/convenios/migrations/0006_auto_20210416_0841.py b/sigi/apps/convenios/migrations/0006_auto_20210416_0841.py index 3698399..f3d4fbe 100644 --- a/sigi/apps/convenios/migrations/0006_auto_20210416_0841.py +++ b/sigi/apps/convenios/migrations/0006_auto_20210416_0841.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations diff --git a/sigi/apps/convenios/migrations/0007_auto_20210416_0918.py b/sigi/apps/convenios/migrations/0007_auto_20210416_0918.py index 0daaf23..200b83c 100644 --- a/sigi/apps/convenios/migrations/0007_auto_20210416_0918.py +++ b/sigi/apps/convenios/migrations/0007_auto_20210416_0918.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations diff --git a/sigi/apps/convenios/migrations/0008_auto_20210422_1907.py b/sigi/apps/convenios/migrations/0008_auto_20210422_1907.py index f061a28..83f1aec 100644 --- a/sigi/apps/convenios/migrations/0008_auto_20210422_1907.py +++ b/sigi/apps/convenios/migrations/0008_auto_20210422_1907.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations diff --git a/sigi/apps/convenios/migrations/0009_auto_20210611_0946.py b/sigi/apps/convenios/migrations/0009_auto_20210611_0946.py index 1e0a1bb..7d39264 100644 --- a/sigi/apps/convenios/migrations/0009_auto_20210611_0946.py +++ b/sigi/apps/convenios/migrations/0009_auto_20210611_0946.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations diff --git a/sigi/apps/convenios/migrations/0010_auto_20210819_0833.py b/sigi/apps/convenios/migrations/0010_auto_20210819_0833.py index e1827de..8c8a8ac 100644 --- a/sigi/apps/convenios/migrations/0010_auto_20210819_0833.py +++ b/sigi/apps/convenios/migrations/0010_auto_20210819_0833.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations diff --git a/sigi/apps/convenios/migrations/0011_convenio_data_termino_vigencia.py b/sigi/apps/convenios/migrations/0011_convenio_data_termino_vigencia.py index c5065c1..5eb61ad 100644 --- a/sigi/apps/convenios/migrations/0011_convenio_data_termino_vigencia.py +++ b/sigi/apps/convenios/migrations/0011_convenio_data_termino_vigencia.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations diff --git a/sigi/apps/convenios/migrations/0012_auto_20210831_0844.py b/sigi/apps/convenios/migrations/0012_auto_20210831_0844.py index b4e2692..5536a9e 100644 --- a/sigi/apps/convenios/migrations/0012_auto_20210831_0844.py +++ b/sigi/apps/convenios/migrations/0012_auto_20210831_0844.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from datetime import date from django.db import models, migrations diff --git a/sigi/apps/convenios/migrations/0013_remove_convenio_duracao.py b/sigi/apps/convenios/migrations/0013_remove_convenio_duracao.py index bcc66bc..41a399c 100644 --- a/sigi/apps/convenios/migrations/0013_remove_convenio_duracao.py +++ b/sigi/apps/convenios/migrations/0013_remove_convenio_duracao.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations diff --git a/sigi/apps/convenios/migrations/0014_gescon.py b/sigi/apps/convenios/migrations/0014_gescon.py index 7fe216c..05beb81 100644 --- a/sigi/apps/convenios/migrations/0014_gescon.py +++ b/sigi/apps/convenios/migrations/0014_gescon.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations diff --git a/sigi/apps/convenios/migrations/0015_remove_convenio_search_text.py b/sigi/apps/convenios/migrations/0015_remove_convenio_search_text.py index c187381..b5b338a 100644 --- a/sigi/apps/convenios/migrations/0015_remove_convenio_search_text.py +++ b/sigi/apps/convenios/migrations/0015_remove_convenio_search_text.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations diff --git a/sigi/apps/convenios/migrations/0016_auto_20210909_0732.py b/sigi/apps/convenios/migrations/0016_auto_20210909_0732.py index 9c98cbc..f6c565f 100644 --- a/sigi/apps/convenios/migrations/0016_auto_20210909_0732.py +++ b/sigi/apps/convenios/migrations/0016_auto_20210909_0732.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations diff --git a/sigi/apps/convenios/migrations/0017_convenio_id_contrato_gescon.py b/sigi/apps/convenios/migrations/0017_convenio_id_contrato_gescon.py index 83bddab..7619a1d 100644 --- a/sigi/apps/convenios/migrations/0017_convenio_id_contrato_gescon.py +++ b/sigi/apps/convenios/migrations/0017_convenio_id_contrato_gescon.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations diff --git a/sigi/apps/convenios/migrations/0018_auto_20211208_1256.py b/sigi/apps/convenios/migrations/0018_auto_20211208_1256.py index ed6b3c2..1755956 100644 --- a/sigi/apps/convenios/migrations/0018_auto_20211208_1256.py +++ b/sigi/apps/convenios/migrations/0018_auto_20211208_1256.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations diff --git a/sigi/apps/convenios/migrations/0019_alter_anexo_arquivo_alter_anexo_descricao_and_more.py b/sigi/apps/convenios/migrations/0019_alter_anexo_arquivo_alter_anexo_descricao_and_more.py new file mode 100644 index 0000000..62ae556 --- /dev/null +++ b/sigi/apps/convenios/migrations/0019_alter_anexo_arquivo_alter_anexo_descricao_and_more.py @@ -0,0 +1,93 @@ +# Generated by Django 4.0.1 on 2022-01-12 17:40 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('convenios', '0018_auto_20211208_1256'), + ] + + operations = [ + migrations.AlterField( + model_name='anexo', + name='arquivo', + field=models.FileField(max_length=500, upload_to='apps/convenios/anexo/arquivo'), + ), + migrations.AlterField( + model_name='anexo', + name='descricao', + field=models.CharField(max_length=70, verbose_name='descrição'), + ), + migrations.AlterField( + model_name='anexo', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='convenio', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='convenio', + name='id_contrato_gescon', + field=models.CharField(blank=True, default='', editable=False, max_length=20, verbose_name='ID do contrato no Gescon'), + ), + migrations.AlterField( + model_name='equipamentoprevisto', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='gescon', + name='email', + field=models.EmailField(help_text='Caixa de e-mail para onde o relatório diário de importação será enviado.', max_length=254, verbose_name='E-mail'), + ), + migrations.AlterField( + model_name='gescon', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='projeto', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='statusconvenio', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='tiposolicitacao', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='tramitacao', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='tramitacao', + name='observacao', + field=models.CharField(blank=True, max_length=512, null=True, verbose_name='observação'), + ), + migrations.AlterField( + model_name='unidadeadministrativa', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='unidadeadministrativa', + name='nome', + field=models.CharField(max_length=100), + ), + migrations.AlterField( + model_name='unidadeadministrativa', + name='sigla', + field=models.CharField(max_length=10), + ), + ] diff --git a/sigi/apps/convenios/models.py b/sigi/apps/convenios/models.py index f55f798..86ddfa5 100644 --- a/sigi/apps/convenios/models.py +++ b/sigi/apps/convenios/models.py @@ -1,24 +1,21 @@ -#-*- coding: utf-8 -*- import re import requests from datetime import datetime, date from django.db import models from django.db.models import Q, fields from django.core.mail import send_mail -from django.core.urlresolvers import reverse +from django.urls import reverse from django.utils.translation import gettext as _ -from sigi.apps.utils import SearchField, to_ascii +from sigi.apps.utils import to_ascii from sigi.apps.casas.models import Orgao from sigi.apps.servidores.models import Servidor, Servico + class Projeto(models.Model): - """ Modelo para representar os projetos do programa - Interlegis - """ nome = models.CharField(max_length=50) sigla = models.CharField(max_length=10) - def __unicode__(self): + def __str__(self): return self.sigla class Meta: @@ -33,7 +30,7 @@ class StatusConvenio(models.Model): verbose_name = _("Estado de convenios") verbose_name_plural = _("Estados de convenios") - def __unicode__(self): + def __str__(self): return self.nome class TipoSolicitacao(models.Model): @@ -44,7 +41,7 @@ class TipoSolicitacao(models.Model): verbose_name = _("tipo de solicitação") verbose_name_plural = _("Tipos de solicitação") - def __unicode__(self): + def __str__(self): return self.nome class Convenio(models.Model): @@ -53,7 +50,6 @@ class Convenio(models.Model): on_delete=models.PROTECT, verbose_name=_('órgão conveniado') ) - # campo de busca em caixa baixa e sem acentos projeto = models.ForeignKey( Projeto, on_delete=models.PROTECT, @@ -225,21 +221,19 @@ class Convenio(models.Model): return "" return obj.get_sigad_url() - link_sigad.short_description = _("Processo no Senado") - link_sigad.allow_tags = True - def get_sigad_url(self): m = re.match( r'(?P