Merge branch 'master' of ssh://git.planet-lab.org/git/plstackapi
[plstackapi.git] / planetstack / core / admin.py
index 3ff973f..1d64d9c 100644 (file)
@@ -21,12 +21,12 @@ import django_evolution
 def backend_icon(obj): # backend_status, enacted, updated):
     #return "%s %s %s" % (str(obj.updated), str(obj.enacted), str(obj.backend_status))
     if (obj.enacted is not None) and obj.enacted >= obj.updated:
-        return '<img src="/static/admin/img/icon_success.gif">'
+        return '<span style="min-width:16px;"><img src="/static/admin/img/icon_success.gif"></span>'
     else:
         if obj.backend_status == "Provisioning in progress" or obj.backend_status=="":
-            return '<span title="%s"><img src="/static/admin/img/icon_clock.gif"></span>' % obj.backend_status
+            return '<span style="min-width:16px;" title="%s"><img src="/static/admin/img/icon_clock.gif"></span>' % obj.backend_status
         else:
-            return '<span title="%s"><img src="/static/admin/img/icon_error.gif"></span>' % obj.backend_status
+            return '<span style="min-width:16px;" title="%s"><img src="/static/admin/img/icon_error.gif"></span>' % obj.backend_status
 
 def backend_text(obj):
     icon = backend_icon(obj)
@@ -285,41 +285,6 @@ class SliverInline(PlStackTabularInline):
 
         return field
 
-"""
-    SMBAKER: This is the old code that implemented each network type as a
-    separate column in the sliver table.
-
-    def _declared_fieldsets(self):
-        # Return None so django will call get_fieldsets and we can insert our
-        # dynamic fields
-        return None
-
-    def get_readonly_fields(self, request, obj=None):
-        readonly_fields = list(super(SliverInline, self).get_readonly_fields(request, obj))
-
-        # Lookup the networks that are bound to the slivers, and add those
-        # network names to the list of readonly fields.
-
-        for sliver in obj.slivers.all():
-            for nbs in sliver.networksliver_set.all():
-                if nbs.ip:
-                    network_name = nbs.network.name
-                    if network_name not in [str(x) for x in readonly_fields]:
-                        readonly_fields.append(NetworkLookerUpper.get(network_name))
-
-        return readonly_fields
-
-    def get_fieldsets(self, request, obj=None):
-        form = self.get_formset(request, obj).form
-        # fields = the read/write files + the read-only fields
-        fields = list(self.fields)
-        for fieldName in self.get_readonly_fields(request,obj):
-            if not fieldName in fields:
-                fields.append(fieldName)
-
-        return [(None, {'fields': fields})]
-"""
-
 class SiteInline(PlStackTabularInline):
     model = Site
     extra = 0
@@ -764,12 +729,18 @@ class SliceAdmin(PlanetStackBaseAdmin):
             for deployment in flavor.deployments.all():
                 deployment_flavors.append( (deployment.id, flavor.id, flavor.name) )
 
+        deployment_images = []
+        for image in Image.objects.all():
+            for imageDeployment in image.imagedeployments_set.all():
+                deployment_images.append( (imageDeployment.deployment.id, image.id, image.name) )
+
         site_login_bases = []
         for site in Site.objects.all():
-            site_login_bases.append((site.id, site.login_base)) 
-        
+            site_login_bases.append((site.id, site.login_base))
+
         context["deployment_nodes"] = deployment_nodes
         context["deployment_flavors"] = deployment_flavors
+        context["deployment_images"] = deployment_images
         context["site_login_bases"] = site_login_bases
         return super(SliceAdmin, self).render_change_form(request, context, add, change, form_url, obj)