From a45f586e7f8c01d27c430a66d1b7f7fae58e046a Mon Sep 17 00:00:00 2001 From: Raphael Kimmig Date: Sat, 18 May 2013 21:45:43 +0200 Subject: [PATCH 1/3] add some docstrings to core.Admin2 --- djadmin2/core.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/djadmin2/core.py b/djadmin2/core.py index 58e2050..d0aa35a 100644 --- a/djadmin2/core.py +++ b/djadmin2/core.py @@ -9,6 +9,13 @@ from . import views class Admin2(object): + """ + The base Admin2 object. + It keeps a registry of all registered Models and collects the urls of their + related ModelAdmin2 instances. + + It also provides an index view that serves as an entry point to the admin site. + """ index_view = views.IndexView def __init__(self, name='admin2', app_name='admin2'): @@ -17,6 +24,15 @@ class Admin2(object): self.app_name = app_name def register(self, model, modeladmin=None, **kwargs): + """ + Registers the given model with the given admin class. + + If no modeladmin is passed, it will use ModelAdmin2. If keyword + arguments are given they will be passed to the admin class on + instantiation. + + If a model is already registered, this will raise ImproperlyConfigured. + """ if model in self.registry: raise ImproperlyConfigured if not modeladmin: @@ -24,13 +40,21 @@ class Admin2(object): self.registry[model] = modeladmin(model, **kwargs) def deregister(self, model): + """ + De-registers the given model. + + If the is not already registered, this will raise ImproperlyConfigured. + """ try: del self.registry[model] except KeyError: raise ImproperlyConfigured def autodiscover(self): - apps = [] + """ + Auto-discovers all admin2.py modules for apps in INSTALLED_APPS by + trying to import them. + """ for app_name in [x for x in settings.INSTALLED_APPS]: try: import_module("%s.admin2" % app_name) From 684b167d117b41e9dd08b76806968d71549cdd1b Mon Sep 17 00:00:00 2001 From: Raphael Kimmig Date: Sat, 18 May 2013 22:40:35 +0200 Subject: [PATCH 2/3] Add missing word to Admin2 docstring. --- djadmin2/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/djadmin2/core.py b/djadmin2/core.py index d0aa35a..4d5c3f4 100644 --- a/djadmin2/core.py +++ b/djadmin2/core.py @@ -43,7 +43,7 @@ class Admin2(object): """ De-registers the given model. - If the is not already registered, this will raise ImproperlyConfigured. + If the model is not already registered, this will raise ImproperlyConfigured. """ try: del self.registry[model] From 1818cbe553e3b0cc0ebf2522d48c6f90c6522aa0 Mon Sep 17 00:00:00 2001 From: Raphael Kimmig Date: Sat, 18 May 2013 23:32:17 +0200 Subject: [PATCH 3/3] fix typos in core docstrings --- djadmin2/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/djadmin2/core.py b/djadmin2/core.py index 4d5c3f4..4418e3e 100644 --- a/djadmin2/core.py +++ b/djadmin2/core.py @@ -41,7 +41,7 @@ class Admin2(object): def deregister(self, model): """ - De-registers the given model. + Deregisters the given model. If the model is not already registered, this will raise ImproperlyConfigured. """ @@ -52,7 +52,7 @@ class Admin2(object): def autodiscover(self): """ - Auto-discovers all admin2.py modules for apps in INSTALLED_APPS by + Autodiscovers all admin2.py modules for apps in INSTALLED_APPS by trying to import them. """ for app_name in [x for x in settings.INSTALLED_APPS]: