blob: da59ac7bf7ac31ff3cc481ecded4aaf07bf3b8ca [file] [log] [blame]
Scott Bakere791dc62014-08-28 14:02:54 -07001""" PlusObjectMixin
2
3 Implements fields that are common to all OpenCloud objects. For example,
4 stuff related to backend icons.
5"""
6
Scott Bakerb6b474d2015-02-10 18:24:20 -08007ICON_URLS = {"success": "/static/admin/img/icon_success.gif",
8 "clock": "/static/admin/img/icon_clock.gif",
9 "error": "/static/admin/img/icon_error.gif"}
10
11
12
Scott Bakere791dc62014-08-28 14:02:54 -070013class PlusObjectMixin:
14 def getBackendIcon(self):
Scott Bakerb6b474d2015-02-10 18:24:20 -080015 (icon, tooltip) = self.get_backend_icon()
16 icon_url = ICON_URLS.get(icon, "unknown")
17 return icon_url
Scott Bakere791dc62014-08-28 14:02:54 -070018
19 def getBackendHtml(self):
Scott Bakerb6b474d2015-02-10 18:24:20 -080020 (icon, tooltip) = self.get_backend_icon()
21 icon_url = ICON_URLS.get(icon, "unknown")
22
23 if tooltip:
24 return '<span title="%s"><img src="%s"></span>' % (tooltip, icon_url)
Scott Bakere791dc62014-08-28 14:02:54 -070025 else:
Scott Bakerb6b474d2015-02-10 18:24:20 -080026 return '<img src="%s">' % icon_url
Scott Bakere791dc62014-08-28 14:02:54 -070027
Scott Bakerd7df91d2015-02-10 10:25:03 -080028