blob: 66c5d00bc7761b1efc88a6d4ae33ffb77c43616b [file] [log] [blame]
Siobhan Tullycf04fb62014-01-11 11:25:57 -05001#sites.py
2
3from django.contrib.admin.sites import AdminSite
4
5
6class 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 Baker2c3cb642014-05-19 17:55:56 -070015 from views import DashboardCustomize, DashboardDynamicView, DashboardWelcomeView, DashboardAjaxView, SimulatorView, DashboardSummaryAjaxView, DashboardAddOrRemoveSliverView, DashboardUserSiteView, DashboardAnalyticsAjaxView, TenantViewData,TenantCreateSlice, TenantAddOrRemoveSliverView, TenantPickSitesView, TenantDeleteSliceView,TenantUpdateSlice
Siobhan Tullycf04fb62014-01-11 11:25:57 -050016
17 urls = super(AdminMixin, self).get_urls()
18 del urls[0]
19 custom_url = patterns('',
Scott Baker2c3cb642014-05-19 17:55:56 -070020 url(r'^$', self.admin_view(DashboardDynamicView.as_view()),
Siobhan Tully06d2c032014-02-23 23:48:52 -050021 name="index"),
Scott Baker537d8232014-04-08 23:40:56 -070022 url(r'^test/', self.admin_view(DashboardUserSiteView.as_view()),
23 name="test"),
Scott Baker2c3cb642014-05-19 17:55:56 -070024 url(r'^dashboard/(?P<name>\w+)/$', self.admin_view(DashboardDynamicView.as_view()),
Scott Baker186ae612014-05-19 10:42:51 -070025 name="dashboard"),
Scott Baker2c3cb642014-05-19 17:55:56 -070026 url(r'^customize/$', self.admin_view(DashboardCustomize.as_view()),
27 name="customize"),
Scott Baker771819b2014-03-19 22:10:17 -070028 url(r'^hpcdashuserslices/', self.admin_view(DashboardUserSiteView.as_view()),
29 name="hpcdashuserslices"),
30 url(r'^hpcdashboard/', self.admin_view(DashboardAjaxView.as_view()), # DEPRECATED
31 name="hpcdashboard"),
32 url(r'^simulator/', self.admin_view(SimulatorView.as_view()),
33 name="simulator"),
34 url(r'^hpcsummary/', self.admin_view(DashboardSummaryAjaxView.as_view()), # DEPRECATED
35 name="hpcsummary"),
Scott Baker27412cd2014-03-27 09:01:28 -070036 url(r'^analytics/(?P<name>\w+)/$', DashboardAnalyticsAjaxView.as_view(),
Scott Baker771819b2014-03-19 22:10:17 -070037 name="analytics"),
38 url(r'^dashboardaddorremsliver/$', self.admin_view(DashboardAddOrRemoveSliverView.as_view()),
Scott Baker537d8232014-04-08 23:40:56 -070039 name="addorremsliver"),
Scott Baker6253dfc2014-04-14 09:29:30 -070040 url(r'^tenantaddorremsliver/$', self.admin_view(TenantAddOrRemoveSliverView.as_view()),
41 name="tenantaddorremsliver"),
Scott Baker537d8232014-04-08 23:40:56 -070042 url(r'^tenantview/$', self.admin_view(TenantViewData.as_view()),
43 name="tenantview"),
44 url(r'^createnewslice/$', self.admin_view(TenantCreateSlice.as_view()),
Scott Bakerbd57a432014-04-14 16:12:15 -070045 name="createnewslice"),
Scott Bakerae04d8d2014-04-22 21:02:45 -070046 url(r'^updateslice/$', self.admin_view(TenantUpdateSlice.as_view()),
47 name="updateslice"),
Scott Bakerbd57a432014-04-14 16:12:15 -070048 url(r'^picksites/$', self.admin_view(TenantPickSitesView.as_view()),
Scott Bakerae04d8d2014-04-22 21:02:45 -070049 name="picksites"),
50 url(r'^tenantdeleteslice/$', self.admin_view(TenantDeleteSliceView.as_view()),
51 name="tenantdeleteslice")
Siobhan Tullycf04fb62014-01-11 11:25:57 -050052 )
53
54 return custom_url + urls
55
56
57class SitePlus(AdminMixin, AdminSite):
58 """
59 A Django AdminSite with the AdminMixin to allow registering custom
60 dashboard view.
61 """