blob: 194e8059ed58f231961751717156174d9e5d6d8f [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 Baker731723b2014-11-03 15:59:52 -080036 url(r'^dashboardWholePage/(?P<name>\w+)/$', self.admin_view(DashboardDynamicView.as_view()),
37 {"wholePage": True},
38 name="dashboardWholePage"),
Scott Baker2c3cb642014-05-19 17:55:56 -070039 url(r'^customize/$', self.admin_view(DashboardCustomize.as_view()),
40 name="customize"),
Scott Baker771819b2014-03-19 22:10:17 -070041 url(r'^hpcdashuserslices/', self.admin_view(DashboardUserSiteView.as_view()),
42 name="hpcdashuserslices"),
Scott Bakera36d77e2014-08-29 11:43:23 -070043 url(r'^welcome/$', self.admin_view(DashboardWelcomeView.as_view()),
44 name="welcome"),
Scott Baker771819b2014-03-19 22:10:17 -070045 url(r'^hpcdashboard/', self.admin_view(DashboardAjaxView.as_view()), # DEPRECATED
46 name="hpcdashboard"),
47 url(r'^simulator/', self.admin_view(SimulatorView.as_view()),
48 name="simulator"),
49 url(r'^hpcsummary/', self.admin_view(DashboardSummaryAjaxView.as_view()), # DEPRECATED
50 name="hpcsummary"),
Scott Baker27412cd2014-03-27 09:01:28 -070051 url(r'^analytics/(?P<name>\w+)/$', DashboardAnalyticsAjaxView.as_view(),
Scott Baker771819b2014-03-19 22:10:17 -070052 name="analytics"),
53 url(r'^dashboardaddorremsliver/$', self.admin_view(DashboardAddOrRemoveSliverView.as_view()),
Scott Baker537d8232014-04-08 23:40:56 -070054 name="addorremsliver"),
Scott Baker6253dfc2014-04-14 09:29:30 -070055 url(r'^tenantaddorremsliver/$', self.admin_view(TenantAddOrRemoveSliverView.as_view()),
56 name="tenantaddorremsliver"),
Scott Baker537d8232014-04-08 23:40:56 -070057 url(r'^tenantview/$', self.admin_view(TenantViewData.as_view()),
58 name="tenantview"),
59 url(r'^createnewslice/$', self.admin_view(TenantCreateSlice.as_view()),
Scott Bakerbd57a432014-04-14 16:12:15 -070060 name="createnewslice"),
Scott Bakera36d77e2014-08-29 11:43:23 -070061 url(r'^adduser/$', self.admin_view(TenantAddUser.as_view()),
62 name="adduser"),
63 url(r'^requestaccess/$', RequestAccessView.as_view(),
64 name="requestacces"),
Scott Bakerae04d8d2014-04-22 21:02:45 -070065 url(r'^updateslice/$', self.admin_view(TenantUpdateSlice.as_view()),
66 name="updateslice"),
Scott Bakerbd57a432014-04-14 16:12:15 -070067 url(r'^picksites/$', self.admin_view(TenantPickSitesView.as_view()),
Scott Bakerae04d8d2014-04-22 21:02:45 -070068 name="picksites"),
69 url(r'^tenantdeleteslice/$', self.admin_view(TenantDeleteSliceView.as_view()),
70 name="tenantdeleteslice")
Scott Bakerbb7e84f2014-06-16 23:08:43 -070071 ]
Siobhan Tullycf04fb62014-01-11 11:25:57 -050072
Scott Bakerbb7e84f2014-06-16 23:08:43 -070073 # these ones are for the views that have a "url" member in the class
74 for (view_url, view_classname, view_class) in view_urls:
75 dashboard_urls.append( url(view_url, self.admin_view(view_class.as_view()), name=view_classname.lower()))
76
77 return dashboard_urls + urls
Siobhan Tullycf04fb62014-01-11 11:25:57 -050078
79
80class SitePlus(AdminMixin, AdminSite):
81 """
82 A Django AdminSite with the AdminMixin to allow registering custom
83 dashboard view.
84 """