Add support for Django 1.10

This commit is contained in:
Iacopo Spalletti 2016-12-03 23:20:00 +01:00
parent 19872a711a
commit 2dff9fb9f3
No known key found for this signature in database
GPG key ID: BDCBC2EB289F60C6
12 changed files with 30 additions and 6 deletions

View file

@ -14,6 +14,7 @@ env:
- TOXENV='pep8' - TOXENV='pep8'
- TOXENV='isort' - TOXENV='isort'
- TOXENV='docs' - TOXENV='docs'
- DJANGO='django110' CMS='cms34'
- DJANGO='django19' CMS='cms34' - DJANGO='django19' CMS='cms34'
- DJANGO='django19' CMS='cms33' - DJANGO='django19' CMS='cms33'
- DJANGO='django19' CMS='cms32' - DJANGO='django19' CMS='cms32'

View file

@ -36,6 +36,7 @@ Supported Django versions:
* Django 1.8 * Django 1.8
* Django 1.9 * Django 1.9
* Django 1.10
Supported django CMS versions: Supported django CMS versions:

View file

@ -9,6 +9,7 @@ from tempfile import mkdtemp
def gettext(s): return s def gettext(s): return s
HELPER_SETTINGS = dict( HELPER_SETTINGS = dict(
ROOT_URLCONF='tests.test_utils.urls', ROOT_URLCONF='tests.test_utils.urls',
INSTALLED_APPS=[ INSTALLED_APPS=[
@ -139,5 +140,6 @@ def setup():
from djangocms_helper import runner from djangocms_helper import runner
runner.setup('djangocms_blog', sys.modules[__name__], use_cms=True) runner.setup('djangocms_blog', sys.modules[__name__], use_cms=True)
if __name__ == '__main__': if __name__ == '__main__':
run() run()

View file

@ -368,6 +368,7 @@ class BlogConfigAdmin(BaseAppHookConfig, TranslatableAdmin):
menu_pool.clear(all=True) menu_pool.clear(all=True)
return super(BlogConfigAdmin, self).save_model(request, obj, form, change) return super(BlogConfigAdmin, self).save_model(request, obj, form, change)
admin.site.register(BlogCategory, BlogCategoryAdmin) admin.site.register(BlogCategory, BlogCategoryAdmin)
admin.site.register(Post, PostAdmin) admin.site.register(Post, PostAdmin)
admin.site.register(BlogConfig, BlogConfigAdmin) admin.site.register(BlogConfig, BlogConfigAdmin)

View file

@ -139,4 +139,6 @@ class BlogConfigForm(AppDataForm):
label=_('Send notifications on post update'), required=False, initial=False, label=_('Send notifications on post update'), required=False, initial=False,
help_text=_('Emits a desktop notification -if enabled- when editing a published post') help_text=_('Emits a desktop notification -if enabled- when editing a published post')
) )
setup_config(BlogConfigForm, BlogConfig) setup_config(BlogConfigForm, BlogConfig)

View file

@ -28,5 +28,7 @@ class BlogApp(AutoCMSAppMixin, CMSConfigApp):
'object_name': get_setting('DEFAULT_OBJECT_NAME') 'object_name': get_setting('DEFAULT_OBJECT_NAME')
}, },
} }
apphook_pool.register(BlogApp) apphook_pool.register(BlogApp)
BlogApp.setup() BlogApp.setup()

View file

@ -106,6 +106,7 @@ class BlogCategoryMenu(CMSAttachMenu):
return nodes return nodes
menu_pool.register_menu(BlogCategoryMenu) menu_pool.register_menu(BlogCategoryMenu)
@ -161,6 +162,7 @@ class BlogNavModifier(Modifier):
node.selected = True node.selected = True
return nodes return nodes
menu_pool.register_modifier(BlogNavModifier) menu_pool.register_modifier(BlogNavModifier)
@ -170,5 +172,6 @@ def clear_menu_cache(**kwargs):
""" """
menu_pool.clear(all=True) menu_pool.clear(all=True)
post_save.connect(clear_menu_cache, sender=BlogCategory) post_save.connect(clear_menu_cache, sender=BlogCategory)
post_delete.connect(clear_menu_cache, sender=BlogCategory) post_delete.connect(clear_menu_cache, sender=BlogCategory)

View file

@ -28,4 +28,5 @@ class LiveblogPlugin(TextPlugin):
context['instance'] = instance context['instance'] = instance
return context return context
plugin_pool.register_plugin(LiveblogPlugin) plugin_pool.register_plugin(LiveblogPlugin)

View file

@ -3,8 +3,9 @@ from __future__ import absolute_import, print_function, unicode_literals
import json import json
import django
from channels import Group 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 cms.utils.plugins import reorder_plugins
from django.db import models from django.db import models
from django.template import Context from django.template import Context
@ -87,6 +88,12 @@ class Liveblog(LiveblogInterface, AbstractText):
""" """
Basic liveblog plugin model 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) title = models.CharField(_('title'), max_length=255)
image = FilerImageField( image = FilerImageField(
verbose_name=_('image'), blank=True, null=True, on_delete=models.SET_NULL, verbose_name=_('image'), blank=True, null=True, on_delete=models.SET_NULL,

View file

@ -20,6 +20,7 @@ def get_urls():
) )
return details return details
detail_urls = get_urls() detail_urls = get_urls()
urlpatterns = [ urlpatterns = [

View file

@ -143,7 +143,7 @@ class AdminTest(BaseTest):
# Add view only has an empty form - no type # Add view only has an empty form - no type
response = post_admin.add_view(request) response = post_admin.add_view(request)
self.assertNotContains(response, 'djangocms_blog.cms_appconfig.BlogConfig') self.assertNotContains(response, 'djangocms_blog.cms_appconfig.BlogConfig')
self.assertContains(response, '<input class="vTextField" id="id_namespace" maxlength="100" name="namespace" type="text" />') self.assertContains(response, '<input class="vTextField" id="id_namespace" maxlength="100" name="namespace" type="text"')
# Changeview is 'normal', with a few preselected items # Changeview is 'normal', with a few preselected items
response = post_admin.change_view(request, str(self.app_config_1.pk)) response = post_admin.change_view(request, str(self.app_config_1.pk))
@ -152,7 +152,7 @@ class AdminTest(BaseTest):
# check that all the form fields are visible in the admin # check that all the form fields are visible in the admin
for fieldname in BlogConfigForm.base_fields: for fieldname in BlogConfigForm.base_fields:
self.assertContains(response, 'id="id_config-%s"' % fieldname) self.assertContains(response, 'id="id_config-%s"' % fieldname)
self.assertContains(response, '<input id="id_config-og_app_id" maxlength="200" name="config-og_app_id" type="text" />') self.assertContains(response, '<input id="id_config-og_app_id" maxlength="200" name="config-og_app_id" type="text"')
self.assertContains(response, 'sample_app') self.assertContains(response, 'sample_app')
def test_admin_category_views(self): def test_admin_category_views(self):
@ -161,12 +161,12 @@ class AdminTest(BaseTest):
# Add view only has an empty form - no type # Add view only has an empty form - no type
response = post_admin.add_view(request) response = post_admin.add_view(request)
self.assertNotContains(response, 'id="id_name" maxlength="255" name="name" type="text" value="category 1" />') self.assertNotContains(response, 'id="id_name" maxlength="255" name="name" type="text" value="category 1"')
self.assertContains(response, '<option value="%s">Blog / sample_app</option>' % self.app_config_1.pk) self.assertContains(response, '<option value="%s">Blog / sample_app</option>' % self.app_config_1.pk)
# Changeview is 'normal', with a few preselected items # Changeview is 'normal', with a few preselected items
response = post_admin.change_view(request, str(self.category_1.pk)) 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, '<option value="%s" selected="selected">Blog / sample_app</option>' % self.app_config_1.pk) self.assertContains(response, '<option value="%s" selected="selected">Blog / sample_app</option>' % self.app_config_1.pk)
def test_admin_category_parents(self): def test_admin_category_parents(self):

View file

@ -1,5 +1,5 @@
[tox] [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] [testenv]
commands = {env:COMMAND:python} cms_helper.py test djangocms_blog commands = {env:COMMAND:python} cms_helper.py test djangocms_blog
@ -14,6 +14,9 @@ deps =
django19: django-mptt>=0.8 django19: django-mptt>=0.8
django19: django-filer<1.3 django19: django-filer<1.3
django19: cmsplugin-filer<1.2 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: https://github.com/divio/django-cms/archive/release/3.2.x.zip
cms32: djangocms-text-ckeditor<3.0 cms32: djangocms-text-ckeditor<3.0
cms33: https://github.com/divio/django-cms/archive/release/3.3.x.zip cms33: https://github.com/divio/django-cms/archive/release/3.3.x.zip