mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
@@ -29,6 +29,8 @@ class CoreConfig(AppConfig):
|
||||
def ready(self):
|
||||
load_core_settings()
|
||||
|
||||
# Import these to force registration of checks and signals
|
||||
from . import checks # noqa:F401
|
||||
from . import handlers
|
||||
|
||||
signals.post_migrate.connect(handlers.create_local_config, sender=self)
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Import these to force registration of checks
|
||||
from . import settings_checks # noqa:F401
|
||||
@@ -0,0 +1,29 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.checks import Warning, register
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
|
||||
W001 = Warning(
|
||||
_("You have USE_TZ set to False, this may result in issues during "
|
||||
"transitions between summer/winter time (ie the same local time occuring "
|
||||
"twice due to clock change)."),
|
||||
hint=_("Set `USE_TZ = True` in settings.py"),
|
||||
id="modoboa.W001",
|
||||
)
|
||||
|
||||
|
||||
@register(deploy=True)
|
||||
def check_use_tz_enabled(app_configs, **kwargs):
|
||||
"""Ensure USE_TZ is enabled in settings.py
|
||||
|
||||
When USE_TZ is enabled all date/times are stored in UTC.
|
||||
Fixes #1086 - https://github.com/modoboa/modoboa/issues/1086
|
||||
"""
|
||||
errors = []
|
||||
if not settings.USE_TZ:
|
||||
errors.append(W001)
|
||||
return errors
|
||||
@@ -0,0 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.test import SimpleTestCase
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from ..checks import settings_checks
|
||||
|
||||
|
||||
class CheckSessionCookieSecureTest(SimpleTestCase):
|
||||
@override_settings(USE_TZ=False)
|
||||
def test_use_tz_false(self):
|
||||
"""If USE_TZ is off provide one warning."""
|
||||
self.assertEqual(
|
||||
settings_checks.check_use_tz_enabled(None),
|
||||
[settings_checks.W001]
|
||||
)
|
||||
|
||||
@override_settings(USE_TZ=True)
|
||||
def test_use_tz_true(self):
|
||||
"""If USE_TZ is on, there's no warning about it."""
|
||||
self.assertEqual(settings_checks.check_use_tz_enabled(None), [])
|
||||
Reference in New Issue
Block a user