Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added test to prove translation models + relations cause issues

  • Loading branch information...
commit b6f12bacfc866dc621bcee33b1d3ca5aacd558d6 1 parent a621918
@ojii authored
View
2  nani/tests/__init__.py
@@ -1,5 +1,5 @@
from nani.tests.admin import (NormalAdminTests, AdminEditTests,
- AdminNoFixturesTests, AdminDeleteTranslationsTests)
+ AdminNoFixturesTests, AdminDeleteTranslationsTests, AdminRelationTests)
from nani.tests.basic import (OptionsTest, BasicQueryTest, CreateTest, GetTest,
TranslatedTest, DeleteLanguageCodeTest, GetByLanguageTest, DescriptorTests,
DefinitionTests)
View
19 nani/tests/admin.py
@@ -7,7 +7,8 @@
from nani.admin import translatable_modelform_factory
from nani.forms import TranslatableModelForm
from nani.test_utils.context_managers import LanguageOverride
-from nani.test_utils.fixtures import TwoTranslatedNormalMixin, SuperuserMixin
+from nani.test_utils.fixtures import (TwoTranslatedNormalMixin, SuperuserMixin,
+ OneSingleTranslatedNormalMixin)
from nani.test_utils.request_factory import RequestFactory
from nani.test_utils.testcase import NaniTestCase
from testproject.app.models import Normal
@@ -355,3 +356,19 @@ class Meta:
self.assertEqual(t.Meta.fields, ['shared_field'])
self.assertEqual(t.Meta.exclude, ['id'])
+
+class AdminRelationTests(NaniTestCase, BaseAdminTests, SuperuserMixin,
+ OneSingleTranslatedNormalMixin):
+ def test_adding_related_object(self):
+ url = reverse('admin:app_simplerelated_add')
+ expected_url = reverse('admin:app_simplerelated_change', args=(1,))
+ with LanguageOverride('en'):
+ en = Normal.objects.all()[0]
+ with self.login_user_context(username='admin', password='admin'):
+ data = {
+ 'normal': en.pk,
+ 'translated_field': 'English Content',
+ }
+ response = self.client.post(url, data)
+ self.assertRedirects(response, expected_url)
+
View
3  testproject/app/admin.py
@@ -1,6 +1,7 @@
from django.contrib import admin
-from models import Normal
+from models import Normal, SimpleRelated
from nani.admin import TranslatableAdmin
admin.site.register(Normal, TranslatableAdmin)
+admin.site.register(SimpleRelated, TranslatableAdmin)
View
9 testproject/app/models.py
@@ -20,6 +20,15 @@ class Related(TranslatableModel):
translated_to_translated = models.ForeignKey(Normal, related_name='rel4', null=True),
)
+
+class SimpleRelated(TranslatableModel):
+ normal = models.ForeignKey(Normal, related_name='simplerel')
+
+ translated_fields = TranslatedFields(
+ translated_field = models.CharField(max_length=255),
+ )
+
+
class Standard(models.Model):
normal_field = models.CharField(max_length=255)
normal = models.ForeignKey(Normal, related_name='standards')
Please sign in to comment.
Something went wrong with that request. Please try again.