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:
1 parent
62aedcaff7
commit
f6293dec50
5 files changed
+15
-11
No files matched your search
@@ -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
|
||||
|
||||
|
||||
@@ -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
@@ -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,
|
||||
)
|
||||
@@ -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"),
|
||||
]
|
||||
|
||||
Reference in new issue
Block a user