Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing issues #61 and #76.

Patch provided by jdemoor - thanks!
  • Loading branch information...
commit de7b0fff607efc150c3b80a60a61b1173a28561b 1 parent d93ad57
marcin.kaszynski authored
View
5 multilingual/translation.py
@@ -366,6 +366,11 @@ def multilingual_modelbase_new(cls, name, bases, attrs):
def multilingual_modeladmin_new(cls, model, admin_site, obj=None):
#TODO: is this check really necessary?
if isinstance(model.objects, manager.Manager):
+ # Don't change ModelAdmin.inlines
+ # If our model is being registered with this base class,
+ # then subclass it before changing its inlines attribute
+ if cls is ModelAdmin:
+ cls = type("%sAdmin" % model.__name__, (ModelAdmin,), {})
X = cls.get_translation_modeladmin(model)
if cls.inlines:
for inline in cls.inlines:
View
0  testproject/issue_61/__init__.py
No changes.
View
5 testproject/issue_61/admin.py
@@ -0,0 +1,5 @@
+from django.contrib import admin
+from issue_61.models import Category, OtherModel
+
+admin.site.register(Category)
+admin.site.register(OtherModel)
View
11 testproject/issue_61/models.py
@@ -0,0 +1,11 @@
+from django.db import models
+import multilingual
+
+class Category(models.Model):
+ created = models.DateTimeField(auto_now_add=True)
+
+ class Translation(multilingual.Translation):
+ name = models.CharField(max_length=250)
+
+class OtherModel(models.Model):
+ name = models.CharField(max_length=250)
View
20 testproject/issue_61/tests.py
@@ -0,0 +1,20 @@
+from django.contrib.auth.models import User
+from django.test import TestCase
+
+class TestIssue61(TestCase):
+ def setUp(self):
+ self.user = User.objects.get_or_create(username='admin',
+ email='admin@test.elksoft.pl')[0]
+ self.user.set_password('admin')
+ self.user.is_staff = True
+ self.user.is_superuser = True
+ self.user.save()
+
+ def test_the_issue(self):
+ self.client.login(username = 'admin', password = 'admin')
+ resp = self.client.get('/admin/issue_61/othermodel/')
+ self.assertEqual(resp.status_code, 200)
+
+ # the next line failed in #61
+ resp = self.client.get('/admin/issue_61/othermodel/add/')
+ self.assertEqual(resp.status_code, 200)
View
1  testproject/settings.py
@@ -99,6 +99,7 @@
'testproject.issue_16',
'testproject.issue_29',
'testproject.issue_37',
+ 'testproject.issue_61',
)
TEMPLATE_CONTEXT_PROCESSORS = (
Please sign in to comment.
Something went wrong with that request. Please try again.