diff --git a/HISTORY.rst b/HISTORY.rst index f156ed0..8278ce0 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -21,6 +21,12 @@ History * Dropped strict dependency on aldryn-search, haystack. Install separately for search support. * Improved admin filtering. +******************* +0.8.10 (2017-01-02) +******************* + +* Fix error in get_absolute_url + ****************** 0.8.9 (2016-10-25) ****************** diff --git a/cms_helper.py b/cms_helper.py index 76404b6..688c8f8 100755 --- a/cms_helper.py +++ b/cms_helper.py @@ -7,7 +7,8 @@ import os from tempfile import mkdtemp -def gettext(s): return s +def gettext(s): + return s HELPER_SETTINGS = dict( diff --git a/djangocms_blog/__init__.py b/djangocms_blog/__init__.py index e95928e..44d494a 100644 --- a/djangocms_blog/__init__.py +++ b/djangocms_blog/__init__.py @@ -3,6 +3,6 @@ from __future__ import absolute_import, print_function, unicode_literals __author__ = 'Iacopo Spalletti' __email__ = 'i.spalletti@nephila.it' -__version__ = '0.9b5' +__version__ = '0.9b6' default_app_config = 'djangocms_blog.apps.BlogAppConfig' diff --git a/djangocms_blog/cms_apps.py b/djangocms_blog/cms_apps.py index aad2a18..6aa2c56 100644 --- a/djangocms_blog/cms_apps.py +++ b/djangocms_blog/cms_apps.py @@ -11,6 +11,7 @@ from .cms_menus import BlogCategoryMenu from .settings import get_setting +@apphook_pool.register class BlogApp(AutoCMSAppMixin, CMSConfigApp): name = _('Blog') urls = ['djangocms_blog.urls'] @@ -30,5 +31,4 @@ class BlogApp(AutoCMSAppMixin, CMSConfigApp): } -apphook_pool.register(BlogApp) BlogApp.setup() diff --git a/djangocms_blog/cms_menus.py b/djangocms_blog/cms_menus.py index 89e2b98..26a6143 100644 --- a/djangocms_blog/cms_menus.py +++ b/djangocms_blog/cms_menus.py @@ -107,9 +107,6 @@ class BlogCategoryMenu(CMSAttachMenu): return nodes -menu_pool.register_menu(BlogCategoryMenu) - - class BlogNavModifier(Modifier): """ This navigation modifier makes sure that when @@ -164,6 +161,7 @@ class BlogNavModifier(Modifier): menu_pool.register_modifier(BlogNavModifier) +menu_pool.register_menu(BlogCategoryMenu) def clear_menu_cache(**kwargs): diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py index 4386c25..6850034 100644 --- a/djangocms_blog/models.py +++ b/djangocms_blog/models.py @@ -256,10 +256,10 @@ class Post(KnockerModel, ModelMeta, TranslatableModel): super(Post, self).save_translation(translation, *args, **kwargs) def get_absolute_url(self, lang=None): - if not lang or lang not in self.get_available_languages(): - lang = self.get_current_language() if not lang or lang not in self.get_available_languages(): lang = get_language() + if not lang or lang not in self.get_available_languages(): + lang = self.get_current_language() with switch_language(self, lang): category = self.categories.first() kwargs = {} diff --git a/tests/test_models.py b/tests/test_models.py index f56d3db..ca3634e 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -717,6 +717,20 @@ class ModelsTest(BaseTest): post.app_config = self.app_config_1 self.assertTrue(re.match(r'.*/%s/$' % post.slug, post.get_absolute_url())) + def test_url_language(self): + self.get_pages() + post = self._get_post(self._post_data[0]['en']) + post = self._get_post(self._post_data[0]['it'], post, 'it') + + with override('it'): + self.assertEqual(post.get_current_language(), 'en') + self.assertEqual(post.get_absolute_url(), post.get_absolute_url('it')) + + post.set_current_language('it') + with override('en'): + self.assertEqual(post.get_current_language(), 'it') + self.assertEqual(post.get_absolute_url(), post.get_absolute_url('en')) + def test_manager(self): self.get_pages() post1 = self._get_post(self._post_data[0]['en'])