Skip to content

Commit

Permalink
Make djangocms-transfer publicly available (#4)
Browse files Browse the repository at this point in the history
* added tests, readme and some updates

* fix django.core.urlresolvers

* fix django CMS 3.6 compatibility
  • Loading branch information
FinalAngel authored Dec 17, 2018
1 parent 77baa6a commit 432e430
Show file tree
Hide file tree
Showing 14 changed files with 234 additions and 20 deletions.
18 changes: 18 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[run]
branch = True
source = djangocms_transfer
omit =
migrations/*
tests/*

[report]
exclude_lines =
pragma: no cover
def __repr__
if self.debug:
if settings.DEBUG
raise AssertionError
raise NotImplementedError
if 0:
if __name__ == .__main__.:
ignore_errors = True
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
.idea/
.tox/
.eggs/
dist/
build/
33 changes: 33 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
language: python

sudo: false

matrix:
include:
- python: 3.5
env: TOX_ENV='flake8'
# Django 1.11
- python: 2.7
env: DJANGO='dj111' CMS='cms34'
- python: 3.5
env: DJANGO='dj111' CMS='cms35'
- python: 3.5
env: DJANGO='dj111' CMS='cms36'
# Django 2.0
- python: 3.5
env: DJANGO='dj20' CMS='cms36'
# Django 2.1
- python: 3.5
env: DJANGO='dj21' CMS='cms36'

install:
- pip install tox coverage
- "if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then export PY_VER=py27; fi"
- "if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then export PY_VER=py35; fi"
- "if [[ ${DJANGO}z != 'z' ]]; then export TOX_ENV=$PY_VER-$DJANGO-$CMS; fi"

script:
- tox -e $TOX_ENV

after_success:
- bash <(curl -s https://codecov.io/bash)
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
=========
Changelog
=========

1.0.0 (unreleased)
==================

* Public release
42 changes: 42 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
===================
django CMS Transfer
===================


|pypi| |build| |coverage|

**django CMS Transfer** is an **experimental** package that allows you to export
and import plugin data from a page or a placeholder. It does not support foreign
key relations and won't import/export related data.

This addon is compatible with `Divio Cloud <http://divio.com>`_ and is also available on the
`django CMS Marketplace <https://marketplace.django-cms.org/en/addons/browse/djangocms-transfer/>`_
for easy installation.


Contributing
============

This is a an open-source project. We'll be delighted to receive your
feedback in the form of issues and pull requests. Before submitting your
pull request, please review our `contribution guidelines
<http://docs.django-cms.org/en/latest/contributing/index.html>`_.


Running Tests
-------------

You can run tests by executing::

virtualenv env
source env/bin/activate
pip install -r tests/requirements.txt
python setup.py test


.. |pypi| image:: https://badge.fury.io/py/djangocms-transfer.svg
:target: http://badge.fury.io/py/djangocms-transfer
.. |build| image:: https://travis-ci.org/divio/djangocms-transfer.svg?branch=master
:target: https://travis-ci.org/divio/djangocms-transfer
.. |coverage| image:: https://codecov.io/gh/divio/djangocms-transfer/branch/master/graph/badge.svg
:target: https://codecov.io/gh/divio/djangocms-transfer
4 changes: 2 additions & 2 deletions djangocms_transfer/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django.conf.urls import url
from django.core.exceptions import PermissionDenied
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.http import JsonResponse, HttpResponse, HttpResponseBadRequest
from django.shortcuts import render
from django.utils.http import urlencode
Expand Down Expand Up @@ -151,7 +151,7 @@ def import_plugins_view(cls, request):

if LTE_CMS_3_4:
return HttpResponse('<div><div class="messagelist"><div class="success"></div></div></div>')

if plugin:
new_plugins = plugin.reload().get_descendants().exclude(pk__in=tree_order)
return plugin.get_plugin_class_instance().render_close_frame(request, obj=new_plugins[0])
Expand Down
9 changes: 8 additions & 1 deletion djangocms_transfer/cms_toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from cms.toolbar_pool import toolbar_pool
from cms.utils.urlutils import admin_reverse

from .compat import GTE_CMS_3_6


@toolbar_pool.register
class PluginImporter(CMSToolbar):
Expand Down Expand Up @@ -37,7 +39,12 @@ def populate(self):
'language': self.current_lang,
'cms_page': page.pk,
})
not_edit_mode = not self.toolbar.edit_mode

if GTE_CMS_3_6:
not_edit_mode = not self.toolbar.toolbar_language
else:
not_edit_mode = not self.toolbar.language

page_menu.add_break('Page menu importer break')
page_menu.add_link_item(
ugettext('Export'),
Expand Down
1 change: 1 addition & 0 deletions djangocms_transfer/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@

LTE_CMS_3_4 = cms_version < LooseVersion('3.5')
LTE_CMS_3_5 = cms_version < LooseVersion('3.6')
GTE_CMS_3_6 = cms_version >= LooseVersion('3.6')
52 changes: 35 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,49 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import find_packages, setup

import djangocms_transfer
from djangocms_transfer import __version__


INSTALL_REQUIREMENTS = [
'Django>=1.8,<2',
'django-cms>=3.4.2',
REQUIREMENTS = [
'django-cms>=3.4.5',
]


CLASSIFIERS = [
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development :: Libraries :: Application Frameworks',
'Topic :: Software Development :: Libraries :: Python Modules',
]


setup(
name='djangocms-transfer',
packages=find_packages(),
include_package_data=True,
version=djangocms_transfer.__version__,
description=djangocms_transfer.__doc__,
long_description=open('README.rst').read(),
classifiers=[
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Topic :: Software Development'
],
install_requires=INSTALL_REQUIREMENTS,
version=__version__,
author='Divio AG',
author_email='[email protected]',
url='http://github.com/divio/djangocms-transfer',
license='BSD',
description='Adds import and export of plugin data.',
packages=find_packages(exclude=['tests']),
long_description=open('README.rst').read(),
include_package_data=True,
zip_safe=False,
install_requires=REQUIREMENTS,
classifiers=CLASSIFIERS,
test_suite='tests.settings.run',
)
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# -*- coding: utf-8 -*-
4 changes: 4 additions & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# other requirements
djangocms-helper
tox
coverage
23 changes: 23 additions & 0 deletions tests/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

HELPER_SETTINGS = {
'INSTALLED_APPS': [],
'LANGUAGE_CODE': 'en',
'CMS_LANGUAGES': {
1: [{
'code': 'en',
'name': 'English',
}]
},
'ALLOWED_HOSTS': ['localhost'],
}


def run():
from djangocms_helper import runner
runner.cms('djangocms_transfer')


if __name__ == '__main__':
run()
31 changes: 31 additions & 0 deletions tests/test_migrations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# original from
# http://tech.octopus.energy/news/2016/01/21/testing-for-missing-migrations-in-django.html
from django.core.management import call_command
from django.test import TestCase, override_settings
from django.utils.six import text_type
from django.utils.six.moves import StringIO


class MigrationTestCase(TestCase):

@override_settings(MIGRATION_MODULES={})
def test_for_missing_migrations(self):
output = StringIO()
options = {
'interactive': False,
'dry_run': True,
'stdout': output,
'check_changes': True,
}

try:
call_command('makemigrations', **options)
except SystemExit as e:
status_code = text_type(e)
else:
# the "no changes" exit code is 0
status_code = '0'

if status_code == '1':
self.fail('There are missing migrations:\n {}'.format(output.getvalue()))
27 changes: 27 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[tox]
envlist =
flake8
py{27,34,35,36}-dj111-cms{34,35,36}
py{34,35,36}-dj20-cms36
py{35,36}-dj21-cms36

skip_missing_interpreters=True

[testenv]
deps =
-r{toxinidir}/tests/requirements.txt
dj111: Django>=1.11,<2.0
dj20: Django>=2.0,<2.1
dj21: Django>=2.1,<2.2
cms34: django-cms>=3.4,<3.5
cms35: django-cms>=3.5,<3.6
cms36: https://github.com/divio/django-cms/archive/release/3.6.x.zip
commands =
{envpython} --version
{env:COMMAND:coverage} erase
{env:COMMAND:coverage} run setup.py test
{env:COMMAND:coverage} report

[flake8]
max-line-length = 120
exclude = */docs/*,*/migrations/*

0 comments on commit 432e430

Please sign in to comment.