From 635844dbb0d2eb7bd42b1c2f3ff2d7b18c314d53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ses=C3=B3stris=20Vieira?= Date: Fri, 11 Nov 2022 16:41:15 -0300 Subject: [PATCH] Adiciona autocomplete fields em diversos cadastros --- sigi/apps/casas/admin.py | 14 +++++-- sigi/apps/convenios/admin.py | 6 ++- sigi/apps/eventos/admin.py | 12 +----- ..._options_remove_convite_aceite_and_more.py | 37 +++++++++++++++++++ sigi/apps/eventos/models.py | 10 +---- sigi/apps/ocorrencias/admin.py | 19 +++++++--- sigi/apps/parlamentares/admin.py | 3 +- sigi/apps/servicos/admin.py | 1 + 8 files changed, 72 insertions(+), 30 deletions(-) create mode 100644 sigi/apps/eventos/migrations/0029_alter_convite_options_remove_convite_aceite_and_more.py diff --git a/sigi/apps/casas/admin.py b/sigi/apps/casas/admin.py index 286ec0a..c8fdb5c 100644 --- a/sigi/apps/casas/admin.py +++ b/sigi/apps/casas/admin.py @@ -94,6 +94,7 @@ class ParlamentarInline(admin.StackedInline): "redes_sociais", "ult_alteracao", ) + autocomplete_fields = ("partido",) readonly_fields = ("ult_alteracao",) extra = 0 @@ -228,6 +229,7 @@ class OcorrenciaInline(admin.StackedInline): "ticket", "data_modificacao", ) + autocomplete_fields = ("categoria", "tipo_contato") readonly_fields = ( "data_criacao", "data_modificacao", @@ -243,6 +245,13 @@ class OcorrenciaInline(admin.StackedInline): return False +@admin.register(TipoOrgao) +class TipoOrgaoAdmin(admin.ModelAdmin): + list_display = ("sigla", "nome", "legislativo") + list_filter = ("legislativo",) + search_fields = ("sigla", "nome") + + @admin.register(Orgao) class OrgaoAdmin(CartExportReportMixin, admin.ModelAdmin): form = OrgaoForm @@ -333,7 +342,7 @@ class OrgaoAdmin(CartExportReportMixin, admin.ModelAdmin): }, ), ) - autocomplete_fields = ("municipio",) + autocomplete_fields = ("tipo", "municipio", "pesquisador") readonly_fields = [ "gerentes_interlegis", ] @@ -482,6 +491,3 @@ class OrgaoAdmin(CartExportReportMixin, admin.ModelAdmin): if "delete_selected" in actions: del actions["delete_selected"] return actions - - -admin.site.register(TipoOrgao) diff --git a/sigi/apps/convenios/admin.py b/sigi/apps/convenios/admin.py index 83483cc..9b69236 100644 --- a/sigi/apps/convenios/admin.py +++ b/sigi/apps/convenios/admin.py @@ -189,7 +189,11 @@ class ConvenioAdmin(CartExportReportMixin, admin.ModelAdmin): "casa_legislativa__municipio__uf", ) ordering = ("casa_legislativa", "-data_retorno_assinatura") - autocomplete_fields = ("casa_legislativa",) + autocomplete_fields = ( + "casa_legislativa", + "servico_gestao", + "servidor_gestao", + ) get_queryset = queryset_ascii search_fields = ( "id", diff --git a/sigi/apps/eventos/admin.py b/sigi/apps/eventos/admin.py index 9352e24..0d0771f 100644 --- a/sigi/apps/eventos/admin.py +++ b/sigi/apps/eventos/admin.py @@ -67,9 +67,6 @@ class EventoResource(ValueLabeledResource): "convite__casa__municipio__uf__sigla", "convite__casa__cep", "convite__casa__email", - "convite__aceite", - "convite__data_convite", - "convite__participou", "convite__qtde_participantes", "convite__nomes_participantes", ) @@ -84,12 +81,6 @@ class EventoResource(ValueLabeledResource): def dehydrate_status(self, obj): return dict(Evento.STATUS_CHOICES)[obj["status"]] - def dehydrate_convite__aceite(self, obj): - return "Sim" if obj["convite__aceite"] else "Não" - - def dehydrate_convite__participou(self, obj): - return "Sim" if obj["convite__participou"] else "Não" - class ChecklistInline(admin.StackedInline): model = Checklist @@ -163,7 +154,7 @@ class EventoAdmin(CartExportMixin, admin.ModelAdmin): "solicitante", "total_participantes", ) - list_display_links = ["get_banner", "nome"] + list_display_links = ("get_banner", "nome") list_filter = ( "status", "publicar", @@ -175,6 +166,7 @@ class EventoAdmin(CartExportMixin, admin.ModelAdmin): "solicitante", ) autocomplete_fields = ( + "tipo_evento", "casa_anfitria", "municipio", ) diff --git a/sigi/apps/eventos/migrations/0029_alter_convite_options_remove_convite_aceite_and_more.py b/sigi/apps/eventos/migrations/0029_alter_convite_options_remove_convite_aceite_and_more.py new file mode 100644 index 0000000..3f5406c --- /dev/null +++ b/sigi/apps/eventos/migrations/0029_alter_convite_options_remove_convite_aceite_and_more.py @@ -0,0 +1,37 @@ +# Generated by Django 4.1.2 on 2022-11-11 18:50 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("eventos", "0028_evento_solicitacao"), + ] + + operations = [ + migrations.AlterModelOptions( + name="convite", + options={ + "ordering": ("evento", "casa"), + "verbose_name": "Casa convidada", + "verbose_name_plural": "Casas convidadas", + }, + ), + migrations.RemoveField( + model_name="convite", + name="aceite", + ), + migrations.RemoveField( + model_name="convite", + name="data_convite", + ), + migrations.RemoveField( + model_name="convite", + name="participou", + ), + migrations.RemoveField( + model_name="convite", + name="servidor", + ), + ] diff --git a/sigi/apps/eventos/models.py b/sigi/apps/eventos/models.py index 996b84a..1557e20 100644 --- a/sigi/apps/eventos/models.py +++ b/sigi/apps/eventos/models.py @@ -295,14 +295,6 @@ class Convite(models.Model): casa = models.ForeignKey( Orgao, on_delete=models.PROTECT, verbose_name=_("Casa convidada") ) - servidor = models.ForeignKey( - Servidor, - on_delete=models.PROTECT, - verbose_name=_("Servidor que convidou"), - ) - data_convite = models.DateField(_("Data do convite")) - aceite = models.BooleanField(_("Aceitou o convite"), default=False) - participou = models.BooleanField(_("Participou do evento"), default=False) qtde_participantes = models.PositiveIntegerField( _("número de participantes"), default=0 ) @@ -313,7 +305,7 @@ class Convite(models.Model): ) class Meta: - ordering = ("evento", "casa", "-data_convite") + ordering = ("evento", "casa") unique_together = ("evento", "casa") verbose_name = _("Casa convidada") verbose_name_plural = _("Casas convidadas") diff --git a/sigi/apps/ocorrencias/admin.py b/sigi/apps/ocorrencias/admin.py index 4c11ab7..e686d56 100644 --- a/sigi/apps/ocorrencias/admin.py +++ b/sigi/apps/ocorrencias/admin.py @@ -54,6 +54,19 @@ class AnexosInline(admin.TabularInline): ] +@admin.register(Categoria) +class CategoriaAdmin(admin.ModelAdmin): + list_display = ("nome", "tipo") + list_filter = ("tipo",) + search_fields = ("nome", "descricao") + + +@admin.register(TipoContato) +class TipoContatoAdmin(admin.ModelAdmin): + list_display = ("descricao",) + search_fields = ("descricao",) + + @admin.register(Ocorrencia) class OcorrenciaAdmin(admin.ModelAdmin): list_display = ( @@ -100,7 +113,7 @@ class OcorrenciaAdmin(admin.ModelAdmin): ComentarioInline, AnexosInline, ) - autocomplete_fields = ("casa_legislativa",) + autocomplete_fields = ("casa_legislativa", "categoria", "tipo_contato") def get_fieldsets(self, request, obj=None): if obj is None: @@ -155,7 +168,3 @@ class OcorrenciaAdmin(admin.ModelAdmin): get_municipio.short_description = _("Município") get_municipio.admin_order_field = "casa_legislativa__municipio__nome" - - -admin.site.register(Categoria) -admin.site.register(TipoContato) diff --git a/sigi/apps/parlamentares/admin.py b/sigi/apps/parlamentares/admin.py index fb2b6ab..b5dcd80 100644 --- a/sigi/apps/parlamentares/admin.py +++ b/sigi/apps/parlamentares/admin.py @@ -196,7 +196,7 @@ class ParlamentarAdmin(CartExportMixin, admin.ModelAdmin): {"fields": ("telefones", "email", "redes_sociais")}, ), ) - autocomplete_fields = ("casa_legislativa",) + autocomplete_fields = ("casa_legislativa", "partido") search_fields = ( "nome_completo", "nome_parlamentar", @@ -294,6 +294,7 @@ class SenadorAdmin(ImportMixin, admin.ModelAdmin): "partido__sigla", "partido__nome", ) + autocomplete_fields = ("partido",) def get_import_formats(self): return [SemicolonCSV] diff --git a/sigi/apps/servicos/admin.py b/sigi/apps/servicos/admin.py index aca11c6..722bdd2 100644 --- a/sigi/apps/servicos/admin.py +++ b/sigi/apps/servicos/admin.py @@ -94,6 +94,7 @@ class ServicoAdmin(CartExportMixin, admin.ModelAdmin): "data_desativacao", "motivo_desativacao", ] + autocomplete_fields = ("casa_legislativa",) readonly_fields = ["data_alteracao"] list_filter = ( "tipo_servico",