src/iconolab_mcc/settings/dev.py.tmpl
author Riwad Salim
Wed, 23 May 2018 12:42:37 +0200
changeset 1 309def3c05dc
parent 0 c21813f95c41
child 2 48b9b57dfbaa
permissions -rw-r--r--
Adding specific items to iconolab-mcc project interface

"""
Django settings for iconolab project.

Generated by 'django-admin startproject' using Django 1.9.5.

For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""
import logging
import os

from iconolab_mcc.settings import *

CONTACT_EMAIL = 'youremail@yourprovider.fr'

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

STATIC_ROOT = os.path.join(BASE_DIR, '../../web/static/site')
MEDIA_ROOT = os.path.join(BASE_DIR, '../../web/media')

# dev_mode useful for src_js
# We need to add 'iconolab.utils.context_processors.env' to context processor

# When JS_DEV_MODE is True, the Webpack dev server should be started
JS_DEV_MODE = False
# STATICFILES_DIRS = [
#     os.path.join(BASE_DIR, 'static'),
#     os.path.join(BASE_DIR, 'media'),
# ]

if JS_DEV_MODE:
    SRC_JS_PATH = os.path.join(BASE_DIR, '..', '..', 'src_js')
    STATICFILES_DIRS.append(SRC_JS_PATH)


BASE_URL = 'http://localhost:8000'
if JS_DEV_MODE:
    STATIC_URL = 'http://localhost:8001/static/'
else:
    STATIC_URL = '/static/'
MEDIA_URL = '/media/'

LOGIN_URL = '/account/login/'

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '#8)+upuo3vc7fi15czxz53ml7*(1__q8hg=m&+9ylq&st1_kqv'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
THUMBNAIL_DEBUG = True

ALLOWED_HOSTS = []


# Application definition


COMMENTS_APP = "django_comments_xtd"
COMMENTS_XTD_MODEL = "iconolab.models.IconolabComment"
COMMENTS_XTD_FORM_CLASS = 'iconolab.forms.comments.IconolabCommentForm'
COMMENTS_XTD_MAX_THREAD_LEVEL = 1
COMMENTS_PER_PAGE_DEFAULT = 10

SITE_ID = 1

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR,'iconolab_mcc','templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'django.template.context_processors.media',
                'django.template.context_processors.static',
                'django.template.context_processors.i18n',
                'iconolab.utils.context_processors.env',
            ],
        },
    },
]

WSGI_APPLICATION = 'iconolab.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': '',                      # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}

# Logging

LOG_FILE = os.path.abspath(os.path.join(BASE_DIR,"../../run/log/log.txt"))
IMPORT_LOG_FILE = os.path.abspath(os.path.join(BASE_DIR,"../../run/log/import_log.txt"))
IMPORT_LOGGER_NAME = "import_command"
LOG_LEVEL = logging.DEBUG
LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'formatters' : {
        'simple' : {
            'format': "%(asctime)s - %(levelname)s : %(message)s",
        },
        'semi-verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(message)s'
        },
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        },
        'stream_to_console': {
            'level': LOG_LEVEL,
            'class': 'logging.StreamHandler'
        },
        'file': {
            'level': LOG_LEVEL,
            'class': 'logging.FileHandler',
            'filename': LOG_FILE,
            'formatter': 'semi-verbose',
        },
        'import_file': {
            'level': LOG_LEVEL,
            'class': 'logging.FileHandler',
            'filename': IMPORT_LOG_FILE,
            'formatter': 'semi-verbose',
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['file'],
            'level': LOG_LEVEL,
            'propagate': True,
        },
        'iconolab': {
            'handlers': ['file'],
            'level': LOG_LEVEL,
            'propagate': True,
        },
        'import_command': {
            'handlers': ['import_file'],
            'level': LOG_LEVEL,
            'propagate': True,
        },
    }
}

# Haystack configuration

# Haystack only supports ElasticSearch 1.x
# http://django-haystack.readthedocs.io/en/v2.5.1/installing_search_engines.html#elasticsearch

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
        'URL': 'http://127.0.0.1:9200/',
        'INDEX_NAME': 'haystack',
    },
}

# HAYSTACK_SIGNAL_PROCESSOR = 'iconolab.search_indexes.signals.RevisionSignalProcessor'

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
        'LOCATION': os.path.join(MEDIA_ROOT, 'cache'),
#        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
#        'LOCATION': 'unix:/var/run/memcached/memcached.socket',
#        'KEY_PREFIX': 'ldt',
    }
}
# Password validation
# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/1.9/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


IMPORT_FIELDS_DICT = {
    "AUTR": [],
    "ECOLE": [],
    "TITR": ["Titre"],
    "DENO": [],
    "DOM": ["Domaine"],
    "APPL": [],
    "PERI": ["Période"],
    "MILL": [],
    "TECH": [],
    "DIMS": ["Dimensions"],
    "EPOQ": [],
    "LIEUX": [],
    "DECV": [],
    "LOCA": ["Localisation"],
    "PHOT": ["Photo"],
    "INV": ["No inventaire",],
    "REF": ["REFERENCE"],
}

INTERNAL_TAGS_URL = BASE_URL
JOCONDE_NOTICE_BASE_URL = "http://www.culture.gouv.fr/public/mistral/joconde_fr?ACTION=CHERCHER&FIELD_98=REF&VALUE_98="

RELEVANT_TAGS_MIN_SCORE = 3
ACCURATE_TAGS_MIN_SCORE = 3