Refactor(admin): remove format_strong_with_subtext and replace usage in ServiceAdmin; add format_colored_text_with_subtext in shared

This commit is contained in:
sankalp committed 2025-12-09 14:50:08 +05:45
1 parent 62aedcaff7
commit f6293dec50
5 files changed
+15 -11

No files matched your search

-1
View File
@@ -8,7 +8,6 @@ from src.admin.shared import (
format_currency,
format_placeholder,
format_strong,
format_strong_with_subtext,
)
from src.models.projects import Milestone, Project, Task
+2 -6
View File
@@ -6,6 +6,7 @@ from src.admin.shared import (
admin_site,
format_badge,
format_boolean_icon,
format_colored_text_with_subtext,
format_currency,
format_link,
format_placeholder,
@@ -132,12 +133,7 @@ class ServiceAdmin(admin.ModelAdmin):
color = "#28a745"
label = f"In {delta}d"
return format_html(
"<span style='color:{}; font-weight:600;'>{}</span><br><small>{}</small>",
color,
label,
obj.expiry_date,
)
return format_colored_text_with_subtext(color, label, obj.expiry_date)
expiry_display.short_description = "Expiry"
+13 -2
View File
@@ -1,5 +1,7 @@
from django.utils.html import format_html
from src.admin.base import * #noqa: F401
from src.admin.base import admin_site # noqa: F401
def format_strong(text):
return format_html("<strong>{}</strong>", text)
@@ -52,4 +54,13 @@ def format_link(url, label=None):
format_html("<a href='{}' target='_blank'>{}</a>", url, label or url)
if url
else format_placeholder()
)
)
def format_colored_text_with_subtext(color, label, subtext):
return format_html(
"<span style='color:{}; font-weight:600;'>{}</span><br><small>{}</small>",
color,
label,
subtext,
)
-1
View File
@@ -6,7 +6,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = []
@@ -5,7 +5,6 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("src", "0001_initial"),
]