add colored background
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3s

This commit is contained in:
2026-08-06 15:33:19 +01:00
parent 9595ea326f
commit a991b69547
+19 -1
View File
@@ -45,9 +45,27 @@ def urlcleaning(modeladmin, request, queryset):
return 0
@admin.register(streamingData)
class streamingAdmin(ImportExportModelAdmin):
list_display = ['clickable_links','result','status']
list_display = ['clickable_links','result_colored','newstatus']
fields = ['url']
actions = [check,urlcleaning]
def clickable_links(self, obj):
return format_html('<a href="{}">{}</a>', obj.url,obj.url)
def result_colored(self, obj):
colors = {
'REACHABLE': 'green',
'VPN REQUIRED': 'yellow',
'UNREACHABLE': 'red',
}
return format_html(
'<b style="background:{};">{}</b>',
colors[obj.result],
obj.result,
)
def newstatus(self, obj):
if obj.status != '200':
return format_html('<div style="width:100%%; height:100%%; background-color:orange;">{}</div>', obj.status)
#return obj.status