Scott Baker | e791dc6 | 2014-08-28 14:02:54 -0700 | [diff] [blame] | 1 | """ PlusObjectMixin |
| 2 | |
| 3 | Implements fields that are common to all OpenCloud objects. For example, |
| 4 | stuff related to backend icons. |
| 5 | """ |
| 6 | |
Scott Baker | b6b474d | 2015-02-10 18:24:20 -0800 | [diff] [blame] | 7 | ICON_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 Baker | e791dc6 | 2014-08-28 14:02:54 -0700 | [diff] [blame] | 13 | class PlusObjectMixin: |
| 14 | def getBackendIcon(self): |
Scott Baker | b6b474d | 2015-02-10 18:24:20 -0800 | [diff] [blame] | 15 | (icon, tooltip) = self.get_backend_icon() |
| 16 | icon_url = ICON_URLS.get(icon, "unknown") |
| 17 | return icon_url |
Scott Baker | e791dc6 | 2014-08-28 14:02:54 -0700 | [diff] [blame] | 18 | |
| 19 | def getBackendHtml(self): |
Scott Baker | b6b474d | 2015-02-10 18:24:20 -0800 | [diff] [blame] | 20 | (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 Baker | e791dc6 | 2014-08-28 14:02:54 -0700 | [diff] [blame] | 25 | else: |
Scott Baker | b6b474d | 2015-02-10 18:24:20 -0800 | [diff] [blame] | 26 | return '<img src="%s">' % icon_url |
Scott Baker | e791dc6 | 2014-08-28 14:02:54 -0700 | [diff] [blame] | 27 | |
Scott Baker | d7df91d | 2015-02-10 10:25:03 -0800 | [diff] [blame] | 28 | |