blob: 4a2e742619122802c21e89a16776d73dae0d6d5f [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 Baker25df4362015-02-04 16:34:18 -080015 from views import DashboardCustomize, DashboardDynamicView, SimulatorView, \
Scott Baker3307ce62015-02-02 16:23:52 -080016 DashboardUserSiteView, \
17 TenantViewData, TenantCreateSlice, TenantAddUser,TenantAddOrRemoveSliverView, TenantPickSitesView, TenantDeleteSliceView, \
Scott Bakera36d77e2014-08-29 11:43:23 -070018 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 Bakerb9da9212014-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 Baker25df4362015-02-04 16:34:18 -080043 url(r'^welcome/$', self.admin_view(DashboardDynamicView.as_view()),
Scott Bakera36d77e2014-08-29 11:43:23 -070044 name="welcome"),
Scott Baker771819b2014-03-19 22:10:17 -070045 url(r'^simulator/', self.admin_view(SimulatorView.as_view()),
46 name="simulator"),
Scott Baker6253dfc2014-04-14 09:29:30 -070047 url(r'^tenantaddorremsliver/$', self.admin_view(TenantAddOrRemoveSliverView.as_view()),
48 name="tenantaddorremsliver"),
Scott Baker537d8232014-04-08 23:40:56 -070049 url(r'^tenantview/$', self.admin_view(TenantViewData.as_view()),
50 name="tenantview"),
51 url(r'^createnewslice/$', self.admin_view(TenantCreateSlice.as_view()),
Scott Bakerbd57a432014-04-14 16:12:15 -070052 name="createnewslice"),
Scott Bakera36d77e2014-08-29 11:43:23 -070053 url(r'^adduser/$', self.admin_view(TenantAddUser.as_view()),
54 name="adduser"),
55 url(r'^requestaccess/$', RequestAccessView.as_view(),
56 name="requestacces"),
Scott Bakerae04d8d2014-04-22 21:02:45 -070057 url(r'^updateslice/$', self.admin_view(TenantUpdateSlice.as_view()),
58 name="updateslice"),
Scott Bakerbd57a432014-04-14 16:12:15 -070059 url(r'^picksites/$', self.admin_view(TenantPickSitesView.as_view()),
Scott Bakerae04d8d2014-04-22 21:02:45 -070060 name="picksites"),
61 url(r'^tenantdeleteslice/$', self.admin_view(TenantDeleteSliceView.as_view()),
62 name="tenantdeleteslice")
Scott Bakerbb7e84f2014-06-16 23:08:43 -070063 ]
Siobhan Tullycf04fb62014-01-11 11:25:57 -050064
Scott Bakerbb7e84f2014-06-16 23:08:43 -070065 # these ones are for the views that have a "url" member in the class
66 for (view_url, view_classname, view_class) in view_urls:
67 dashboard_urls.append( url(view_url, self.admin_view(view_class.as_view()), name=view_classname.lower()))
68
69 return dashboard_urls + urls
Siobhan Tullycf04fb62014-01-11 11:25:57 -050070
71
72class SitePlus(AdminMixin, AdminSite):
73 """
74 A Django AdminSite with the AdminMixin to allow registering custom
75 dashboard view.
76 """