blob: da86a10c3f32f4b34486c8f36ac0afbc90509ebe [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
15 from views import DashboardWelcomeView
16
17 urls = super(AdminMixin, self).get_urls()
18 del urls[0]
19 custom_url = patterns('',
20 url(r'^$', self.admin_view(DashboardWelcomeView.as_view()),
21 name="index")
22 )
23
24 return custom_url + urls
25
26
27class SitePlus(AdminMixin, AdminSite):
28 """
29 A Django AdminSite with the AdminMixin to allow registering custom
30 dashboard view.
31 """