Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 1 | #sites.py |
| 2 | |
| 3 | from django.contrib.admin.sites import AdminSite |
| 4 | |
| 5 | |
| 6 | class 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 Baker | 3307ce6 | 2015-02-02 16:23:52 -0800 | [diff] [blame] | 15 | from views import DashboardCustomize, DashboardDynamicView, DashboardWelcomeView, SimulatorView, \ |
| 16 | DashboardUserSiteView, \ |
| 17 | TenantViewData, TenantCreateSlice, TenantAddUser,TenantAddOrRemoveSliverView, TenantPickSitesView, TenantDeleteSliceView, \ |
Scott Baker | a36d77e | 2014-08-29 11:43:23 -0700 | [diff] [blame] | 18 | TenantUpdateSlice, DashboardSliceInteractions, RequestAccessView |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 19 | |
Scott Baker | bb7e84f | 2014-06-16 23:08:43 -0700 | [diff] [blame] | 20 | from views import view_urls |
| 21 | |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 22 | urls = super(AdminMixin, self).get_urls() |
| 23 | del urls[0] |
Scott Baker | bb7e84f | 2014-06-16 23:08:43 -0700 | [diff] [blame] | 24 | |
| 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 Baker | 2c3cb64 | 2014-05-19 17:55:56 -0700 | [diff] [blame] | 28 | url(r'^$', self.admin_view(DashboardDynamicView.as_view()), |
Siobhan Tully | 06d2c03 | 2014-02-23 23:48:52 -0500 | [diff] [blame] | 29 | name="index"), |
Scott Baker | 537d823 | 2014-04-08 23:40:56 -0700 | [diff] [blame] | 30 | url(r'^test/', self.admin_view(DashboardUserSiteView.as_view()), |
| 31 | name="test"), |
Scott Baker | 6b65420 | 2014-05-27 16:55:00 -0700 | [diff] [blame] | 32 | url(r'^sliceinteractions/(?P<name>\w+)/$', self.admin_view(DashboardSliceInteractions.as_view()), |
| 33 | name="interactions"), |
Scott Baker | 2c3cb64 | 2014-05-19 17:55:56 -0700 | [diff] [blame] | 34 | url(r'^dashboard/(?P<name>\w+)/$', self.admin_view(DashboardDynamicView.as_view()), |
Scott Baker | 186ae61 | 2014-05-19 10:42:51 -0700 | [diff] [blame] | 35 | name="dashboard"), |
Scott Baker | b9da921 | 2014-11-03 15:59:52 -0800 | [diff] [blame] | 36 | url(r'^dashboardWholePage/(?P<name>\w+)/$', self.admin_view(DashboardDynamicView.as_view()), |
| 37 | {"wholePage": True}, |
| 38 | name="dashboardWholePage"), |
Scott Baker | 2c3cb64 | 2014-05-19 17:55:56 -0700 | [diff] [blame] | 39 | url(r'^customize/$', self.admin_view(DashboardCustomize.as_view()), |
| 40 | name="customize"), |
Scott Baker | 771819b | 2014-03-19 22:10:17 -0700 | [diff] [blame] | 41 | url(r'^hpcdashuserslices/', self.admin_view(DashboardUserSiteView.as_view()), |
| 42 | name="hpcdashuserslices"), |
Scott Baker | a36d77e | 2014-08-29 11:43:23 -0700 | [diff] [blame] | 43 | url(r'^welcome/$', self.admin_view(DashboardWelcomeView.as_view()), |
| 44 | name="welcome"), |
Scott Baker | 771819b | 2014-03-19 22:10:17 -0700 | [diff] [blame] | 45 | url(r'^simulator/', self.admin_view(SimulatorView.as_view()), |
| 46 | name="simulator"), |
Scott Baker | 6253dfc | 2014-04-14 09:29:30 -0700 | [diff] [blame] | 47 | url(r'^tenantaddorremsliver/$', self.admin_view(TenantAddOrRemoveSliverView.as_view()), |
| 48 | name="tenantaddorremsliver"), |
Scott Baker | 537d823 | 2014-04-08 23:40:56 -0700 | [diff] [blame] | 49 | url(r'^tenantview/$', self.admin_view(TenantViewData.as_view()), |
| 50 | name="tenantview"), |
| 51 | url(r'^createnewslice/$', self.admin_view(TenantCreateSlice.as_view()), |
Scott Baker | bd57a43 | 2014-04-14 16:12:15 -0700 | [diff] [blame] | 52 | name="createnewslice"), |
Scott Baker | a36d77e | 2014-08-29 11:43:23 -0700 | [diff] [blame] | 53 | url(r'^adduser/$', self.admin_view(TenantAddUser.as_view()), |
| 54 | name="adduser"),
|
| 55 | url(r'^requestaccess/$', RequestAccessView.as_view(),
|
| 56 | name="requestacces"), |
Scott Baker | ae04d8d | 2014-04-22 21:02:45 -0700 | [diff] [blame] | 57 | url(r'^updateslice/$', self.admin_view(TenantUpdateSlice.as_view()), |
| 58 | name="updateslice"), |
Scott Baker | bd57a43 | 2014-04-14 16:12:15 -0700 | [diff] [blame] | 59 | url(r'^picksites/$', self.admin_view(TenantPickSitesView.as_view()), |
Scott Baker | ae04d8d | 2014-04-22 21:02:45 -0700 | [diff] [blame] | 60 | name="picksites"), |
| 61 | url(r'^tenantdeleteslice/$', self.admin_view(TenantDeleteSliceView.as_view()), |
| 62 | name="tenantdeleteslice") |
Scott Baker | bb7e84f | 2014-06-16 23:08:43 -0700 | [diff] [blame] | 63 | ] |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 64 | |
Scott Baker | bb7e84f | 2014-06-16 23:08:43 -0700 | [diff] [blame] | 65 | # 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 Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 70 | |
| 71 | |
| 72 | class SitePlus(AdminMixin, AdminSite): |
| 73 | """ |
| 74 | A Django AdminSite with the AdminMixin to allow registering custom |
| 75 | dashboard view. |
| 76 | """ |