Added in ajax support for refreshing hpcdashboard view based on polling - without...
[plstackapi.git] / planetstack / core / plus / sites.py
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
15         from views import DashboardWelcomeView, DashboardAjaxView
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                url(r'^hpcdashboard/', self.admin_view(DashboardAjaxView.as_view()), 
23                     name="hpcdashboard")
24         )
25
26         return custom_url + urls
27
28
29 class SitePlus(AdminMixin, AdminSite):
30     """
31     A Django AdminSite with the AdminMixin to allow registering custom
32     dashboard view.
33     """