common_settings.py 25.9 KB
Newer Older
Patrick Colmant's avatar
Patrick Colmant committed
1
# -*- coding: utf-8 -*-
Patrick's avatar
Patrick committed
2 3 4
import ConfigParser
import codecs
import logging
Patrick Colmant's avatar
Patrick Colmant committed
5 6
from settings import *

Patrick Colmant's avatar
Patrick Colmant committed
7
import os
Patrick's avatar
Patrick committed
8

Patrick Colmant's avatar
Patrick Colmant committed
9
gettext = lambda s: s
Patrick's avatar
Patrick committed
10 11 12

# os.path.realpath resolves symlinks and os.path.abspath doesn't.
PROJECT_PATH = os.path.split(os.path.realpath(os.path.dirname(__file__)))[0]
Patrick Colmant's avatar
Patrick Colmant committed
13
PROJECT_DIR = os.path.realpath(os.path.dirname(__file__))
Patrick's avatar
Patrick committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
os.sys.path.insert(0, PROJECT_PATH)
MEDIA_ROOT = os.path.join(PROJECT_DIR, "media", "public")
MEDIA_URL = "/media/"
STATIC_ROOT = os.path.join(PROJECT_DIR, "collect-static")
STATIC_URL = "/static/"
# STATICFILES_DIRS = (
#     os.path.join(PROJECT_PATH, "repanier", "static"),
# )

config = ConfigParser.RawConfigParser(allow_no_value=True)
conf_file_name = '%s/%s.ini' % (
            PROJECT_DIR,
            os.path.split(PROJECT_DIR)[-1]
)
try:
    # Open the file with the correct encoding
    with codecs.open(conf_file_name, 'r', encoding='utf-8') as f:
        config.readfp(f)
    DJANGO_SETTINGS_ADMIN_EMAIL = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_ADMIN_EMAIL')
    DJANGO_SETTINGS_ADMIN_NAME = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_ADMIN_NAME')
    DJANGO_SETTINGS_DATABASE_HOST = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_DATABASE_HOST')
    DJANGO_SETTINGS_DATABASE_NAME = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_DATABASE_NAME')
    DJANGO_SETTINGS_DATABASE_PASSWORD = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_DATABASE_PASSWORD')
    DJANGO_SETTINGS_DATABASE_PORT = config.getint('DJANGO_SETTINGS', 'DJANGO_SETTINGS_DATABASE_PORT')
    DJANGO_SETTINGS_DATABASE_USER = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_DATABASE_USER')
    DJANGO_SETTINGS_DEBUG = config.getboolean('DJANGO_SETTINGS', 'DJANGO_SETTINGS_DEBUG')
    DJANGO_SETTINGS_DEMO = config.getboolean('DJANGO_SETTINGS', 'DJANGO_SETTINGS_DEMO')
    DJANGO_SETTINGS_EMAIL_HOST = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_EMAIL_HOST')
    DJANGO_SETTINGS_EMAIL_HOST_PASSWORD = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_EMAIL_HOST_PASSWORD')
    DJANGO_SETTINGS_EMAIL_HOST_USER = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_EMAIL_HOST_USER')
    DJANGO_SETTINGS_EMAIL_PORT = config.getint('DJANGO_SETTINGS', 'DJANGO_SETTINGS_EMAIL_PORT')
    DJANGO_SETTINGS_EMAIL_USE_SSL = config.getboolean('DJANGO_SETTINGS', 'DJANGO_SETTINGS_EMAIL_USE_TLS')
    DJANGO_SETTINGS_EMAIL_USE_TLS = config.getboolean('DJANGO_SETTINGS', 'DJANGO_SETTINGS_EMAIL_USE_TLS')
    DJANGO_SETTINGS_ENV = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_ENV')
    DJANGO_SETTINGS_LANGUAGE = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_LANGUAGE')
    DJANGO_SETTINGS_LOGGING = config.getboolean('DJANGO_SETTINGS', 'DJANGO_SETTINGS_LOGGING')
    DJANGO_SETTINGS_SITE_NAME = os.path.split(PROJECT_DIR)[-1]
    DJANGO_SETTINGS_CACHE = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_CACHE')
    DJANGO_SETTINGS_SESSION = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_SESSION')
    DJANGO_SETTINGS_ALLOWED_HOSTS = []
    for name in config.options('ALLOWED_HOSTS'):
        DJANGO_SETTINGS_ALLOWED_HOSTS.append(config.get('ALLOWED_HOSTS', name))
    logging.info("Settings loaded from %s" % (conf_file_name,))
    print ("Settings loaded from %s" % (conf_file_name,))
    print(DJANGO_SETTINGS_ALLOWED_HOSTS)
except IOError:
    logging.exception("Unable to open %s settings" % (conf_file_name,))
    print ("Unable to open %s settings" % (conf_file_name,))
    raise SystemExit(-1)
Patrick Colmant's avatar
Patrick Colmant committed
63

Patrick Colmant's avatar
Patrick Colmant committed
64
###################### DEBUG
Patrick's avatar
Patrick committed
65

Patrick's avatar
Patrick committed
66
DEBUG = DJANGO_SETTINGS_DEBUG
Patrick Colmant's avatar
Patrick Colmant committed
67
DEBUG_PROPAGATE_EXCEPTIONS = DEBUG
Patrick's avatar
Patrick committed
68 69
ADMINS = (
    (
Patrick's avatar
Patrick committed
70 71
        DJANGO_SETTINGS_ADMIN_NAME,
        DJANGO_SETTINGS_ADMIN_EMAIL
Patrick's avatar
Patrick committed
72 73
    ),
)
Patrick's avatar
Patrick committed
74 75
SERVER_EMAIL = DJANGO_SETTINGS_ADMIN_EMAIL
######################
76 77 78

DATABASES = {
    'default': {
79 80
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
Patrick's avatar
Patrick committed
81
        'NAME': DJANGO_SETTINGS_DATABASE_NAME,  # Or path to database file if using sqlite3.
82
        # The following settings are not used with sqlite3:
Patrick's avatar
Patrick committed
83 84
        'USER': DJANGO_SETTINGS_DATABASE_USER,
        'PASSWORD': DJANGO_SETTINGS_DATABASE_PASSWORD,
85
        # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
Patrick's avatar
Patrick committed
86
        'HOST': DJANGO_SETTINGS_DATABASE_HOST,
87
        # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
Patrick's avatar
Patrick committed
88
        'PORT': DJANGO_SETTINGS_DATABASE_PORT,  # Set to empty string for default.
89 90
    }
}
Patrick's avatar
Patrick committed
91 92 93 94 95 96
EMAIL_HOST = DJANGO_SETTINGS_EMAIL_HOST
EMAIL_HOST_USER = DJANGO_SETTINGS_EMAIL_HOST_USER
EMAIL_HOST_PASSWORD = DJANGO_SETTINGS_EMAIL_HOST_PASSWORD
EMAIL_PORT = DJANGO_SETTINGS_EMAIL_PORT
EMAIL_USE_TLS = DJANGO_SETTINGS_EMAIL_USE_TLS
if EMAIL_USE_TLS:
Patrick Colmant's avatar
Patrick Colmant committed
97
    EMAIL_USE_SSL = False
Patrick's avatar
Patrick committed
98 99
else:
    EMAIL_USE_SSL =DJANGO_SETTINGS_EMAIL_USE_SSL
Patrick's avatar
Patrick committed
100 101
# if DEBUG:
#     EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
Patrick Colmant's avatar
Patrick Colmant committed
102 103 104
###################### I18N

TIME_ZONE = 'Europe/Brussels'
Patrick's avatar
Patrick committed
105 106 107 108 109 110 111
USE_TZ = True
# Before 22/02/2014 - DJANGO-CMS LANGUAGE_CODE = 'fr-BE'
USE_L10N = True
USE_THOUSAND_SEPARATOR = True
THOUSAND_SEPARATOR = '.'
NUMBER_GROUPING = 3
DECIMAL_SEPARATOR = ','
112
# 'fr-be'
Patrick Colmant's avatar
Patrick Colmant committed
113

Patrick's avatar
Patrick committed
114 115 116 117 118 119 120
SITE_ID = 1
ALLOWED_HOSTS = DJANGO_SETTINGS_ALLOWED_HOSTS
ROOT_URLCONF = '%s.urls' % (DJANGO_SETTINGS_SITE_NAME,)
WSGI_APPLICATION = '%s.wsgi.application' % (DJANGO_SETTINGS_SITE_NAME,)
EMAIL_SUBJECT_PREFIX = '[' + DJANGO_SETTINGS_ALLOWED_HOSTS[0] + ']'
# DEFAULT_FROM_EMAIL Used by PASSWORD RESET
DEFAULT_FROM_EMAIL = DJANGO_SETTINGS_ALLOWED_HOSTS[0] + "@repanier.be"
Patrick Colmant's avatar
Patrick Colmant committed
121

Patrick's avatar
Patrick committed
122 123 124 125 126 127
USE_X_FORWARDED_HOST = True
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SESSION_ENGINE = "django.contrib.sessions.backends.file"
SESSION_COOKIE_HTTPONLY = True
SESSION_FILE_PATH = DJANGO_SETTINGS_SESSION
# SOUTH_TESTS_MIGRATE = DEBUG
Patrick Colmant's avatar
Patrick Colmant committed
128

Patrick's avatar
Patrick committed
129
##################### Django & Django CMS
Patrick Colmant's avatar
Patrick Colmant committed
130 131 132 133
LOCALE_PATHS = (
    os.path.join(PROJECT_DIR, "locale"),
)

Patrick Colmant's avatar
Patrick Colmant committed
134 135 136 137 138 139 140 141
INSTALLED_APPS = (
    'django.contrib.sites',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sitemaps',
Patrick's avatar
Patrick committed
142 143
    'filer',
    'repanier', # ! Important : for template precedence Repanier must be first INSTALLED_APPS after django.contrib
Patrick Colmant's avatar
Patrick Colmant committed
144
    'djangocms_text_ckeditor',  # note this needs to be above the 'cms' entry
Patrick's avatar
Patrick committed
145 146 147
    'cmsplugin_cascade',
    'cmsplugin_cascade.extra_fields',  # optional
    'cmsplugin_cascade.sharable',  # optional
Patrick Colmant's avatar
Patrick Colmant committed
148 149 150 151 152 153 154 155
    'cms',
    "treebeard",
    'mptt',
    'menus',
    'djangocms_admin_style',  # note this needs to be above the 'django.contrib.admin' entry
    'django.contrib.admin',
    'django_mptt_admin',
    'easy_thumbnails',
Patrick's avatar
Patrick committed
156 157
    'easy_thumbnails.optimize',
    'sekizai',
Patrick Colmant's avatar
Patrick Colmant committed
158 159 160 161 162 163
    'cmsplugin_filer_file',
    'cmsplugin_filer_folder',
    'cmsplugin_filer_link',
    'cmsplugin_filer_image',
    'cmsplugin_filer_video',
    'reversion',
Patrick's avatar
Patrick committed
164
    'aldryn_reversion',
Patrick Colmant's avatar
Patrick Colmant committed
165
    'parler',
Patrick's avatar
Patrick committed
166 167
    'import_export',

Patrick Colmant's avatar
Patrick Colmant committed
168

Patrick's avatar
Patrick committed
169
    # 'aldryn_bootstrap3',
Patrick Colmant's avatar
Patrick Colmant committed
170 171
)

Patrick Colmant's avatar
Patrick Colmant committed
172 173 174
MIDDLEWARE_CLASSES = (
    'django.middleware.cache.UpdateCacheMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
Patrick's avatar
Patrick committed
175
    'django.middleware.csrf.CsrfViewMiddleware',
Patrick Colmant's avatar
Patrick Colmant committed
176
    'django.contrib.auth.middleware.AuthenticationMiddleware',
Patrick Colmant's avatar
Patrick Colmant committed
177 178
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.middleware.common.BrokenLinkEmailsMiddleware',
Patrick Colmant's avatar
Patrick Colmant committed
179
    'django.contrib.messages.middleware.MessageMiddleware',
Patrick Colmant's avatar
Patrick Colmant committed
180
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
Patrick Colmant's avatar
Patrick Colmant committed
181
    'django.middleware.locale.LocaleMiddleware',
Patrick's avatar
Patrick committed
182 183
    'django.middleware.common.CommonMiddleware',
    # 'django.middleware.doc.XViewMiddleware',
Patrick Colmant's avatar
Patrick Colmant committed
184
    'cms.middleware.user.CurrentUserMiddleware',
Patrick's avatar
Patrick committed
185
    'cms.middleware.page.CurrentPageMiddleware',
Patrick Colmant's avatar
Patrick Colmant committed
186
    'cms.middleware.toolbar.ToolbarMiddleware',
Patrick's avatar
Patrick committed
187
    'cms.middleware.language.LanguageCookieMiddleware',
Patrick's avatar
Cleanup  
Patrick committed
188
    'django.middleware.cache.FetchFromCacheMiddleware',
Patrick Colmant's avatar
Patrick Colmant committed
189
)
Patrick Colmant's avatar
Patrick Colmant committed
190

Patrick's avatar
Patrick committed
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
TEMPLATES = [
{
    'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [
        os.path.join(PROJECT_DIR, "templates"),
    ],
    'APP_DIRS': True,
    'OPTIONS': {
        'context_processors': [
            'django.contrib.auth.context_processors.auth',
            'django.template.context_processors.debug',
            'django.template.context_processors.i18n',
            'django.template.context_processors.media',
            'django.template.context_processors.static',
            'django.template.context_processors.tz',
            'django.template.context_processors.csrf',
            'django.template.context_processors.request',
            'django.contrib.messages.context_processors.messages',
            'cms.context_processors.cms_settings',
            'sekizai.context_processors.sekizai',
        ],
    }
},
]
Patrick Colmant's avatar
Patrick Colmant committed
215

Patrick Colmant's avatar
Patrick Colmant committed
216
MIGRATION_MODULES = {
Patrick's avatar
Patrick committed
217 218 219
    # 'cms': 'cms.migrations_django',
    # 'menus': 'menus.migrations_django',
    # 'filer': 'filer.migrations_django',
Patrick Colmant's avatar
Patrick Colmant committed
220 221 222 223 224 225 226 227
    'djangocms_text_ckeditor': 'djangocms_text_ckeditor.migrations_django',
    'cmsplugin_filer_file': 'cmsplugin_filer_file.migrations_django',
    'cmsplugin_filer_folder': 'cmsplugin_filer_folder.migrations_django',
    'cmsplugin_filer_link': 'cmsplugin_filer_link.migrations_django',
    'cmsplugin_filer_image': 'cmsplugin_filer_image.migrations_django',
    'cmsplugin_filer_video': 'cmsplugin_filer_video.migrations_django',
}

228
CMS_PERMISSION = False  # When set to True, don't forget 'cms.middleware.user.CurrentUserMiddleware'
Patrick Colmant's avatar
Patrick Colmant committed
229
CMS_PUBLIC_FOR = 'all'
Patrick Colmant's avatar
Patrick Colmant committed
230
# CMS_PUBLIC_FOR = 'staff'
Patrick Colmant's avatar
Patrick Colmant committed
231 232 233 234 235 236
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
237

Patrick's avatar
Patrick committed
238
CKEDITOR_SETTINGS = {
239
    'language': '{{ language }}',
Patrick Colmant's avatar
Patrick Colmant committed
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
    'toolbar_CMS': [
        ['Undo', 'Redo'],
        ['cmsplugins', '-', 'ShowBlocks'],
        ['Format', 'Templates'],
        ['TextColor', 'BGColor', '-', 'PasteText'],
        ['Maximize', ''],
        '/',
        ['Bold', 'Italic', 'Underline', '-', 'Subscript', 'Superscript', '-', 'RemoveFormat'],
        ['JustifyLeft', 'JustifyCenter', 'JustifyRight'],
        ['HorizontalRule'],
        ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Table'],
        ['Source']
    ],
    'toolbar_HTMLField': [
        ['Format', 'Bold', 'Italic', 'TextColor', '-', 'NumberedList', 'BulletedList', 'RemoveFormat'],
        ['Preview', 'Cut', 'Copy', 'PasteText', 'Link', '-', 'Undo', 'Redo'],
        ['Maximize', '']
    ],
    'forcePasteAsPlainText': 'true',
Patrick's avatar
Cleanup  
Patrick committed
259
    'skin': 'moono',
260 261
    # 'stylesSet' : 'my_styles:%sjs/ckeditor-styles.js' % STATIC_URL,
    # 'stylesSet' : [],
Patrick Colmant's avatar
Patrick Colmant committed
262 263
    # 'extraPlugins': 'cmsplugins',
    'format_tags': 'p;h4;h5;blockquote;mutted;success;info;danger;heart;pushpin',
264 265 266 267 268 269 270 271 272 273 274 275 276 277
    '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' : '*(*)',
Patrick Colmant's avatar
Patrick Colmant committed
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
    'removeFormatTags': 'big,code,del,dfn,em,font,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,u,var',
    'basicEntities': False,
    'entities': False,
    'removePlugins': 'elementspath',
}

CKEDITOR_SETTINGS_MODEL2 = {
    'language': '{{ language }}',
    'toolbar_HTMLField': [
        ['Format', 'Bold', 'Italic', 'TextColor', '-', 'NumberedList', 'BulletedList', 'RemoveFormat'],
        ['Preview', 'Cut', 'Copy', 'PasteText', 'Link', '-', 'Undo', 'Redo'],
        ['Maximize', '']
    ],
    'forcePasteAsPlainText': 'true',
    'skin': 'moono',
    'format_tags': 'p;h4;h5',
    'contentsCss': '%sbootstrap/css/bootstrap.css' % STATIC_URL,
    'removeFormatTags': 'big,code,del,dfn,em,font,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,u,var',
    'basicEntities': False,
    'entities': False,
    'removePlugins': 'elementspath',
Patrick's avatar
Patrick committed
299 300
}

Patrick's avatar
Cleanup  
Patrick committed
301
TEXT_ADDITIONAL_TAGS = ('span',)
Patrick Colmant's avatar
Patrick Colmant committed
302 303
TEXT_ADDITIONAL_ATTRIBUTES = ('class',)
TEXT_HTML_SANITIZE = True
Patrick's avatar
Cleanup  
Patrick committed
304 305 306
# 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
307
TEXT_PLUGINS_INTEGRATION = 'buttons'
Patrick Colmant's avatar
Patrick Colmant committed
308 309 310

FILER_ENABLE_LOGGING = False
FILER_IMAGE_USE_ICON = True
Patrick's avatar
Patrick committed
311 312
FILER_ALLOW_REGULAR_USERS_TO_ADD_ROOT_FOLDERS = True
FILER_ENABLE_PERMISSIONS = False
Patrick Colmant's avatar
Patrick Colmant committed
313 314
FILER_IS_PUBLIC_DEFAULT = True
FILER_SUBJECT_LOCATION_IMAGE_DEBUG = True
Patrick's avatar
Patrick committed
315
FILER_DUMP_PAYLOAD = True
Patrick Colmant's avatar
Patrick Colmant committed
316
FILER_DEBUG = False
Patrick Colmant's avatar
Patrick Colmant committed
317 318 319 320 321 322 323

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's avatar
Patrick committed
324
    'easy_thumbnails.processors.background',
Patrick Colmant's avatar
Patrick Colmant committed
325
)
Patrick Colmant's avatar
Patrick Colmant committed
326
THUMBNAIL_HIGH_RESOLUTION = True
Patrick's avatar
Patrick committed
327 328
THUMBNAIL_PROGRESSIVE = 100
THUMBNAIL_PRESERVE_EXTENSIONS = True
Patrick Colmant's avatar
Patrick Colmant committed
329

Patrick's avatar
Patrick committed
330 331 332 333 334 335
THUMBNAIL_OPTIMIZE_COMMAND = {
    'png': '/usr/bin/optipng {filename}',
    'gif': '/usr/bin/optipng {filename}',
    'jpeg': '/usr/bin/jpegoptim {filename}',
}
THUMBNAIL_DEBUG = FILER_DEBUG
Patrick Colmant's avatar
Patrick Colmant committed
336 337

##################### Repanier
338
AUTH_USER_MODEL = 'auth.User'
Patrick Colmant's avatar
Patrick Colmant committed
339
AUTHENTICATION_BACKENDS = ('repanier.auth_backend.RepanierCustomBackend',)
Patrick's avatar
Patrick committed
340
# ADMIN_LOGIN = 'pi'
341
# ADMIN_PASSWORD = 'raspberry'
Patrick's avatar
Patrick committed
342 343 344 345
# ! Important : for template precedence Repanier must be first INSTALLED_APPS
# INSTALLED_APPS = (
#     'repanier',
# ) + INSTALLED_APPS
Patrick Colmant's avatar
Patrick Colmant committed
346 347 348
LOGIN_URL = "/repanier/go_repanier/"
LOGIN_REDIRECT_URL = "/"
LOGOUT_URL = "/repanier/leave_repanier/"
Patrick Colmant's avatar
Patrick Colmant committed
349

Patrick Colmant's avatar
Patrick Colmant committed
350
################# Django_crispy_forms
Patrick Colmant's avatar
Patrick Colmant committed
351 352 353 354
INSTALLED_APPS += (
    'crispy_forms',
    # 'crispy_forms_foundation',
)
Patrick Colmant's avatar
Patrick Colmant committed
355

Patrick Colmant's avatar
Patrick Colmant committed
356 357
CRISPY_TEMPLATE_PACK = "bootstrap3"
# # CRISPY_TEMPLATE_PACK = "foundation"
Patrick's avatar
Cleanup  
Patrick committed
358
# JSON_MODULE = 'ujson'
Patrick Colmant's avatar
Patrick Colmant committed
359

Patrick Colmant's avatar
Patrick Colmant committed
360 361 362
################# Django_compressor
INSTALLED_APPS += (
    'compressor',
Patrick Colmant's avatar
Patrick Colmant committed
363
)
Patrick Colmant's avatar
Patrick Colmant committed
364 365 366 367
##### From : django/conf/global_settings.py
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
368
    #    'django.contrib.staticfiles.finders.DefaultStorageFinder',
Patrick Colmant's avatar
Patrick Colmant committed
369 370
)

Patrick Colmant's avatar
Patrick Colmant committed
371
STATICFILES_FINDERS += (
372
    'compressor.finders.CompressorFinder',
Patrick Colmant's avatar
Patrick Colmant committed
373 374
)

Patrick Colmant's avatar
Patrick Colmant committed
375 376 377 378 379 380 381 382 383
COMPRESS_ENABLED = True
COMPRESS_OUTPUT_DIR = "compressor"
COMPRESS_STORAGE = 'compressor.storage.GzipCompressorFileStorage'
COMPRESS_PARSER = "compressor.parser.HtmlParser"
COMPRESS_OFFLINE = False

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

CACHE_MIDDLEWARE_ALIAS = 'default'
Patrick's avatar
Patrick committed
384
CACHE_MIDDLEWARE_SECONDS = 3600
Patrick Colmant's avatar
Patrick Colmant committed
385

Patrick's avatar
Patrick committed
386 387 388 389 390 391 392 393 394 395 396
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
        'LOCATION': os.path.join(DJANGO_SETTINGS_CACHE, ALLOWED_HOSTS[0]),
        'TIMEOUT': 300,
        'OPTIONS': {
            'MAX_ENTRIES': 1000,
            'CULL_FREQUENCY': 3
        }
    }
}
Patrick Colmant's avatar
Patrick Colmant committed
397 398

CMS_CACHE_DURATIONS = {
399 400 401 402 403
    'content': 300,  # default 60
    'menus': 3600,  # default 3600
    'permissions': 3600  # default: 3600
}

Patrick Colmant's avatar
Patrick Colmant committed
404 405 406 407 408
##################### DECIMAL
from decimal import getcontext, ROUND_HALF_UP

getcontext().rounding = ROUND_HALF_UP

Patrick's avatar
Patrick committed
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456
##################### DJANGOCMS-CASCADE
CMSPLUGIN_CASCADE_PLUGINS = (
    'cmsplugin_cascade.bootstrap3',
    'cmsplugin_cascade.link',)
CMSPLUGIN_CASCADE_ALIEN_PLUGINS = ('TextPlugin', )

##################### DJANGO IMPORT EXPORT
IMPORT_EXPORT_USE_TRANSACTIONS = True
DATE_INPUT_FORMATS = ('%d-%m-%Y',)
DATETIME_INPUT_FORMATS = ("%d-%m-%Y %H:%M:%S",)

if DJANGO_SETTINGS_LOGGING:
    import logging
    l = logging.getLogger('django.db.backends')
    l.setLevel(logging.DEBUG)
    l.addHandler(logging.StreamHandler())


    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'],
            },
        }
    }

457

Patrick's avatar
Patrick committed
458 459 460 461 462
CMS_TEMPLATES = (
    ('cms_home.html', gettext("Homepage")),
    ('cms_page.html', gettext("Primary Page")),
    ('cms_subpage.html', gettext("Secondary Page")),
)
463

Patrick's avatar
Patrick committed
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717
if DJANGO_SETTINGS_LANGUAGE == 'fr':

    LANGUAGE_CODE = 'fr'
    LANGUAGES = [
        ('fr', u'Français'),
    ]
    CMS_LANGUAGES = {
        SITE_ID: [
            {
            'code': 'fr',
            'name': gettext('French'),
            'public': True,
            'hide_untranslated': False,
            },
        ]
    }
    PARLER_DEFAULT_LANGUAGE_CODE = LANGUAGE_CODE
    PARLER_LANGUAGES = {
        SITE_ID: (
            {'code': 'fr',},
        ),
    }

elif DJANGO_SETTINGS_LANGUAGE == 'fr-nl-en':

    LANGUAGE_CODE = 'fr'
    LANGUAGES = [
        ('fr', u'Français'),
        ('nl', u'Neederlands'),
        ('en', u'English'),
    ]
    CMS_LANGUAGES = {
        SITE_ID: [
            {
                'code': 'fr',
                'name': gettext('French'),
                'fallbacks': ['en', 'nl'],
                'public': True,
                'redirect_on_fallback':False,
                'hide_untranslated': False,
            },
            {
                'code': 'nl',
                'name': gettext('Dutch'),
                'fallbacks': ['en', 'fr'],
                'public': True,
            },
            {
                'code': 'en',
                'name': gettext('English'),
                'fallbacks': ['fr'],
                'public': True,
            },
        ]
    }
    PARLER_DEFAULT_LANGUAGE_CODE = LANGUAGE_CODE
    PARLER_LANGUAGES = {
        SITE_ID: (
            {'code': 'fr',},
            {'code': 'nl',},
            {'code': 'en',},
        ),
        'default': {
                'fallbacks': ['fr'],
                'hide_untranslated': False,
        },
    }

DJANGOCMS_CASCADE_COLUMN_GLOSSARY = {
    'breakpoints': ['xs', 'sm', 'md', 'lg'],
    'container_max_widths': {'xs': 750, 'sm': 750, 'md': 970, 'lg': 1170},
    'fluid': False,
    'media_queries': {
        'xs': ['(max-width: 768px)'],
        'sm': ['(min-width: 768px)', '(max-width: 992px)'],
        'md': ['(min-width: 992px)', '(max-width: 1200px)'],
        'lg': ['(min-width: 1200px)'],
    },
}

CMS_PLACEHOLDER_CONF = {
    'home-hero': {
        'name': gettext('Hero'),
        'plugins': [
            'TextPlugin',
        ],
        'text_only_plugins': [
            'FilerLinkPlugin', 'FilerImagePlugin', 'FilerFilePlugin', 'FilerVideoPlugin',
        ],
        'default_plugins': [
            {
                'plugin_type': 'TextPlugin',
                'values': {
                    'body':
                        """
                        <h3>Lorem ipsum</h3>
                        <p>Lorem ipsum.</p>
                        <p class="text-muted"><span class="glyphicon glyphicon-pushpin"></span>&nbsp;Lorem ipsum.</p>
                        <h3>Lorem ipsum</h3>
                        <p class="text-muted">Lorem ipsum.</p>
                        """
                },
            },
        ]
    },
    'home-col-1': {
        'name': gettext('Column 1'),
        'plugins': [
            'TextPlugin',
        ],
        'text_only_plugins': [
            'FilerLinkPlugin', 'FilerImagePlugin', 'FilerFilePlugin', 'FilerVideoPlugin',
        ],
        'default_plugins': [
            {
                'plugin_type': 'TextPlugin',
                'values': {
                    'body':
                        """
                        <div class="panel panel-info">
                        <div class="panel-heading"><h4>Lorem ipsum</h4></div>
                        <div class="panel-body">
                        <ul class="list-group">
                        <li class="list-group-item">Lorem ipsum.</li>
                        <li class="list-group-item">Lorem ipsum.</li>
                        </ul>
                        </div>
                        </div>
                        """
                },
            },
        ]
    },
    'home-col-2': {
        'name': gettext('Column 2'),
        'plugins': [
            'TextPlugin',
        ],
        'text_only_plugins': [
            'FilerLinkPlugin', 'FilerImagePlugin', 'FilerFilePlugin', 'FilerVideoPlugin',
        ],

        'default_plugins': [
            {
                'plugin_type': 'TextPlugin',
                'values': {
                    'body':
                        """
                        <div class="panel panel-danger">
                        <div class="panel-heading"><h4>Lorem ipsum</h4></div>
                        <div class="panel-body">
                        <ul class="list-group">
                        <li class="list-group-item">Lorem ipsum.</li>
                        <li class="list-group-item">Lorem ipsum.</li>
                        </ul>
                        </div>
                        </div>
                        """
                },
            },
        ]
    },
    'home-col-3': {
        'name': gettext('Column 3'),
        'plugins': [
            'TextPlugin',
        ],
        'text_only_plugins': [
            'FilerLinkPlugin', 'FilerImagePlugin', 'FilerFilePlugin', 'FilerVideoPlugin',
        ],
        'default_plugins': [
            {
                'plugin_type': 'TextPlugin',
                'values': {
                    'body':
                        """
                        <div class="panel panel-warning">
                        <div class="panel-heading"><h4>Lorem ipsum</h4></div>
                        <div class="panel-body">
                        <ul class="list-group">
                        <li class="list-group-item">Lorem ipsum.</li>
                        <li class="list-group-item">Lorem ipsum.</li>
                        </ul>
                        </div>
                        </div>
                        """
                },
            },
        ]
    },
    'subpage_content': {
        'name': gettext('Content'),
        'plugins': [
            'TextPlugin',
            'BootstrapRowPlugin',
            # Aldryn start
            # 'Bootstrap3BlockquoteCMSPlugin',
            # 'Bootstrap3IconCMSPlugin',
            # 'Bootstrap3LabelCMSPlugin',
            # 'Bootstrap3WellCMSPlugin',
            # 'Bootstrap3AlertCMSPlugin',
            # 'Bootstrap3ButtonCMSPlugin',
            # 'Bootstrap3ImageCMSPlugin',
            # 'Bootstrap3SpacerCMSPlugin',
            # 'Bootstrap3FileCMSPlugin',
            # 'Bootstrap3PanelCMSPlugin',
            # 'Bootstrap3RowCMSPlugin',
            # 'Bootstrap3AccordionCMSPlugin',
            # 'Bootstrap3ListGroupCMSPlugin',
            # 'Bootstrap3CarouselCMSPlugin',
            # Aldryn end

        ],
        'text_only_plugins': [
            'FilerLinkPlugin', 'FilerImagePlugin', 'FilerFilePlugin', 'FilerVideoPlugin',
        ],
        'parent_classes': {
            'BootstrapRowPlugin': [],
        },
        'require_parent': False,
        'glossary': DJANGOCMS_CASCADE_COLUMN_GLOSSARY,
        'default_plugins': [
            {
                'plugin_type': 'TextPlugin',
                'values': {
                    'body':
                        """
                        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed luctus tortor quis imperdiet egestas. Proin mollis sem ipsum, nec facilisis nibh cursus eu. Sed convallis cursus venenatis. Maecenas rutrum, elit ut ornare lobortis, mi dolor placerat elit, at laoreet sapien urna vitae arcu. Phasellus consectetur tincidunt ullamcorper. Sed et enim at lacus cursus rhoncus. Vestibulum porttitor velit non ante ullamcorper, ut gravida ipsum vestibulum. Aenean sed condimentum nisi. Quisque sagittis mauris non leo tincidunt vulputate. Ut euismod ante purus, sed pulvinar nisl volutpat quis. Maecenas consequat mi vitae libero egestas varius. Nam in tempor augue, sit amet pulvinar purus.</p>
                        <p>Vestibulum sed elit mollis, dapibus ligula in, ultricies purus. Proin fermentum blandit ultrices. Suspendisse vitae nisi mollis, viverra ipsum vitae, adipiscing lorem. Curabitur vestibulum orci felis, nec pretium arcu elementum a. Curabitur blandit fermentum tellus at consequat. Sed eget tempor elit. Donec in elit purus.</p>
                        <p>Morbi vulputate dolor sed nibh ullamcorper, eget molestie justo adipiscing. Fusce faucibus vel quam eu ultrices. Sed aliquet fringilla tristique. Vestibulum sit amet nunc tincidunt turpis tristique ullamcorper. Nam tempor mi felis, ac vulputate quam varius eget. Nunc blandit nulla vel metus lacinia, sit amet posuere lectus viverra. Praesent vel tortor facilisis, imperdiet orci sed, auctor erat.</p>
                        """
                },
            },
        ]
    },
    'footer': {
        'name': gettext('Footer'),
        'plugins': ['TextPlugin', ],
        'text_only_plugins': ['FilerLinkPlugin',],
        'limits': {
            'TextPlugin': 1,
        },
        'default_plugins': [
            {
                'plugin_type': 'TextPlugin',
                'values': {
                    'body':
                        'Lorem ipsum dolor sit amet'

                },
            },
        ]
    },
}