Skip to content

Commit

Permalink
Add Django 1.10 / django CMS 3.4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
yakky committed Aug 24, 2016
1 parent d1807ef commit ce0620f
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 11 deletions.
32 changes: 30 additions & 2 deletions .travis.yml
Expand Up @@ -13,6 +13,8 @@ python:

env:
matrix:
- TOXENV='pep8'
- TOXENV='isort'
- DJANGO='django16' CMS='cms30'
- DJANGO='django16' CMS='cms31'
- DJANGO='django16' CMS='cms32'
Expand All @@ -24,12 +26,16 @@ env:
- DJANGO='django18' CMS='cms31'
- DJANGO='django18' CMS='cms32'
- DJANGO='django18' CMS='cms33'
- DJANGO='django18' CMS='cms34'
- DJANGO='django18' CMS='cmsno'
- DJANGO='django19' CMS='cms32'
- DJANGO='django19' CMS='cms33'
- DJANGO='django19' CMS='cms34'
- DJANGO='django19' CMS='cmsno'
- TOXENV='pep8'
- TOXENV='isort'
- DJANGO='django110' CMS='cms32'
- DJANGO='django110' CMS='cms33'
- DJANGO='django110' CMS='cms34'
- DJANGO='django110' CMS='cmsno'

before_install:
- pip install codecov
Expand Down Expand Up @@ -82,14 +88,26 @@ matrix:
env: DJANGO='django18' CMS='cms32'
- python: 2.6
env: DJANGO='django18' CMS='cms33'
- python: 2.6
env: DJANGO='django18' CMS='cms34'
- python: 2.6
env: DJANGO='django18' CMS='cmsno'
- python: 2.6
env: DJANGO='django19' CMS='cms32'
- python: 2.6
env: DJANGO='django19' CMS='cms33'
- python: 2.6
env: DJANGO='django19' CMS='cms34'
- python: 2.6
env: DJANGO='django19' CMS='cmsno'
- python: 2.6
env: DJANGO='django110' CMS='cms32'
- python: 2.6
env: DJANGO='django110' CMS='cms33'
- python: 2.6
env: DJANGO='django110' CMS='cms34'
- python: 2.6
env: DJANGO='django110' CMS='cmsno'
- python: 2.7
env: DJANGO='django17' CMS='cms30'
- python: 2.7
Expand Down Expand Up @@ -118,8 +136,18 @@ matrix:
env: DJANGO='django19' CMS='cms32'
- python: 3.3
env: DJANGO='django19' CMS='cms33'
- python: 3.3
env: DJANGO='django19' CMS='cms34'
- python: 3.3
env: DJANGO='django19' CMS='cmsno'
- python: 3.3
env: DJANGO='django110' CMS='cms32'
- python: 3.3
env: DJANGO='django110' CMS='cms33'
- python: 3.3
env: DJANGO='django110' CMS='cms34'
- python: 3.3
env: DJANGO='django110' CMS='cmsno'
- python: 3.5
env: DJANGO='django16' CMS='cms30'
- python: 3.5
Expand Down
2 changes: 2 additions & 0 deletions HISTORY.rst
Expand Up @@ -8,6 +8,8 @@ History

* Added support for channels runserver.
* Added verbosity level to server command.
* Added support for Django 1.10.
* Added support for django CMS 3.4.

0.9.5 (2016-06-06)
++++++++++++++++++
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Expand Up @@ -45,9 +45,9 @@ Supported versions

Python: 2.6, 2.7, 3.3, 3.4, 3.5

Django: 1.6 to 1.9
Django: 1.6 to 1.10

django CMS: 3.0 to 3.2
django CMS: 3.0 to 3.4

.. warning:: Starting from version 1.0, compatibily with Python 2.6, Python 3.3, Django<=1.7 and
django CMS<=3.1 will be dropped. Pin your test requirements accordingly
Expand Down
21 changes: 20 additions & 1 deletion djangocms_helper/base_test.py
Expand Up @@ -210,6 +210,19 @@ def create_pages(source, languages):
reload_urls(settings, cms_apps=True)
return list(pages.values())

def get_content_renderer(self, request):
"""
Returns a the plugin renderer. Only for django CMS 3.4+
:param request: request instance
:return: ContentRenderer instance
"""
try:
from cms.plugin_rendering import ContentRenderer
return ContentRenderer(request)
except ImportError:
return None

def get_plugin_context(self, page, lang, plugin, edit=False):
"""
Returns a context suitable for CMSPlugin.render_plugin / render_placeholder
Expand All @@ -222,7 +235,13 @@ def get_plugin_context(self, page, lang, plugin, edit=False):
"""
from cms.plugin_rendering import PluginContext
request = self.get_page_request(page, self.user, lang=lang, edit=edit)
return PluginContext({'request': request}, plugin, plugin.placeholder)
context = {
'request': request
}
renderer = self.get_content_renderer(request)
if renderer:
context['cms_content_renderer'] = renderer
return PluginContext(context, plugin, plugin.placeholder)

def render_plugin(self, page, lang, plugin, edit=False):
"""
Expand Down
7 changes: 4 additions & 3 deletions djangocms_helper/test_utils/example1/tests/test_fake.py
Expand Up @@ -11,6 +11,7 @@
from djangocms_helper.base_test import BaseTestCase
from djangocms_helper.utils import get_user_model_labels


class FakeTests(BaseTestCase):
_pages_data = (
{'en': {'title': 'Page title', 'template': 'page.html', 'publish': True},
Expand Down Expand Up @@ -129,10 +130,10 @@ def test_render_plugin(self):
plugin = add_plugin(placeholder=placeholder, plugin_type='FakePlugin', language='en')
pages[0].publish('en')
context = self.get_plugin_context(pages[0], 'en', plugin, edit=False)
rendered_1 = plugin.render_plugin(context, placeholder)
rendered_2 = self.render_plugin(pages[0], 'en', plugin)
self.assertEqual(rendered_1, rendered_2)
self.assertEqual(rendered_1, sample_text)
rendered_1 = plugin.render_plugin(context, placeholder)
self.assertEqual(rendered_2, rendered_1)
self.assertEqual(rendered_2, sample_text)

def test_request(self):
from django.conf import settings
Expand Down
1 change: 0 additions & 1 deletion djangocms_helper/tests/test_commands.py
Expand Up @@ -494,7 +494,6 @@ def test_runner(self):
args.append('djangocms_helper')
args.append('test')
args.append('example1')
args.append('tests')
runner.cms('example1', args)
self.assertTrue('visible string' in out.getvalue())
self.assertFalse('hidden string' in out.getvalue())
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Expand Up @@ -143,7 +143,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
#html_static_path = ['_static']

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Expand Up @@ -45,6 +45,8 @@
'Framework :: Django :: 1.6',
'Framework :: Django :: 1.7',
'Framework :: Django :: 1.8',
'Framework :: Django :: 1.9',
'Framework :: Django :: 1.10',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
Expand Down
19 changes: 18 additions & 1 deletion tox.ini
@@ -1,5 +1,5 @@
[tox]
envlist = pep8,isort,py{35,34,27}-django{19}-cms{33,32,no},py{35,34,33,27}-django{18}-cms{33,32,31,no},py{34,33,27}-django{17,16}-cms{32,31,30,no},py{26}-django{16}-cms{32,31,30,no}
envlist = pep8,isort,docs,py{35,34,27}-django{110,19}-cms{34,33,32,no},py{35,34,33,27}-django{18}-cms{34,33,32,31,no},py{34,33,27}-django{17,16}-cms{32,31,30,no},py{26}-django{16}-cms{32,31,30,no}
skip_missing_interpreters=True

[testenv]
Expand All @@ -17,6 +17,9 @@ deps=
django19: django<1.10
django19: django-mptt>0.8
django19: django-nose<1.5
django110: django<1.10
django110: django-mptt>0.8
django110: django-nose<1.5
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
Expand All @@ -25,6 +28,8 @@ deps=
cms32: djangocms-text-ckeditor>=2.8,<3.0
cms33: https://github.com/divio/django-cms/archive/release/3.3.x.zip
cms33: djangocms-text-ckeditor>=3.0
cms34: https://github.com/divio/django-cms/archive/develop.zip
cms34: djangocms-text-ckeditor>=3.1
py26: django-filer<1.2
py27: https://github.com/stefanfoulis/django-filer/archive/develop.zip
py33: django-filer<1.2
Expand All @@ -48,3 +53,15 @@ skip_install = true
deps = isort
commands = isort -c -rc -df djangocms_helper
skip_install = true

[testenv:docs]
deps =
sphinx
sphinx-rtd-theme
django-filer
django<1.10
-rrequirements-test.txt
changedir=docs
skip_install = true
commands=
sphinx-build -W -b html -d {envtmpdir}/doctrees . {toxinidir}/docs/_build/html

0 comments on commit ce0620f

Please sign in to comment.