diff --git a/.travis.yml b/.travis.yml
index de5b777..f7a3685 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,6 +5,6 @@ before_install:
- export PIP_USE_MIRRORS=true
- export PIP_INDEX_URL=https://simple.crate.io/
install:
- - python setup.py develop
+ - pip install -r requirements.txt
script:
- python runtests.py
diff --git a/djadmin2/core.py b/djadmin2/core.py
index a289a7a..3109ce5 100644
--- a/djadmin2/core.py
+++ b/djadmin2/core.py
@@ -25,7 +25,9 @@ class Admin2(object):
def register(self, model, modeladmin=None, **kwargs):
"""
- Registers the given model with the given admin class.
+ Registers the given model with the given admin class. Once a model is
+ registered in self.registry, we also add it to app registries in
+ self.apps.
If no modeladmin is passed, it will use ModelAdmin2. If keyword
arguments are given they will be passed to the admin class on
@@ -33,8 +35,7 @@ class Admin2(object):
If a model is already registered, this will raise ImproperlyConfigured.
- Once a model is registered in self.registry, we also add it to app registries
- in self.apps.
+
"""
if model in self.registry:
raise ImproperlyConfigured('%s is already registered in django-admin2' % model)
@@ -51,16 +52,25 @@ class Admin2(object):
def deregister(self, model):
"""
- Deregisters the given model.
+ Deregisters the given model. Remove the model from the self.app as well
If the model is not already registered, this will raise ImproperlyConfigured.
-
- TODO: Remove the model from the self.app as well
"""
try:
del self.registry[model]
except KeyError:
- raise ImproperlyConfigured
+ raise ImproperlyConfigured('%s was never registered in django-admin2' % model)
+
+ # Remove the model from the apps registry
+ # Get the app label
+ app_label = model._meta.app_label
+ # Delete the model from it's app registry
+ del self.apps[app_label][model]
+
+ # if no more models in an app's registry
+ # then delete the app from the apps.
+ if self.apps[app_label] is {}:
+ del self.apps[app_label] # no
def autodiscover(self):
"""
@@ -78,6 +88,7 @@ class Admin2(object):
def get_index_kwargs(self):
return {
'registry': self.registry,
+ 'apps': self.apps,
}
def get_urls(self):
diff --git a/djadmin2/exceptions.py b/djadmin2/exceptions.py
deleted file mode 100644
index 31a12c8..0000000
--- a/djadmin2/exceptions.py
+++ /dev/null
@@ -1,2 +0,0 @@
-class NoAdminSpecified(Exception):
- pass
diff --git a/djadmin2/static/themes/bootstrap/css/bootstrap-custom.css b/djadmin2/static/themes/bootstrap/css/bootstrap-custom.css
new file mode 100644
index 0000000..6a29526
--- /dev/null
+++ b/djadmin2/static/themes/bootstrap/css/bootstrap-custom.css
@@ -0,0 +1,15 @@
+/* Fixes a Bootstrap 2.3 bug. This can be removed when upgrading to Bootstrap v3. */
+.text-right
+{
+ text-align: right !important;
+}
+
+.text-center
+{
+ text-align: center !important;
+}
+
+.text-left
+{
+ text-align: left !important;
+}
\ No newline at end of file
diff --git a/djadmin2/templates/admin2/bootstrap/base.html b/djadmin2/templates/admin2/bootstrap/base.html
index 231b9a8..546f26f 100644
--- a/djadmin2/templates/admin2/bootstrap/base.html
+++ b/djadmin2/templates/admin2/bootstrap/base.html
@@ -7,6 +7,7 @@
+