Skip to content

Commit

Permalink
Merge 1.1.1 (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
yakky committed Jul 3, 2019
1 parent b2c3d12 commit 30a8e39
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ python:

env:
matrix:
- TOXENV='docs'
- TOXENV='pep8'
- TOXENV='isort'
- DJANGO='django111' CMS='cms34'
Expand Down Expand Up @@ -41,10 +42,14 @@ script: COMMAND='coverage run' tox -e$TOXENV

matrix:
exclude:
- python: 2.7
env: TOXENV='docs'
- python: 2.7
env: TOXENV='pep8'
- python: 2.7
env: TOXENV='isort'
- python: 3.5
env: TOXENV='docs'
- python: 3.5
env: TOXENV='pep8'
- python: 3.5
Expand Down
7 changes: 6 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
History
-------

1.2.1 (2019-06-30)
1.2.1 (2019-07-03)
++++++++++++++++++

* Fixed error when creating users with non-writable email attribute
Expand All @@ -15,6 +15,11 @@ History
* Added django CMS 3.6
* Added django 2.0, 2.1

1.1.1 (2019-07-03)
++++++++++++++++++

* Fixed error when creating users with non-writable email attribute

1.1.0 (2018-02-20)
++++++++++++++++++

Expand Down
2 changes: 1 addition & 1 deletion djangocms_helper/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals

__version__ = '1.2.0.post1'
__version__ = '1.2.0.a1'
__author__ = 'Iacopo Spalletti <i.spalletti@nephila.it>'
__all__ = ['runner']

Expand Down
60 changes: 60 additions & 0 deletions djangocms_helper/test_utils/cms_helper_custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# -*- coding: utf-8 -*-
from tempfile import mkdtemp

try:
import djangocms_text_ckeditor # NOQA
text_plugin = ['djangocms_text_ckeditor']
except ImportError:
text_plugin = []

HELPER_SETTINGS = {
'TIME_ZONE': 'Europe/Rome',
'INSTALLED_APPS': [
'example2',
'filer',
] + text_plugin,
'CMS_LANGUAGES': {
1: [
{
'code': 'en',
'name': 'English',
'public': True,
},
{
'code': 'it',
'name': 'Italiano',
'public': True,
},
{
'code': 'fr',
'name': 'French',
'public': True,
},
],
'default': {
'hide_untranslated': False,
},
},
'FILE_UPLOAD_TEMP_DIR': mkdtemp(),
}


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


def setup():
import sys
from djangocms_helper import runner
runner.setup('example1', sys.modules[__name__], use_cms=True)


def setup_nocms():
import sys
from djangocms_helper import runner
runner.setup('example1', sys.modules[__name__], use_cms=False)


if __name__ == "__main__":
run()
1 change: 1 addition & 0 deletions djangocms_helper/test_utils/custom_user/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# -*- coding: utf-8 -*-
11 changes: 11 additions & 0 deletions djangocms_helper/test_utils/custom_user/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals

from django.contrib.auth.models import AbstractUser


class CustomUser(AbstractUser):

@property
def email(self):
return 'some@example.com'
2 changes: 1 addition & 1 deletion djangocms_helper/test_utils/example1/tests/test_fake.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def test_requests(self):
self.assertEqual(request.META['REQUEST_METHOD'], 'GET')

def test_get_user_model(self):
if 'AUTH_USER_MODEL' not in os.environ:
if os.environ.get('AUTH_USER_MODEL', 'auth.User'):
user_orm_label, user_model_label = get_user_model_labels()
self.assertEqual(user_orm_label, 'auth.User')
self.assertEqual(user_model_label, 'auth.user')
Expand Down
19 changes: 19 additions & 0 deletions djangocms_helper/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def setUp(self):
pass

def tearDown(self):
os.environ['AUTH_USER_MODEL'] = 'auth.User'
self.setUp()

def test_map_argv(self):
Expand Down Expand Up @@ -699,6 +700,24 @@ def test_setup_cms(self):
self.assertTrue('aldryn_boilerplates' in settings.INSTALLED_APPS)
self.assertTrue('cms' in settings.INSTALLED_APPS)

def test_setup_custom_user(self):
os.environ['AUTH_USER_MODEL'] = 'custom_user.CustomUser'
try:
import cms
except ImportError:
raise unittest.SkipTest('django CMS not available, skipping test')
with work_in(self.basedir):
with captured_output() as (out, err):
from djangocms_helper.test_utils import cms_helper_custom
settings = runner.setup(
'example1', cms_helper_custom, use_cms=True, extra_args=['--boilerplate']
)
self.assertTrue('example2' in settings.INSTALLED_APPS)
self.assertTrue('custom_user' in settings.INSTALLED_APPS)
self.assertTrue('aldryn_boilerplates' in settings.INSTALLED_APPS)
self.assertTrue('cms' in settings.INSTALLED_APPS)
del os.environ['AUTH_USER_MODEL']

def test_setup_nocms(self):
with work_in(self.basedir):
with captured_output() as (out, err):
Expand Down
14 changes: 10 additions & 4 deletions djangocms_helper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,16 @@ def _make_settings(args, application, settings, STATIC_ROOT, MEDIA_ROOT):
if 'AUTH_USER_MODEL' in os.environ:
custom_user_app = os.environ['AUTH_USER_MODEL'].rpartition('.')[0]
custom_user_model = '.'.join(os.environ['AUTH_USER_MODEL'].split('.')[-2:])
default_settings['INSTALLED_APPS'].insert(
default_settings['INSTALLED_APPS'].index('cms'),
custom_user_app
)
if 'cms' in default_settings['INSTALLED_APPS']:
default_settings['INSTALLED_APPS'].insert(
default_settings['INSTALLED_APPS'].index('cms'),
custom_user_app
)
else:
default_settings['INSTALLED_APPS'].insert(
default_settings['INSTALLED_APPS'].index('django.contrib.auth') + 1,
custom_user_app
)
default_settings['AUTH_USER_MODEL'] = custom_user_model

if args['test']:
Expand Down

0 comments on commit 30a8e39

Please sign in to comment.