From ff7d97b67cf1d7b59d99e07e5bb49c82d94e545c Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Mon, 24 Oct 2016 18:22:56 +0200 Subject: [PATCH 1/6] Fix slug generation in wizard --- HISTORY.rst | 1 + djangocms_blog/models.py | 2 ++ tests/test_models.py | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index 5b12d2d..0b81fa2 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -9,6 +9,7 @@ History ****************** * Optimized querysets +* Fixed slug generation in wizard ****************** 0.8.8 (2016-09-04) diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py index 8ace18e..706be47 100644 --- a/djangocms_blog/models.py +++ b/djangocms_blog/models.py @@ -221,6 +221,8 @@ class Post(KnockerModel, ModelMeta, TranslatableModel): """ if self.publish and self.date_published is None: self.date_published = timezone.now() + if not self.slug and self.title: + self.slug = slugify(self.title) super(Post, self).save(*args, **kwargs) def save_translation(self, translation, *args, **kwargs): diff --git a/tests/test_models.py b/tests/test_models.py index 26d3c1a..a03dd1e 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -439,6 +439,10 @@ class AdminTest(BaseTest): class ModelsTest(BaseTest): + def test_slug(self): + post = Post.objects.language('en').create(title='I am a title') + self.assertEqual(post.slug, 'i-am-a-title') + def test_model_attributes(self): self.get_pages() From ab66b1307b052e8ef25eca567441e4208ea8a876 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Mon, 24 Oct 2016 18:57:05 +0200 Subject: [PATCH 2/6] Ping djangocms-admin-style in tox --- tox.ini | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tox.ini b/tox.ini index c5d4231..f61b3bb 100644 --- a/tox.ini +++ b/tox.ini @@ -11,21 +11,25 @@ deps = django16: django-filer<1.2 django16: cmsplugin-filer<1.1 django16: django-haystack<2.5 + django16: djangocms-admin-style<1.2 django17: Django>=1.7,<1.8 django17: django-mptt<0.8 django17: django-filer<1.3 django17: cmsplugin-filer<1.2 django17: django-haystack + django17: djangocms-admin-style<1.2 django18: Django>=1.8,<1.9 django18: django-mptt>=0.8 django18: django-filer<1.3 django18: cmsplugin-filer<1.2 django18: django-haystack + django18: djangocms-admin-style>1.2,<1.3 django19: Django>=1.9,<1.10 django19: django-mptt>=0.8 django19: django-filer<1.3 django19: cmsplugin-filer<1.2 django19: django-haystack + django19: djangocms-admin-style>1.2,<1.3 cms30: https://github.com/divio/django-cms/archive/release/3.0.x.zip cms30: djangocms-text-ckeditor<2.8 cms31: https://github.com/divio/django-cms/archive/release/3.1.x.zip From 9e7f66b3f5810f268bd39027bf21323bc6b7524e Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Tue, 25 Oct 2016 09:14:28 +0200 Subject: [PATCH 3/6] Release 0.8.9 --- HISTORY.rst | 2 +- djangocms_blog/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 0b81fa2..3eae7fb 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -5,7 +5,7 @@ History ======= ****************** -0.8.9 (unreleased) +0.8.9 (2016-10-25) ****************** * Optimized querysets diff --git a/djangocms_blog/__init__.py b/djangocms_blog/__init__.py index e294ff4..78ccb6f 100644 --- a/djangocms_blog/__init__.py +++ b/djangocms_blog/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- __author__ = 'Iacopo Spalletti' __email__ = 'i.spalletti@nephila.it' -__version__ = '0.8.8' +__version__ = '0.8.9' default_app_config = 'djangocms_blog.apps.BlogAppConfig' From 446b4b83e97673d9392c3fad15e638282f69d0f2 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Mon, 2 Jan 2017 00:09:25 +0100 Subject: [PATCH 4/6] Fix post language url --- djangocms_blog/models.py | 4 ++-- tests/test_models.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py index 706be47..44b3545 100644 --- a/djangocms_blog/models.py +++ b/djangocms_blog/models.py @@ -234,10 +234,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 a03dd1e..c5aeb52 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -608,6 +608,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']) From 6a4218eeeafd9c4564df695c7255bb011d5c27c3 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Mon, 2 Jan 2017 00:09:34 +0100 Subject: [PATCH 5/6] Fix code style --- cms_helper.py | 5 ++++- djangocms_blog/admin.py | 1 + djangocms_blog/cms_appconfig.py | 2 ++ djangocms_blog/cms_apps.py | 4 +++- djangocms_blog/cms_menus.py | 5 +++-- djangocms_blog/urls.py | 1 + 6 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cms_helper.py b/cms_helper.py index ad35c1b..ae6b887 100755 --- a/cms_helper.py +++ b/cms_helper.py @@ -7,7 +7,9 @@ import os from tempfile import mkdtemp -def gettext(s): return s +def gettext(s): + return s + HELPER_SETTINGS = dict( ROOT_URLCONF='tests.test_utils.urls', @@ -138,5 +140,6 @@ def run(): from djangocms_helper import runner runner.cms('djangocms_blog') + if __name__ == '__main__': run() diff --git a/djangocms_blog/admin.py b/djangocms_blog/admin.py index 5d8a799..c3b09ae 100755 --- a/djangocms_blog/admin.py +++ b/djangocms_blog/admin.py @@ -308,6 +308,7 @@ class BlogConfigAdmin(BaseAppHookConfig, TranslatableAdmin): menu_pool.clear(all=True) return super(BlogConfigAdmin, self).save_model(request, obj, form, change) + admin.site.register(BlogCategory, BlogCategoryAdmin) admin.site.register(Post, PostAdmin) admin.site.register(BlogConfig, BlogConfigAdmin) diff --git a/djangocms_blog/cms_appconfig.py b/djangocms_blog/cms_appconfig.py index e7e028d..29a4c9c 100644 --- a/djangocms_blog/cms_appconfig.py +++ b/djangocms_blog/cms_appconfig.py @@ -134,4 +134,6 @@ class BlogConfigForm(AppDataForm): label=_('Send notifications on post update'), required=False, initial=False, help_text=_('Emits a desktop notification -if enabled- when editing a published post') ) + + setup_config(BlogConfigForm, BlogConfig) diff --git a/djangocms_blog/cms_apps.py b/djangocms_blog/cms_apps.py index 62f8780..7cfdc05 100644 --- a/djangocms_blog/cms_apps.py +++ b/djangocms_blog/cms_apps.py @@ -11,6 +11,7 @@ from .menu import BlogCategoryMenu from .settings import get_setting +@apphook_pool.register class BlogApp(AutoCMSAppMixin, CMSConfigApp): name = _('Blog') urls = ['djangocms_blog.urls'] @@ -28,5 +29,6 @@ class BlogApp(AutoCMSAppMixin, CMSConfigApp): 'object_name': get_setting('DEFAULT_OBJECT_NAME') }, } -apphook_pool.register(BlogApp) + + BlogApp.setup() diff --git a/djangocms_blog/cms_menus.py b/djangocms_blog/cms_menus.py index bfdf74d..2e61642 100644 --- a/djangocms_blog/cms_menus.py +++ b/djangocms_blog/cms_menus.py @@ -104,8 +104,6 @@ class BlogCategoryMenu(CMSAttachMenu): return nodes -menu_pool.register_menu(BlogCategoryMenu) - class BlogNavModifier(Modifier): """ @@ -159,7 +157,9 @@ class BlogNavModifier(Modifier): node.selected = True return nodes + menu_pool.register_modifier(BlogNavModifier) +menu_pool.register_menu(BlogCategoryMenu) def clear_menu_cache(**kwargs): @@ -168,5 +168,6 @@ def clear_menu_cache(**kwargs): """ menu_pool.clear(all=True) + post_save.connect(clear_menu_cache, sender=BlogCategory) post_delete.connect(clear_menu_cache, sender=BlogCategory) diff --git a/djangocms_blog/urls.py b/djangocms_blog/urls.py index 84b9db2..2d68439 100644 --- a/djangocms_blog/urls.py +++ b/djangocms_blog/urls.py @@ -20,6 +20,7 @@ def get_urls(): ) return details + detail_urls = get_urls() urlpatterns = [ From aa1f17efc0065c108db3698b0ff2a0f3c8abcc0f Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Mon, 2 Jan 2017 11:22:09 +0100 Subject: [PATCH 6/6] Release 0.8.10 --- HISTORY.rst | 6 ++++++ djangocms_blog/__init__.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 3eae7fb..fe9385b 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,6 +4,12 @@ History ======= +****************** +0.8.10 (2017-01-02) +****************** + +* Fix error in get_absolute_url + ****************** 0.8.9 (2016-10-25) ****************** diff --git a/djangocms_blog/__init__.py b/djangocms_blog/__init__.py index 78ccb6f..1446555 100644 --- a/djangocms_blog/__init__.py +++ b/djangocms_blog/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- __author__ = 'Iacopo Spalletti' __email__ = 'i.spalletti@nephila.it' -__version__ = '0.8.9' +__version__ = '0.8.10' default_app_config = 'djangocms_blog.apps.BlogAppConfig'