refactor the backend icon stuff to one spot
diff --git a/planetstack/core/xoslib/objects/plus.py b/planetstack/core/xoslib/objects/plus.py
index 01cb8d7..da59ac7 100644
--- a/planetstack/core/xoslib/objects/plus.py
+++ b/planetstack/core/xoslib/objects/plus.py
@@ -4,20 +4,25 @@
stuff related to backend icons.
"""
+ICON_URLS = {"success": "/static/admin/img/icon_success.gif",
+ "clock": "/static/admin/img/icon_clock.gif",
+ "error": "/static/admin/img/icon_error.gif"}
+
+
+
class PlusObjectMixin:
def getBackendIcon(self):
- if (self.enacted is not None) and self.enacted >= self.updated or self.backend_status.startswith("1 -"):
- return "/static/admin/img/icon_success.gif"
- else:
- if ((self.backend_status is not None) and self.backend_status.startswith("0 -")) or self.backend_status == "Provisioning in progress" or self.backend_status=="":
- return "/static/admin/img/icon_clock.gif"
- else:
- return "/static/admin/img/icon_error.gif"
+ (icon, tooltip) = self.get_backend_icon()
+ icon_url = ICON_URLS.get(icon, "unknown")
+ return icon_url
def getBackendHtml(self):
- if (self.enacted is not None) and self.enacted >= self.updated:
- return '<img src="%s">' % self.getBackendIcon()
+ (icon, tooltip) = self.get_backend_icon()
+ icon_url = ICON_URLS.get(icon, "unknown")
+
+ if tooltip:
+ return '<span title="%s"><img src="%s"></span>' % (tooltip, icon_url)
else:
- return '<span title="%s"><img src="%s"></span>' % (self.backend_status, self.getBackendIcon())
+ return '<img src="%s">' % icon_url