From 31c90e1ea9943e51afb9f2da011d6edf07792be1 Mon Sep 17 00:00:00 2001 From: Sesostris Vieira Date: Mon, 22 Jul 2024 10:29:47 -0300 Subject: [PATCH] =?UTF-8?q?Destaca=20conv=C3=AAnios=20vigentes.=20Gertiq?= =?UTF-8?q?=20#184829?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi/apps/casas/admin.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/sigi/apps/casas/admin.py b/sigi/apps/casas/admin.py index cf49311..4cb0819 100644 --- a/sigi/apps/casas/admin.py +++ b/sigi/apps/casas/admin.py @@ -1,4 +1,8 @@ +from typing import Any +from django.db.models.query import QuerySet +from django.http import HttpRequest from email_validator import validate_email, EmailNotValidError +from django.db.models import F from django.contrib import admin from django.contrib.contenttypes.admin import GenericTabularInline from django.template.loader import render_to_string @@ -205,20 +209,30 @@ class ConveniosInline(admin.TabularInline): show_change_link = True can_delete = False + def get_queryset(self, request: HttpRequest): + return ( + super() + .get_queryset(request) + .order_by( + F("data_retorno_assinatura").desc(nulls_last=True), + F("data_termino_vigencia").desc(nulls_last=True), + ) + ) + @admin.display(description=_("Status do convĂȘnio")) def status_convenio(self, obj): if obj.pk is None: return "" status = obj.get_status() if status in ["Vencido", "DesistĂȘncia", "Cancelado", "Extinto"]: - label = r"danger" + label = r"red lighten-3" elif status == "Vigente": - label = r"success" + label = r"green lighten-3" elif status == "Pendente": - label = r"warning" + label = r"deep-orange lighten-3" else: - label = r"info" - return mark_safe(f'

{status}

') + label = r"" + return mark_safe(f'

{status}

') @admin.display(description=_("Ver no SIGAD")) def link_sigad(self, obj):