common_settings.py 12.2 KB
Newer Older
Patrick Colmant's avatar
Patrick Colmant committed
1 2 3 4
# -*- coding: utf-8 -*-
from settings import *

import os
Patrick Colmant's avatar
Patrick Colmant committed
5
import sys
Patrick Colmant's avatar
Patrick Colmant committed
6
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

Patrick's avatar
Patrick committed
11 12 13 14 15 16 17 18 19 20 21
###################### DEBUG

# Defined into /etc/uwsgi/apps-available/*.ini
DEBUG = True if os.getenv('DJANGO_SETTINGS_MODULE_DEBUG','') == 'True' else False
TEMPLATE_DEBUG = DEBUG
ADMINS = (
    (
        os.getenv('DJANGO_SETTINGS_MODULE_ADMIN_NAME',''), 
        os.getenv('DJANGO_SETTINGS_MODULE_ADMIN_EMAIL','')
    ),
)
Patrick's avatar
Patrick committed
22 23 24 25 26 27 28
SERVER_EMAIL = os.getenv('DJANGO_SETTINGS_MODULE_ADMIN_EMAIL','')
# MANAGERS = (
#     (
#         os.getenv('DJANGO_SETTINGS_MODULE_ADMIN_NAME',''), 
#         os.getenv('DJANGO_SETTINGS_MODULE_ADMIN_EMAIL','')
#     ),
# )
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
###################### 

DATABASES = {
    'default': {
        '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.
        # The following settings are not used with sqlite3:
        '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',''),  # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
        'PORT': os.getenv('DJANGO_SETTINGS_MODULE_DATABASE_PORT',''),                      # Set to empty string for default.
    }
}
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
48 49
# if DEBUG:
#     EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
Patrick Colmant's avatar
Patrick Colmant committed
50 51 52
###################### I18N

TIME_ZONE = 'Europe/Brussels'
Patrick's avatar
Patrick committed
53 54 55 56 57 58 59 60
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 = ','
61
# 'fr-be'
Patrick Colmant's avatar
Patrick Colmant committed
62 63 64 65 66 67 68 69 70

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

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

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

MIDDLEWARE_CLASSES = (
Patrick's avatar
Patrick committed
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
    # '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
100 101
    'django.middleware.cache.UpdateCacheMiddleware',
    'django.middleware.cache.FetchFromCacheMiddleware',
Patrick's avatar
Patrick committed
102

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

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
Patrick Colmant's avatar
Patrick Colmant committed
118
    'django.contrib.messages.context_processors.messages',
Patrick Colmant's avatar
Patrick Colmant committed
119 120 121 122
    '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
123 124
    'cms.context_processors.cms_settings',
    # 'cms.context_processors.media',
Patrick Colmant's avatar
Patrick Colmant committed
125
    'sekizai.context_processors.sekizai',  
Patrick Colmant's avatar
Patrick Colmant committed
126
)
Patrick Colmant's avatar
Patrick Colmant committed
127 128 129 130 131 132 133 134 135 136

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
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154

    # 'cms.plugins.file',
    # 'cms.plugins.flash',
    # 'cms.plugins.googlemap',
    # 'cms.plugins.picture',
    # 'cms.plugins.teaser',
    # 'djangocms_link',
    # 'djangocms_snippet',
    # 'djangocms_style',
    # 'djangocms_column',
    # # 'djangocms_grid',
    # 'djangocms_oembed',
    # 'djangocms_table',
    # 'djangocms_googlemap',
    # 'djangocms_accordion',
    'djangocms_text_ckeditor',  # note this needs to be above the 'cms' entry
    # 'cms.plugins.video',

Patrick Colmant's avatar
Patrick Colmant committed
155 156 157 158 159 160 161 162
    'cms',
    'mptt',
    'menus',
    'south',
    'sekizai',
    'djangocms_admin_style', # note this needs to be above 
                            # the 'django.contrib.admin' entry
    'django.contrib.admin',
163
    'adminsortable',
Patrick's avatar
Patrick committed
164
    # 'hvad',
Patrick Colmant's avatar
Patrick Colmant committed
165 166 167 168 169 170 171
    'filer',
    'easy_thumbnails',
    'cmsplugin_filer_file',
    'cmsplugin_filer_folder',
    'cmsplugin_filer_image',
    'cmsplugin_filer_video',
    'reversion',
Patrick's avatar
Patrick committed
172
    'password_reset',
173 174

    # 'wkhtmltopdf', # --> PDF
Patrick Colmant's avatar
Patrick Colmant committed
175 176
) 

177
# WKHTMLTOPDF_CMD = '/usr/bin/wkhtmltopdf.sh' # --> PDF
Patrick Colmant's avatar
Patrick Colmant committed
178 179
CMS_PERMISSION = False # When set to True, don't forget 'cms.middleware.user.CurrentUserMiddleware' 
CMS_PUBLIC_FOR = 'all'
180
# CMS_PUBLIC_FOR = 'staff'
Patrick Colmant's avatar
Patrick Colmant committed
181 182 183 184 185 186
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
187
LOGIN_URL = "/go_repanier/"
Patrick Colmant's avatar
Patrick Colmant committed
188
LOGIN_REDIRECT_URL = "/"
Patrick's avatar
Patrick committed
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
LOGOUT_URL = "/leave_repanier/"


# CKEDITOR_SETTINGS = {
#         'language': '{{ language }}',
#         'toolbar': 'HTMLField',
#         'skin': 'moono',
#         'toolbarCanCollapse' : False,
# #        'stylesSet' : 'default:%sckeditor/styles.js' % STATIC_URL,
#         # 'stylesSet' : 'my_styles:%sjs/ckeditor-styles.js' % STATIC_URL,
#         'stylesSet' : [],
#         'extraPlugins' : 'stylesheetparser',
#         'contentsCss' : '%sjs/bootstrap.css',
#         'autoGrow_onStartup' :  True,
# #        'height' : '450px',
#         'emailProtection' : '2',
#         'toolbar_CMS2': [
#                 ['Undo', 'Redo'],
#                 ['cmsplugins'],
#                 # ['Format', '-','TextColor', 'BGColor', '-', 'Bold', 'Italic', 'Underline', '-', 
#                 # ['Styles', '-','TextColor', 'Bold', 'Italic', '-', 'RemoveFormat', 'PasteText'],
#                 ['-','TextColor', 'Bold', 'Italic', '-', 'RemoveFormat', 'PasteText'],
#                 ['JustifyLeft', 'JustifyCenter', 'JustifyRight'],
#                 ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Table'],
#                 ['Source'],['Maximize', '-', 'ShowBlocks'],
#         ],
# }
Patrick Colmant's avatar
Patrick Colmant committed
216

Patrick's avatar
Patrick committed
217 218 219 220 221
CKEDITOR_SETTINGS = {
        'language': '{{ language }}',
        'toolbar': 'HTMLField',
}

Patrick Colmant's avatar
Patrick Colmant committed
222 223 224 225
TEXT_SAVE_IMAGE_FUNCTION='cmsplugin_filer_image.integrations.ckeditor.create_image_plugin'

FILER_ENABLE_LOGGING = False
FILER_IMAGE_USE_ICON = True
Patrick's avatar
Patrick committed
226 227
FILER_ALLOW_REGULAR_USERS_TO_ADD_ROOT_FOLDERS = True
FILER_ENABLE_PERMISSIONS = False
Patrick Colmant's avatar
Patrick Colmant committed
228 229 230 231 232 233 234 235 236 237
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
238
)
Patrick Colmant's avatar
Patrick Colmant committed
239 240
THUMBNAIL_DEBUG = DEBUG

241
# https://docs.djangoproject.com/en/1.5/howto/static-files/
Patrick Colmant's avatar
Patrick Colmant committed
242 243 244 245 246 247 248 249 250 251
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
252 253 254

##################### Repanier
AUTHENTICATION_BACKENDS = ('repanier.auth_backend.RepanierCustomBackend',)
255 256
# ADMIN_LOGIN = 'pise'
# ADMIN_PASSWORD = 'raspberry'
Patrick Colmant's avatar
Patrick Colmant committed
257 258 259 260 261
INSTALLED_APPS += (
	'repanier',
)


Patrick Colmant's avatar
Patrick Colmant committed
262 263 264
################# Django_crispy_forms
INSTALLED_APPS += (
    'crispy_forms',
Patrick's avatar
Patrick committed
265
    # 'crispy_forms_foundation',
Patrick Colmant's avatar
Patrick Colmant committed
266 267
)

Patrick's avatar
Patrick committed
268 269
CRISPY_TEMPLATE_PACK = "bootstrap3"
# CRISPY_TEMPLATE_PACK = "foundation"
Patrick Colmant's avatar
Patrick Colmant committed
270
JSON_MODULE = 'ujson'
Patrick Colmant's avatar
Patrick Colmant committed
271

Patrick Colmant's avatar
Patrick Colmant committed
272 273 274
################# Django_compressor
INSTALLED_APPS += (
    'compressor',
Patrick Colmant's avatar
Patrick Colmant committed
275
)
Patrick Colmant's avatar
Patrick Colmant committed
276 277 278 279 280
##### From : django/conf/global_settings.py
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
Patrick Colmant's avatar
Patrick Colmant committed
281 282
)

Patrick Colmant's avatar
Patrick Colmant committed
283 284
STATICFILES_FINDERS += (
     'compressor.finders.CompressorFinder',
Patrick Colmant's avatar
Patrick Colmant committed
285 286
)

Patrick Colmant's avatar
Patrick Colmant committed
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
COMPRESS_ENABLED = True
COMPRESS_OUTPUT_DIR = "compressor"
COMPRESS_STORAGE = 'compressor.storage.GzipCompressorFileStorage'
COMPRESS_PARSER = "compressor.parser.HtmlParser"
COMPRESS_OFFLINE = False

    # 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}'),
    # )

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

CACHE_MIDDLEWARE_ALIAS = 'default'
Patrick's avatar
Patrick committed
321
CACHE_MIDDLEWARE_SECONDS = 3600
Patrick Colmant's avatar
Patrick Colmant committed
322 323 324 325 326

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
        'LOCATION': '/var/tmp/django_cache',
Patrick's avatar
Patrick committed
327
        'TIMEOUT': 300,
Patrick Colmant's avatar
Patrick Colmant committed
328 329 330 331 332 333 334 335 336
        'OPTIONS': {
            'MAX_ENTRIES': 1000,
            'CULL_FREQUENCY': 3
        }
    }
}

CMS_CACHE_DURATIONS = {
    'content' : 300, # default 60
Patrick's avatar
Patrick committed
337
    'menus' : 3600, # default 3600
Patrick Colmant's avatar
Patrick Colmant committed
338 339
    'permissions' : 3600 # default: 3600
}
340 341 342 343 344 345 346 347
###################### EASYMAP
#EASY_MAPS_CENTER = ( 50.630545,3.776955 )

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


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


Patrick's avatar
Patrick committed
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 382 383
# 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'],
#         },
#     }
# }