blob: 27ae35289aaf6470025b4d9690d949ca74ff2d53 [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
Siobhan Tully06d2c032014-02-23 23:48:52 -050015 from views import DashboardWelcomeView, DashboardAjaxView
Siobhan Tullycf04fb62014-01-11 11:25:57 -050016
17 urls = super(AdminMixin, self).get_urls()
18 del urls[0]
19 custom_url = patterns('',
20 url(r'^$', self.admin_view(DashboardWelcomeView.as_view()),
Siobhan Tully06d2c032014-02-23 23:48:52 -050021 name="index"),
22 url(r'^hpcdashboard/', self.admin_view(DashboardAjaxView.as_view()),
23 name="hpcdashboard")
Siobhan Tullycf04fb62014-01-11 11:25:57 -050024 )
25
26 return custom_url + urls
27
28
29class SitePlus(AdminMixin, AdminSite):
30 """
31 A Django AdminSite with the AdminMixin to allow registering custom
32 dashboard view.
33 """