provisioning status in admin UI
diff --git a/planetstack/core/admin.py b/planetstack/core/admin.py
index 6b24282..d1f6f86 100644
--- a/planetstack/core/admin.py
+++ b/planetstack/core/admin.py
@@ -18,6 +18,14 @@
import django_evolution
+def backend_icon(value):
+ if value == "":
+ return ""
+ elif value == "Provisioning in progress":
+ return '<img src="/static/admin/img/icon_clock.gif">'
+ else:
+ return '<img src="/static/admin/img/icon_error.gif">'
+
class PlainTextWidget(forms.HiddenInput):
input_type = 'hidden'
@@ -28,21 +36,11 @@
class BackendStatusIconWidget(forms.Widget):
def render(self, name, value, attrs=None):
- if value == "Provisioning in progress":
- icon = "/static/admin/img/icon_clock.gif"
- else:
- icon = "/static/admin/img/icon_error.gif"
-
- return mark_safe('<div title="%s"><img src="%s"></div>' % (value, icon))
+ return mark_safe('<div title="%s">%s</div>' % (value, backend_icon(value)))
class BackendStatusFullWidget(forms.Widget):
def render(self, name, value, attrs=None):
- if value == "Provisioning in progress":
- icon = "/static/admin/img/icon_clock.gif"
- else:
- icon = "/static/admin/img/icon_error.gif"
-
- return mark_safe('<img src="%s"> %s' % (icon, value))
+ return mark_safe('%s %s' % (backend_icon(value), value))
class ReadOnlyAwareAdmin(admin.ModelAdmin):
@@ -107,6 +105,14 @@
return result
+ def backend_status_icon(self, obj):
+ if hasattr(obj, 'backend_status'):
+ value = obj.backend_status
+ return mark_safe('<div title="%s">%s</div>' % (value, backend_icon(value)))
+ else:
+ return ""
+ backend_status_icon.short_description = ""
+
class SingletonAdmin (ReadOnlyAwareAdmin):
def has_add_permission(self, request):
@@ -565,6 +571,8 @@
fieldList = ['backend_status', 'name', 'sites', 'images', 'accessControl']
fieldsets = [(None, {'fields': fieldList, 'classes':['suit-tab suit-tab-sites']})]
inlines = [DeploymentPrivilegeInline,NodeInline,TagInline] # ,ImageDeploymentsInline]
+ list_display = ['backend_status_icon', 'name']
+ list_display_links = ('backend_status_icon', 'name', )
user_readonly_fields = ['name']
@@ -593,7 +601,8 @@
suit_classes = 'suit-tab suit-tab-serviceattrs'
class ServiceAdmin(PlanetStackBaseAdmin):
- list_display = ("name","description","versionNumber","enabled","published")
+ list_display = ("backend_status_icon","name","description","versionNumber","enabled","published")
+ list_display_links = ('backend_status_icon', 'name', )
fieldList = ["backend_status","name","description","versionNumber","enabled","published"]
fieldsets = [(None, {'fields': fieldList, 'classes':['suit-tab suit-tab-general']})]
inlines = [ServiceAttrAsTabInline,SliceInline]
@@ -623,7 +632,8 @@
user_readonly_fields = ['name', 'deployments','site_url', 'enabled', 'is_public', 'login_base', 'accountLink']
- list_display = ('name', 'login_base','site_url', 'enabled')
+ list_display = ('backend_status_icon', 'name', 'login_base','site_url', 'enabled')
+ list_display_links = ('backend_status_icon', 'name', )
filter_horizontal = ('deployments',)
inlines = [SliceInline,UserInline,TagInline, NodeInline, SitePrivilegeInline, SiteDeploymentInline]
search_fields = ['name']
@@ -673,7 +683,8 @@
fieldsets = [
(None, {'fields': fieldList, 'classes':['collapse']})
]
- list_display = ('user', 'site', 'role')
+ list_display = ('backend_status_icon', 'user', 'site', 'role')
+ list_display_links = list_display
user_readonly_fields = fieldList
user_readonly_inlines = []
@@ -723,7 +734,8 @@
form = SliceForm
fieldList = ['backend_status', 'name', 'site', 'serviceClass', 'enabled','description', 'service', 'slice_url', 'max_slivers']
fieldsets = [('Slice Details', {'fields': fieldList, 'classes':['suit-tab suit-tab-general']}),]
- list_display = ('name', 'site','serviceClass', 'slice_url', 'max_slivers')
+ list_display = ('backend_status_icon', 'name', 'site','serviceClass', 'slice_url', 'max_slivers')
+ list_display_links = ('backend_status_icon', 'name', )
inlines = [SlicePrivilegeInline,SliverInline, TagInline, ReservationInline,SliceNetworkInline]
user_readonly_fields = fieldList
@@ -773,7 +785,8 @@
fieldsets = [
(None, {'fields': ['backend_status', 'user', 'slice', 'role']})
]
- list_display = ('user', 'slice', 'role')
+ list_display = ('backend_status_icon', 'user', 'slice', 'role')
+ list_display_links = list_display
user_readonly_fields = ['user', 'slice', 'role']
user_readonly_inlines = []
@@ -820,6 +833,9 @@
user_readonly_fields = ['name', 'disk_format', 'container_format']
+ list_display = ['backend_status_icon', 'name']
+ list_display_links = ('backend_status_icon', 'name', )
+
class NodeForm(forms.ModelForm):
class Meta:
widgets = {
@@ -829,7 +845,8 @@
class NodeAdmin(PlanetStackBaseAdmin):
form = NodeForm
- list_display = ('name', 'site', 'deployment')
+ list_display = ('backend_status_icon', 'name', 'site', 'deployment')
+ list_display_links = ('backend_status_icon', 'name', )
list_filter = ('deployment',)
inlines = [TagInline,SliverInline]
@@ -856,7 +873,8 @@
}
class TagAdmin(PlanetStackBaseAdmin):
- list_display = ['service', 'name', 'value', 'content_type', 'content_object',]
+ list_display = ['backend_status_icon', 'service', 'name', 'value', 'content_type', 'content_object',]
+ list_display_links = list_display
user_readonly_fields = ['service', 'name', 'value', 'content_type', 'content_object',]
user_readonly_inlines = []
@@ -865,7 +883,8 @@
fieldsets = [
('Sliver Details', {'fields': ['backend_status', 'slice', 'deploymentNetwork', 'node', 'ip', 'instance_name', 'numberCores', 'image', ], 'classes': ['suit-tab suit-tab-general'], })
]
- list_display = ['ip', 'instance_name', 'slice', 'numberCores', 'image', 'node', 'deploymentNetwork']
+ list_display = ['backend_status_icon', 'ip', 'instance_name', 'slice', 'numberCores', 'image', 'node', 'deploymentNetwork']
+ list_display_links = ('backend_status_icon', 'ip',)
suit_form_tabs =(('general', 'Sliver Details'),
('tags','Tags'),
@@ -1091,7 +1110,8 @@
extra = 0
class ServiceClassAdmin(PlanetStackBaseAdmin):
- list_display = ('backend_status', 'name', 'commitment', 'membershipFee')
+ list_display = ('backend_status_icon', 'name', 'commitment', 'membershipFee')
+ list_display_links = ('backend_status_icon', 'name', )
inlines = [ServiceResourceInline]
user_readonly_fields = ['name', 'commitment', 'membershipFee']
@@ -1237,12 +1257,14 @@
return Reservation.select_by_user(request.user)
class NetworkParameterTypeAdmin(PlanetStackBaseAdmin):
- list_display = ("name", )
+ list_display = ("backend_status_icon", "name", )
+ list_display_links = ('backend_status_icon', 'name', )
user_readonly_fields = ['name']
user_readonly_inlines = []
class RouterAdmin(PlanetStackBaseAdmin):
- list_display = ("name", )
+ list_display = ("backend_status_icon", "name", )
+ list_display_links = ('backend_status_icon', 'name', )
user_readonly_fields = ['name']
user_readonly_inlines = []
@@ -1281,7 +1303,8 @@
fields = ['backend_status', 'network','slice']
class NetworkAdmin(PlanetStackBaseAdmin):
- list_display = ("name", "subnet", "ports", "labels")
+ list_display = ("backend_status_icon", "name", "subnet", "ports", "labels")
+ list_display_links = ('backend_status_icon', 'name', )
readonly_fields = ("subnet", )
inlines = [NetworkParameterInline, NetworkSliversInline, NetworkSlicesInline, RouterInline]
@@ -1299,7 +1322,8 @@
('routers','Routers'),
)
class NetworkTemplateAdmin(PlanetStackBaseAdmin):
- list_display = ("name", "guaranteedBandwidth", "visibility")
+ list_display = ("backend_status_icon", "name", "guaranteedBandwidth", "visibility")
+ list_display_links = ('backend_status_icon', 'name', )
user_readonly_fields = ["name", "guaranteedBandwidth", "visibility"]
user_readonly_inlines = []
diff --git a/planetstack/hpc/admin.py b/planetstack/hpc/admin.py
index 1a4e77b..c90ec6c 100644
--- a/planetstack/hpc/admin.py
+++ b/planetstack/hpc/admin.py
@@ -16,7 +16,8 @@
model = HpcService
verbose_name = "HPC Service"
verbose_name_plural = "HPC Service"
- list_display = ("name","enabled")
+ list_display = ("backend_status_icon", "name","enabled")
+ list_display_links = ('backend_status_icon', 'name', )
fieldsets = [(None, {'fields': ['backend_status', 'name','enabled','versionNumber', 'description'], 'classes':['suit-tab suit-tab-general']})]
inlines = [SliceInline,ServiceAttrAsTabInline]
@@ -42,7 +43,8 @@
readonly_fields = ('content_provider_id',)
class OriginServerAdmin(ReadOnlyAwareAdmin):
- list_display = ('url','protocol','redirects','contentProvider','authenticated','enabled' )
+ list_display = ('backend_status_icon', 'url','protocol','redirects','contentProvider','authenticated','enabled' )
+ list_display_links = ('backend_status_icon', 'url', )
fields = ('backend_status', 'url','protocol','redirects','contentProvider','authenticated','enabled','origin_server_id','description' )
readonly_fields = ('origin_server_id',)
@@ -56,7 +58,8 @@
class ContentProviderAdmin(ReadOnlyAwareAdmin):
form = ContentProviderForm
- list_display = ('name','description','enabled' )
+ list_display = ('backend_status_icon', 'name','description','enabled' )
+ list_display_links = ('backend_status_icon', 'name', )
fieldsets = [ (None, {'fields': ['backend_status', 'name','enabled','description','serviceProvider','users'], 'classes':['suit-tab suit-tab-general']})]
inlines = [CDNPrefixInline]
@@ -66,7 +69,8 @@
suit_form_tabs = (('general','Details'),('prefixes','CDN Prefixes'))
class ServiceProviderAdmin(ReadOnlyAwareAdmin):
- list_display = ('name', 'description', 'enabled')
+ list_display = ('backend_status_icon', 'name', 'description', 'enabled')
+ list_display_links = ('backend_status_icon', 'name', )
fieldsets = [
(None, {'fields': ['backend_status', 'name','description','enabled'], 'classes':['suit-tab suit-tab-general']})]
#, ('Content Providers', {'fields':['contentProviders'],'classes':['suit-tab suit-tab-cps']})]
@@ -84,7 +88,8 @@
class CDNPrefixAdmin(ReadOnlyAwareAdmin):
form = CDNPrefixForm
- list_display = ['prefix','contentProvider']
+ list_display = ['backend_status_icon', 'prefix','contentProvider']
+ list_display_links = ('backend_status_icon', 'prefix', )
fields = ['backend_status', 'prefix', 'contentProvider', 'cdn_prefix_id', 'description', 'defaultOriginServer', 'enabled']
user_readonly_fields = ['prefix','contentProvider', "cdn_prefix_id", "description", "defaultOriginServer", "enabled"]
@@ -92,14 +97,16 @@
model = SiteMap
verbose_name = "Site Map"
verbose_name_plural = "Site Map"
- list_display = ("name", "contentProvider", "serviceProvider")
+ list_display = ("backend_status_icon", "name", "contentProvider", "serviceProvider")
+ list_display_links = ('backend_status_icon', 'name', )
user_readonly_fields = ('backend_status', "name", "contentProvider", "serviceProvider", "description", "map")
class AccessMapAdmin(ReadOnlyAwareAdmin):
model = AccessMap
verbose_name = "Access Map"
verbose_name_plural = "Access Map"
- list_display = ("name", "contentProvider")
+ list_display = ("backend_status_icon", "name", "contentProvider")
+ list_display_links = ('backend_status_icon', 'name', )
user_readonly_fields = ('backend_status', "name", "contentProvider", "description", "map")
admin.site.register(ServiceProvider, ServiceProviderAdmin)