From 2dff9fb9f389ca49f84fbb062c1d1adef071b591 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 3 Dec 2016 23:20:00 +0100 Subject: [PATCH] Add support for Django 1.10 --- .travis.yml | 1 + README.rst | 1 + cms_helper.py | 2 ++ djangocms_blog/admin.py | 1 + djangocms_blog/cms_appconfig.py | 2 ++ djangocms_blog/cms_apps.py | 2 ++ djangocms_blog/cms_menus.py | 3 +++ djangocms_blog/liveblog/cms_plugins.py | 1 + djangocms_blog/liveblog/models.py | 9 ++++++++- djangocms_blog/urls.py | 1 + tests/test_models.py | 8 ++++---- tox.ini | 5 ++++- 12 files changed, 30 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index d8f3cb4..62c2777 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ env: - TOXENV='pep8' - TOXENV='isort' - TOXENV='docs' + - DJANGO='django110' CMS='cms34' - DJANGO='django19' CMS='cms34' - DJANGO='django19' CMS='cms33' - DJANGO='django19' CMS='cms32' diff --git a/README.rst b/README.rst index 2d18b6c..581c6d0 100644 --- a/README.rst +++ b/README.rst @@ -36,6 +36,7 @@ Supported Django versions: * Django 1.8 * Django 1.9 +* Django 1.10 Supported django CMS versions: diff --git a/cms_helper.py b/cms_helper.py index fd63480..76404b6 100755 --- a/cms_helper.py +++ b/cms_helper.py @@ -9,6 +9,7 @@ from tempfile import mkdtemp def gettext(s): return s + HELPER_SETTINGS = dict( ROOT_URLCONF='tests.test_utils.urls', INSTALLED_APPS=[ @@ -139,5 +140,6 @@ def setup(): from djangocms_helper import runner runner.setup('djangocms_blog', sys.modules[__name__], use_cms=True) + if __name__ == '__main__': run() diff --git a/djangocms_blog/admin.py b/djangocms_blog/admin.py index 5f17c47..0f301c2 100755 --- a/djangocms_blog/admin.py +++ b/djangocms_blog/admin.py @@ -368,6 +368,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 0ac4542..36ff2cc 100644 --- a/djangocms_blog/cms_appconfig.py +++ b/djangocms_blog/cms_appconfig.py @@ -139,4 +139,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 c6e25ae..aad2a18 100644 --- a/djangocms_blog/cms_apps.py +++ b/djangocms_blog/cms_apps.py @@ -28,5 +28,7 @@ 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 9cd6e20..89e2b98 100644 --- a/djangocms_blog/cms_menus.py +++ b/djangocms_blog/cms_menus.py @@ -106,6 +106,7 @@ class BlogCategoryMenu(CMSAttachMenu): return nodes + menu_pool.register_menu(BlogCategoryMenu) @@ -161,6 +162,7 @@ class BlogNavModifier(Modifier): node.selected = True return nodes + menu_pool.register_modifier(BlogNavModifier) @@ -170,5 +172,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/liveblog/cms_plugins.py b/djangocms_blog/liveblog/cms_plugins.py index 7e0d9fa..c351679 100644 --- a/djangocms_blog/liveblog/cms_plugins.py +++ b/djangocms_blog/liveblog/cms_plugins.py @@ -28,4 +28,5 @@ class LiveblogPlugin(TextPlugin): context['instance'] = instance return context + plugin_pool.register_plugin(LiveblogPlugin) diff --git a/djangocms_blog/liveblog/models.py b/djangocms_blog/liveblog/models.py index 2b801ba..52ad13d 100644 --- a/djangocms_blog/liveblog/models.py +++ b/djangocms_blog/liveblog/models.py @@ -3,8 +3,9 @@ from __future__ import absolute_import, print_function, unicode_literals import json +import django from channels import Group -from cms.models import itemgetter, now, python_2_unicode_compatible +from cms.models import CMSPlugin, itemgetter, now, python_2_unicode_compatible from cms.utils.plugins import reorder_plugins from django.db import models from django.template import Context @@ -87,6 +88,12 @@ class Liveblog(LiveblogInterface, AbstractText): """ Basic liveblog plugin model """ + if django.VERSION >= (1, 10): + cmsplugin_ptr = models.OneToOneField( + CMSPlugin, + related_name='%(app_label)s_%(class)s', primary_key=True, + parent_link=True, on_delete=models.CASCADE + ) title = models.CharField(_('title'), max_length=255) image = FilerImageField( verbose_name=_('image'), blank=True, null=True, on_delete=models.SET_NULL, 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 = [ diff --git a/tests/test_models.py b/tests/test_models.py index cdfb71a..f56d3db 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -143,7 +143,7 @@ class AdminTest(BaseTest): # Add view only has an empty form - no type response = post_admin.add_view(request) self.assertNotContains(response, 'djangocms_blog.cms_appconfig.BlogConfig') - self.assertContains(response, '') + self.assertContains(response, '') + self.assertContains(response, '') + self.assertNotContains(response, 'id="id_name" maxlength="255" name="name" type="text" value="category 1"') self.assertContains(response, '' % self.app_config_1.pk) # Changeview is 'normal', with a few preselected items response = post_admin.change_view(request, str(self.category_1.pk)) - self.assertContains(response, 'id="id_name" maxlength="255" name="name" type="text" value="category 1" />') + self.assertContains(response, 'id="id_name" maxlength="255" name="name" type="text" value="category 1"') self.assertContains(response, '' % self.app_config_1.pk) def test_admin_category_parents(self): diff --git a/tox.ini b/tox.ini index e0b6270..af35fbf 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = pep8,isort,docs,py{35,34,27}-django{19}-{cms34,cms33,cms32},py{35,34,33,27}-django{18}-cms{34,33,32} +envlist = pep8,isort,docs,py{35,34,27}-django{110}-{cms34},py{35,34,27}-django{19}-{cms34,cms33,cms32},py{35,34,33,27}-django{18}-cms{34,33,32} [testenv] commands = {env:COMMAND:python} cms_helper.py test djangocms_blog @@ -14,6 +14,9 @@ deps = django19: django-mptt>=0.8 django19: django-filer<1.3 django19: cmsplugin-filer<1.2 + django110: Django>=1.10,<1.11 + django110: django-mptt>=0.8 + django110: https://github.com/divio/django-filer/archive/develop.zip cms32: https://github.com/divio/django-cms/archive/release/3.2.x.zip cms32: djangocms-text-ckeditor<3.0 cms33: https://github.com/divio/django-cms/archive/release/3.3.x.zip