blob: 5d670d0016c66c6e582a8f1d4541e82755373751 [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 Baker6b654202014-05-27 16:55:00 -070015 from views import DashboardCustomize, DashboardDynamicView, DashboardWelcomeView, DashboardAjaxView, SimulatorView, \
16 DashboardSummaryAjaxView, DashboardAddOrRemoveSliverView, DashboardUserSiteView, DashboardAnalyticsAjaxView, \
17 TenantViewData,TenantCreateSlice, TenantAddOrRemoveSliverView, TenantPickSitesView, TenantDeleteSliceView, \
18 TenantUpdateSlice, DashboardSliceInteractions
Siobhan Tullycf04fb62014-01-11 11:25:57 -050019
20 urls = super(AdminMixin, self).get_urls()
21 del urls[0]
22 custom_url = patterns('',
Scott Baker2c3cb642014-05-19 17:55:56 -070023 url(r'^$', self.admin_view(DashboardDynamicView.as_view()),
Siobhan Tully06d2c032014-02-23 23:48:52 -050024 name="index"),
Scott Baker537d8232014-04-08 23:40:56 -070025 url(r'^test/', self.admin_view(DashboardUserSiteView.as_view()),
26 name="test"),
Scott Baker6b654202014-05-27 16:55:00 -070027 url(r'^sliceinteractions/(?P<name>\w+)/$', self.admin_view(DashboardSliceInteractions.as_view()),
28 name="interactions"),
Scott Baker2c3cb642014-05-19 17:55:56 -070029 url(r'^dashboard/(?P<name>\w+)/$', self.admin_view(DashboardDynamicView.as_view()),
Scott Baker186ae612014-05-19 10:42:51 -070030 name="dashboard"),
Scott Baker2c3cb642014-05-19 17:55:56 -070031 url(r'^customize/$', self.admin_view(DashboardCustomize.as_view()),
32 name="customize"),
Scott Baker771819b2014-03-19 22:10:17 -070033 url(r'^hpcdashuserslices/', self.admin_view(DashboardUserSiteView.as_view()),
34 name="hpcdashuserslices"),
35 url(r'^hpcdashboard/', self.admin_view(DashboardAjaxView.as_view()), # DEPRECATED
36 name="hpcdashboard"),
37 url(r'^simulator/', self.admin_view(SimulatorView.as_view()),
38 name="simulator"),
39 url(r'^hpcsummary/', self.admin_view(DashboardSummaryAjaxView.as_view()), # DEPRECATED
40 name="hpcsummary"),
Scott Baker27412cd2014-03-27 09:01:28 -070041 url(r'^analytics/(?P<name>\w+)/$', DashboardAnalyticsAjaxView.as_view(),
Scott Baker771819b2014-03-19 22:10:17 -070042 name="analytics"),
43 url(r'^dashboardaddorremsliver/$', self.admin_view(DashboardAddOrRemoveSliverView.as_view()),
Scott Baker537d8232014-04-08 23:40:56 -070044 name="addorremsliver"),
Scott Baker6253dfc2014-04-14 09:29:30 -070045 url(r'^tenantaddorremsliver/$', self.admin_view(TenantAddOrRemoveSliverView.as_view()),
46 name="tenantaddorremsliver"),
Scott Baker537d8232014-04-08 23:40:56 -070047 url(r'^tenantview/$', self.admin_view(TenantViewData.as_view()),
48 name="tenantview"),
49 url(r'^createnewslice/$', self.admin_view(TenantCreateSlice.as_view()),
Scott Bakerbd57a432014-04-14 16:12:15 -070050 name="createnewslice"),
Scott Bakerae04d8d2014-04-22 21:02:45 -070051 url(r'^updateslice/$', self.admin_view(TenantUpdateSlice.as_view()),
52 name="updateslice"),
Scott Bakerbd57a432014-04-14 16:12:15 -070053 url(r'^picksites/$', self.admin_view(TenantPickSitesView.as_view()),
Scott Bakerae04d8d2014-04-22 21:02:45 -070054 name="picksites"),
55 url(r'^tenantdeleteslice/$', self.admin_view(TenantDeleteSliceView.as_view()),
56 name="tenantdeleteslice")
Siobhan Tullycf04fb62014-01-11 11:25:57 -050057 )
58
59 return custom_url + urls
60
61
62class SitePlus(AdminMixin, AdminSite):
63 """
64 A Django AdminSite with the AdminMixin to allow registering custom
65 dashboard view.
66 """