blob: 7200035f82b2b4b7e765404210feebfd0c8289f2 [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
Scott Bakerbb7e84f2014-06-16 23:08:43 -070020 from views import view_urls
21
Siobhan Tullycf04fb62014-01-11 11:25:57 -050022 urls = super(AdminMixin, self).get_urls()
23 del urls[0]
Scott Bakerbb7e84f2014-06-16 23:08:43 -070024
25 # these ones are for the views that were written before we implemented
26 # the ability to get the url from the View class.
27 dashboard_urls = [
Scott Baker2c3cb642014-05-19 17:55:56 -070028 url(r'^$', self.admin_view(DashboardDynamicView.as_view()),
Siobhan Tully06d2c032014-02-23 23:48:52 -050029 name="index"),
Scott Baker537d8232014-04-08 23:40:56 -070030 url(r'^test/', self.admin_view(DashboardUserSiteView.as_view()),
31 name="test"),
Scott Baker6b654202014-05-27 16:55:00 -070032 url(r'^sliceinteractions/(?P<name>\w+)/$', self.admin_view(DashboardSliceInteractions.as_view()),
33 name="interactions"),
Scott Baker2c3cb642014-05-19 17:55:56 -070034 url(r'^dashboard/(?P<name>\w+)/$', self.admin_view(DashboardDynamicView.as_view()),
Scott Baker186ae612014-05-19 10:42:51 -070035 name="dashboard"),
Scott Baker2c3cb642014-05-19 17:55:56 -070036 url(r'^customize/$', self.admin_view(DashboardCustomize.as_view()),
37 name="customize"),
Scott Baker771819b2014-03-19 22:10:17 -070038 url(r'^hpcdashuserslices/', self.admin_view(DashboardUserSiteView.as_view()),
39 name="hpcdashuserslices"),
40 url(r'^hpcdashboard/', self.admin_view(DashboardAjaxView.as_view()), # DEPRECATED
41 name="hpcdashboard"),
42 url(r'^simulator/', self.admin_view(SimulatorView.as_view()),
43 name="simulator"),
44 url(r'^hpcsummary/', self.admin_view(DashboardSummaryAjaxView.as_view()), # DEPRECATED
45 name="hpcsummary"),
Scott Baker27412cd2014-03-27 09:01:28 -070046 url(r'^analytics/(?P<name>\w+)/$', DashboardAnalyticsAjaxView.as_view(),
Scott Baker771819b2014-03-19 22:10:17 -070047 name="analytics"),
48 url(r'^dashboardaddorremsliver/$', self.admin_view(DashboardAddOrRemoveSliverView.as_view()),
Scott Baker537d8232014-04-08 23:40:56 -070049 name="addorremsliver"),
Scott Baker6253dfc2014-04-14 09:29:30 -070050 url(r'^tenantaddorremsliver/$', self.admin_view(TenantAddOrRemoveSliverView.as_view()),
51 name="tenantaddorremsliver"),
Scott Baker537d8232014-04-08 23:40:56 -070052 url(r'^tenantview/$', self.admin_view(TenantViewData.as_view()),
53 name="tenantview"),
54 url(r'^createnewslice/$', self.admin_view(TenantCreateSlice.as_view()),
Scott Bakerbd57a432014-04-14 16:12:15 -070055 name="createnewslice"),
Scott Bakerae04d8d2014-04-22 21:02:45 -070056 url(r'^updateslice/$', self.admin_view(TenantUpdateSlice.as_view()),
57 name="updateslice"),
Scott Bakerbd57a432014-04-14 16:12:15 -070058 url(r'^picksites/$', self.admin_view(TenantPickSitesView.as_view()),
Scott Bakerae04d8d2014-04-22 21:02:45 -070059 name="picksites"),
60 url(r'^tenantdeleteslice/$', self.admin_view(TenantDeleteSliceView.as_view()),
61 name="tenantdeleteslice")
Scott Bakerbb7e84f2014-06-16 23:08:43 -070062 ]
Siobhan Tullycf04fb62014-01-11 11:25:57 -050063
Scott Bakerbb7e84f2014-06-16 23:08:43 -070064 # these ones are for the views that have a "url" member in the class
65 for (view_url, view_classname, view_class) in view_urls:
66 dashboard_urls.append( url(view_url, self.admin_view(view_class.as_view()), name=view_classname.lower()))
67
68 return dashboard_urls + urls
Siobhan Tullycf04fb62014-01-11 11:25:57 -050069
70
71class SitePlus(AdminMixin, AdminSite):
72 """
73 A Django AdminSite with the AdminMixin to allow registering custom
74 dashboard view.
75 """