You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've currently monkey-patches all the admin classes for Overseer but it would be nice to see icons for the — "No Problems", "Some Issues" and "Unavailable" statuses. Django already includes these icons. Here's my code of how I accomplished this:
from overseer.models import *
from overseer.admin import *
admin.site.unregister(Service)
class ModdedServiceAdmin(ServiceAdmin):
"""
Modified service administration with icon support
"""
list_display = ('name', 'state', 'order', 'date_updated')
def state(self, obj):
"""
Returns an icon depending upon the status
"""
if obj.status == 0:
return '<img alt="Working" style="height: 11.5px;" src="/media/img/admin/icon_success.gif">'
if obj.status == 1:
return '<img alt="Errors" style="height: 11.5px;" src="/media/img/admin/icon_alert.gif">'
if obj.status == 2:
return '<img alt="Unavailable" style="height: 11.5px;" src="/media/img/admin/icon_error.gif">'
state.allow_tags=True
admin.site.register(Service, ModdedServiceAdmin)
admin.site.unregister(Event)
class ModdedEventAdmin(EventAdmin):
"""
Modified event administration with icon support
"""
list_display = ('date_created', 'description', 'state', 'date_updated')
def state(self, obj):
"""
Returns an icon depending upon the status
"""
if obj.status == 0:
return '<img alt="Working" style="height: 11.5px;" src="/media/img/admin/icon_success.gif">'
if obj.status == 1:
return '<img alt="Errors" style="height: 11.5px;" src="/media/img/admin/icon_alert.gif">'
if obj.status == 2:
return '<img alt="Unavailable" style="height: 11.5px;" src="/media/img/admin/icon_error.gif">'
state.allow_tags=True
admin.site.register(Event, ModdedEventAdmin)
admin.site.unregister(EventUpdate)
class ModdedEventUpdateAdmin(EventUpdateAdmin):
"""
Modified event-update administration with icon support
"""
list_display = ('date_created', 'message', 'state', 'event')
def state(self, obj):
"""
Returns an icon depending upon the status
"""
if obj.status == 0:
return '<img alt="Working" style="height: 11.5px;" src="/media/img/admin/icon_success.gif">'
if obj.status == 1:
return '<img alt="Errors" style="height: 11.5px;" src="/media/img/admin/icon_alert.gif">'
if obj.status == 2:
return '<img alt="Unavailable" style="height: 11.5px;" src="/media/img/admin/icon_error.gif">'
state.allow_tags=True
admin.site.register(EventUpdate, ModdedEventUpdateAdmin)
The text was updated successfully, but these errors were encountered:
I've currently monkey-patches all the admin classes for Overseer but it would be nice to see icons for the — "No Problems", "Some Issues" and "Unavailable" statuses. Django already includes these icons. Here's my code of how I accomplished this:
The text was updated successfully, but these errors were encountered: