blob: a1001173e07a74ddd6fb20fa778310be1b273e4a [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, \
Scott Bakera36d77e2014-08-29 11:43:23 -070017 TenantViewData,TenantCreateSlice, TenantAddUser,TenantAddOrRemoveSliverView, TenantPickSitesView, TenantDeleteSliceView, \
18 TenantUpdateSlice, DashboardSliceInteractions, RequestAccessView
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"),
Scott Bakera36d77e2014-08-29 11:43:23 -070040 url(r'^welcome/$', self.admin_view(DashboardWelcomeView.as_view()),
41 name="welcome"),
Scott Baker771819b2014-03-19 22:10:17 -070042 url(r'^hpcdashboard/', self.admin_view(DashboardAjaxView.as_view()), # DEPRECATED
43 name="hpcdashboard"),
44 url(r'^simulator/', self.admin_view(SimulatorView.as_view()),
45 name="simulator"),
46 url(r'^hpcsummary/', self.admin_view(DashboardSummaryAjaxView.as_view()), # DEPRECATED
47 name="hpcsummary"),
Scott Baker27412cd2014-03-27 09:01:28 -070048 url(r'^analytics/(?P<name>\w+)/$', DashboardAnalyticsAjaxView.as_view(),
Scott Baker771819b2014-03-19 22:10:17 -070049 name="analytics"),
50 url(r'^dashboardaddorremsliver/$', self.admin_view(DashboardAddOrRemoveSliverView.as_view()),
Scott Baker537d8232014-04-08 23:40:56 -070051 name="addorremsliver"),
Scott Baker6253dfc2014-04-14 09:29:30 -070052 url(r'^tenantaddorremsliver/$', self.admin_view(TenantAddOrRemoveSliverView.as_view()),
53 name="tenantaddorremsliver"),
Scott Baker537d8232014-04-08 23:40:56 -070054 url(r'^tenantview/$', self.admin_view(TenantViewData.as_view()),
55 name="tenantview"),
56 url(r'^createnewslice/$', self.admin_view(TenantCreateSlice.as_view()),
Scott Bakerbd57a432014-04-14 16:12:15 -070057 name="createnewslice"),
Scott Bakera36d77e2014-08-29 11:43:23 -070058 url(r'^adduser/$', self.admin_view(TenantAddUser.as_view()),
59 name="adduser"),
60 url(r'^requestaccess/$', RequestAccessView.as_view(),
61 name="requestacces"),
Scott Bakerae04d8d2014-04-22 21:02:45 -070062 url(r'^updateslice/$', self.admin_view(TenantUpdateSlice.as_view()),
63 name="updateslice"),
Scott Bakerbd57a432014-04-14 16:12:15 -070064 url(r'^picksites/$', self.admin_view(TenantPickSitesView.as_view()),
Scott Bakerae04d8d2014-04-22 21:02:45 -070065 name="picksites"),
66 url(r'^tenantdeleteslice/$', self.admin_view(TenantDeleteSliceView.as_view()),
67 name="tenantdeleteslice")
Scott Bakerbb7e84f2014-06-16 23:08:43 -070068 ]
Siobhan Tullycf04fb62014-01-11 11:25:57 -050069
Scott Bakerbb7e84f2014-06-16 23:08:43 -070070 # these ones are for the views that have a "url" member in the class
71 for (view_url, view_classname, view_class) in view_urls:
72 dashboard_urls.append( url(view_url, self.admin_view(view_class.as_view()), name=view_classname.lower()))
73
74 return dashboard_urls + urls
Siobhan Tullycf04fb62014-01-11 11:25:57 -050075
76
77class SitePlus(AdminMixin, AdminSite):
78 """
79 A Django AdminSite with the AdminMixin to allow registering custom
80 dashboard view.
81 """