Browse Source

Adiciona autocomplete fields em diversos cadastros

pull/159/head
Sesostris Vieira 2 years ago
parent
commit
635844dbb0
  1. 14
      sigi/apps/casas/admin.py
  2. 6
      sigi/apps/convenios/admin.py
  3. 12
      sigi/apps/eventos/admin.py
  4. 37
      sigi/apps/eventos/migrations/0029_alter_convite_options_remove_convite_aceite_and_more.py
  5. 10
      sigi/apps/eventos/models.py
  6. 19
      sigi/apps/ocorrencias/admin.py
  7. 3
      sigi/apps/parlamentares/admin.py
  8. 1
      sigi/apps/servicos/admin.py

14
sigi/apps/casas/admin.py

@ -94,6 +94,7 @@ class ParlamentarInline(admin.StackedInline):
"redes_sociais", "redes_sociais",
"ult_alteracao", "ult_alteracao",
) )
autocomplete_fields = ("partido",)
readonly_fields = ("ult_alteracao",) readonly_fields = ("ult_alteracao",)
extra = 0 extra = 0
@ -228,6 +229,7 @@ class OcorrenciaInline(admin.StackedInline):
"ticket", "ticket",
"data_modificacao", "data_modificacao",
) )
autocomplete_fields = ("categoria", "tipo_contato")
readonly_fields = ( readonly_fields = (
"data_criacao", "data_criacao",
"data_modificacao", "data_modificacao",
@ -243,6 +245,13 @@ class OcorrenciaInline(admin.StackedInline):
return False return False
@admin.register(TipoOrgao)
class TipoOrgaoAdmin(admin.ModelAdmin):
list_display = ("sigla", "nome", "legislativo")
list_filter = ("legislativo",)
search_fields = ("sigla", "nome")
@admin.register(Orgao) @admin.register(Orgao)
class OrgaoAdmin(CartExportReportMixin, admin.ModelAdmin): class OrgaoAdmin(CartExportReportMixin, admin.ModelAdmin):
form = OrgaoForm form = OrgaoForm
@ -333,7 +342,7 @@ class OrgaoAdmin(CartExportReportMixin, admin.ModelAdmin):
}, },
), ),
) )
autocomplete_fields = ("municipio",) autocomplete_fields = ("tipo", "municipio", "pesquisador")
readonly_fields = [ readonly_fields = [
"gerentes_interlegis", "gerentes_interlegis",
] ]
@ -482,6 +491,3 @@ class OrgaoAdmin(CartExportReportMixin, admin.ModelAdmin):
if "delete_selected" in actions: if "delete_selected" in actions:
del actions["delete_selected"] del actions["delete_selected"]
return actions return actions
admin.site.register(TipoOrgao)

6
sigi/apps/convenios/admin.py

@ -189,7 +189,11 @@ class ConvenioAdmin(CartExportReportMixin, admin.ModelAdmin):
"casa_legislativa__municipio__uf", "casa_legislativa__municipio__uf",
) )
ordering = ("casa_legislativa", "-data_retorno_assinatura") ordering = ("casa_legislativa", "-data_retorno_assinatura")
autocomplete_fields = ("casa_legislativa",) autocomplete_fields = (
"casa_legislativa",
"servico_gestao",
"servidor_gestao",
)
get_queryset = queryset_ascii get_queryset = queryset_ascii
search_fields = ( search_fields = (
"id", "id",

12
sigi/apps/eventos/admin.py

@ -67,9 +67,6 @@ class EventoResource(ValueLabeledResource):
"convite__casa__municipio__uf__sigla", "convite__casa__municipio__uf__sigla",
"convite__casa__cep", "convite__casa__cep",
"convite__casa__email", "convite__casa__email",
"convite__aceite",
"convite__data_convite",
"convite__participou",
"convite__qtde_participantes", "convite__qtde_participantes",
"convite__nomes_participantes", "convite__nomes_participantes",
) )
@ -84,12 +81,6 @@ class EventoResource(ValueLabeledResource):
def dehydrate_status(self, obj): def dehydrate_status(self, obj):
return dict(Evento.STATUS_CHOICES)[obj["status"]] 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): class ChecklistInline(admin.StackedInline):
model = Checklist model = Checklist
@ -163,7 +154,7 @@ class EventoAdmin(CartExportMixin, admin.ModelAdmin):
"solicitante", "solicitante",
"total_participantes", "total_participantes",
) )
list_display_links = ["get_banner", "nome"] list_display_links = ("get_banner", "nome")
list_filter = ( list_filter = (
"status", "status",
"publicar", "publicar",
@ -175,6 +166,7 @@ class EventoAdmin(CartExportMixin, admin.ModelAdmin):
"solicitante", "solicitante",
) )
autocomplete_fields = ( autocomplete_fields = (
"tipo_evento",
"casa_anfitria", "casa_anfitria",
"municipio", "municipio",
) )

37
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",
),
]

10
sigi/apps/eventos/models.py

@ -295,14 +295,6 @@ class Convite(models.Model):
casa = models.ForeignKey( casa = models.ForeignKey(
Orgao, on_delete=models.PROTECT, verbose_name=_("Casa convidada") 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( qtde_participantes = models.PositiveIntegerField(
_("número de participantes"), default=0 _("número de participantes"), default=0
) )
@ -313,7 +305,7 @@ class Convite(models.Model):
) )
class Meta: class Meta:
ordering = ("evento", "casa", "-data_convite") ordering = ("evento", "casa")
unique_together = ("evento", "casa") unique_together = ("evento", "casa")
verbose_name = _("Casa convidada") verbose_name = _("Casa convidada")
verbose_name_plural = _("Casas convidadas") verbose_name_plural = _("Casas convidadas")

19
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) @admin.register(Ocorrencia)
class OcorrenciaAdmin(admin.ModelAdmin): class OcorrenciaAdmin(admin.ModelAdmin):
list_display = ( list_display = (
@ -100,7 +113,7 @@ class OcorrenciaAdmin(admin.ModelAdmin):
ComentarioInline, ComentarioInline,
AnexosInline, AnexosInline,
) )
autocomplete_fields = ("casa_legislativa",) autocomplete_fields = ("casa_legislativa", "categoria", "tipo_contato")
def get_fieldsets(self, request, obj=None): def get_fieldsets(self, request, obj=None):
if obj is None: if obj is None:
@ -155,7 +168,3 @@ class OcorrenciaAdmin(admin.ModelAdmin):
get_municipio.short_description = _("Município") get_municipio.short_description = _("Município")
get_municipio.admin_order_field = "casa_legislativa__municipio__nome" get_municipio.admin_order_field = "casa_legislativa__municipio__nome"
admin.site.register(Categoria)
admin.site.register(TipoContato)

3
sigi/apps/parlamentares/admin.py

@ -196,7 +196,7 @@ class ParlamentarAdmin(CartExportMixin, admin.ModelAdmin):
{"fields": ("telefones", "email", "redes_sociais")}, {"fields": ("telefones", "email", "redes_sociais")},
), ),
) )
autocomplete_fields = ("casa_legislativa",) autocomplete_fields = ("casa_legislativa", "partido")
search_fields = ( search_fields = (
"nome_completo", "nome_completo",
"nome_parlamentar", "nome_parlamentar",
@ -294,6 +294,7 @@ class SenadorAdmin(ImportMixin, admin.ModelAdmin):
"partido__sigla", "partido__sigla",
"partido__nome", "partido__nome",
) )
autocomplete_fields = ("partido",)
def get_import_formats(self): def get_import_formats(self):
return [SemicolonCSV] return [SemicolonCSV]

1
sigi/apps/servicos/admin.py

@ -94,6 +94,7 @@ class ServicoAdmin(CartExportMixin, admin.ModelAdmin):
"data_desativacao", "data_desativacao",
"motivo_desativacao", "motivo_desativacao",
] ]
autocomplete_fields = ("casa_legislativa",)
readonly_fields = ["data_alteracao"] readonly_fields = ["data_alteracao"]
list_filter = ( list_filter = (
"tipo_servico", "tipo_servico",

Loading…
Cancel
Save