common_settings.py 12.1 KB
Newer Older
Patrick Colmant's avatar
Patrick Colmant committed
1
# -*- coding: utf-8 -*-
2 3
import os

Patrick Colmant's avatar
Patrick Colmant committed
4 5 6
from settings import *

gettext = lambda s: s
Patrick Colmant's avatar
Patrick Colmant committed
7 8 9
PROJECT_PATH = os.path.split(os.path.abspath(os.path.dirname(__file__)))[0]
PROJECT_DIR = os.path.realpath(os.path.dirname(__file__))
os.sys.path.insert(0, os.path.dirname(PROJECT_DIR))
Patrick Colmant's avatar
Patrick Colmant committed
10

11
# ##################### DEBUG
Patrick's avatar
Patrick committed
12 13

# Defined into /etc/uwsgi/apps-available/*.ini
14
DEBUG = True if os.getenv('DJANGO_SETTINGS_MODULE_DEBUG', '') == 'True' else False
Patrick's avatar
Patrick committed
15 16 17
TEMPLATE_DEBUG = DEBUG
ADMINS = (
    (
18 19
        os.getenv('DJANGO_SETTINGS_MODULE_ADMIN_NAME', ''),
        os.getenv('DJANGO_SETTINGS_MODULE_ADMIN_EMAIL', '')
Patrick's avatar
Patrick committed
20 21
    ),
)
22
SERVER_EMAIL = os.getenv('DJANGO_SETTINGS_MODULE_ADMIN_EMAIL', '')
Patrick's avatar
Patrick committed
23 24 25 26 27 28
# MANAGERS = (
#     (
#         os.getenv('DJANGO_SETTINGS_MODULE_ADMIN_NAME',''), 
#         os.getenv('DJANGO_SETTINGS_MODULE_ADMIN_EMAIL','')
#     ),
# )
29 30 31 32
###################### 

DATABASES = {
    'default': {
33 34 35
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': os.getenv('DJANGO_SETTINGS_MODULE_DATABASE_NAME', ''),  # Or path to database file if using sqlite3.
36
        # The following settings are not used with sqlite3:
37 38 39 40
        'USER': os.getenv('DJANGO_SETTINGS_MODULE_DATABASE_USER', ''),
        'PASSWORD': os.getenv('DJANGO_SETTINGS_MODULE_DATABASE_PASSWORD', ''),
        # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
        'HOST': os.getenv('DJANGO_SETTINGS_MODULE_DATABASE_HOST', ''),
41
        # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
42
        'PORT': os.getenv('DJANGO_SETTINGS_MODULE_DATABASE_PORT', ''),  # Set to empty string for default.
43 44
    }
}
45 46 47 48 49
EMAIL_HOST = os.getenv('DJANGO_SETTINGS_MODULE_EMAIL_HOST', '')
EMAIL_HOST_USER = os.getenv('DJANGO_SETTINGS_MODULE_EMAIL_HOST_USER', '')
EMAIL_HOST_PASSWORD = os.getenv('DJANGO_SETTINGS_MODULE_EMAIL_HOST_PASSWORD', '')
EMAIL_PORT = os.getenv('DJANGO_SETTINGS_MODULE_EMAIL_PORT', '')
EMAIL_USE_TLS = True if os.getenv('DJANGO_SETTINGS_MODULE_EMAIL_USE_TLS', '') == 'True' else False
Patrick's avatar
Patrick committed
50 51
# if DEBUG:
#     EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
Patrick Colmant's avatar
Patrick Colmant committed
52 53 54
###################### I18N

TIME_ZONE = 'Europe/Brussels'
Patrick's avatar
Patrick committed
55 56 57 58 59 60 61 62
USE_TZ = True
# Before 22/02/2014 - DJANGO-CMS LANGUAGE_CODE = 'fr-BE'
LANGUAGE_CODE = 'fr'
USE_L10N = True
USE_THOUSAND_SEPARATOR = True
THOUSAND_SEPARATOR = '.'
NUMBER_GROUPING = 3
DECIMAL_SEPARATOR = ','
63
# 'fr-be'
Patrick Colmant's avatar
Patrick Colmant committed
64 65 66 67 68 69 70 71 72

##################### Django & Django CMS
LANGUAGES = [
    ('fr', 'Français'),
    ('nl', 'Neederlands'),
    ('en', 'English'),
]

CMS_LANGUAGES = {
Patrick Colmant's avatar
Patrick Colmant committed
73
    'default': {
Patrick Colmant's avatar
Patrick Colmant committed
74
        'fallbacks': ['fr', 'en', 'nl'],
75
        'redirect_on_fallback': True,
Patrick Colmant's avatar
Patrick Colmant committed
76 77
        'public': False,
        'hide_untranslated': False,
Patrick Colmant's avatar
Patrick Colmant committed
78 79 80
    }
}

Patrick Colmant's avatar
Patrick Colmant committed
81 82 83 84 85
LOCALE_PATHS = (
    os.path.join(PROJECT_DIR, "locale"),
)

MIDDLEWARE_CLASSES = (
Patrick's avatar
Patrick committed
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
    # 'django.middleware.cache.UpdateCacheMiddleware',
    # 'django.middleware.cache.FetchFromCacheMiddleware',
    # 'django.contrib.sessions.middleware.SessionMiddleware',
    # 'django.middleware.common.CommonMiddleware',
    # 'django.middleware.csrf.CsrfViewMiddleware', 
    # 'django.contrib.auth.middleware.AuthenticationMiddleware',
    # 'django.contrib.messages.middleware.MessageMiddleware',
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
    # 'django.middleware.locale.LocaleMiddleware',
    # 'django.middleware.doc.XViewMiddleware',
    # 'cms.middleware.page.CurrentPageMiddleware',
    # 'cms.middleware.user.CurrentUserMiddleware',      
    # 'cms.middleware.toolbar.ToolbarMiddleware',
    # 'cms.middleware.language.LanguageCookieMiddleware',


Patrick Colmant's avatar
Patrick Colmant committed
102 103
    'django.middleware.cache.UpdateCacheMiddleware',
    'django.middleware.cache.FetchFromCacheMiddleware',
Patrick's avatar
Patrick committed
104

Patrick Colmant's avatar
Patrick Colmant committed
105
    'django.contrib.sessions.middleware.SessionMiddleware',
Patrick's avatar
Patrick committed
106
    'django.middleware.csrf.CsrfViewMiddleware',
Patrick Colmant's avatar
Patrick Colmant committed
107 108 109 110
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.doc.XViewMiddleware',
Patrick's avatar
Patrick committed
111
    'django.middleware.common.CommonMiddleware',
Patrick Colmant's avatar
Patrick Colmant committed
112
    'cms.middleware.page.CurrentPageMiddleware',
Patrick's avatar
Patrick committed
113
    'cms.middleware.user.CurrentUserMiddleware',
Patrick Colmant's avatar
Patrick Colmant committed
114
    'cms.middleware.toolbar.ToolbarMiddleware',
115
    # 'cms.middleware.language.LanguageCookieMiddleware',
Patrick Colmant's avatar
Patrick Colmant committed
116
)
Patrick Colmant's avatar
Patrick Colmant committed
117 118 119

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
Patrick Colmant's avatar
Patrick Colmant committed
120
    'django.contrib.messages.context_processors.messages',
Patrick Colmant's avatar
Patrick Colmant committed
121 122 123 124
    'django.core.context_processors.i18n',
    'django.core.context_processors.request',
    'django.core.context_processors.media',
    'django.core.context_processors.static',
Patrick's avatar
Patrick committed
125 126
    'cms.context_processors.cms_settings',
    # 'cms.context_processors.media',
127
    'sekizai.context_processors.sekizai',
Patrick Colmant's avatar
Patrick Colmant committed
128
)
Patrick Colmant's avatar
Patrick Colmant committed
129 130 131 132 133 134 135 136 137 138

INSTALLED_APPS = (
    'django.contrib.sites',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sitemaps',
    'django.contrib.formtools',
Patrick's avatar
Patrick committed
139

140

Patrick's avatar
Patrick committed
141 142
    'djangocms_text_ckeditor',  # note this needs to be above the 'cms' entry

Patrick Colmant's avatar
Patrick Colmant committed
143 144 145 146 147
    'cms',
    'mptt',
    'menus',
    'south',
    'sekizai',
148 149
    'djangocms_admin_style',  # note this needs to be above
    # the 'django.contrib.admin' entry
Patrick Colmant's avatar
Patrick Colmant committed
150
    'django.contrib.admin',
151
    'adminsortable',
Patrick's avatar
Patrick committed
152
    # 'hvad',
Patrick Colmant's avatar
Patrick Colmant committed
153 154
    'filer',
    'easy_thumbnails',
155

Patrick Colmant's avatar
Patrick Colmant committed
156 157 158 159
    'cmsplugin_filer_file',
    'cmsplugin_filer_folder',
    'cmsplugin_filer_image',
    'cmsplugin_filer_video',
160
    'cmsplugin_filer_link',
Patrick Colmant's avatar
Patrick Colmant committed
161
    'reversion',
Patrick's avatar
Patrick committed
162
    'password_reset',
163

164
)
Patrick Colmant's avatar
Patrick Colmant committed
165

166
CMS_PERMISSION = False  # When set to True, don't forget 'cms.middleware.user.CurrentUserMiddleware'
Patrick Colmant's avatar
Patrick Colmant committed
167
CMS_PUBLIC_FOR = 'all'
168
# CMS_PUBLIC_FOR = 'staff'
Patrick Colmant's avatar
Patrick Colmant committed
169 170 171 172 173 174
CMS_SHOW_START_DATE = False
CMS_SHOW_END_DATE = False
CMS_SEO_FIELDS = False
CMS_URL_OVERWRITE = True
CMS_MENU_TITLE_OVERWRITE = True
CMS_REDIRECTS = True
Patrick's avatar
Patrick committed
175
LOGIN_URL = "/go_repanier/"
Patrick Colmant's avatar
Patrick Colmant committed
176
LOGIN_REDIRECT_URL = "/"
Patrick's avatar
Patrick committed
177 178
LOGOUT_URL = "/leave_repanier/"

Patrick's avatar
Patrick committed
179
CKEDITOR_SETTINGS = {
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
    'language': '{{ language }}',
    'toolbar': 'HTMLField',
    # 'stylesSet' : 'my_styles:%sjs/ckeditor-styles.js' % STATIC_URL,
    # 'stylesSet' : [],
    'extraPlugins': 'cmsplugins,templates',
    'format_tags': 'p;h1;h2;h3;h4;h5;blockquote;mutted;success;info;danger;heart;infosign;warningsign;pushpin;div',
    'format_blockquote': {'element': 'blockquote', 'name': 'Blockquote'},
    'format_heart': {'element': 'span', 'attributes': {'class': 'glyphicon glyphicon-heart-empty'}},
    'format_infosign': {'element': 'span', 'attributes': {'class': 'glyphicon glyphicon-info-sign'}},
    'format_warningsign': {'element': 'span', 'attributes': {'class': 'glyphicon glyphicon-warning-sign'}},
    'format_pushpin': {'element': 'span', 'attributes': {'class': 'glyphicon glyphicon-pushpin'}},
    'format_mutted': {'element': 'p', 'attributes': {'class': 'text-muted'}, 'name': 'Mutted'},
    'format_success': {'element': 'p', 'attributes': {'class': 'bg-success'}, 'name': 'Success'},
    'format_info': {'element': 'p', 'attributes': {'class': 'bg-info'}, 'name': 'Info'},
    'format_danger': {'element': 'p', 'attributes': {'class': 'bg-danger'}, 'name': 'Danger'},
    # format_p = { element: 'p', attributes: { 'class': 'normalPara' } };
    # format_test = { element : 'span', attributes : { 'class' : 'test' }, styles: { color: 'blue'} };
    # 'contentsCss' : '//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css',
    'contentsCss': '%sbootstrap/css/bootstrap.css' % STATIC_URL,
    # 'extraAllowedContent' : '*(*)',
    # 'removeFormatTags' : 'b,big,code,del,dfn,em,font,i,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,u,var'
Patrick's avatar
Patrick committed
201 202
}

203
TEXT_SAVE_IMAGE_FUNCTION = 'cmsplugin_filer_image.integrations.ckeditor.create_image_plugin'
Patrick Colmant's avatar
Patrick Colmant committed
204 205 206

FILER_ENABLE_LOGGING = False
FILER_IMAGE_USE_ICON = True
Patrick's avatar
Patrick committed
207 208
FILER_ALLOW_REGULAR_USERS_TO_ADD_ROOT_FOLDERS = True
FILER_ENABLE_PERMISSIONS = False
Patrick Colmant's avatar
Patrick Colmant committed
209 210 211 212 213 214 215 216 217 218
FILER_IS_PUBLIC_DEFAULT = True
FILER_SUBJECT_LOCATION_IMAGE_DEBUG = True
FILER_DEBUG = DEBUG

THUMBNAIL_PROCESSORS = (
    'easy_thumbnails.processors.colorspace',
    'easy_thumbnails.processors.autocrop',
    #'easy_thumbnails.processors.scale_and_crop',
    'filer.thumbnail_processors.scale_and_crop_with_subject_location',
    'easy_thumbnails.processors.filters',
Patrick Colmant's avatar
Patrick Colmant committed
219
)
Patrick Colmant's avatar
Patrick Colmant committed
220 221
THUMBNAIL_DEBUG = DEBUG

222
# https://docs.djangoproject.com/en/1.5/howto/static-files/
Patrick Colmant's avatar
Patrick Colmant committed
223 224 225 226 227 228 229 230 231 232
STATIC_ROOT = os.path.join(PROJECT_DIR, "collect-static")
STATIC_URL = "/static/"
MEDIA_URL = "/media/"
USE_X_FORWARDED_HOST = True
SEND_BROKEN_LINK_EMAILS = True
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SESSION_ENGINE = "django.contrib.sessions.backends.file"
SESSION_COOKIE_HTTPONLY = True
SESSION_FILE_PATH = '/var/tmp/django_session'
SOUTH_TESTS_MIGRATE = DEBUG
Patrick Colmant's avatar
Patrick Colmant committed
233 234

##################### Repanier
235
AUTH_USER_MODEL = 'auth.User'
Patrick Colmant's avatar
Patrick Colmant committed
236
AUTHENTICATION_BACKENDS = ('repanier.auth_backend.RepanierCustomBackend',)
237 238
# ADMIN_LOGIN = 'pise'
# ADMIN_PASSWORD = 'raspberry'
Patrick Colmant's avatar
Patrick Colmant committed
239
INSTALLED_APPS += (
240
'repanier',
Patrick Colmant's avatar
Patrick Colmant committed
241 242 243
)


Patrick Colmant's avatar
Patrick Colmant committed
244 245 246
################# Django_crispy_forms
INSTALLED_APPS += (
    'crispy_forms',
Patrick's avatar
Patrick committed
247
    # 'crispy_forms_foundation',
Patrick Colmant's avatar
Patrick Colmant committed
248 249
)

Patrick's avatar
Patrick committed
250 251
CRISPY_TEMPLATE_PACK = "bootstrap3"
# CRISPY_TEMPLATE_PACK = "foundation"
Patrick Colmant's avatar
Patrick Colmant committed
252
JSON_MODULE = 'ujson'
Patrick Colmant's avatar
Patrick Colmant committed
253

Patrick Colmant's avatar
Patrick Colmant committed
254 255 256
################# Django_compressor
INSTALLED_APPS += (
    'compressor',
Patrick Colmant's avatar
Patrick Colmant committed
257
)
Patrick Colmant's avatar
Patrick Colmant committed
258 259 260 261
##### From : django/conf/global_settings.py
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
262
    #    'django.contrib.staticfiles.finders.DefaultStorageFinder',
Patrick Colmant's avatar
Patrick Colmant committed
263 264
)

Patrick Colmant's avatar
Patrick Colmant committed
265
STATICFILES_FINDERS += (
266
    'compressor.finders.CompressorFinder',
Patrick Colmant's avatar
Patrick Colmant committed
267 268
)

Patrick Colmant's avatar
Patrick Colmant committed
269 270 271 272 273 274
COMPRESS_ENABLED = True
COMPRESS_OUTPUT_DIR = "compressor"
COMPRESS_STORAGE = 'compressor.storage.GzipCompressorFileStorage'
COMPRESS_PARSER = "compressor.parser.HtmlParser"
COMPRESS_OFFLINE = False

275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
# COMPRESS_YUI_BINARY = "yui-compressor"
# COMPRESS_CLOSURE_COMPILER_BINARY = "/usr/local/bin/node /usr/local/bin/uglifyjs"
# COMPRESS_CLOSURE_COMPILER_ARGUMENTS = '--compress'

# COMPRESS_CSS_FILTERS = [
#    'compressor.filters.yui.YUICSSFilter',
#    'compressor.filters.css_default.CssAbsoluteFilter',
#    'compressor.filters.template.TemplateFilter'
#    ]

# COMPRESS_JS_FILTERS = [
#    'compressor.filters.yui.YUIJSFilter',
#     'compressor.filters.closure.ClosureCompilerFilter',
#    'compressor.filters.jsmin.JSMinFilter',
#    'compressor.filters.template.TemplateFilter'
#    ]

# COMPRESS_PRECOMPILERS = (
#    ('text/coffeescript', 'coffee --compile --stdio'),
#    ('text/less', 'lessc {infile} {outfile}'),
#    ('text/x-sass', 'sass {infile} {outfile}'),
#    ('text/x-scss', 'sass --scss {infile} {outfile}'),
#    ('text/stylus', 'stylus < {infile} > {outfile}'),
# )
Patrick Colmant's avatar
Patrick Colmant committed
299 300 301 302

###################### Django : Cache setup (https://docs.djangoproject.com/en/dev/topics/cache/)

CACHE_MIDDLEWARE_ALIAS = 'default'
Patrick's avatar
Patrick committed
303
CACHE_MIDDLEWARE_SECONDS = 3600
Patrick Colmant's avatar
Patrick Colmant committed
304 305 306 307 308

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
        'LOCATION': '/var/tmp/django_cache',
Patrick's avatar
Patrick committed
309
        'TIMEOUT': 300,
Patrick Colmant's avatar
Patrick Colmant committed
310 311 312 313 314 315 316 317
        'OPTIONS': {
            'MAX_ENTRIES': 1000,
            'CULL_FREQUENCY': 3
        }
    }
}

CMS_CACHE_DURATIONS = {
318 319 320 321 322 323 324
    'content': 300,  # default 60
    'menus': 3600,  # default 3600
    'permissions': 3600  # default: 3600
}

SOUTH_MIGRATION_MODULES = {
    'easy_thumbnails': 'easy_thumbnails.south_migrations',
Patrick Colmant's avatar
Patrick Colmant committed
325
}
326 327 328 329 330 331 332 333
###################### EASYMAP
#EASY_MAPS_CENTER = ( 50.630545,3.776955 )

#INSTALLED_APPS += (
#    'easy_maps',
#)


Patrick's avatar
Patrick committed
334 335 336 337 338
# if DEBUG:
#     import logging
#     l = logging.getLogger('django.db.backends')
#     l.setLevel(logging.DEBUG)
#     l.addHandler(logging.StreamHandler())
339 340


Patrick's avatar
Patrick committed
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369
# LOGGING = {
#     'version': 1,
#     'disable_existing_loggers': False,
#     'filters': {
#         'require_debug_false': {
#             '()': 'django.utils.log.RequireDebugFalse'
#         }
#     },
#     'handlers': {
#         'mail_admins': {
#             'level': 'ERROR',
#             'filters': ['require_debug_false'],
#             'class': 'django.utils.log.AdminEmailHandler'
#         },'console': {
#             'level': 'DEBUG',
#             'class': 'logging.StreamHandler',
#         },
#     },
#     'loggers': {
#         'django.request': {
#             'handlers': ['mail_admins'],
#             'level': 'ERROR',
#             'propagate': True,
#         },'django.db.backends': {
#             'level': 'DEBUG',
#             'handlers': ['console'],
#         },
#     }
# }