Skip to content

Commit

Permalink
Merge pull request #561 from jerome-poisson/default_timezone
Browse files Browse the repository at this point in the history
[SETTINGS] use local timezone in DEFAULT_TIMEZONE when it is not expl…
  • Loading branch information
jerome-poisson committed Sep 6, 2016
2 parents 67dba2b + f3bf95e commit bbd0b60
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
'python-magic>=0.4',
'python3-ldap>=0.9.8',
'pytz>=2015.4',
'tzlocal>=1.2.2',
'raven[flask]>=5.10.0,<5.11',
'requests>=2.7.0',
'statsd>=3.1',
Expand Down
9 changes: 8 additions & 1 deletion superdesk/factory/default_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from datetime import timedelta
from celery.schedules import crontab
from kombu import Queue, Exchange
import tzlocal

try:
from urllib.parse import urlparse
Expand Down Expand Up @@ -359,7 +360,13 @@ def env(variable, fallback_value=None):
SUPERDESK_TESTING = (env('SUPERDESK_TESTING', 'false').lower() == 'true')

# Default TimeZone
DEFAULT_TIMEZONE = env('DEFAULT_TIMEZONE', 'Europe/Prague')
DEFAULT_TIMEZONE = env('DEFAULT_TIMEZONE')

if DEFAULT_TIMEZONE is None:
DEFAULT_TIMEZONE = tzlocal.get_localzone().zone

if not DEFAULT_TIMEZONE:
raise ValueError("DEFAULT_TIMEZONE is empty")

# The number of minutes since the last update of the Mongo auth object after which it will be deleted
SESSION_EXPIRY_MINUTES = int(env('SESSION_EXPIRY_MINUTES', 240))
Expand Down

0 comments on commit bbd0b60

Please sign in to comment.