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 | e5f9d7d | 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 | e5f9d7d | 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 | e5f9d7d | 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 | e5f9d7d | 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 | 664b44d | 2015-02-10 10:25:03 -0800 | [diff] [blame] | 28 | |