Skip to content

Commit

Permalink
Docstrings, \o/
Browse files Browse the repository at this point in the history
  • Loading branch information
James Socol committed Mar 4, 2011
1 parent 3800d35 commit 4198380
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion adminplus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@


class AdminSitePlus(AdminSite):
index_template = 'adminplus/index.html'
"""Extend AdminSite to allow registering custom admin views."""
index_template = 'adminplus/index.html' # That was easy.
custom_views = []

def register_view(self, path, view, name=None):
"""Add a custom admin view.
* `path` is the path in the admin where the view will live, e.g.
http://example.com/admin/somepath
* `view` is any view function you can imagine.
* `name` is an optional pretty name for the list of custom views. If
empty, we'll guess based on view.__name__.
"""
self.custom_views.append((path, view, name))

def get_urls(self):
"""Add our custom views to the admin urlconf."""
urls = super(KAdminSite, self).get_urls()
from django.conf.urls.defaults import patterns, url, include
for path, view, name in self.custom_views:
Expand All @@ -19,6 +29,7 @@ def get_urls(self):
return urls

def index(self, request, extra_context=None):
"""Make sure our list of custom views is on the index page."""
if not extra_context:
extra_context = {}
custom_list = [(path, name if name else
Expand Down

0 comments on commit 4198380

Please sign in to comment.