blob: efa1b8391ff919cc546de426014bee0b5333abbc [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 Bakerbd57a432014-04-14 16:12:15 -070015 from views import DashboardWelcomeView, DashboardAjaxView, SimulatorView, DashboardSummaryAjaxView, DashboardAddOrRemoveSliverView, DashboardUserSiteView, DashboardAnalyticsAjaxView, TenantViewData,TenantCreateSlice, TenantAddOrRemoveSliverView, TenantPickSitesView
Siobhan Tullycf04fb62014-01-11 11:25:57 -050016
17 urls = super(AdminMixin, self).get_urls()
18 del urls[0]
19 custom_url = patterns('',
Scott Baker771819b2014-03-19 22:10:17 -070020 url(r'^$', self.admin_view(DashboardWelcomeView.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 Baker771819b2014-03-19 22:10:17 -070024 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 Baker27412cd2014-03-27 09:01:28 -070032 url(r'^analytics/(?P<name>\w+)/$', DashboardAnalyticsAjaxView.as_view(),
Scott Baker771819b2014-03-19 22:10:17 -070033 name="analytics"),
34 url(r'^dashboardaddorremsliver/$', self.admin_view(DashboardAddOrRemoveSliverView.as_view()),
Scott Baker537d8232014-04-08 23:40:56 -070035 name="addorremsliver"),
Scott Baker6253dfc2014-04-14 09:29:30 -070036 url(r'^tenantaddorremsliver/$', self.admin_view(TenantAddOrRemoveSliverView.as_view()),
37 name="tenantaddorremsliver"),
Scott Baker537d8232014-04-08 23:40:56 -070038 url(r'^tenantview/$', self.admin_view(TenantViewData.as_view()),
39 name="tenantview"),
40 url(r'^createnewslice/$', self.admin_view(TenantCreateSlice.as_view()),
Scott Bakerbd57a432014-04-14 16:12:15 -070041 name="createnewslice"),
42 url(r'^picksites/$', self.admin_view(TenantPickSitesView.as_view()),
43 name="picksites")
Siobhan Tullycf04fb62014-01-11 11:25:57 -050044 )
45
46 return custom_url + urls
47
48
49class SitePlus(AdminMixin, AdminSite):
50 """
51 A Django AdminSite with the AdminMixin to allow registering custom
52 dashboard view.
53 """