Skip to content
This repository has been archived by the owner on Feb 1, 2019. It is now read-only.

Commit

Permalink
Merge pull request #40 from aldryn/feature/django-cms-33
Browse files Browse the repository at this point in the history
feature/django cms 33
  • Loading branch information
czpython committed May 22, 2016
2 parents bc5fdad + b37fd94 commit e0de8ab
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 29 deletions.
16 changes: 13 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
language: python

python: 3.5

# Use container based infrastructure
sudo: false

env:
- TOX_ENV=flake8
- TOX_ENV=py35-dj19-cms33
- TOX_ENV=py35-dj19-cms32
- TOX_ENV=py34-dj19-cms33
- TOX_ENV=py34-dj19-cms32
- TOX_ENV=py27-dj19-cms33
- TOX_ENV=py27-dj19-cms32
- TOX_ENV=py35-dj18-cms33
- TOX_ENV=py35-dj18-cms32
- TOX_ENV=py34-dj18-cms33
- TOX_ENV=py34-dj18-cms32
- TOX_ENV=py34-dj18-cms31
- TOX_ENV=py27-dj18-cms33
- TOX_ENV=py27-dj18-cms32
- TOX_ENV=py27-dj18-cms31
- TOX_ENV=py34-dj17-cms32
- TOX_ENV=py34-dj17-cms31
- TOX_ENV=py34-dj17-cms30
- TOX_ENV=py27-dj19-cms32
- TOX_ENV=py27-dj18-cms32
- TOX_ENV=py27-dj18-cms31
- TOX_ENV=py27-dj17-cms32
- TOX_ENV=py27-dj17-cms31
- TOX_ENV=py27-dj17-cms30
Expand Down
14 changes: 12 additions & 2 deletions aldryn_reversion/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,20 @@ def post_clear_placeholder(self, request, placeholder):

self._create_aldryn_revision(placeholder, request.user, comment)

def post_add_plugin(self, request, placeholder, plugin):
def post_add_plugin(self, request, *args):
# The signature for post_add_plugin
# prior to 3.3 was request, placeholder, plugin.
# On 3.3 this was changed to request, plugin
# to keep consistency with the other hook methods.
try:
# CMS <= 3.2.x
placeholder, plugin = args
except ValueError:
# CMS >= 3.3.x
plugin = args[0]
comment_dict = self.get_commen_plugin_info(plugin)
comment = _('Added plugin #%(plugin_id)s: %(plugin)s') % comment_dict
self._create_aldryn_revision(placeholder, request.user, comment)
self._create_aldryn_revision(plugin.placeholder, request.user, comment)

def post_edit_plugin(self, request, plugin):
comment_dict = self.get_commen_plugin_info(plugin)
Expand Down
28 changes: 15 additions & 13 deletions aldryn_reversion/tests/test_placeholders.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

from django.contrib import admin
from django.contrib.contenttypes.models import ContentType
from django.http.request import QueryDict
from django.utils.encoding import force_text
from django.utils.http import urlencode

from reversion.models import Version, Revision

Expand All @@ -33,6 +35,7 @@
# CMS 3.2.1 introduced several fixes for reversions.
# We count on these fixes in some tests.
CMS_3_2_1 = LooseVersion(cms.__version__) >= LooseVersion('3.2.1')
CMS_3_3 = LooseVersion(cms.__version__) >= LooseVersion('3.3')


class ReversionRevisionAdminTestCase(CMSRequestBasedMixin,
Expand Down Expand Up @@ -517,21 +520,24 @@ def test_revision_view_reverts_object_to_selected_state(self):
'plugin_language': 'en',
}

request = self.get_post_request(data)
if CMS_3_3:
request = self.get_su_request(post_data={})
request.GET = QueryDict(urlencode(data))
request._dont_enforce_csrf_checks = True
else:
request = self.get_post_request(data)

# first plugin
response = m_pl_admin.add_plugin(request)

self.assertEqual(response.status_code, 200)
self.assertEqual(m_pl.cmsplugin_set.count(), 1)

# First version for example obj
example_obj_v1 = example_obj_versions[0]

# Point to the newly created sample plugin
sample_plugin_pk = self.get_plugin_id_from_response(
response,
path='url',
)
sample_plugin_pk = m_pl.cmsplugin_set.get().pk

sample_plugin_versions = (
example_obj_v1.revision.version_set.all()
Expand All @@ -551,15 +557,13 @@ def test_revision_view_reverts_object_to_selected_state(self):
response = m_pl_admin.add_plugin(request)

self.assertEqual(response.status_code, 200)
self.assertEqual(m_pl.cmsplugin_set.count(), 2)

# Second version for example obj
example_obj_v2 = example_obj_versions[0]

# Point to the newly created sample plugin
sample_plugin_pk = self.get_plugin_id_from_response(
response,
path='url',
)
sample_plugin_pk = m_pl.cmsplugin_set.latest('id').pk

sample_plugin_versions = (
example_obj_v2.revision.version_set.all()
Expand All @@ -579,15 +583,13 @@ def test_revision_view_reverts_object_to_selected_state(self):
response = m_pl_admin.add_plugin(request)

self.assertEqual(response.status_code, 200)
self.assertEqual(m_pl.cmsplugin_set.count(), 3)

# third version for example obj
example_obj_v3 = example_obj_versions[0]

# Point to the newly created sample plugin
sample_plugin_pk = self.get_plugin_id_from_response(
response,
path='url',
)
sample_plugin_pk = m_pl.cmsplugin_set.latest('id').pk

sample_plugin_versions = (
example_obj_v3.revision.version_set.all()
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
'Framework :: Django :: 1.6',
'Framework :: Django :: 1.7',
'Framework :: Django :: 1.8',
'Framework :: Django :: 1.9',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development',
'Topic :: Software Development :: Libraries :: Application Frameworks',
Expand Down
30 changes: 19 additions & 11 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
[tox]
envlist =
flake8,
py34-dj19-cms32
py34-dj{18,17}-cms{32,31}
py34-dj17-cms30
py27-dj19-cms32
py27-dj{18,17,16}-cms{32,31}
py27-dj16-cms30
py{26}-dj{16}-cms{32,31,30}
flake8
py{35,34,27}-dj19-cms{33,32}
py{34,27}-dj18-cms{32,31}
py{34,27}-dj17-cms{32,31,30}
py{33,27}-dj16-cms{32,31,30}
py{26}-dj16-cms{32,31,30}

[testenv]
commands =
Expand All @@ -20,14 +18,24 @@ deps =
dj17: -rtest_requirements/django-1.7.txt
dj18: -rtest_requirements/django-1.8.txt
dj19: -rtest_requirements/django-1.9.txt

cms30: django-cms<3.1
cms30: djangocms-text-ckeditor<=2.7
dj17-cms30: django-reversion<1.9
cms31: django-cms<3.2

cms31: django-cms>=3.1,<3.2
cms31: djangocms-text-ckeditor>2.7,<=2.9.3
dj{18,17}-cms31: django-reversion<1.10
cms32: django-cms<3.3

cms32: django-cms>=3.2,<3.3
cms32: djangocms-text-ckeditor>2.7,<=2.9.3
dj{19,18,17}-cms32: django-reversion<1.11

cms33: https://github.com/divio/django-cms/archive/develop.zip#egg=django-cms
cms33: https://github.com/divio/djangocms-text-ckeditor/archive/develop.zip#egg=djangocms-text-ckeditor
dj{19,18}-cms33: django-reversion<1.11

py26: unittest2
djangocms_text_ckeditor

[testenv:flake8]
deps = flake8
Expand Down

0 comments on commit e0de8ab

Please sign in to comment.