Newer
Older
"""
Django settings for SciPost_v1 project.
Generated by 'django-admin startproject' using Django 1.8.5.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
import json
from django.utils.translation import ugettext_lazy as _
from django.core.exceptions import ImproperlyConfigured
from django.contrib.messages import constants as message_constants
# Build paths inside the project
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
PROJECT_ROOT = os.path.dirname(BASE_DIR)
# JSON-based secrets
secrets = json.load(open(os.path.join(BASE_DIR, "secrets.json")))
def get_secret(setting, secrets=secrets):
"""Get the secret variable or return explicit exception."""
try:
return secrets[setting]
except KeyError:
error_msg = "Set the {0} environment variable".format(setting)
raise ImproperlyConfigured(error_msg)
SECRET_KEY = get_secret("SECRET_KEY")
CERTFILE = ''
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['localhost', '127.0.0.1']
# Secure proxy SSL header and secure cookies
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SESSION_COOKIE_SECURE = False
CSRF_COOKIE_SECURE = False

Jean-Sébastien Caux
committed
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',

Jean-Sébastien Caux
committed
'guardian.backends.ObjectPermissionBackend'
)
LOGIN_URL = '/login/'
GUARDIAN_RENDER_403 = True
# Session expire at browser close
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
os.environ['wsgi.url_scheme'] = 'https'
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

Jean-Sébastien Caux
committed
'django_countries',
Boris Ponsioen
committed
'affiliations',
Boris Ponsioen
committed
'background_task',
'commentaries',
'comments',
Boris Ponsioen
committed
'django_celery_results',
Boris Ponsioen
committed
'funders',
'guardian',
'haystack',
Boris Ponsioen
committed
'mails',
'metacore',
Boris Ponsioen
committed
'partners',
'petitions',
'proceedings',
'production',
'rest_framework',
Boris Ponsioen
committed
'sphinxdoc',
'stats',
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
'EXCLUDED_INDEXES': ['sphinxdoc.search_indexes.DocumentIndex'],
# Brute force automatically re-index Haystack using post_save signals on all models.
# When write-traffic increases, a custom processor is preferred which only connects
# signals to eg. `vet-accepted` signals possibly using cron jobs instead of realtime updates.
HAYSTACK_SIGNAL_PROCESSOR = 'SciPost_v1.signalprocessors.AutoSearchIndexingProcessor'
SPHINXDOC_BASE_TEMPLATE = 'scipost/base.html'
SPHINXDOC_PROTECTED_PROJECTS = {
'codebase': ['scipost.can_view_docs_scipost'],
'users': ['scipost.can_view_docs_scipost'],
CAPTCHA_CHALLENGE_FUNCT = 'captcha.helpers.math_challenge'
CAPTCHA_LETTER_ROTATION = (-15, 15)
CAPTCHA_NOISE_FUNCTIONS = ('captcha.helpers.noise_dots',)
SHELL_PLUS_POST_IMPORTS = (
('theses.factories', ('ThesisLinkFactory')),
('comments.factories', ('CommentFactory')),
('submissions.factories', ('SubmissionFactory', 'EICassignedSubmissionFactory')),
('commentaries.factories',
('EmptyCommentaryFactory',
('scipost.factories', ('ContributorFactory')),
MATHJAX_ENABLED = True
MATHJAX_CONFIG_DATA = {
"tex2jax": {
"inlineMath": [['$', '$'], ['\\(', '\\)']],
"processEscapes": True
}
}
# 'django.middleware.http.ConditionalGetMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)
ROOT_URLCONF = 'SciPost_v1.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'SciPost_v1.wsgi.application'
# Messages
MESSAGE_TAGS = {
message_constants.DEBUG: 'debug',
message_constants.INFO: 'info',
message_constants.SUCCESS: 'success',
message_constants.WARNING: 'warning',
message_constants.ERROR: 'danger',
}
# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': get_secret("DB_NAME"),
'USER': get_secret("DB_USER"),
'PASSWORD': get_secret("DB_PWD"),
'HOST': '127.0.0.1',
MONGO_DATABASE = {
'database': 'scipost',
'host': 'localhost',
'user': '',
'password': '',
'port': '27017',
}
# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
LANGUAGE_CODE = 'en-us'
LANGUAGES = (
('en', _('English')),
)
LOCALE_PATHS = (
os.path.join(BASE_DIR, 'locale'),
)
TIME_ZONE = 'CET'
USE_I18N = True
USE_TZ = True
MEDIA_URL_SECURE = '/files/secure/'
MAX_UPLOAD_SIZE = "1310720" # Default max attachment size in Bytes
# -- These MEDIA settings are machine-dependent
MEDIA_ROOT = 'local_files/media/'
MEDIA_ROOT_SECURE = 'local_files/secure/media/'
# Static files (CSS, JavaScript, Images)
STATIC_URL = '/static/'
STATIC_ROOT = 'local_files/static/'
)
# Webpack handling the static bundles
WEBPACK_LOADER = {
'DEFAULT': {
'CACHE': not DEBUG,
'BUNDLE_DIR_NAME': 'local_files/static/bundles/',
'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json'),
'POLL_INTERVAL': 0.1,
'TIMEOUT': None,
'IGNORE': ['.+\.hot-update.js', '.+\.map']
}
}
EMAIL_BACKEND = 'mails.backends.filebased.EmailBackend'
EMAIL_FILE_PATH = 'local_files/email/'
MAILCHIMP_DATABASE_CODE = 'us6'
MAILCHIMP_API_USER = 'test_API-user'
# iThenticate
ITHENTICATE_USERNAME = 'test_ithenticate_username'
ITHENTICATE_PASSWORD = 'test_ithenticate_password'
JOURNALS_DIR = 'journals'
CROSSREF_LOGIN_ID = ''
CROSSREF_LOGIN_PASSWORD = ''
CROSSREF_DEPOSIT_EMAIL = 'techsupport@scipost.org'
# Google reCaptcha with Google's global test keys
# https://developers.google.com/recaptcha/docs/faq#id-like-to-run-automated-tests-with-recaptcha-v2-what-should-i-do
RECAPTCHA_PUBLIC_KEY = '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'
RECAPTCHA_PRIVATE_KEY = '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
# PASSWORDS
PASSWORD_HASHERS = [
'django.contrib.auth.hashers.Argon2PasswordHasher',
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
'django.contrib.auth.hashers.BCryptPasswordHasher',
]
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
'OPTIONS': {
'min_length': 8,
}
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
CSRF_FAILURE_VIEW = 'scipost.views.csrf_failure'
331
332
333
334
335
336
337
338
339
340
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
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '[%(asctime)s] %(levelname)s | %(message)s'
},
},
'handlers': {
'scipost_file_arxiv': {
'level': 'INFO',
'class': 'logging.FileHandler',
'filename': '/path/to/logs/arxiv.log',
'formatter': 'verbose',
},
'scipost_file_doi': {
'level': 'INFO',
'class': 'logging.FileHandler',
'filename': '/path/to/logs/doi.log',
'formatter': 'verbose',
},
},
'loggers': {
'scipost.services.arxiv': {
'handlers': ['scipost_file_arxiv'],
'level': 'INFO',
'propagate': True,
'formatter': 'simple',
},
'scipost.services.doi': {
'handlers': ['scipost_file_doi'],
'level': 'INFO',
'propagate': True,
'formatter': 'simple',
},
},
}
Boris Ponsioen
committed
# Celery extra config
CELERY_RESULT_BACKEND = 'django-db'
CELERY_BROKER_URL = 'amqp://localhost'