Merge pull request #378 from ungleich/pcoder-set_debug_false

On prodcution we should always have Debug = False
Please refer to redmine bug report #3538 for details.
This commit is contained in:
Pcoder 2017-07-07 02:20:50 +02:00 committed by GitHub
commit eec8caf5ad
4 changed files with 26 additions and 15 deletions

View file

@ -20,6 +20,11 @@ def env(env_name):
return os.environ.get(env_name) return os.environ.get(env_name)
def bool_env(val):
"""Replaces string based environment values with Python booleans"""
return True if os.environ.get(val, False) == 'True' else False
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PROJECT_DIR = os.path.abspath( PROJECT_DIR = os.path.abspath(
@ -474,14 +479,6 @@ REGISTRATION_MESSAGE = {'subject': "Validation mail",
STRIPE_API_PRIVATE_KEY = env('STRIPE_API_PRIVATE_KEY') STRIPE_API_PRIVATE_KEY = env('STRIPE_API_PRIVATE_KEY')
STRIPE_API_PUBLIC_KEY = env('STRIPE_API_PUBLIC_KEY') STRIPE_API_PUBLIC_KEY = env('STRIPE_API_PUBLIC_KEY')
DEBUG = True
if DEBUG:
from .local import * # flake8: noqa
else:
from .prod import * # flake8: noqa
ANONYMOUS_USER_NAME = 'anonymous@ungleich.ch' ANONYMOUS_USER_NAME = 'anonymous@ungleich.ch'
GUARDIAN_GET_INIT_ANONYMOUS_USER = 'membership.models.get_anonymous_user_instance' GUARDIAN_GET_INIT_ANONYMOUS_USER = 'membership.models.get_anonymous_user_instance'
@ -525,3 +522,10 @@ GOOGLE_ANALYTICS_PROPERTY_IDS = {
'dynamicweb-development.ungleich.ch': 'development', 'dynamicweb-development.ungleich.ch': 'development',
'dynamicweb-staging.ungleich.ch': 'staging' 'dynamicweb-staging.ungleich.ch': 'staging'
} }
DEBUG = bool_env('DEBUG')
if DEBUG:
from .local import * # flake8: noqa
else:
from .prod import * # flake8: noqa

View file

@ -7,6 +7,13 @@ DEBUG = False
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
}
}
# MANAGERS = ADMINS # MANAGERS = ADMINS
REGISTRATION_MESSAGE['message'] = REGISTRATION_MESSAGE['message'].format(host='digitalglarus.ungleich.ch', REGISTRATION_MESSAGE['message'] = REGISTRATION_MESSAGE['message'].format(host='digitalglarus.ungleich.ch',

View file

@ -43,12 +43,11 @@ urlpatterns += i18n_patterns('',
url(r'^blog/', include('ungleich.urls', namespace='ungleich')), url(r'^blog/', include('ungleich.urls', namespace='ungleich')),
url(r'^', include('cms.urls')) url(r'^', include('cms.urls'))
) )
urlpatterns += patterns('',
if settings.DEBUG:
urlpatterns += patterns('',
url(r'^media/(?P<path>.*)$', url(r'^media/(?P<path>.*)$',
'django.views.static.serve', { 'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT, 'document_root': settings.MEDIA_ROOT,
}), }),
) )
if settings.DEBUG:
urlpatterns += patterns('', url(r'^__debug__/', include(debug_toolbar.urls))) urlpatterns += patterns('', url(r'^__debug__/', include(debug_toolbar.urls)))

View file

@ -85,3 +85,4 @@ coverage==4.3.4
git+https://github.com/ungleich/python-oca.git#egg=python-oca git+https://github.com/ungleich/python-oca.git#egg=python-oca
djangorestframework djangorestframework
flake8==3.3.0 flake8==3.3.0
python-memcached==1.58