Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 1 | #sites.py |
| 2 | |
| 3 | from django.contrib.admin.sites import AdminSite |
| 4 | |
| 5 | |
| 6 | class AdminMixin(object): |
| 7 | """Mixin for AdminSite to allow custom dashboard views.""" |
| 8 | |
| 9 | def __init__(self, *args, **kwargs): |
| 10 | return super(AdminMixin, self).__init__(*args, **kwargs) |
| 11 | |
| 12 | def get_urls(self): |
| 13 | """Add our dashboard view to the admin urlconf. Deleted the default index.""" |
| 14 | from django.conf.urls import patterns, url |
Scott Baker | ae04d8d | 2014-04-22 21:02:45 -0700 | [diff] [blame] | 15 | from views import DashboardWelcomeView, DashboardAjaxView, SimulatorView, DashboardSummaryAjaxView, DashboardAddOrRemoveSliverView, DashboardUserSiteView, DashboardAnalyticsAjaxView, TenantViewData,TenantCreateSlice, TenantAddOrRemoveSliverView, TenantPickSitesView, TenantDeleteSliceView,TenantUpdateSlice |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 16 | |
| 17 | urls = super(AdminMixin, self).get_urls() |
| 18 | del urls[0] |
| 19 | custom_url = patterns('', |
Scott Baker | 771819b | 2014-03-19 22:10:17 -0700 | [diff] [blame] | 20 | url(r'^$', self.admin_view(DashboardWelcomeView.as_view()), |
Siobhan Tully | 06d2c03 | 2014-02-23 23:48:52 -0500 | [diff] [blame] | 21 | name="index"), |
Scott Baker | 537d823 | 2014-04-08 23:40:56 -0700 | [diff] [blame] | 22 | url(r'^test/', self.admin_view(DashboardUserSiteView.as_view()), |
| 23 | name="test"), |
Scott Baker | 771819b | 2014-03-19 22:10:17 -0700 | [diff] [blame] | 24 | url(r'^hpcdashuserslices/', self.admin_view(DashboardUserSiteView.as_view()), |
| 25 | name="hpcdashuserslices"), |
| 26 | url(r'^hpcdashboard/', self.admin_view(DashboardAjaxView.as_view()), # DEPRECATED |
| 27 | name="hpcdashboard"), |
| 28 | url(r'^simulator/', self.admin_view(SimulatorView.as_view()), |
| 29 | name="simulator"), |
| 30 | url(r'^hpcsummary/', self.admin_view(DashboardSummaryAjaxView.as_view()), # DEPRECATED |
| 31 | name="hpcsummary"), |
Scott Baker | 27412cd | 2014-03-27 09:01:28 -0700 | [diff] [blame] | 32 | url(r'^analytics/(?P<name>\w+)/$', DashboardAnalyticsAjaxView.as_view(), |
Scott Baker | 771819b | 2014-03-19 22:10:17 -0700 | [diff] [blame] | 33 | name="analytics"), |
| 34 | url(r'^dashboardaddorremsliver/$', self.admin_view(DashboardAddOrRemoveSliverView.as_view()), |
Scott Baker | 537d823 | 2014-04-08 23:40:56 -0700 | [diff] [blame] | 35 | name="addorremsliver"), |
Scott Baker | 6253dfc | 2014-04-14 09:29:30 -0700 | [diff] [blame] | 36 | url(r'^tenantaddorremsliver/$', self.admin_view(TenantAddOrRemoveSliverView.as_view()), |
| 37 | name="tenantaddorremsliver"), |
Scott Baker | 537d823 | 2014-04-08 23:40:56 -0700 | [diff] [blame] | 38 | url(r'^tenantview/$', self.admin_view(TenantViewData.as_view()), |
| 39 | name="tenantview"), |
| 40 | url(r'^createnewslice/$', self.admin_view(TenantCreateSlice.as_view()), |
Scott Baker | bd57a43 | 2014-04-14 16:12:15 -0700 | [diff] [blame] | 41 | name="createnewslice"), |
Scott Baker | ae04d8d | 2014-04-22 21:02:45 -0700 | [diff] [blame] | 42 | url(r'^updateslice/$', self.admin_view(TenantUpdateSlice.as_view()), |
| 43 | name="updateslice"), |
Scott Baker | bd57a43 | 2014-04-14 16:12:15 -0700 | [diff] [blame] | 44 | url(r'^picksites/$', self.admin_view(TenantPickSitesView.as_view()), |
Scott Baker | ae04d8d | 2014-04-22 21:02:45 -0700 | [diff] [blame] | 45 | name="picksites"), |
| 46 | url(r'^tenantdeleteslice/$', self.admin_view(TenantDeleteSliceView.as_view()), |
| 47 | name="tenantdeleteslice") |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 48 | ) |
| 49 | |
| 50 | return custom_url + urls |
| 51 | |
| 52 | |
| 53 | class SitePlus(AdminMixin, AdminSite): |
| 54 | """ |
| 55 | A Django AdminSite with the AdminMixin to allow registering custom |
| 56 | dashboard view. |
| 57 | """ |