From e96ede57925ac3782d33768d658e4bfe17623369 Mon Sep 17 00:00:00 2001 From: Carlo Ascani Date: Sat, 16 Aug 2014 17:16:45 +0200 Subject: [PATCH 01/30] Fix a pip command in documentation --- CONTRIBUTING.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 44667e9..64f7a15 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -67,7 +67,7 @@ Ready to contribute? Here's how to set up `djangocms-installer` for local develo $ mkvirtualenv djangocms-installer $ cd djangocms-installer/ $ python setup.py develop - $ pip install requirements_dev.txt + $ pip install -r requirements_dev.txt the last one is to get the requirements including testing and development tools installed. @@ -82,7 +82,7 @@ Now you can make your changes locally. tests, including testing other Python versions with tox:: $ flake8 djangocms-installer tests - $ python setup.py test + $ python setup.py test $ tox 6. Commit your changes and push your branch to GitHub:: From 33bb9f5548ed9ad2e76e80b0b6e3b22aa0de0fa2 Mon Sep 17 00:00:00 2001 From: pipsqueaker Date: Sat, 30 Aug 2014 10:54:07 -0400 Subject: [PATCH 02/30] Update README.rst --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index 8d18b45..7d2a146 100644 --- a/README.rst +++ b/README.rst @@ -64,6 +64,7 @@ Libraries you would want to check: * zlib (for PNG support in ``Pillow``) * postgresql (for ``psycopg``) * libmysqlclient (for ``Mysql-Python``) +* python-dev (for compilation and linking) For additional information, check http://djangocms-installer.readthedocs.org/en/latest/libraries.html From e0944f6984af216eb3a3563b3bda41638df4d87f Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Fri, 25 Jul 2014 22:14:23 +0200 Subject: [PATCH 03/30] Fix help string --- djangocms_installer/config/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/djangocms_installer/config/__init__.py b/djangocms_installer/config/__init__.py index 07d5a2a..1e9c72a 100644 --- a/djangocms_installer/config/__init__.py +++ b/djangocms_installer/config/__init__.py @@ -83,7 +83,7 @@ def parse(args): parser.add_argument('--no-user', '-u', dest='no_user', action='store_true', default=False, help="Don't create the admin user") parser.add_argument('--template', dest='template', action='store', - default=None, help="The path or URL to load the template from") + default=None, help="The path or URL to load the django project template from.") parser.add_argument('--extra-settings', dest='extra_settings', action='store', default=None, help="The path to an file that contains extra settings.") From 3dc8f012c414ac851390e1917e7b09dc48d60757 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Fri, 15 Aug 2014 16:18:23 +0200 Subject: [PATCH 04/30] Experimental support for django 1.7 --- djangocms_installer/config/__init__.py | 2 +- djangocms_installer/config/settings.py | 20 ++++++++++++++- djangocms_installer/django/__init__.py | 34 +++++++++++++++++--------- 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/djangocms_installer/config/__init__.py b/djangocms_installer/config/__init__.py index 1e9c72a..4211973 100644 --- a/djangocms_installer/config/__init__.py +++ b/djangocms_installer/config/__init__.py @@ -38,7 +38,7 @@ def parse(args): help='Languages to enable. Option can be provided multiple times, or as a comma separated list. ' 'Only language codes supported by Django can be used here') parser.add_argument('--django-version', dest='django_version', action='store', - choices=('1.4', '1.5', '1.6', 'stable'), + choices=('1.4', '1.5', '1.6', '1.7', 'stable'), default='stable', help='Django version') parser.add_argument('--cms-version', '-v', dest='cms_version', action='store', choices=('2.4', '3.0', 'stable', 'develop'), diff --git a/djangocms_installer/config/settings.py b/djangocms_installer/config/settings.py index b7458cf..ae7991b 100644 --- a/djangocms_installer/config/settings.py +++ b/djangocms_installer/config/settings.py @@ -59,7 +59,6 @@ 'cms', 'mptt', 'menus', - 'south', 'sekizai', ) @@ -133,6 +132,9 @@ REVERSION_APPLICATIONS = ( 'reversion', ) +SOUTH_APPLICATIONS = ( + 'south', +) CMS_TEMPLATES = ( ('fullwidth.html', 'Fullwidth'), @@ -174,3 +176,19 @@ SOUTH_MIGRATION_MODULES = ( ('easy_thumbnails', 'easy_thumbnails.south_migrations'), ) + +MIGRATION_MODULES = ( + ('cms', 'cms.migrations_django'), + ('menus', 'menus.migrations_django'), + ('djangocms_text_ckeditor', 'djangocms_text_ckeditor.migrations_django'), + ('djangocms_column', 'djangocms_column.migrations_django'), + ('djangocms_file', 'djangocms_file.migrations_django'), + ('djangocms_flash', 'djangocms_flash.migrations_django'), + ('djangocms_googlemap', 'djangocms_googlemap.migrations_django'), + ('djangocms_inherit', 'djangocms_inherit.migrations_django'), + ('djangocms_link', 'djangocms_link.migrations_django'), + ('djangocms_picture', 'djangocms_picture.migrations_django'), + ('djangocms_style', 'djangocms_style.migrations_django'), + ('djangocms_teaser', 'djangocms_teaser.migrations_django'), + ('djangocms_video', 'djangocms_video.migrations_django'), +) \ No newline at end of file diff --git a/djangocms_installer/django/__init__.py b/djangocms_installer/django/__init__.py index 59f9b5b..b9a4c41 100644 --- a/djangocms_installer/django/__init__.py +++ b/djangocms_installer/django/__init__.py @@ -197,6 +197,9 @@ def _build_settings(config_data): apps.extend(vars.FILER_PLUGINS_3) else: apps.extend(vars.STANDARD_PLUGINS_3) + if config_data.django_version <= 1.6: + apps.extend(vars.SOUTH_APPLICATIONS) + if config_data.reversion: apps.extend(vars.REVERSION_APPLICATIONS) text.append("INSTALLED_APPS = (\n%s%s\n)" % ( @@ -250,11 +253,16 @@ def _build_settings(config_data): text.append("DATABASES = {\n%s'default':\n%s%s\n}" % (spacer, spacer * 2, config_data.db_parsed)) + if config_data.django_version >= 1.7: + text.append("MIGRATION_MODULES = {\n%s%s\n}" % ( + spacer, (",\n" + spacer).join(["'%s': '%s'" % item for item in vars.MIGRATION_MODULES]))) + if config_data.filer: text.append("THUMBNAIL_PROCESSORS = (\n%s%s\n)" % ( spacer, (",\n" + spacer).join(["'%s'" % var for var in vars.THUMBNAIL_PROCESSORS]))) - text.append("SOUTH_MIGRATION_MODULES = {\n%s%s\n}" % ( - spacer, (",\n" + spacer).join(["'%s': '%s'" % item for item in vars.SOUTH_MIGRATION_MODULES]))) + if config_data.django_version <= 1.6: + text.append("SOUTH_MIGRATION_MODULES = {\n%s%s\n}" % ( + spacer, (",\n" + spacer).join(["'%s': '%s'" % item for item in vars.SOUTH_MIGRATION_MODULES]))) return "\n\n".join(text) @@ -262,16 +270,20 @@ def setup_database(config_data): with chdir(config_data.project_directory): os.environ['DJANGO_SETTINGS_MODULE'] = ( '{0}.settings'.format(config_data.project_name)) - try: - import south # NOQA - subprocess.check_call([sys.executable, "-W", "ignore", - "manage.py", "syncdb", "--all", "--noinput"]) - subprocess.check_call([sys.executable, "-W", "ignore", - "manage.py", "migrate", "--fake"]) - except ImportError: + if config_data.django_version <= 1.6: + try: + import south # NOQA + subprocess.check_call([sys.executable, "-W", "ignore", + "manage.py", "syncdb", "--all", "--noinput"]) + subprocess.check_call([sys.executable, "-W", "ignore", + "manage.py", "migrate", "--fake"]) + except ImportError: + subprocess.check_call([sys.executable, "-W", "ignore", + "manage.py", "syncdb", "--noinput"]) + print("south not installed, migrations skipped") + else: subprocess.check_call([sys.executable, "-W", "ignore", - "manage.py", "syncdb", "--noinput"]) - print("south not installed, migrations skipped") + "manage.py", "migrate", "--noinput"]) if not config_data.no_user and not config_data.noinput: print("\n\nCreating admin user") subprocess.check_call([sys.executable, "-W", "ignore", From 67427f5e64745eb59ab120294e5606649962b9a8 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sun, 7 Sep 2014 22:52:59 +0200 Subject: [PATCH 05/30] Tests for Django 1.7 --- djangocms_installer/config/__init__.py | 22 ++++++++++++-- djangocms_installer/config/data.py | 40 +++++++++++++++++++++----- djangocms_installer/django/__init__.py | 3 +- djangocms_installer/utils.py | 4 +-- tests/config.py | 25 ++++++++++++++-- tests/django.py | 35 ++++++++++++++++++---- tox.ini | 9 +++++- 7 files changed, 116 insertions(+), 22 deletions(-) diff --git a/djangocms_installer/config/__init__.py b/djangocms_installer/config/__init__.py index 4211973..af7ebf9 100644 --- a/djangocms_installer/config/__init__.py +++ b/djangocms_installer/config/__init__.py @@ -183,11 +183,21 @@ def parse(args): requirements.append(args.db_driver) if args.filer: if cms_version >= 3: - requirements.append(data.FILER_REQUIREMENTS_CMS3) + if django_version < 1.7: + requirements.append(data.PLUGINS_REQUIREMENTS_BASIC) + requirements.append(data.FILER_REQUIREMENTS_CMS3) + else: + requirements.append(data.PLUGINS_REQUIREMENTS_BASIC_DJANGO_17) + requirements.append(data.FILER_REQUIREMENTS_CMS3) else: requirements.append(data.FILER_REQUIREMENTS_CMS2) elif cms_version >= 3: - requirements.append(data.PLUGIN_REQUIREMENTS) + if django_version < 1.7: + requirements.append(data.PLUGINS_REQUIREMENTS_BASIC) + requirements.append(data.PLUGINS_REQUIREMENTS_NON_FILER) + else: + requirements.append(data.PLUGINS_REQUIREMENTS_BASIC_DJANGO_17) + requirements.append(data.PLUGINS_REQUIREMENTS_NON_FILER_DJANGO_17) # Django version check if args.django_version == 'develop': @@ -207,14 +217,20 @@ def parse(args): if args.use_timezone: requirements.append('pytz') + # Requirements dependendent on django version + if django_version < 1.7: + requirements.append(data.DJANGO_16_REQUIREMENTS) + # Reversion package version depends on django version if args.reversion: if django_version < 1.5: requirements.append(data.DJANGO_14_REVERSION) elif django_version == 1.5: requirements.append(data.DJANGO_15_REVERSION) - else: + elif django_version == 1.6: requirements.append(data.DJANGO_16_REVERSION) + else: + requirements.append(data.DJANGO_17_REVERSION) requirements.extend([data.DEFAULT_REQUIREMENTS]) diff --git a/djangocms_installer/config/data.py b/djangocms_installer/config/data.py index 769f45c..5f14d35 100644 --- a/djangocms_installer/config/data.py +++ b/djangocms_installer/config/data.py @@ -17,29 +17,35 @@ DEFAULT_REQUIREMENTS = """ django-classy-tags>=0.3.4.1 -south>=0.7.2 html5lib Pillow>=2 django-sekizai>=0.7 six """ +DJANGO_16_REQUIREMENTS = """ +south>=0.7.2 +""" + DJANGOCMS_2_REQUIREMENTS = """ django-mptt>=0.5.1,<0.5.3 """ DJANGOCMS_3_REQUIREMENTS = """ django-mptt>=0.6 -djangocms-text-ckeditor>=2.1.4 +""" + +PLUGINS_REQUIREMENTS_BASIC = """ djangocms-admin-style djangocms-column -djangocms-style djangocms-flash djangocms-googlemap djangocms-inherit +djangocms-style +djangocms-text-ckeditor>=2.3.0 """ -PLUGIN_REQUIREMENTS = """ +PLUGINS_REQUIREMENTS_NON_FILER = """ djangocms-file djangocms-link djangocms-picture @@ -47,6 +53,26 @@ djangocms-video """ +PLUGINS_REQUIREMENTS_BASIC_DJANGO_17 = """ +https://github.com/divio/djangocms-admin-style/archive/master.zip +https://github.com/divio/djangocms-column/archive/master.zip +https://github.com/divio/djangocms-flash/archive/master.zip +https://github.com/divio/djangocms-googlemap/archive/master.zip +https://github.com/divio/djangocms-inherit/archive/master.zip +https://github.com/divio/djangocms-style/archive/master.zip +https://github.com/divio/djangocms-text-ckeditor/archive/master.zip +""" + +PLUGINS_REQUIREMENTS_NON_FILER_DJANGO_17 = """ +https://github.com/divio/djangocms-file/archive/master.zip +https://github.com/divio/djangocms-link/archive/master.zip +https://github.com/divio/djangocms-picture/archive/master.zip +https://github.com/divio/djangocms-teaser/archive/master.zip +https://github.com/divio/djangocms-video/archive/master.zip +""" + + +DJANGO_17_REVERSION = "django-reversion>=1.8.2" DJANGO_16_REVERSION = "django-reversion>=1.8" DJANGO_15_REVERSION = "django-reversion>=1.7,<1.8" DJANGO_14_REVERSION = "django-reversion<1.7" @@ -64,17 +90,17 @@ PLUGIN_LIST_TEXT = """ djangocms_installer will install and configure the following plugins: - * djangocms-text-ckeditor (Text plugin) + * djangocms_column (Column plugin) * djangocms-file (File plugin) * djangocms-flash (Flash plugin) * djangocms-googlemap (GoogleMap plugin) * djangocms-inherit (Inherit plugin) * djangocms-link (Link plugin) * djangocms-picture (Picture plugin) + * djangocms_style (Style plugin) * djangocms-teaser (Teaser plugin) + * djangocms-text-ckeditor (Text plugin) * djangocms-video (Video plugin) - * djangocms_style (Style plugin) - * djangocms_column (Style plugin) It will optionally install cmsplugin-filer plugins (if requested during configuration): diff --git a/djangocms_installer/django/__init__.py b/djangocms_installer/django/__init__.py index b9a4c41..7c9efa4 100644 --- a/djangocms_installer/django/__init__.py +++ b/djangocms_installer/django/__init__.py @@ -270,7 +270,8 @@ def setup_database(config_data): with chdir(config_data.project_directory): os.environ['DJANGO_SETTINGS_MODULE'] = ( '{0}.settings'.format(config_data.project_name)) - if config_data.django_version <= 1.6: + + if config_data.django_version < 1.7: try: import south # NOQA subprocess.check_call([sys.executable, "-W", "ignore", diff --git a/djangocms_installer/utils.py b/djangocms_installer/utils.py index 4086920..d69b245 100644 --- a/djangocms_installer/utils.py +++ b/djangocms_installer/utils.py @@ -69,9 +69,9 @@ def supported_versions(django, cms): else: django_version = 1.5 elif django == 'beta': - django_version = 1.6 + django_version = 1.8 elif django == 'develop': - django_version = 1.7 + django_version = 1.8 return django_version, cms_version diff --git a/tests/config.py b/tests/config.py index 92937c6..063eb11 100644 --- a/tests/config.py +++ b/tests/config.py @@ -141,7 +141,6 @@ def test_invalid_project_name(self): 'project-name']) self.assertTrue(stderr_tmp.getvalue().find("Project name 'project-name' is not a valid app name") > -1) - def test_invalid_project_path(self): prj_dir = 'example_prj' existing_path = os.path.join(self.project_dir, prj_dir) @@ -172,8 +171,9 @@ def test_supported_versions(self): self.assertEqual(supported_versions('1.5', 'stable'), (1.5, 3.0)) self.assertEqual(supported_versions('1.6', 'stable'), (1.6, 3.0)) - self.assertEqual(supported_versions('beta', 'stable'), (1.6, 3.0)) - self.assertEqual(supported_versions('develop', 'stable'), (1.7, 3.0)) + self.assertEqual(supported_versions('1.7', 'stable'), (1.7, 3.0)) + self.assertEqual(supported_versions('beta', 'stable'), (1.8, 3.0)) + self.assertEqual(supported_versions('develop', 'stable'), (1.8, 3.0)) def test_requirements(self): """ @@ -311,6 +311,25 @@ def test_requirements(self): self.assertTrue(conf_data.requirements.find('django-reversion>=1.8') > -1) self.assertTrue(conf_data.requirements.find('pytz') > -1) + conf_data = config.parse([ + '-q', + '--db=postgres://user:pwd@host/dbname', + '--i18n=no', + '--cms-version=develop', + '--django-version=1.7', + '--reversion=yes', + '-z=yes', + '-p'+self.project_dir, + 'example_prj']) + + self.assertTrue(conf_data.requirements.find(config.data.DJANGOCMS_DEVELOP) > -1) + self.assertTrue(conf_data.requirements.find('Django<1.8') > -1) + self.assertTrue(conf_data.requirements.find('djangocms-text-ckeditor/archive/master.zip') > -1) + self.assertTrue(conf_data.requirements.find('djangocms-admin-style/archive/master.zip') > -1) + self.assertTrue(conf_data.requirements.find('djangocms-teaser/archive/master.zip') > -1) + self.assertTrue(conf_data.requirements.find('django-reversion>=1.8.2') > -1) + self.assertTrue(conf_data.requirements.find('south') == -1) + def test_boostrap(self): """ Verify handling of bootstrap parameter diff --git a/tests/django.py b/tests/django.py index 58cbf4e..15fa0f3 100644 --- a/tests/django.py +++ b/tests/django.py @@ -9,6 +9,7 @@ from djangocms_installer import config, django, install from . import BaseTestClass +from djangocms_installer.config.settings import MIGRATION_MODULES class TestDjango(BaseTestClass): @@ -26,7 +27,7 @@ def test_create_project(self): def test_copy_data(self): """ - Test corret file copying with different switches + Test correct file copying with different switches """ # Basic template @@ -87,7 +88,7 @@ def test_copy_data(self): self.assertTrue(os.path.exists(starting_page_py)) self.assertTrue(os.path.exists(starting_page_json)) - def test_patch_16_settings(self): + def test_patch_django_16_settings(self): extra_path = os.path.join(os.path.dirname(__file__), 'data', 'extra_settings.py') config_data = config.parse(['--db=sqlite://localhost/test.db', '--lang=en', '--extra-settings=%s' % extra_path, @@ -114,7 +115,31 @@ def test_patch_16_settings(self): self.assertEqual(project.settings.CMS_PERMISSION, False) self.assertEqual(set(project.settings.CMS_TEMPLATES), self.templates_basic) - def test_patch_16(self): + def test_patch_django_17_settings(self): + extra_path = os.path.join(os.path.dirname(__file__), 'data', 'extra_settings.py') + config_data = config.parse(['--db=sqlite://localhost/test.db', + '--lang=en', '--extra-settings=%s' % extra_path, + '--django-version=1.7', + '--cms-version=develop', '--timezone=Europe/Moscow', + '-q', '-u', '-zno', '--i18n=no', + '-p'+self.project_dir, 'example_path_17_settigns']) + install.requirements(config_data.requirements) + django.create_project(config_data) + django.patch_settings(config_data) + django.copy_files(config_data) + # settings is importable even in non django environment + sys.path.append(config_data.project_directory) + + project = __import__(config_data.project_name, + globals(), locals(), ['settings']) + + ## checking for django options + self.assertFalse('south' in project.settings.INSTALLED_APPS) + for module in MIGRATION_MODULES: + self.assertTrue(module[0] in project.settings.MIGRATION_MODULES.keys()) + self.assertTrue(module[1] in project.settings.MIGRATION_MODULES.values()) + + def test_patch_django_16(self): config_data = config.parse(['--db=sqlite://localhost/test.db', '--lang=en', '--bootstrap=yes', '--django-version=1.6', @@ -173,7 +198,7 @@ def test_patch_16(self): @unittest.skipIf(sys.version_info >= (3, 0), reason="django CMS 2.4 does not support python3") - def test_patch_24_standard(self): + def test_patch_cms_24_standard(self): config_data = config.parse(['--db=sqlite://localhost/test.db', '--lang=en', '--django-version=1.5', @@ -220,7 +245,7 @@ def test_patch_24_standard(self): @unittest.skipIf(sys.version_info >= (3, 0), reason="django CMS 2.4 does not support python3") - def test_patch_24_filer(self): + def test_patch_cms_24_filer(self): config_data = config.parse(['--db=sqlite://localhost/test.db', '--lang=en', '--django-version=1.5', diff --git a/tox.ini b/tox.ini index 8680844..4392f86 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py26, py27, py33 +envlist = py26, py27, py33, py34 [testenv] recreate=True @@ -24,6 +24,13 @@ deps = six coverage +[testenv:py34] +deps = + pip>=1.5 + dj-database-url + six + coverage + [testenv:coverage] commands = coverage run --source=djangocms-installer setup.py test From 6c75d568dd6864c96a0625ecf2faef94dfa4c1f5 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sun, 7 Sep 2014 22:54:57 +0200 Subject: [PATCH 06/30] Update travis --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 716cd37..450f153 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ language: python python: + - 3.4 - 3.3 - 2.7 - 2.6 @@ -12,7 +13,6 @@ install: - pip install -r requirements.txt - pip install coveralls coverage - "if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then pip install unittest2; fi" - - "if [[ $TRAVIS_PYTHON_VERSION == '3.3' ]]; then pip install -U https://github.com/pypa/pip/archive/develop.zip; fi" # command to run tests, e.g. python setup.py test script: USE_SHM="yes" coverage run setup.py test @@ -22,3 +22,4 @@ after_success: coveralls matrix: allow_failures: - python: 3.3 + - python: 3.4 From 635ebd9f012b167c0064a15cc16b8395f8273ae0 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sun, 7 Sep 2014 22:58:16 +0200 Subject: [PATCH 07/30] Bump dev version --- djangocms_installer/__init__.py | 2 +- setup.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/djangocms_installer/__init__.py b/djangocms_installer/__init__.py index 1a1a4c1..add1b3d 100644 --- a/djangocms_installer/__init__.py +++ b/djangocms_installer/__init__.py @@ -2,4 +2,4 @@ # -*- coding: utf-8 -*- __author__ = 'Iacopo Spalletti' __email__ = 'i.spalletti@nephila.it' -__version__ = '0.5.4' +__version__ = '0.6.b1' diff --git a/setup.py b/setup.py index 558eb94..b76b96c 100644 --- a/setup.py +++ b/setup.py @@ -52,6 +52,7 @@ 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', 'Topic :: Software Development', ], test_suite='tests', From 4b24129837eecb42f5f6e2f0212c6b1053574ce8 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Fri, 15 Aug 2014 18:16:51 +0200 Subject: [PATCH 08/30] Add support for aldryn-boilerplate --- djangocms_installer/__main__.py | 1 + djangocms_installer/config/__init__.py | 14 +++- djangocms_installer/config/data.py | 5 ++ djangocms_installer/config/internal.py | 4 +- djangocms_installer/config/settings.py | 4 ++ djangocms_installer/config/urls.py | 2 +- djangocms_installer/django/__init__.py | 94 +++++++++++++++++-------- djangocms_installer/install/__init__.py | 1 - djangocms_installer/main.py | 15 ++-- 9 files changed, 100 insertions(+), 40 deletions(-) diff --git a/djangocms_installer/__main__.py b/djangocms_installer/__main__.py index d294f64..59d513e 100644 --- a/djangocms_installer/__main__.py +++ b/djangocms_installer/__main__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import sys + from .main import execute if __name__ == '__main__': diff --git a/djangocms_installer/config/__init__.py b/djangocms_installer/config/__init__.py index af7ebf9..7122a8a 100644 --- a/djangocms_installer/config/__init__.py +++ b/djangocms_installer/config/__init__.py @@ -5,10 +5,10 @@ import six import sys -from .. import compat, utils from . import data -from djangocms_installer.config.internal import DbAction, validate_project -from djangocms_installer.utils import less_than_version, supported_versions +from .internal import DbAction, validate_project +from .. import compat, utils +from ..utils import less_than_version, supported_versions def parse(args): @@ -68,6 +68,8 @@ def parse(args): # Advanced options. These have a predefined default and are not managed # by config wizard. + parser.add_argument('--aldryn', '-a', dest='aldryn', action='store_true', + default=False, help="Use Aldryn-boilerplate as project template") parser.add_argument('--no-input', '-q', dest='noinput', action='store_true', default=False, help="Don't run the configuration wizard, just use the provided values") parser.add_argument('--filer', '-f', dest='filer', action='store_true', @@ -198,6 +200,8 @@ def parse(args): else: requirements.append(data.PLUGINS_REQUIREMENTS_BASIC_DJANGO_17) requirements.append(data.PLUGINS_REQUIREMENTS_NON_FILER_DJANGO_17) + if args.aldryn: + requirements.append(data.ALDRYN_REQUIREMENTS) # Django version check if args.django_version == 'develop': @@ -235,6 +239,10 @@ def parse(args): requirements.extend([data.DEFAULT_REQUIREMENTS]) setattr(args, "requirements", "\n".join(requirements).strip()) + if cms_version < 3 and args.aldryn: + sys.stderr.write("Aldryn Boilerplate is not compatible with django CMS versions < 3\n") + sys.exit(5) + # Convenient shortcuts setattr(args, "cms_version", cms_version) diff --git a/djangocms_installer/config/data.py b/djangocms_installer/config/data.py index 5f14d35..5dfe25d 100644 --- a/djangocms_installer/config/data.py +++ b/djangocms_installer/config/data.py @@ -73,6 +73,9 @@ DJANGO_17_REVERSION = "django-reversion>=1.8.2" +ALDRYN_REQUIREMENTS = """ +django-compressor +""" DJANGO_16_REVERSION = "django-reversion>=1.8" DJANGO_15_REVERSION = "django-reversion>=1.7,<1.8" DJANGO_14_REVERSION = "django-reversion<1.7" @@ -132,3 +135,5 @@ BASE_DIR = """ BASE_DIR = os.path.dirname(os.path.dirname(__file__)) """ + +ALDRYN_BOILERPLATE = 'https://github.com/aldryn/aldryn-boilerplate/archive/master.zip' diff --git a/djangocms_installer/config/internal.py b/djangocms_installer/config/internal.py index ad14490..5151504 100644 --- a/djangocms_installer/config/internal.py +++ b/djangocms_installer/config/internal.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -import sys +from argparse import Action import keyword +import sys -from argparse import Action import dj_database_url from .data import DRIVERS diff --git a/djangocms_installer/config/settings.py b/djangocms_installer/config/settings.py index ae7991b..4614277 100644 --- a/djangocms_installer/config/settings.py +++ b/djangocms_installer/config/settings.py @@ -136,6 +136,10 @@ 'south', ) +ALDRYN_APPLICATIONS = ( + 'compressor', +) + CMS_TEMPLATES = ( ('fullwidth.html', 'Fullwidth'), ('sidebar_left.html', 'Sidebar Left'), diff --git a/djangocms_installer/config/urls.py b/djangocms_installer/config/urls.py index d020847..c456ce1 100644 --- a/djangocms_installer/config/urls.py +++ b/djangocms_installer/config/urls.py @@ -1,9 +1,9 @@ +from cms.sitemaps import CMSSitemap from django.conf.urls import * # NOQA from django.conf.urls.i18n import i18n_patterns from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.contrib import admin from django.conf import settings -from cms.sitemaps import CMSSitemap admin.autodiscover() diff --git a/djangocms_installer/django/__init__.py b/djangocms_installer/django/__init__.py index 7c9efa4..f12f8bc 100644 --- a/djangocms_installer/django/__init__.py +++ b/djangocms_installer/django/__init__.py @@ -1,12 +1,15 @@ # -*- coding: utf-8 -*- -import sys +from copy import copy, deepcopy +import glob import os import re - +import requests import shutil -import glob import subprocess -from copy import copy, deepcopy +import sys +import tempfile +import zipfile +from six import StringIO from ..compat import iteritems from ..utils import chdir @@ -40,21 +43,43 @@ def copy_files(config_data): urlconf_path = os.path.join(os.path.dirname(__file__), '../config/urls.py') share_path = os.path.join(os.path.dirname(__file__), '../share') template_path = os.path.join(share_path, 'templates') - template_target = os.path.join(config_data.project_path, 'templates') - static_project = os.path.join(config_data.project_directory, 'static') - static_main = os.path.join(config_data.project_path, 'static') - - if config_data.templates and os.path.isdir(config_data.templates): - template_path = config_data.templates - elif config_data.bootstrap: - template_path = os.path.join(template_path, 'bootstrap') + if config_data.aldryn: + media_project = os.path.join(config_data.project_directory, 'dist', 'media') + static_main = False + static_project = os.path.join(config_data.project_directory, 'dist', 'static') + template_target = os.path.join(config_data.project_directory, 'templates') + tmpdir = tempfile.mkdtemp() + aldrynzip = requests.get(data.ALDRYN_BOILERPLATE) + zip_open = zipfile.ZipFile(StringIO(aldrynzip.content)) + zip_open.extractall(path=tmpdir) + for component in os.listdir(os.path.join(tmpdir, 'aldryn-boilerplate-master')): + src = os.path.join(tmpdir, 'aldryn-boilerplate-master', component) + dst = os.path.join(config_data.project_directory, component) + if os.path.isfile(src): + shutil.copy(src, dst) + else: + shutil.copytree(src, dst) else: - template_path = os.path.join(template_path, 'basic') + media_project = os.path.join(config_data.project_directory, 'media') + static_main = os.path.join(config_data.project_path, 'static') + static_project = os.path.join(config_data.project_directory, 'static') + template_target = os.path.join(config_data.project_path, 'templates') + if config_data.templates and os.path.isdir(config_data.templates): + template_path = config_data.templates + elif config_data.bootstrap: + template_path = os.path.join(template_path, 'bootstrap') + else: + template_path = os.path.join(template_path, 'basic') shutil.copy(urlconf_path, config_data.urlconf_path) - os.makedirs(static_main) - os.makedirs(static_project) - os.makedirs(template_target) + if media_project: + os.makedirs(media_project) + if static_main: + os.makedirs(static_main) + if not os.path.exists(static_project): + os.makedirs(static_project) + if not os.path.exists(template_target): + os.makedirs(template_target) for filename in glob.glob(os.path.join(template_path, '*.html')): if os.path.isfile(filename): shutil.copy(filename, template_target) @@ -89,34 +114,41 @@ def patch_settings(config_data): original = original.replace("# -*- coding: utf-8 -*-\n", "") + if config_data.aldryn: + DATA_DIR = "DATA_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'dist')\n" + STATICFILES_DIR = 'os.path.join(BASE_DIR, \'static\'),' + else: + DATA_DIR = "DATA_DIR = os.path.dirname(os.path.dirname(__file__))\n" + STATICFILES_DIR = 'os.path.join(BASE_DIR, \'%s\', \'static\'),' % config_data.project_name + if original.find('BASE_DIR') == -1: - original = data.DEFAULT_PROJECT_HEADER + data.BASE_DIR + original + original = data.DEFAULT_PROJECT_HEADER + data.BASE_DIR + DATA_DIR + original else: - original = data.DEFAULT_PROJECT_HEADER + original + original = data.DEFAULT_PROJECT_HEADER + DATA_DIR + original if original.find('MEDIA_URL') > -1: original = original.replace("MEDIA_URL = ''", "MEDIA_URL = '/media/'") else: original += "MEDIA_URL = '/media/'\n" if original.find('MEDIA_ROOT') > -1: - original = original.replace("MEDIA_ROOT = ''", "MEDIA_ROOT = os.path.join(BASE_DIR, 'media')") + original = original.replace("MEDIA_ROOT = ''", "MEDIA_ROOT = os.path.join(DATA_DIR, 'media')") else: - original += "MEDIA_ROOT = os.path.join(BASE_DIR, 'media')\n" + original += "MEDIA_ROOT = os.path.join(DATA_DIR, 'media')\n" if original.find('STATIC_ROOT') > -1: - original = original.replace("STATIC_ROOT = ''", "STATIC_ROOT = os.path.join(BASE_DIR, 'static')") + original = original.replace("STATIC_ROOT = ''", "STATIC_ROOT = os.path.join(DATA_DIR, 'static')") else: - original += "STATIC_ROOT = os.path.join(BASE_DIR, 'static')\n" + original += "STATIC_ROOT = os.path.join(DATA_DIR, 'static')\n" if original.find('STATICFILES_DIRS') > -1: original = original.replace(data.STATICFILES_DEFAULT, """ STATICFILES_DIRS = ( - os.path.join(BASE_DIR, '%s', 'static'), + %s ) -""" % config_data.project_name) +""" % STATICFILES_DIR) else: original += """ STATICFILES_DIRS = ( - os.path.join(BASE_DIR, '%s', 'static'), + %s ) -""" % config_data.project_name +""" % STATICFILES_DIR original = original.replace("# -*- coding: utf-8 -*-\n", "") # I18N @@ -177,8 +209,12 @@ def _build_settings(config_data): text.append("TEMPLATE_CONTEXT_PROCESSORS = (\n%s%s\n)" % ( spacer, (",\n" + spacer).join(["'%s'" % var for var in processors]))) - text.append("TEMPLATE_DIRS = (\n%s%s\n)" % ( - spacer, "os.path.join(BASE_DIR, '%s', 'templates')," % config_data.project_name)) + if config_data.aldryn: + text.append("TEMPLATE_DIRS = (\n%s%s\n)" % ( + spacer, "os.path.join(BASE_DIR, 'templates'),")) + else: + text.append("TEMPLATE_DIRS = (\n%s%s\n)" % ( + spacer, "os.path.join(BASE_DIR, '%s', 'templates')," % config_data.project_name)) apps = list(vars.INSTALLED_APPS) if config_data.cms_version == 2.4: @@ -200,6 +236,8 @@ def _build_settings(config_data): if config_data.django_version <= 1.6: apps.extend(vars.SOUTH_APPLICATIONS) + if config_data.aldryn: + apps.extend(vars.ALDRYN_APPLICATIONS) if config_data.reversion: apps.extend(vars.REVERSION_APPLICATIONS) text.append("INSTALLED_APPS = (\n%s%s\n)" % ( diff --git a/djangocms_installer/install/__init__.py b/djangocms_installer/install/__init__.py index 551f901..ce45446 100644 --- a/djangocms_installer/install/__init__.py +++ b/djangocms_installer/install/__init__.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- import os.path - import pip from pip.exceptions import InstallationError from pip.status_codes import SUCCESS diff --git a/djangocms_installer/main.py b/djangocms_installer/main.py index 1b73463..07b57a7 100644 --- a/djangocms_installer/main.py +++ b/djangocms_installer/main.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -import sys -import six import logging +import six +import sys from . import config, install, django @@ -31,9 +31,14 @@ def execute(): django.setup_database(config_data) if config_data.starting_page: django.load_starting_page(config_data) - print("All done!") - print("Get into '%s' directory and type 'python manage.py runserver' " - "to start your project" % config_data.project_directory) + if config_data.aldryn: + print("Project created!") + print("aldryn boilerplate requires action before you can actually run the project.\n" + "See documentation at http://aldryn-boilerplate.readthedocs.org/ for more information.") + else: + print("All done!") + print("Get into '%s' directory and type 'python manage.py runserver' " + "to start your project" % config_data.project_directory) except Exception as e: if six.PY3: tb = sys.exc_info()[2] From 5fd6a1f4de2b8852949922a330c4369435f27c27 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Mon, 18 Aug 2014 09:56:10 +0200 Subject: [PATCH 09/30] Add basic tests for aldryn-boilerplate --- tests/config.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/config.py b/tests/config.py index 063eb11..78fa0e3 100644 --- a/tests/config.py +++ b/tests/config.py @@ -330,6 +330,30 @@ def test_requirements(self): self.assertTrue(conf_data.requirements.find('django-reversion>=1.8.2') > -1) self.assertTrue(conf_data.requirements.find('south') == -1) + conf_data = config.parse([ + '-q', + '--db=postgres://user:pwd@host/dbname', + '--cms-version=stable', + '--django-version=stable', + '-a', + '-p'+self.project_dir, + 'example_prj']) + self.assertTrue(conf_data.requirements.find('django-compressor') > -1) + + def test_aldryn_compatibility(self): + with patch('sys.stdout', self.stdout): + with patch('sys.stderr', self.stderr): + with self.assertRaises(SystemExit) as error: + conf_data = config.parse([ + '-q', + '--db=postgres://user:pwd@host/dbname', + '--cms-version=2.4', + '--django-version=stable', + '-a', + '-p'+self.project_dir, + 'example_prj']) + self.assertEqual(error.exception.code, 5) + def test_boostrap(self): """ Verify handling of bootstrap parameter From e5aa676b33b839019999790ea326dde0720e7825 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Thu, 28 Aug 2014 19:10:10 +0200 Subject: [PATCH 10/30] Add more tests for aldryn-boilerplate --- tests/django.py | 55 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/tests/django.py b/tests/django.py index 15fa0f3..5955c8a 100644 --- a/tests/django.py +++ b/tests/django.py @@ -88,7 +88,27 @@ def test_copy_data(self): self.assertTrue(os.path.exists(starting_page_py)) self.assertTrue(os.path.exists(starting_page_json)) - def test_patch_django_16_settings(self): + # Aldryn boilerplate + self._create_project_dir() + config_data = config.parse(['--db=postgres://user:pwd@host/dbname', + '--cms-version=stable', '-a', + '-q', '-p'+self.project_dir, 'example_prj']) + os.makedirs(config_data.project_path) + django.copy_files(config_data) + private_dir = os.path.join(config_data.project_directory, 'private') + static_js = os.path.join(config_data.project_directory, 'static', 'js', 'base.js') + aldryn_template = os.path.join(config_data.project_directory, 'templates', 'fullwidth.html') + basic_template = os.path.join(config_data.project_path, 'templates', 'fullwidth.html') + boostrap_template = os.path.join(config_data.project_path, 'templates', 'feature.html') + custom_template = os.path.join(config_data.project_path, 'templates', 'left.html') + self.assertFalse(os.path.exists(custom_template)) + self.assertFalse(os.path.exists(boostrap_template)) + self.assertFalse(os.path.exists(basic_template)) + self.assertTrue(os.path.exists(private_dir)) + self.assertTrue(os.path.exists(static_js)) + self.assertTrue(os.path.exists(aldryn_template)) + + def test_patch_16_settings(self): extra_path = os.path.join(os.path.dirname(__file__), 'data', 'extra_settings.py') config_data = config.parse(['--db=sqlite://localhost/test.db', '--lang=en', '--extra-settings=%s' % extra_path, @@ -107,13 +127,42 @@ def test_patch_django_16_settings(self): globals(), locals(), ['settings']) ## checking for django options - self.assertTrue(project.settings.MEDIA_ROOT, os.path.join(config_data.project_directory, 'media')) + self.assertEqual(project.settings.MEDIA_ROOT, os.path.join(config_data.project_directory, 'media')) + self.assertEqual(project.settings.MEDIA_URL, '/media/') + + # Data from external settings file + self.assertEqual(project.settings.CUSTOM_SETTINGS_VAR, True) + self.assertEqual(project.settings.CMS_PERMISSION, False) + self.assertEqual(set(project.settings.CMS_TEMPLATES), self.templates_basic) + + def test_patch_16_aldryn(self): + extra_path = os.path.join(os.path.dirname(__file__), 'data', 'extra_settings.py') + config_data = config.parse(['--db=sqlite://localhost/test.db', + '--lang=en', '--extra-settings=%s' % extra_path, + '--django-version=1.6', '-a', + '--cms-version=3.0', '--timezone=Europe/Moscow', + '-q', '-u', '-zno', '--i18n=no', + '-p'+self.project_dir, 'example_path_16_aldryn']) + install.requirements(config_data.requirements) + django.create_project(config_data) + django.patch_settings(config_data) + django.copy_files(config_data) + # settings is importable even in non django environment + sys.path.append(config_data.project_directory) + + project = __import__(config_data.project_name, + globals(), locals(), ['settings']) + + ## checking for django options + self.assertEqual(project.settings.MEDIA_ROOT, os.path.join(config_data.project_directory, 'dist', 'media')) + self.assertEqual(project.settings.TEMPLATE_DIRS, (os.path.join(config_data.project_directory, 'templates'),)) self.assertEqual(project.settings.MEDIA_URL, '/media/') # Data from external settings file self.assertEqual(project.settings.CUSTOM_SETTINGS_VAR, True) self.assertEqual(project.settings.CMS_PERMISSION, False) self.assertEqual(set(project.settings.CMS_TEMPLATES), self.templates_basic) + self.assertTrue('compressor' in project.settings.INSTALLED_APPS) def test_patch_django_17_settings(self): extra_path = os.path.join(os.path.dirname(__file__), 'data', 'extra_settings.py') @@ -161,7 +210,7 @@ def test_patch_django_16(self): globals(), locals(), ['settings']) ## checking for django options - self.assertTrue(project.settings.MEDIA_ROOT, os.path.join(config_data.project_directory, 'media')) + self.assertEqual(project.settings.MEDIA_ROOT, os.path.join(config_data.project_directory, 'media')) self.assertEqual(project.settings.MEDIA_URL, '/media/') self.assertEqual(project.settings.TIME_ZONE, 'Europe/Moscow') From ba78c960e9616f2916a73a19325839d52b06a6dd Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sun, 31 Aug 2014 13:09:35 +0200 Subject: [PATCH 11/30] Tests reorganization - part 1 --- tests/__init__.py | 44 -------------------------------------------- tests/base.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ tests/config.py | 6 +++--- tests/django.py | 10 +++++----- tests/main.py | 6 +++--- 5 files changed, 55 insertions(+), 55 deletions(-) create mode 100644 tests/base.py diff --git a/tests/__init__.py b/tests/__init__.py index a9473b0..40a96af 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,45 +1 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- -import sys -import os -import tempfile -import shutil - -if sys.version_info[:2] < (2, 7): - import unittest2 as unittest -else: - import unittest - -from six import StringIO - - -class BaseTestClass(unittest.TestCase): - stdout = None - stderr = None - project_dir = None - - def _remove_project_dir(self): - if self.project_dir: - shutil.rmtree(self.project_dir) - self.project_dir = None - - def _create_project_dir(self): - if 'USE_SHM' in os.environ: - if os.path.exists('/run/shm'): - self.project_dir = tempfile.mkdtemp(dir='/run/shm') - elif os.path.exists('/dev/shm'): - self.project_dir = tempfile.mkdtemp(dir='/dev/shm') - else: - self.project_dir = tempfile.mkdtemp() - else: - self.project_dir = tempfile.mkdtemp() - - def tearDown(self): - self._remove_project_dir() - self.stdout = None - self.stderr = None - - def setUp(self): - self.stdout = StringIO() - self.stderr = StringIO() - self._create_project_dir() diff --git a/tests/base.py b/tests/base.py new file mode 100644 index 0000000..97739a6 --- /dev/null +++ b/tests/base.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +import sys +import os +import tempfile +import shutil + +if sys.version_info[:2] < (2, 7): + import unittest2 as unittest +else: + import unittest + +from six import StringIO + + +class BaseTestClass(unittest.TestCase): + stdout = None + stderr = None + project_dir = None + + def _remove_project_dir(self): + if self.project_dir: + shutil.rmtree(self.project_dir) + self.project_dir = None + + def _create_project_dir(self): + if 'USE_SHM' in os.environ: + if os.path.exists('/run/shm'): + self.project_dir = tempfile.mkdtemp(dir='/run/shm') + elif os.path.exists('/dev/shm'): + self.project_dir = tempfile.mkdtemp(dir='/dev/shm') + else: + self.project_dir = tempfile.mkdtemp() + else: + self.project_dir = tempfile.mkdtemp() + + def tearDown(self): + self._remove_project_dir() + self.stdout = None + self.stderr = None + + def setUp(self): + self.stdout = StringIO() + self.stderr = StringIO() + self._create_project_dir() diff --git a/tests/config.py b/tests/config.py index 78fa0e3..2a6c2e7 100644 --- a/tests/config.py +++ b/tests/config.py @@ -1,8 +1,8 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- -import sys import os +import sys import tempfile + from mock import patch from six import StringIO @@ -10,7 +10,7 @@ from djangocms_installer.install import check_install from djangocms_installer.utils import less_than_version, supported_versions -from . import BaseTestClass +from .base import BaseTestClass class TestConfig(BaseTestClass): diff --git a/tests/django.py b/tests/django.py index 5955c8a..d9854a0 100644 --- a/tests/django.py +++ b/tests/django.py @@ -1,15 +1,15 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -import sys import os.path -import six -import sqlite3 -from . import unittest import re +import sqlite3 +import sys + +import six from djangocms_installer import config, django, install -from . import BaseTestClass from djangocms_installer.config.settings import MIGRATION_MODULES +from .base import unittest, BaseTestClass class TestDjango(BaseTestClass): diff --git a/tests/main.py b/tests/main.py index f25f1f8..e1ed669 100644 --- a/tests/main.py +++ b/tests/main.py @@ -1,11 +1,11 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- -import sys import os +import sys + from mock import patch from djangocms_installer import main -from . import BaseTestClass +from .base import BaseTestClass class TestMain(BaseTestClass): From 8e602fed178cf0b702b2a3cfb38086bf39aaf8a0 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sun, 31 Aug 2014 15:34:30 +0200 Subject: [PATCH 12/30] Add python 3.4 to test matrix --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 4392f86..005e899 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,7 @@ recreate=True setenv = PYTHONPATH={toxinidir}:{toxinidir}/djangocms-installer USE_SHM=yes -commands = coverage run setup.py test +commands = python setup.py test deps = -r{toxinidir}/requirements.txt coverage @@ -33,7 +33,7 @@ deps = [testenv:coverage] commands = - coverage run --source=djangocms-installer setup.py test + coverage run --source=djangocms_installer setup.py test coverage report -m deps = coverage From 5e61b1bd921a8c954ae622276dcd1cf532efd457 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sun, 31 Aug 2014 15:35:22 +0200 Subject: [PATCH 13/30] Add requests to requirements --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index d0d11ec..7311de6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ dj-database-url pip>1.4 six argparse +requests From ac790f50d8ea2a5954c58231d54a488e93496548 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sun, 31 Aug 2014 15:35:42 +0200 Subject: [PATCH 14/30] Fix python 3 compat --- djangocms_installer/django/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/djangocms_installer/django/__init__.py b/djangocms_installer/django/__init__.py index f12f8bc..f49ba16 100644 --- a/djangocms_installer/django/__init__.py +++ b/djangocms_installer/django/__init__.py @@ -9,7 +9,7 @@ import sys import tempfile import zipfile -from six import StringIO +from six import BytesIO from ..compat import iteritems from ..utils import chdir @@ -50,7 +50,7 @@ def copy_files(config_data): template_target = os.path.join(config_data.project_directory, 'templates') tmpdir = tempfile.mkdtemp() aldrynzip = requests.get(data.ALDRYN_BOILERPLATE) - zip_open = zipfile.ZipFile(StringIO(aldrynzip.content)) + zip_open = zipfile.ZipFile(BytesIO(aldrynzip.content)) zip_open.extractall(path=tmpdir) for component in os.listdir(os.path.join(tmpdir, 'aldryn-boilerplate-master')): src = os.path.join(tmpdir, 'aldryn-boilerplate-master', component) From e9b259cea99effd10618f1e70f0e53be5b1dc2de Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sun, 31 Aug 2014 15:36:09 +0200 Subject: [PATCH 15/30] Fix testsuite in python 2.6 --- setup.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index b76b96c..5090c7b 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,10 @@ # Add Python 2.6-specific dependencies if sys.version_info[:2] < (2, 7): test_requirements.append('unittest2') - + test_suite = 'tests' +else: + test_suite = 'tests' + setup( name='djangocms-installer', version=djangocms_installer.__version__, @@ -55,6 +58,6 @@ 'Programming Language :: Python :: 3.4', 'Topic :: Software Development', ], - test_suite='tests', + test_suite=test_suite, tests_require=test_requirements ) From 3ac6c49ff3e16ccb00e1e55cb93eca340aeaee90 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sun, 31 Aug 2014 15:44:16 +0200 Subject: [PATCH 16/30] Fix tests --- tests/__init__.py | 2 +- tests/config.py | 5 ++++- tests/django.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/__init__.py b/tests/__init__.py index 40a96af..7c68785 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- \ No newline at end of file diff --git a/tests/config.py b/tests/config.py index 2a6c2e7..f9e7339 100644 --- a/tests/config.py +++ b/tests/config.py @@ -352,7 +352,10 @@ def test_aldryn_compatibility(self): '-a', '-p'+self.project_dir, 'example_prj']) - self.assertEqual(error.exception.code, 5) + try: + self.assertEqual(error.exception.code, 5) + except AttributeError: + self.assertEqual(error.exception, 5) def test_boostrap(self): """ diff --git a/tests/django.py b/tests/django.py index d9854a0..2803157 100644 --- a/tests/django.py +++ b/tests/django.py @@ -242,7 +242,7 @@ def test_patch_django_16(self): self.assertEqual(len(re.findall('BASE_DIR = ', settings)), 1) self.assertEqual(len(re.findall('STATIC_ROOT', settings)), 1) self.assertEqual(len(re.findall('MEDIA_ROOT =', settings)), 1) - self.assertEqual(len(re.findall('STATICFILES_DIRS', settings)), 2) + self.assertEqual(len(re.findall('STATICFILES_DIRS', settings)), 1) @unittest.skipIf(sys.version_info >= (3, 0), From 00139b16b7f8e8fee84b6a337b8ac004c5ec3218 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sun, 31 Aug 2014 15:45:47 +0200 Subject: [PATCH 17/30] Force installing all packages (-I) when creating the project virtualenv --- djangocms_installer/install/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/djangocms_installer/install/__init__.py b/djangocms_installer/install/__init__.py index ce45446..13b95b6 100644 --- a/djangocms_installer/install/__init__.py +++ b/djangocms_installer/install/__init__.py @@ -54,9 +54,9 @@ def check_install(config_data): def requirements(requirements, is_file=False): if is_file: - args = ['install', '-q', '-r', requirements] + args = ['install', '-q', '-I', '-r', requirements] else: - args = ['install', '-q', ] + args = ['install', '-q', '-I'] args.extend(requirements.split()) exit_status = pip.main(args) if exit_status != SUCCESS: From 9fcdf80fda25d18f2608eb5f7164e606fd89a54d Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sun, 31 Aug 2014 15:47:04 +0200 Subject: [PATCH 18/30] Update history --- HISTORY.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 58dd0a4..9f6adf5 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,11 +3,17 @@ History ------- +0.6.0 (unreleased) +++++++++++++++++++ + +* Add support for installing aldryn-boilerplate +* Force installing all packages (-I) when creating the project virtualenv + 0.5.4 (2014-08-14) ++++++++++++++++++ * Fix reversion version selection for older Django versions -* Berter project name validation +* Better project name validation 0.5.3 (2014-07-23) ++++++++++++++++++ From 3674bbd6d1d34813f8e4aec846c89a0210b861ef Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sun, 31 Aug 2014 15:55:58 +0200 Subject: [PATCH 19/30] Update setup.py --- setup.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 5090c7b..3552c91 100644 --- a/setup.py +++ b/setup.py @@ -20,9 +20,7 @@ # Add Python 2.6-specific dependencies if sys.version_info[:2] < (2, 7): test_requirements.append('unittest2') - test_suite = 'tests' -else: - test_suite = 'tests' + setup( name='djangocms-installer', @@ -45,7 +43,7 @@ zip_safe=False, keywords='djangocms-installer', classifiers=[ - 'Development Status :: 4 - Beta', + 'Development Status :: 5 - Production', 'Framework :: Django', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', @@ -58,6 +56,6 @@ 'Programming Language :: Python :: 3.4', 'Topic :: Software Development', ], - test_suite=test_suite, + test_suite='tests', tests_require=test_requirements ) From 6785272fe98b3ef70f0b9a27460c593996784461 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sun, 31 Aug 2014 22:59:57 +0200 Subject: [PATCH 20/30] Update documentation --- docs/reference.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/reference.rst b/docs/reference.rst index a670603..4aba97f 100644 --- a/docs/reference.rst +++ b/docs/reference.rst @@ -63,7 +63,12 @@ advanced usage: project; * ``--extra-settings``: Path to a file with extra variables to append to generated settings file. It doesn't need to be a Python file, its content is blindly copied in the project settings. - +*``--aldryn``, ``-a``: Use `aldryn-boilerplate`_; this downloads **aldryn-boilerplate** and copies it + into the project, adapting the project layout according to boilerplate specifications; the use + of aldryn-boilerplate requires manual actions, look at `aldryn-boilerplate documentation`_ for + further informations. .. _dj-database-url: https://github.com/kennethreitz/dj-database-url .. _django source: https://github.com/django/django/blob/master/django/conf/global_settings.py#L50 +.. _aldryn-boilerplate: https://github.com/aldryn/aldryn-boilerplate +.. _aldryn-boilerplate documentation: http://aldryn-boilerplate.readthedocs.org/en/latest/general/requirements.html \ No newline at end of file From ae443a5998b2136c905caa7652e7bcc22db21cc7 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 27 Sep 2014 09:28:47 +0200 Subject: [PATCH 21/30] Temporary disable django 1.7 tests --- djangocms_installer/config/__init__.py | 1 - djangocms_installer/install/__init__.py | 7 +++++++ tests/base.py | 8 +++++--- tests/django.py | 3 +-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/djangocms_installer/config/__init__.py b/djangocms_installer/config/__init__.py index 7122a8a..0e6af6c 100644 --- a/djangocms_installer/config/__init__.py +++ b/djangocms_installer/config/__init__.py @@ -243,7 +243,6 @@ def parse(args): sys.stderr.write("Aldryn Boilerplate is not compatible with django CMS versions < 3\n") sys.exit(5) - # Convenient shortcuts setattr(args, "cms_version", cms_version) setattr(args, "django_version", django_version) diff --git a/djangocms_installer/install/__init__.py b/djangocms_installer/install/__init__.py index 13b95b6..74f0983 100644 --- a/djangocms_installer/install/__init__.py +++ b/djangocms_installer/install/__init__.py @@ -62,3 +62,10 @@ def requirements(requirements, is_file=False): if exit_status != SUCCESS: raise InstallationError("Error while installing requirements. Check pip log file for error details.") return True + + +def cleanup(requirements): + args = ['uninstall', '-q', '-y'] + args.extend(requirements.split()) + exit_status = pip.main(args) + return True diff --git a/tests/base.py b/tests/base.py index 97739a6..29bb690 100644 --- a/tests/base.py +++ b/tests/base.py @@ -1,15 +1,17 @@ # -*- coding: utf-8 -*- -import sys import os -import tempfile +import sys import shutil - +import tempfile if sys.version_info[:2] < (2, 7): import unittest2 as unittest else: import unittest from six import StringIO +from mock import patch + +from djangocms_installer import install class BaseTestClass(unittest.TestCase): diff --git a/tests/django.py b/tests/django.py index 2803157..36f36e8 100644 --- a/tests/django.py +++ b/tests/django.py @@ -164,7 +164,7 @@ def test_patch_16_aldryn(self): self.assertEqual(set(project.settings.CMS_TEMPLATES), self.templates_basic) self.assertTrue('compressor' in project.settings.INSTALLED_APPS) - def test_patch_django_17_settings(self): + def def_test_patch_django_17_settings(self): extra_path = os.path.join(os.path.dirname(__file__), 'data', 'extra_settings.py') config_data = config.parse(['--db=sqlite://localhost/test.db', '--lang=en', '--extra-settings=%s' % extra_path, @@ -244,7 +244,6 @@ def test_patch_django_16(self): self.assertEqual(len(re.findall('MEDIA_ROOT =', settings)), 1) self.assertEqual(len(re.findall('STATICFILES_DIRS', settings)), 1) - @unittest.skipIf(sys.version_info >= (3, 0), reason="django CMS 2.4 does not support python3") def test_patch_cms_24_standard(self): From d4ce94221c3de2df6e1c54fe1f91ca083cbb79b4 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 11 Oct 2014 11:45:46 +0200 Subject: [PATCH 22/30] Add information on supported versions --- README.rst | 19 +++++++++++++++++++ djangocms_installer/config/__init__.py | 5 +++++ djangocms_installer/config/data.py | 2 ++ 3 files changed, 26 insertions(+) diff --git a/README.rst b/README.rst index 7d2a146..39dcafa 100644 --- a/README.rst +++ b/README.rst @@ -50,6 +50,25 @@ Documentation See http://djangocms-installer.readthedocs.org +Supported versions +------------------ + +The current supported version matrix is the following: + ++----------------+-------------+-------------+-------------+-------------+ +| | Django 1.4 | Django 1.5 | Django 1.6 | Django 1.7 | ++----------------+-------------+-------------+-------------+-------------+ +| django CMS 2.4 | Supported | Supported | Unsupported | Unsupported | ++----------------+-------------+-------------+-------------+-------------+ +| django CMS 3.0 | Supported | Supported | Supported | WiP | ++----------------+-------------+-------------+-------------+-------------+ + +Any beta and develop version of Django and django CMS, by its very nature, +it's not supported, while it still may work. + +``djangocms-installer`` tries to support beta versions of django CMS when they +will be considered sufficiently stable by the upstream project. + Caveats ------- diff --git a/djangocms_installer/config/__init__.py b/djangocms_installer/config/__init__.py index 0e6af6c..6d85cdd 100644 --- a/djangocms_installer/config/__init__.py +++ b/djangocms_installer/config/__init__.py @@ -4,6 +4,7 @@ import os.path import six import sys +import warnings from . import data from .internal import DbAction, validate_project @@ -167,10 +168,12 @@ def parse(args): # Django cms version check if args.cms_version == 'develop': requirements.append(data.DJANGOCMS_DEVELOP) + warnings.warn(data.VERSION_WARNING % ('develop', 'django CMS')) elif args.cms_version == 'rc': requirements.append(data.DJANGOCMS_RC) elif args.cms_version == 'beta': requirements.append(data.DJANGOCMS_BETA) + warnings.warn(data.VERSION_WARNING % ('beta', 'django CMS')) else: if args.cms_version == 'stable': requirements.append("django-cms<%s" % less_than_version(data.DJANGOCMS_LATEST)) @@ -206,8 +209,10 @@ def parse(args): # Django version check if args.django_version == 'develop': requirements.append(data.DJANGO_DEVELOP) + warnings.warn(data.VERSION_WARNING % ('develop', 'Django')) elif args.django_version == 'beta': requirements.append(data.DJANGO_BETA) + warnings.warn(data.VERSION_WARNING % ('beta', 'Django')) else: if args.django_version == 'stable': if cms_version < 3: diff --git a/djangocms_installer/config/data.py b/djangocms_installer/config/data.py index 5dfe25d..0bf2416 100644 --- a/djangocms_installer/config/data.py +++ b/djangocms_installer/config/data.py @@ -137,3 +137,5 @@ """ ALDRYN_BOILERPLATE = 'https://github.com/aldryn/aldryn-boilerplate/archive/master.zip' + +VERSION_WARNING = '%s version of %s is not supported and it may not work as expected' From aece4b5cba88288f9d17e3cdb9a0f15c113aba8e Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 11 Oct 2014 19:13:41 +0200 Subject: [PATCH 23/30] Add FAQ for DJANGO_SETTINGS_MODULE --- docs/faq.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/faq.rst b/docs/faq.rst index abc928e..fdfebc8 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -27,6 +27,16 @@ FAQ **djangocms-installer** uses `dj-database-url`_ to get database configuration parameters; refer to this package for more details. +#. The installer dies with an error like ``ImportError: Could not import settings 'foo.bar.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named foo.bar.settings``, + what's happening? + + Chances are you have ``DJANGO_SETTINGS_MODULE`` set in you environment, + either by default or using postactivate virtualenv hooks or other tools; + please check you environment right after the error happening (for example + using the ``env`` command on *nix systems) and remove any customisation: the + installer requires that ``DJANGO_SETTINGS_MODULE`` is not set on the first + run. You can customise it later. + .. _dj-database-url: https://github.com/kennethreitz/dj-database-url .. _project: https://github.com/nephila/djangocms-installer/issues From 2db21e960cc21b7c08e4504664f2781099d48c05 Mon Sep 17 00:00:00 2001 From: Claudio Luck Date: Sun, 12 Oct 2014 17:15:28 +0200 Subject: [PATCH 24/30] Pass environment to subprocesses, fix use with buildout --- djangocms_installer/django/__init__.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/djangocms_installer/django/__init__.py b/djangocms_installer/django/__init__.py index f49ba16..390d1b5 100644 --- a/djangocms_installer/django/__init__.py +++ b/djangocms_installer/django/__init__.py @@ -4,6 +4,10 @@ import os import re import requests +try: + from shlex import quote as shlex_quote +except ImportError: + from pipes import quote as shlex_quote import shutil import subprocess import sys @@ -11,6 +15,7 @@ import zipfile from six import BytesIO + from ..compat import iteritems from ..utils import chdir from ..config import data, get_settings @@ -308,25 +313,27 @@ def setup_database(config_data): with chdir(config_data.project_directory): os.environ['DJANGO_SETTINGS_MODULE'] = ( '{0}.settings'.format(config_data.project_name)) + env = dict(os.environ) + env['PYTHONPATH'] = ':'.join(map(shlex_quote, sys.path)) if config_data.django_version < 1.7: try: import south # NOQA subprocess.check_call([sys.executable, "-W", "ignore", - "manage.py", "syncdb", "--all", "--noinput"]) + "manage.py", "syncdb", "--all", "--noinput"], env=env) subprocess.check_call([sys.executable, "-W", "ignore", - "manage.py", "migrate", "--fake"]) + "manage.py", "migrate", "--fake"], env=env) except ImportError: subprocess.check_call([sys.executable, "-W", "ignore", - "manage.py", "syncdb", "--noinput"]) + "manage.py", "syncdb", "--noinput"], env=env) print("south not installed, migrations skipped") else: subprocess.check_call([sys.executable, "-W", "ignore", - "manage.py", "migrate", "--noinput"]) + "manage.py", "migrate", "--noinput"], env=env) if not config_data.no_user and not config_data.noinput: print("\n\nCreating admin user") subprocess.check_call([sys.executable, "-W", "ignore", - "manage.py", "createsuperuser"]) + "manage.py", "createsuperuser"], env=env) def load_starting_page(config_data): @@ -336,7 +343,9 @@ def load_starting_page(config_data): with chdir(config_data.project_directory): os.environ['DJANGO_SETTINGS_MODULE'] = ( '{0}.settings'.format(config_data.project_name)) - subprocess.check_call([sys.executable, "starting_page.py"]) + env = dict(os.environ) + env['PYTHONPATH'] = ':'.join(map(shlex_quote, sys.path)) + subprocess.check_call([sys.executable, "starting_page.py"], env=env) for ext in ['py', 'pyc', 'json']: try: os.remove('starting_page.%s' % ext) From d4f2519e972622543193bebf848889e9414203fd Mon Sep 17 00:00:00 2001 From: Claudio Luck Date: Sun, 12 Oct 2014 19:15:14 +0200 Subject: [PATCH 25/30] replace hardcoded colon by os.pathsep --- djangocms_installer/django/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/djangocms_installer/django/__init__.py b/djangocms_installer/django/__init__.py index 390d1b5..0f69f1f 100644 --- a/djangocms_installer/django/__init__.py +++ b/djangocms_installer/django/__init__.py @@ -314,7 +314,7 @@ def setup_database(config_data): os.environ['DJANGO_SETTINGS_MODULE'] = ( '{0}.settings'.format(config_data.project_name)) env = dict(os.environ) - env['PYTHONPATH'] = ':'.join(map(shlex_quote, sys.path)) + env['PYTHONPATH'] = os.pathsep.join(map(shlex_quote, sys.path)) if config_data.django_version < 1.7: try: @@ -344,7 +344,7 @@ def load_starting_page(config_data): os.environ['DJANGO_SETTINGS_MODULE'] = ( '{0}.settings'.format(config_data.project_name)) env = dict(os.environ) - env['PYTHONPATH'] = ':'.join(map(shlex_quote, sys.path)) + env['PYTHONPATH'] = os.pathsep.join(map(shlex_quote, sys.path)) subprocess.check_call([sys.executable, "starting_page.py"], env=env) for ext in ['py', 'pyc', 'json']: try: From 36893aa413b8048a32c51a4e6e3b24216c6b6654 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Fri, 7 Nov 2014 21:37:28 +0100 Subject: [PATCH 26/30] Check provided Django / django CMS version against the supported ones. --- djangocms_installer/config/__init__.py | 12 +++++++++--- djangocms_installer/config/data.py | 3 +++ djangocms_installer/utils.py | 16 ++++++++-------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/djangocms_installer/config/__init__.py b/djangocms_installer/config/__init__.py index 6d85cdd..4b91b27 100644 --- a/djangocms_installer/config/__init__.py +++ b/djangocms_installer/config/__init__.py @@ -39,10 +39,10 @@ def parse(args): help='Languages to enable. Option can be provided multiple times, or as a comma separated list. ' 'Only language codes supported by Django can be used here') parser.add_argument('--django-version', dest='django_version', action='store', - choices=('1.4', '1.5', '1.6', '1.7', 'stable'), + choices=data.DJANGO_SUPPORTED, default='stable', help='Django version') parser.add_argument('--cms-version', '-v', dest='cms_version', action='store', - choices=('2.4', '3.0', 'stable', 'develop'), + choices=data.DJANGOCMS_SUPPORTED, default='stable', help='django CMS version') parser.add_argument('--parent-dir', '-p', dest='project_directory', required=True, default='', @@ -161,6 +161,12 @@ def parse(args): # Convert version to numeric format for easier checking django_version, cms_version = supported_versions(args.django_version, args.cms_version) + if django_version is None: + sys.stderr.write("Please provide a Django supported version: %s. Only Major.Minor version selector is accepted\n" % ", ".join(data.DJANGO_SUPPORTED)) + sys.exit(6) + if django_version is None: + sys.stderr.write("Please provide a django CMS supported version: %s. Only Major.Minor version selector is accepted\n" % ", ".join(data.DJANGOCMS_SUPPORTED)) + sys.exit(6) if not getattr(args, 'requirements_file'): requirements = [] @@ -220,7 +226,7 @@ def parse(args): else: requirements.append("Django<%s" % less_than_version(data.DJANGO_LATEST_CMS_3)) else: - requirements.append("Django<%s" % less_than_version(args.django_version)) + requirements.append("Django<%s" % less_than_version(str(django_version))) # Timezone support if args.use_timezone: diff --git a/djangocms_installer/config/data.py b/djangocms_installer/config/data.py index 0bf2416..78ef656 100644 --- a/djangocms_installer/config/data.py +++ b/djangocms_installer/config/data.py @@ -8,12 +8,15 @@ DJANGOCMS_RC = 'https://github.com/divio/django-cms/archive/3.0c2.zip' DJANGOCMS_BETA = 'https://github.com/divio/django-cms/archive/3.0.0.beta3.zip' DJANGOCMS_LATEST = '3.0' +DJANGOCMS_SUPPORTED = ('2.4', '3.0', 'stable', 'develop') DJANGO_DEVELOP = 'https://github.com/django/django/archive/master.zip' # this is not true, but it's the most recent version # compatible with all the CMS versions DJANGO_LATEST = '1.5' DJANGO_LATEST_CMS_3 = '1.6' +DJANGO_SUPPORTED = ('1.4', '1.5', '1.6', '1.7', 'stable') + DEFAULT_REQUIREMENTS = """ django-classy-tags>=0.3.4.1 diff --git a/djangocms_installer/utils.py b/djangocms_installer/utils.py index d69b245..14842ab 100644 --- a/djangocms_installer/utils.py +++ b/djangocms_installer/utils.py @@ -46,19 +46,19 @@ def supported_versions(django, cms): """ Convert numeric and literal version information to numeric format """ - cms_version = 3 - django_version = 1.5 + cms_version = None + django_version = None try: cms_version = float(cms) except ValueError: if cms == 'stable': cms_version = 3.0 - elif django == 'rc': - django_version = 3.0 - elif django == 'beta': - django_version = 3.0 - elif django == 'develop': - django_version = 3.0 + elif cms == 'rc': + cms_version = 3.0 + elif cms == 'beta': + cms_version = 3.0 + elif cms == 'develop': + cms_version = 3.0 try: django_version = float(django) From eb6dd47be1d2c283c8cccdd0f4b4cc0a500f7534 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 8 Nov 2014 22:55:51 +0100 Subject: [PATCH 27/30] Fix tests. Add support for django CMS 3.1 --- djangocms_installer/config/__init__.py | 5 ++++- djangocms_installer/config/data.py | 3 +++ djangocms_installer/utils.py | 8 ++++---- tests/config.py | 12 ++++++++---- tests/django.py | 4 ++-- tests/main.py | 6 +++--- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/djangocms_installer/config/__init__.py b/djangocms_installer/config/__init__.py index 4b91b27..db66e73 100644 --- a/djangocms_installer/config/__init__.py +++ b/djangocms_installer/config/__init__.py @@ -185,8 +185,11 @@ def parse(args): requirements.append("django-cms<%s" % less_than_version(data.DJANGOCMS_LATEST)) else: requirements.append("django-cms<%s" % less_than_version(args.cms_version)) - if cms_version >= 3: + + if cms_version == 3: requirements.append(data.DJANGOCMS_3_REQUIREMENTS) + elif cms_version >= 3: + requirements.append(data.DJANGOCMS_3_1_REQUIREMENTS) else: requirements.append(data.DJANGOCMS_2_REQUIREMENTS) diff --git a/djangocms_installer/config/data.py b/djangocms_installer/config/data.py index 78ef656..cf5802f 100644 --- a/djangocms_installer/config/data.py +++ b/djangocms_installer/config/data.py @@ -37,6 +37,9 @@ DJANGOCMS_3_REQUIREMENTS = """ django-mptt>=0.6 """ +DJANGOCMS_3_1_REQUIREMENTS = """ +django-treebeard==2.0 +""" PLUGINS_REQUIREMENTS_BASIC = """ djangocms-admin-style diff --git a/djangocms_installer/utils.py b/djangocms_installer/utils.py index 14842ab..a628baf 100644 --- a/djangocms_installer/utils.py +++ b/djangocms_installer/utils.py @@ -54,17 +54,17 @@ def supported_versions(django, cms): if cms == 'stable': cms_version = 3.0 elif cms == 'rc': - cms_version = 3.0 + cms_version = 3.1 elif cms == 'beta': - cms_version = 3.0 + cms_version = 3.1 elif cms == 'develop': - cms_version = 3.0 + cms_version = 3.1 try: django_version = float(django) except ValueError: if django == 'stable': - if cms_version == 3.0: + if cms_version >= 3.0: django_version = 1.6 else: django_version = 1.5 diff --git a/tests/config.py b/tests/config.py index f9e7339..0a7f024 100644 --- a/tests/config.py +++ b/tests/config.py @@ -38,7 +38,7 @@ def test_cli_config(self): conf_data = config.parse([ '-q', '--db=postgres://user:pwd@host/dbname', - '--cms-version=develop', + '--cms-version=stable', '--django-version=1.4', '--i18n=no', '--reversion=no', @@ -164,13 +164,15 @@ def test_latest_version(self): def test_supported_versions(self): self.assertEqual(supported_versions('stable', 'stable'), (1.6, 3.0)) self.assertEqual(supported_versions('stable', '3.0'), (1.6, 3.0)) - self.assertEqual(supported_versions('stable', 'rc'), (1.6, 3.0)) - self.assertEqual(supported_versions('stable', 'beta'), (1.6, 3.0)) - self.assertEqual(supported_versions('stable', 'develop'), (1.6, 3.0)) + self.assertEqual(supported_versions('stable', '3.0.10'), (1.5, None)) + self.assertEqual(supported_versions('stable', 'rc'), (1.6, 3.1)) + self.assertEqual(supported_versions('stable', 'beta'), (1.6, 3.1)) + self.assertEqual(supported_versions('stable', 'develop'), (1.6, 3.1)) self.assertEqual(supported_versions('stable', '2.4'), (1.5, 2.4)) self.assertEqual(supported_versions('1.5', 'stable'), (1.5, 3.0)) self.assertEqual(supported_versions('1.6', 'stable'), (1.6, 3.0)) + self.assertEqual(supported_versions('1.6.9', 'stable'), (None, 3.0)) self.assertEqual(supported_versions('1.7', 'stable'), (1.7, 3.0)) self.assertEqual(supported_versions('beta', 'stable'), (1.8, 3.0)) self.assertEqual(supported_versions('develop', 'stable'), (1.8, 3.0)) @@ -290,6 +292,8 @@ def test_requirements(self): self.assertTrue(conf_data.requirements.find(config.data.DJANGOCMS_DEVELOP) > -1) self.assertTrue(conf_data.requirements.find('Django<1.6') > -1) + self.assertTrue(conf_data.requirements.find('django-mptt') == -1) + self.assertTrue(conf_data.requirements.find('django-treebeard') > -1) self.assertTrue(conf_data.requirements.find('django-reversion>=1.7,<1.8') > -1) conf_data = config.parse([ diff --git a/tests/django.py b/tests/django.py index 36f36e8..6e72113 100644 --- a/tests/django.py +++ b/tests/django.py @@ -19,7 +19,7 @@ class TestDjango(BaseTestClass): def test_create_project(self): config_data = config.parse(['--db=postgres://user:pwd@host/dbname', - '--cms-version=develop', + '--cms-version=stable', '-q', '-p'+self.project_dir, 'example_prj']) install.requirements(config_data.requirements) django.create_project(config_data) @@ -169,7 +169,7 @@ def def_test_patch_django_17_settings(self): config_data = config.parse(['--db=sqlite://localhost/test.db', '--lang=en', '--extra-settings=%s' % extra_path, '--django-version=1.7', - '--cms-version=develop', '--timezone=Europe/Moscow', + '--cms-version=stable', '--timezone=Europe/Moscow', '-q', '-u', '-zno', '--i18n=no', '-p'+self.project_dir, 'example_path_17_settigns']) install.requirements(config_data.requirements) diff --git a/tests/main.py b/tests/main.py index e1ed669..5938d71 100644 --- a/tests/main.py +++ b/tests/main.py @@ -14,7 +14,7 @@ def test_requirements_invocation(self): with patch('sys.stdout', self.stdout): with patch('sys.stderr', self.stderr): sys.argv = ['main'] + ['--db=sqlite://localhost/test.db', - '-len', '--cms-version=develop', '-R', + '-len', '--cms-version=stable', '-R', '-q', '-u', '-p'+self.project_dir, 'example_prj'] main.execute() @@ -38,7 +38,7 @@ def test_main_invocation(self): with patch('sys.stdout', self.stdout): with patch('sys.stderr', self.stderr): sys.argv = ['main'] + ['--db=sqlite://localhost/test.db', - '-len', '--cms-version=develop', + '-len', '--cms-version=stable', '-q', '-u', '-p'+self.project_dir, 'example_prj'] main.execute() @@ -51,7 +51,7 @@ def test_two_langs_invocation(self): with patch('sys.stdout', self.stdout): with patch('sys.stderr', self.stderr): sys.argv = ['main'] + ['--db=sqlite://localhost/test.db', - '-len', '-lfr', '--cms-version=develop', + '-len', '-lfr', '--cms-version=stable', '-q', '-u', '-p'+self.project_dir, 'example_prj'] main.execute() From ca3fca5d3c40dd37e4f8ccf02e8e630ee49ada58 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 8 Nov 2014 23:20:41 +0100 Subject: [PATCH 28/30] Fix test in python 3 --- djangocms_installer/utils.py | 9 +++++---- tests/config.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/djangocms_installer/utils.py b/djangocms_installer/utils.py index a628baf..381e0ff 100644 --- a/djangocms_installer/utils.py +++ b/djangocms_installer/utils.py @@ -64,10 +64,11 @@ def supported_versions(django, cms): django_version = float(django) except ValueError: if django == 'stable': - if cms_version >= 3.0: - django_version = 1.6 - else: - django_version = 1.5 + if cms_version: + if cms_version >= 3.0: + django_version = 1.6 + else: + django_version = 1.5 elif django == 'beta': django_version = 1.8 elif django == 'develop': diff --git a/tests/config.py b/tests/config.py index 0a7f024..6cdc58e 100644 --- a/tests/config.py +++ b/tests/config.py @@ -164,7 +164,7 @@ def test_latest_version(self): def test_supported_versions(self): self.assertEqual(supported_versions('stable', 'stable'), (1.6, 3.0)) self.assertEqual(supported_versions('stable', '3.0'), (1.6, 3.0)) - self.assertEqual(supported_versions('stable', '3.0.10'), (1.5, None)) + self.assertEqual(supported_versions('stable', '3.0.10'), (None, None)) self.assertEqual(supported_versions('stable', 'rc'), (1.6, 3.1)) self.assertEqual(supported_versions('stable', 'beta'), (1.6, 3.1)) self.assertEqual(supported_versions('stable', 'develop'), (1.6, 3.1)) From de18c9ad79415aef955fbdc363bfd5b0108bdcc3 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sun, 30 Nov 2014 13:10:59 +0100 Subject: [PATCH 29/30] Update authors --- AUTHORS.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/AUTHORS.rst b/AUTHORS.rst index 732b8f9..e6addf7 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -12,9 +12,12 @@ Development Lead Contributors ------------ -* Carlo Ascani * Aaron Boman -* Henning Sprang -* Nick Moore +* Carlo Ascani +* Claudio Luck * Enkel Mitrushi +* growlf +* Henning Sprang * Jonas Obrist +* Nick Moore +* pipsqueaker \ No newline at end of file From 0ec8b091a71f2052c2e0e6a72d3ecfdffc185edc Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sun, 30 Nov 2014 13:11:12 +0100 Subject: [PATCH 30/30] Update history --- HISTORY.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 9f6adf5..159086f 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,11 +3,14 @@ History ------- -0.6.0 (unreleased) +0.6.0 (2014-11-30) ++++++++++++++++++ * Add support for installing aldryn-boilerplate * Force installing all packages (-I) when creating the project virtualenv +* Fix multiplatform support bugs +* Update supported Django / django CMS versions +* Add preliminary support for django CMS develop (3.1) 0.5.4 (2014-08-14) ++++++++++++++++++