diff --git a/cms_helper.py b/cms_helper.py index 4f77738..17d6bce 100755 --- a/cms_helper.py +++ b/cms_helper.py @@ -71,9 +71,6 @@ HELPER_SETTINGS = { 'hide_untranslated': False, } }, - 'MIDDLEWARE_CLASSES': [ - 'django.contrib.messages.middleware.MessageMiddleware', - ], 'MIGRATION_MODULES': { 'cmsplugin_filer_image': 'cmsplugin_filer_image.migrations_django', }, diff --git a/tests/__init__.py b/tests/__init__.py index 9531302..c4e61d0 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -145,8 +145,10 @@ class BaseTest(TestCase): request.errors = StringIO() return request - def post_request(self, page, lang, data): - request = self.request_factory.post(page.get_path(lang), data) + def post_request(self, page, lang, data, path=None): + if not path: + path = page.get_path(lang) + request = self.request_factory.post(path, data) request.current_page = page request.user = self.user request.session = {} diff --git a/tests/test_models.py b/tests/test_models.py index c6255fe..95e31af 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -90,6 +90,20 @@ class AdminTest(BaseTest): self.assertEqual(Post.objects.count(), 3) self.assertEqual(Post.objects.get(translations__slug='third-post').author.username, 'staff') + def test_admin_post_text(self): + page1, page2 = self.get_pages() + post = self._get_post(self.data['en'][0]) + + with self.settings(BLOG_USE_PLACEHOLDER=False): + data = {'post_text': 'ehi text'} + request = self.post_request(page1, 'en', data=data, path='/en/?edit_fields=post_text') + msg_mid = MessageMiddleware() + msg_mid.process_request(request) + post_admin = admin.site._registry[Post] + post_admin.edit_field(request, post.pk, 'en') + modified_post = Post.objects.get(pk=post.pk) + self.assertEqual(modified_post.safe_translation_getter('post_text'), data['post_text']) + class ModelsTest(BaseTest):