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 | |
| 7 | class PlusObjectMixin: |
| 8 | def getBackendIcon(self): |
| 9 | if (self.enacted is not None) and self.enacted >= self.updated: |
| 10 | return "/static/admin/img/icon_success.gif" |
| 11 | else: |
| 12 | if self.backend_status == "Provisioning in progress" or self.backend_status=="": |
| 13 | return "/static/admin/img/icon_clock.gif" |
| 14 | else: |
| 15 | return "/static/admin/img/icon_error.gif" |
| 16 | |
| 17 | def getBackendHtml(self): |
| 18 | if (self.enacted is not None) and self.enacted >= self.updated: |
| 19 | return '<img src="%s">' % self.getBackendIcon() |
| 20 | else: |
| 21 | return '<div title="%s"><img src="%s"></div>' % (self.backend_status, self.getBackendIcon()) |
| 22 | |