From a991b69547d1147689048b6ec388637c112c987d Mon Sep 17 00:00:00 2001 From: pierregeeraert Date: Thu, 6 Aug 2026 15:33:19 +0100 Subject: [PATCH] add colored background --- django_code/apps/streaming/admin.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/django_code/apps/streaming/admin.py b/django_code/apps/streaming/admin.py index e6503f2..88d825d 100644 --- a/django_code/apps/streaming/admin.py +++ b/django_code/apps/streaming/admin.py @@ -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('{}', obj.url,obj.url) \ No newline at end of file + return format_html('{}', obj.url,obj.url) + + def result_colored(self, obj): + colors = { + 'REACHABLE': 'green', + 'VPN REQUIRED': 'yellow', + 'UNREACHABLE': 'red', + } + + return format_html( + '{}', + colors[obj.result], + obj.result, + ) + def newstatus(self, obj): + if obj.status != '200': + return format_html('
{}
', obj.status) + #return obj.status + \ No newline at end of file