common_settings.py 12.5 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 86 87
LOCALE_PATHS = (
    os.path.join(PROJECT_DIR, "locale"),
)

MIDDLEWARE_CLASSES = (
    'django.middleware.cache.UpdateCacheMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
Patrick's avatar
Patrick committed
88
    'django.middleware.csrf.CsrfViewMiddleware',
Patrick Colmant's avatar
Patrick Colmant committed
89 90 91 92
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.doc.XViewMiddleware',
Patrick's avatar
Patrick committed
93
    'django.middleware.common.CommonMiddleware',
Patrick's avatar
Cleanup  
Patrick committed
94
    # 'cms.middleware.language.LanguageCookieMiddleware', Disable to avoid cookies advertising requirement
Patrick's avatar
Patrick committed
95
    'cms.middleware.user.CurrentUserMiddleware',
Patrick's avatar
Cleanup  
Patrick committed
96
    'cms.middleware.page.CurrentPageMiddleware',
Patrick Colmant's avatar
Patrick Colmant committed
97
    'cms.middleware.toolbar.ToolbarMiddleware',
Patrick's avatar
Cleanup  
Patrick committed
98
    'django.middleware.cache.FetchFromCacheMiddleware',
Patrick Colmant's avatar
Patrick Colmant committed
99
)
Patrick Colmant's avatar
Patrick Colmant committed
100 101 102

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
Patrick Colmant's avatar
Patrick Colmant committed
103
    'django.contrib.messages.context_processors.messages',
Patrick Colmant's avatar
Patrick Colmant committed
104 105 106 107
    '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
108 109
    'cms.context_processors.cms_settings',
    # 'cms.context_processors.media',
110
    'sekizai.context_processors.sekizai',
Patrick Colmant's avatar
Patrick Colmant committed
111
)
Patrick Colmant's avatar
Patrick Colmant committed
112 113 114 115 116 117 118 119 120 121

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
122
    'djangocms_text_ckeditor',  # note this needs to be above the 'cms' entry
Patrick Colmant's avatar
Patrick Colmant committed
123 124 125 126 127
    'cms',
    'mptt',
    'menus',
    'south',
    'sekizai',
128 129
    'djangocms_admin_style',  # note this needs to be above
    # the 'django.contrib.admin' entry
Patrick Colmant's avatar
Patrick Colmant committed
130
    'django.contrib.admin',
131
    'adminsortable',
Patrick's avatar
Patrick committed
132
    # 'hvad',
Patrick Colmant's avatar
Patrick Colmant committed
133 134
    'filer',
    'easy_thumbnails',
135

Patrick Colmant's avatar
Patrick Colmant committed
136 137 138 139
    'cmsplugin_filer_file',
    'cmsplugin_filer_folder',
    'cmsplugin_filer_image',
    'cmsplugin_filer_video',
140
    'cmsplugin_filer_link',
Patrick Colmant's avatar
Patrick Colmant committed
141
    'reversion',
Patrick's avatar
Patrick committed
142
    'password_reset',
143

144
)
Patrick Colmant's avatar
Patrick Colmant committed
145

146
CMS_PERMISSION = False  # When set to True, don't forget 'cms.middleware.user.CurrentUserMiddleware'
Patrick Colmant's avatar
Patrick Colmant committed
147 148 149 150 151 152 153
CMS_PUBLIC_FOR = 'all'
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
154
LOGIN_URL = "/go_repanier/"
Patrick Colmant's avatar
Patrick Colmant committed
155
LOGIN_REDIRECT_URL = "/"
Patrick's avatar
Patrick committed
156 157
LOGOUT_URL = "/leave_repanier/"

Patrick's avatar
Patrick committed
158
CKEDITOR_SETTINGS = {
159
    'language': '{{ language }}',
Patrick's avatar
Cleanup  
Patrick committed
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
	'toolbar_CMS': [
		['Undo', 'Redo'],
		['cmsplugins', '-', 'ShowBlocks'],
		 # ['Format', 'Styles'],
		['Format', 'Templates'],
		['TextColor', 'BGColor', '-', 'PasteText'], #, 'PasteFromWord'],
		['Maximize', ''],
		'/',
		['Bold', 'Italic', 'Underline', '-', 'Subscript', 'Superscript', '-', 'RemoveFormat'],
		['JustifyLeft', 'JustifyCenter', 'JustifyRight'],
		['HorizontalRule'],
		['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Table'],
		['Source']
	],
	'toolbar_HTMLField': [
		['Undo', 'Redo'],
		['ShowBlocks', 'Format'],
		['TextColor', 'BGColor', '-', 'PasteText'], #, 'PasteFromWord'],
		['Maximize', ''],
		'/',
		['Bold', 'Italic', 'Underline', '-', 'Subscript', 'Superscript', '-', 'RemoveFormat'],
		['JustifyLeft', 'JustifyCenter', 'JustifyRight'],
		['HorizontalRule'],
		['Link', 'Unlink'],
		['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Table'],
		['Source']
	],
    'skin': 'moono',
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
    # '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
207 208
}

Patrick's avatar
Cleanup  
Patrick committed
209 210 211 212 213 214
TEXT_ADDITIONAL_TAGS = ('span',)
TEXT_ADDITIONAL_ATTRIBUTES  = ('class',)
# TEXT_HTML_SANITIZE = False
# TEXT_SAVE_IMAGE_FUNCTION = 'cmsplugin_filer_image.integrations.ckeditor.create_image_plugin'
# TEXT_SAVE_IMAGE_FUNCTION = 'djangocms_text_ckeditor.picture_save.create_picture_plugin'
TEXT_SAVE_IMAGE_FUNCTION = None
Patrick Colmant's avatar
Patrick Colmant committed
215 216 217

FILER_ENABLE_LOGGING = False
FILER_IMAGE_USE_ICON = True
Patrick's avatar
Patrick committed
218 219
FILER_ALLOW_REGULAR_USERS_TO_ADD_ROOT_FOLDERS = True
FILER_ENABLE_PERMISSIONS = False
Patrick Colmant's avatar
Patrick Colmant committed
220 221 222 223 224 225 226 227 228 229
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
230
)
Patrick Colmant's avatar
Patrick Colmant committed
231 232
THUMBNAIL_DEBUG = DEBUG

233
# https://docs.djangoproject.com/en/1.5/howto/static-files/
Patrick Colmant's avatar
Patrick Colmant committed
234 235 236 237 238 239 240 241 242 243
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
244 245

##################### Repanier
246
AUTH_USER_MODEL = 'auth.User'
Patrick Colmant's avatar
Patrick Colmant committed
247
AUTHENTICATION_BACKENDS = ('repanier.auth_backend.RepanierCustomBackend',)
248 249
# ADMIN_LOGIN = 'pise'
# ADMIN_PASSWORD = 'raspberry'
Patrick Colmant's avatar
Patrick Colmant committed
250
INSTALLED_APPS += (
251
'repanier',
Patrick Colmant's avatar
Patrick Colmant committed
252 253 254
)


Patrick Colmant's avatar
Patrick Colmant committed
255
################# Django_crispy_forms
Patrick's avatar
Cleanup  
Patrick committed
256 257 258
# INSTALLED_APPS += (
#     'crispy_forms',
# )
Patrick Colmant's avatar
Patrick Colmant committed
259

Patrick's avatar
Cleanup  
Patrick committed
260 261
# CRISPY_TEMPLATE_PACK = "bootstrap3"
# JSON_MODULE = 'ujson'
Patrick Colmant's avatar
Patrick Colmant committed
262

Patrick Colmant's avatar
Patrick Colmant committed
263 264 265
################# Django_compressor
INSTALLED_APPS += (
    'compressor',
Patrick Colmant's avatar
Patrick Colmant committed
266
)
Patrick Colmant's avatar
Patrick Colmant committed
267 268 269 270
##### From : django/conf/global_settings.py
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
271
    #    'django.contrib.staticfiles.finders.DefaultStorageFinder',
Patrick Colmant's avatar
Patrick Colmant committed
272 273
)

Patrick Colmant's avatar
Patrick Colmant committed
274
STATICFILES_FINDERS += (
275
    'compressor.finders.CompressorFinder',
Patrick Colmant's avatar
Patrick Colmant committed
276 277
)

Patrick Colmant's avatar
Patrick Colmant committed
278 279 280 281 282 283
COMPRESS_ENABLED = True
COMPRESS_OUTPUT_DIR = "compressor"
COMPRESS_STORAGE = 'compressor.storage.GzipCompressorFileStorage'
COMPRESS_PARSER = "compressor.parser.HtmlParser"
COMPRESS_OFFLINE = False

284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
# 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
308 309 310 311

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

CACHE_MIDDLEWARE_ALIAS = 'default'
Patrick's avatar
Patrick committed
312
CACHE_MIDDLEWARE_SECONDS = 3600
Patrick Colmant's avatar
Patrick Colmant committed
313 314 315 316 317

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
        'LOCATION': '/var/tmp/django_cache',
Patrick's avatar
Patrick committed
318
        'TIMEOUT': 300,
Patrick Colmant's avatar
Patrick Colmant committed
319 320 321 322 323 324 325 326
        'OPTIONS': {
            'MAX_ENTRIES': 1000,
            'CULL_FREQUENCY': 3
        }
    }
}

CMS_CACHE_DURATIONS = {
327 328 329 330
    'content': 300,  # default 60
    'menus': 3600,  # default 3600
    'permissions': 3600  # default: 3600
}
Patrick's avatar
Cleanup  
Patrick committed
331 332 333
CMS_PAGE_CACHE = True
CMS_PLACEHOLDER_CACHE = True
CMS_PLUGIN_CACHE = True
334 335 336

SOUTH_MIGRATION_MODULES = {
    'easy_thumbnails': 'easy_thumbnails.south_migrations',
Patrick Colmant's avatar
Patrick Colmant committed
337
}
338 339 340 341 342 343 344 345
###################### EASYMAP
#EASY_MAPS_CENTER = ( 50.630545,3.776955 )

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


Patrick's avatar
Patrick committed
346 347 348 349 350
# if DEBUG:
#     import logging
#     l = logging.getLogger('django.db.backends')
#     l.setLevel(logging.DEBUG)
#     l.addHandler(logging.StreamHandler())
351 352


Patrick's avatar
Patrick committed
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
# 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'],
#         },
#     }
# }