Skip to content

Commit

Permalink
Fix timezone on Django 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
yakky committed May 6, 2014
1 parent 0d48788 commit 5718595
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions djangocms_installer/django/__init__.py
Expand Up @@ -125,6 +125,9 @@ def patch_settings(config_data):
if config_data.languages:
original = original.replace("LANGUAGE_CODE = 'en-us'", "LANGUAGE_CODE = '%s'" % config_data.languages[0])
if config_data.timezone:
# This is for Django 1.6 which changed the default timezone
original = original.replace("TIME_ZONE = 'UTC'", "TIME_ZONE = '%s'" % config_data.timezone)
# This is for older django versions
original = original.replace("TIME_ZONE = 'America/Chicago'", "TIME_ZONE = '%s'" % config_data.timezone)

for item in overridden_settings:
Expand Down
6 changes: 4 additions & 2 deletions tests/django.py
Expand Up @@ -88,7 +88,7 @@ def test_patch_16(self):
config_data = config.parse(['--db=sqlite://localhost/test.db',
'--lang=en',
'--django-version=1.6',
'--cms-version=3.0',
'--cms-version=3.0', '--timezone=Europe/Moscow',
'-q', '-u', '-zno', '--i18n=no',
'-p'+self.project_dir, 'example_path_16'])

Expand All @@ -109,6 +109,7 @@ def test_patch_16(self):
self.assertTrue(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')
self.assertTrue('cmsplugin_filer_image' not in project.settings.INSTALLED_APPS)
self.assertTrue('cmsplugin_filer_file' not in project.settings.INSTALLED_APPS)
self.assertTrue('cmsplugin_filer_folder' not in project.settings.INSTALLED_APPS)
Expand Down Expand Up @@ -233,7 +234,7 @@ def test_patch(self):
config_data = config.parse(['--db=sqlite://localhost/test.db',
'--lang=en',
'--django-version=1.5',
'--cms-version=3.0',
'--cms-version=3.0', '--timezone=Europe/Moscow',
'-f', '-q', '-u', '-zno', '--i18n=no',
'-p'+self.project_dir, 'example_path_patch'])
install.requirements(config_data.requirements)
Expand All @@ -252,6 +253,7 @@ def test_patch(self):
## checking for django options
self.assertFalse(project.settings.USE_L10N)
self.assertFalse(project.settings.USE_TZ)
self.assertEqual(project.settings.TIME_ZONE, 'Europe/Moscow')
self.assertEqual(project.settings.LANGUAGE_CODE, 'en')
self.assertTrue(project.settings.MEDIA_ROOT, os.path.join(config_data.project_directory, 'media'))
self.assertEqual(project.settings.MEDIA_URL, '/media/')
Expand Down

0 comments on commit 5718595

Please sign in to comment.