Testing #28
@@ -45,9 +45,27 @@ def urlcleaning(modeladmin, request, queryset):
|
|||||||
return 0
|
return 0
|
||||||
@admin.register(streamingData)
|
@admin.register(streamingData)
|
||||||
class streamingAdmin(ImportExportModelAdmin):
|
class streamingAdmin(ImportExportModelAdmin):
|
||||||
list_display = ['clickable_links','result','status']
|
list_display = ['clickable_links','result_colored','newstatus']
|
||||||
fields = ['url']
|
fields = ['url']
|
||||||
actions = [check,urlcleaning]
|
actions = [check,urlcleaning]
|
||||||
|
|
||||||
def clickable_links(self, obj):
|
def clickable_links(self, obj):
|
||||||
return format_html('<a href="{}">{}</a>', obj.url,obj.url)
|
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
|
||||||
|
|
||||||
Reference in New Issue
Block a user