Changeset View
Changeset View
Standalone View
Standalone View
swh/web/settings/common.py
# Copyright (C) 2017-2019 The Software Heritage developers | # Copyright (C) 2017-2019 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU Affero General Public License version 3, or any later version | # License: GNU Affero General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
""" | """ | ||||
Django common settings for swh-web. | Django common settings for swh-web. | ||||
""" | """ | ||||
import os | import os | ||||
import sys | |||||
from swh.web.config import get_config | from swh.web.config import get_config | ||||
swh_web_config = get_config() | swh_web_config = get_config() | ||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) | ||||
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__)) | PROJECT_DIR = os.path.dirname(os.path.abspath(__file__)) | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | |||||
USE_L10N = True | USE_L10N = True | ||||
USE_TZ = True | USE_TZ = True | ||||
# Static files (CSS, JavaScript, Images) | # Static files (CSS, JavaScript, Images) | ||||
# https://docs.djangoproject.com/en/1.11/howto/static-files/ | # https://docs.djangoproject.com/en/1.11/howto/static-files/ | ||||
STATIC_URL = '/static/' | STATIC_URL = '/static/' | ||||
STATICFILES_DIRS = [ | # static folder location when swh-web has been installed with pip | ||||
os.path.join(PROJECT_DIR, "../static") | STATIC_DIR = os.path.join(sys.prefix, 'share/swh/web/static') | ||||
] | if not os.path.exists(STATIC_DIR): | ||||
# static folder location when developping swh-web | |||||
STATIC_DIR = os.path.join(PROJECT_DIR, '../../../static') | |||||
STATICFILES_DIRS = [STATIC_DIR] | |||||
INTERNAL_IPS = ['127.0.0.1'] | INTERNAL_IPS = ['127.0.0.1'] | ||||
throttle_rates = {} | throttle_rates = {} | ||||
http_requests = ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'PATCH'] | http_requests = ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'PATCH'] | ||||
throttling = swh_web_config['throttling'] | throttling = swh_web_config['throttling'] | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | 'loggers': { | ||||
}, | }, | ||||
'django.db.backends': { | 'django.db.backends': { | ||||
'handlers': ['null'], | 'handlers': ['null'], | ||||
'propagate': False | 'propagate': False | ||||
}, | }, | ||||
}, | }, | ||||
} | } | ||||
WEBPACK_LOADER = { # noqa | WEBPACK_LOADER = { | ||||
'DEFAULT': { | 'DEFAULT': { | ||||
'CACHE': False, | 'CACHE': False, | ||||
'BUNDLE_DIR_NAME': './', | 'BUNDLE_DIR_NAME': './', | ||||
'STATS_FILE': os.path.join(PROJECT_DIR, '../static/webpack-stats.json'), # noqa | 'STATS_FILE': os.path.join(STATIC_DIR, 'webpack-stats.json'), | ||||
'POLL_INTERVAL': 0.1, | 'POLL_INTERVAL': 0.1, | ||||
'TIMEOUT': None, | 'TIMEOUT': None, | ||||
'IGNORE': ['.+\.hot-update.js', '.+\.map'] | 'IGNORE': ['.+\\.hot-update.js', '.+\\.map'] | ||||
} | } | ||||
} | } | ||||
LOGIN_URL = '/admin/login/' | LOGIN_URL = '/admin/login/' | ||||
LOGIN_REDIRECT_URL = 'admin' | LOGIN_REDIRECT_URL = 'admin' | ||||
SESSION_ENGINE = 'django.contrib.sessions.backends.cache' | SESSION_ENGINE = 'django.contrib.sessions.backends.cache' | ||||
Show All 14 Lines |