|
@ -2,6 +2,7 @@ from django.contrib import admin |
|
|
from django.contrib.contenttypes.admin import GenericTabularInline |
|
|
from django.contrib.contenttypes.admin import GenericTabularInline |
|
|
from django.template.loader import render_to_string |
|
|
from django.template.loader import render_to_string |
|
|
from django.urls import reverse |
|
|
from django.urls import reverse |
|
|
|
|
|
from django.utils.html import format_html |
|
|
from django.utils.safestring import mark_safe |
|
|
from django.utils.safestring import mark_safe |
|
|
from django.utils.translation import gettext as _ |
|
|
from django.utils.translation import gettext as _ |
|
|
from django_weasyprint.views import WeasyTemplateResponse |
|
|
from django_weasyprint.views import WeasyTemplateResponse |
|
@ -141,12 +142,11 @@ class FuncionarioInline(admin.TabularInline): |
|
|
model = Funcionario |
|
|
model = Funcionario |
|
|
template = "admin/casas/orgao/tabular.html" |
|
|
template = "admin/casas/orgao/tabular.html" |
|
|
fields = ( |
|
|
fields = ( |
|
|
|
|
|
"get_setor", |
|
|
"nome", |
|
|
"nome", |
|
|
"nota", |
|
|
"nota", |
|
|
"email", |
|
|
"get_email_link", |
|
|
"setor", |
|
|
|
|
|
"ult_alteracao", |
|
|
"ult_alteracao", |
|
|
"redes_sociais", |
|
|
|
|
|
"observacoes", |
|
|
"observacoes", |
|
|
) |
|
|
) |
|
|
readonly_fields = fields |
|
|
readonly_fields = fields |
|
@ -155,14 +155,26 @@ class FuncionarioInline(admin.TabularInline): |
|
|
show_change_link = True |
|
|
show_change_link = True |
|
|
can_delete = False |
|
|
can_delete = False |
|
|
verbose_name_plural = _("Contatos da Casa") |
|
|
verbose_name_plural = _("Contatos da Casa") |
|
|
|
|
|
ordering = ["setor", "-ult_alteracao"] |
|
|
|
|
|
|
|
|
def get_queryset(self, request): |
|
|
def get_queryset(self, request): |
|
|
return ( |
|
|
qs = super().get_queryset(request) |
|
|
self.model.objects.exclude(desativado=True) |
|
|
return qs.exclude(desativado=True) |
|
|
.extra(select={"ult_null": "ult_alteracao is null"}) |
|
|
|
|
|
.order_by("ult_null", "-ult_alteracao") |
|
|
@admin.display(description=_("setor")) |
|
|
# A função extra foi usada para quando existir um registro com |
|
|
def get_setor(self, func): |
|
|
# o campo igual a null não aparecer na frente dos mais novos |
|
|
if func.setor == "contato_interlegis": |
|
|
|
|
|
return format_html( |
|
|
|
|
|
"<span class='green lighten-5 z-depth-1'>{setor}</span>", |
|
|
|
|
|
setor=func.get_setor_display(), |
|
|
|
|
|
) |
|
|
|
|
|
return func.get_setor_display() |
|
|
|
|
|
|
|
|
|
|
|
@admin.display(description=_("e-mail")) |
|
|
|
|
|
def get_email_link(self, func): |
|
|
|
|
|
return format_html( |
|
|
|
|
|
"<a href='mailto:{email}' targe='_blank'>{email}</a>", |
|
|
|
|
|
email=func.email, |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -224,7 +236,7 @@ class ServicoInline(admin.TabularInline): |
|
|
"data_ultimo_uso", |
|
|
"data_ultimo_uso", |
|
|
) |
|
|
) |
|
|
readonly_fields = fields |
|
|
readonly_fields = fields |
|
|
ordering = ("tipo_servico", "-data_alteracao") |
|
|
ordering = ("-data_desativacao", "-data_ativacao", "tipo_servico") |
|
|
extra = 0 |
|
|
extra = 0 |
|
|
max_num = 0 |
|
|
max_num = 0 |
|
|
show_change_link = True |
|
|
show_change_link = True |
|
@ -245,12 +257,12 @@ class OcorrenciaInline(admin.TabularInline): |
|
|
template = "admin/casas/orgao/tabular.html" |
|
|
template = "admin/casas/orgao/tabular.html" |
|
|
fields = ( |
|
|
fields = ( |
|
|
"data_criacao", |
|
|
"data_criacao", |
|
|
|
|
|
"data_modificacao", |
|
|
"categoria", |
|
|
"categoria", |
|
|
"tipo_contato", |
|
|
"tipo_contato", |
|
|
"assunto", |
|
|
"assunto", |
|
|
"prioridade", |
|
|
"prioridade", |
|
|
"status", |
|
|
"status", |
|
|
"data_modificacao", |
|
|
|
|
|
) |
|
|
) |
|
|
autocomplete_fields = ("categoria", "tipo_contato") |
|
|
autocomplete_fields = ("categoria", "tipo_contato") |
|
|
readonly_fields = fields |
|
|
readonly_fields = fields |
|
@ -398,9 +410,7 @@ class OrgaoAdmin(CartExportReportMixin, admin.ModelAdmin): |
|
|
), |
|
|
), |
|
|
) |
|
|
) |
|
|
autocomplete_fields = ("tipo", "municipio", "pesquisador") |
|
|
autocomplete_fields = ("tipo", "municipio", "pesquisador") |
|
|
readonly_fields = [ |
|
|
readonly_fields = ["gerentes_interlegis", "ult_alt_endereco"] |
|
|
"gerentes_interlegis", |
|
|
|
|
|
] |
|
|
|
|
|
search_fields = ( |
|
|
search_fields = ( |
|
|
"search_text", |
|
|
"search_text", |
|
|
"sigla", |
|
|
"sigla", |
|
|