mirror of
https://github.com/YunoHost-Apps/weblate_ynh.git
synced 2024-10-01 13:35:04 +02:00
Global upgrade
This commit is contained in:
parent
8c3d013292
commit
7435990215
31 changed files with 770 additions and 12138 deletions
|
@ -10,7 +10,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
|
||||||
|
|
||||||
Weblate is a libre web-based translation tool with tight version control integration. It provides two user interfaces, propagation of translations across components, quality checks and automatic linking to source files.
|
Weblate is a libre web-based translation tool with tight version control integration. It provides two user interfaces, propagation of translations across components, quality checks and automatic linking to source files.
|
||||||
|
|
||||||
**Shipped version:** 3.8.0
|
**Shipped version:** 3.11.3
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
backup_restore=1
|
backup_restore=1
|
||||||
multi_instance=1
|
multi_instance=1
|
||||||
port_already_use=0
|
port_already_use=0
|
||||||
change_url=0
|
change_url=1
|
||||||
;;; Levels
|
;;; Levels
|
||||||
# If the level 5 (Package linter) is forced to 1. Please add justifications here.
|
# If the level 5 (Package linter) is forced to 1. Please add justifications here.
|
||||||
Level 5=auto
|
Level 5=auto
|
||||||
|
|
|
@ -1,19 +1,23 @@
|
||||||
# Name of nodes to start
|
# Name of nodes to start
|
||||||
CELERYD_NODES="celery notify search memory"
|
CELERYD_NODES="celery notify search memory backup translate"
|
||||||
|
|
||||||
# Absolute or relative path to the 'celery' command:
|
# Absolute or relative path to the 'celery' command:
|
||||||
CELERY_BIN="__FINALPATH__/venv/bin/celery"
|
CELERY_BIN="__FINALPATH__/venv/bin/celery"
|
||||||
|
|
||||||
# App instance to use
|
# App instance to use
|
||||||
# comment out this line if you don't use an app
|
# comment out this line if you don't use an app
|
||||||
CELERY_APP="weblate"
|
CELERY_APP="weblate.utils"
|
||||||
|
|
||||||
# Extra command-line arguments to the worker
|
# Extra command-line arguments to the worker,
|
||||||
|
# increase concurency if you get weblate.E019
|
||||||
CELERYD_OPTS="--beat:celery --concurrency:celery=4 --queues:celery=celery --prefetch-multiplier:celery=4 \
|
CELERYD_OPTS="--beat:celery --concurrency:celery=4 --queues:celery=celery --prefetch-multiplier:celery=4 \
|
||||||
--concurrency:notify=4 --queues:notify=notify --prefetch-multiplier:notify=4 \
|
--concurrency:notify=4 --queues:notify=notify --prefetch-multiplier:notify=10 \
|
||||||
--concurrency:search=1 --queues:search=search --prefetch-multiplier:search=2000 \
|
--concurrency:search=1 --queues:search=search --prefetch-multiplier:search=2000 \
|
||||||
--concurrency:memory=1 --queues:memory=memory --prefetch-multiplier:memory=2000"
|
--concurrency:memory=1 --queues:memory=memory --prefetch-multiplier:memory=2000 \
|
||||||
|
--concurrency:translate=4 --queues:translate=translate --prefetch-multiplier:translate=4 \
|
||||||
|
--concurrency:backup=1 --queues:backup=backup --prefetch-multiplier:backup=2"
|
||||||
|
|
||||||
|
# Logging configuration
|
||||||
# - %n will be replaced with the first part of the nodename.
|
# - %n will be replaced with the first part of the nodename.
|
||||||
# - %I will be replaced with the current child process index
|
# - %I will be replaced with the current child process index
|
||||||
# and is important when using the prefork pool to avoid race conditions.
|
# and is important when using the prefork pool to avoid race conditions.
|
||||||
|
|
|
@ -1,19 +1,16 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Celery Service for Weblate (__APP__)
|
Description=Celery Service (__APP__)
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=forking
|
Type=forking
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Group=www-data
|
Group=__APP__
|
||||||
PermissionsStartOnly=true
|
|
||||||
EnvironmentFile=__FINALPATH__/celery-weblate
|
EnvironmentFile=__FINALPATH__/celery-weblate
|
||||||
WorkingDirectory=__FINALPATH__/
|
WorkingDirectory=__FINALPATH__/
|
||||||
# https://www.freedesktop.org/software/systemd/man/systemd.exec.html#RuntimeDirectory=
|
|
||||||
RuntimeDirectory=__APP__
|
RuntimeDirectory=__APP__
|
||||||
|
RuntimeDirectoryPreserve=restart
|
||||||
ExecStartPre=/bin/chown -R __APP__ /var/log/__APP__
|
LogsDirectory=celery
|
||||||
|
|
||||||
ExecStart=/bin/sh -c '${CELERY_BIN} multi start ${CELERYD_NODES} \
|
ExecStart=/bin/sh -c '${CELERY_BIN} multi start ${CELERYD_NODES} \
|
||||||
-A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \
|
-A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \
|
||||||
--logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}'
|
--logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}'
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
# https://docs.weblate.org/en/latest/admin/install.html#production-cron
|
|
||||||
# now automatically done with celery
|
|
|
@ -1,5 +1,5 @@
|
||||||
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
||||||
# https://github.com/WeblateOrg/weblate/blob/master/examples/weblate.nginx.conf
|
# https://github.com/WeblateOrg/weblate/blob/master/weblate/examples/weblate.nginx.conf
|
||||||
location = __PATH__/favicon.ico {
|
location = __PATH__/favicon.ico {
|
||||||
# DATA_DIR/static/favicon.ico
|
# DATA_DIR/static/favicon.ico
|
||||||
alias __FINALPATH__/data/static/favicon.ico;
|
alias __FINALPATH__/data/static/favicon.ico;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,699 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# Copyright © 2012 - 2017 Michal Čihař <michal@cihar.com>
|
|
||||||
#
|
|
||||||
# This file is part of Weblate <https://weblate.org/>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import platform
|
|
||||||
import os
|
|
||||||
from logging.handlers import SysLogHandler
|
|
||||||
|
|
||||||
#
|
|
||||||
# Django settings for Weblate project.
|
|
||||||
#
|
|
||||||
|
|
||||||
DEBUG = False
|
|
||||||
|
|
||||||
ADMINS = (
|
|
||||||
('__ADMIN__', '__ADMINMAIL__'),
|
|
||||||
)
|
|
||||||
|
|
||||||
MANAGERS = ADMINS
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
# Database engine
|
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
||||||
# Database name
|
|
||||||
'NAME': '__NAME__',
|
|
||||||
# Database user
|
|
||||||
'USER': '__NAME__',
|
|
||||||
# Database password
|
|
||||||
'PASSWORD': '__DB_PWD__',
|
|
||||||
# Set to empty string for localhost
|
|
||||||
'HOST': 'localhost',
|
|
||||||
# Set to empty string for default
|
|
||||||
'PORT': '5432',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BASE_DIR = '__FINALPATH__'
|
|
||||||
|
|
||||||
# Data directory
|
|
||||||
DATA_DIR = os.path.join(BASE_DIR, 'data')
|
|
||||||
|
|
||||||
# Local time zone for this installation. Choices can be found here:
|
|
||||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
|
||||||
# although not all choices may be available on all operating systems.
|
|
||||||
# On Unix systems, a value of None will cause Django to use the same
|
|
||||||
# timezone as the operating system.
|
|
||||||
# If running in a Windows environment this must be set to the same as your
|
|
||||||
# system time zone.
|
|
||||||
TIME_ZONE = 'UTC'
|
|
||||||
|
|
||||||
# Language code for this installation. All choices can be found here:
|
|
||||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
|
||||||
|
|
||||||
LANGUAGES = (
|
|
||||||
('az', 'Azərbaycan'),
|
|
||||||
('be', 'Беларуская'),
|
|
||||||
('be@latin', 'Biełaruskaja'),
|
|
||||||
('bg', 'Български'),
|
|
||||||
('br', 'Brezhoneg'),
|
|
||||||
('ca', 'Català'),
|
|
||||||
('cs', 'Čeština'),
|
|
||||||
('da', 'Dansk'),
|
|
||||||
('de', 'Deutsch'),
|
|
||||||
('en', 'English'),
|
|
||||||
('en-gb', 'English (United Kingdom)'),
|
|
||||||
('el', 'Ελληνικά'),
|
|
||||||
('es', 'Español'),
|
|
||||||
('fi', 'Suomi'),
|
|
||||||
('fr', 'Français'),
|
|
||||||
('fy', 'Frysk'),
|
|
||||||
('gl', 'Galego'),
|
|
||||||
('he', 'עברית'),
|
|
||||||
('hu', 'Magyar'),
|
|
||||||
('id', 'Indonesia'),
|
|
||||||
('it', 'Italiano'),
|
|
||||||
('ja', '日本語'),
|
|
||||||
('ko', '한국어'),
|
|
||||||
('ksh', 'Kölsch'),
|
|
||||||
('nb', 'Norsk bokmål'),
|
|
||||||
('nl', 'Nederlands'),
|
|
||||||
('pl', 'Polski'),
|
|
||||||
('pt', 'Português'),
|
|
||||||
('pt-br', 'Português brasileiro'),
|
|
||||||
('ru', 'Русский'),
|
|
||||||
('sk', 'Slovenčina'),
|
|
||||||
('sl', 'Slovenščina'),
|
|
||||||
('sr', 'Српски'),
|
|
||||||
('sv', 'Svenska'),
|
|
||||||
('tr', 'Türkçe'),
|
|
||||||
('uk', 'Українська'),
|
|
||||||
('zh-hans', '简体字'),
|
|
||||||
('zh-hant', '正體字'),
|
|
||||||
)
|
|
||||||
|
|
||||||
SITE_ID = 1
|
|
||||||
|
|
||||||
# If you set this to False, Django will make some optimizations so as not
|
|
||||||
# to load the internationalization machinery.
|
|
||||||
USE_I18N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not format dates, numbers and
|
|
||||||
# calendars according to the current locale.
|
|
||||||
USE_L10N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not use timezone-aware datetimes.
|
|
||||||
USE_TZ = True
|
|
||||||
|
|
||||||
# URL prefix to use, please see documentation for more details
|
|
||||||
URL_PREFIX = '__PATHURL__'
|
|
||||||
|
|
||||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
|
||||||
# Example: "/home/media/media.lawrence.com/media/"
|
|
||||||
MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
|
|
||||||
|
|
||||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
|
||||||
# trailing slash.
|
|
||||||
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
|
||||||
MEDIA_URL = '{0}/media/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Absolute path to the directory static files should be collected to.
|
|
||||||
# Don't put anything in this directory yourself; store your static files
|
|
||||||
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
|
|
||||||
# Example: "/home/media/media.lawrence.com/static/"
|
|
||||||
STATIC_ROOT = os.path.join(DATA_DIR, 'static')
|
|
||||||
|
|
||||||
# URL prefix for static files.
|
|
||||||
# Example: "http://media.lawrence.com/static/"
|
|
||||||
STATIC_URL = '{0}/static/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Additional locations of static files
|
|
||||||
STATICFILES_DIRS = (
|
|
||||||
# Put strings here, like "/home/html/static" or "C:/www/django/static".
|
|
||||||
# Always use forward slashes, even on Windows.
|
|
||||||
# Don't forget to use absolute paths, not relative paths.
|
|
||||||
)
|
|
||||||
|
|
||||||
# List of finder classes that know how to find static files in
|
|
||||||
# various locations.
|
|
||||||
STATICFILES_FINDERS = (
|
|
||||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
|
||||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
|
||||||
'compressor.finders.CompressorFinder',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Make this unique, and don't share it with anybody.
|
|
||||||
# You can generate it using examples/generate-secret-key
|
|
||||||
SECRET_KEY = '__KEY__' # noqa
|
|
||||||
|
|
||||||
TEMPLATES = [
|
|
||||||
{
|
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
||||||
'OPTIONS': {
|
|
||||||
'context_processors': [
|
|
||||||
'django.contrib.auth.context_processors.auth',
|
|
||||||
'django.template.context_processors.debug',
|
|
||||||
'django.template.context_processors.i18n',
|
|
||||||
'django.template.context_processors.request',
|
|
||||||
'django.template.context_processors.csrf',
|
|
||||||
'django.contrib.messages.context_processors.messages',
|
|
||||||
'weblate.trans.context_processors.weblate_context',
|
|
||||||
],
|
|
||||||
'loaders': [
|
|
||||||
('django.template.loaders.cached.Loader', [
|
|
||||||
'django.template.loaders.filesystem.Loader',
|
|
||||||
'django.template.loaders.app_directories.Loader',
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# GitHub username for sending pull requests.
|
|
||||||
# Please see the documentation for more details.
|
|
||||||
GITHUB_USERNAME = "__GITHUBUSER__"
|
|
||||||
|
|
||||||
# Authentication configuration
|
|
||||||
AUTHENTICATION_BACKENDS = (
|
|
||||||
'social_core.backends.email.EmailAuth',
|
|
||||||
# 'social_core.backends.google.GoogleOAuth2',
|
|
||||||
# 'social_core.backends.github.GithubOAuth2',
|
|
||||||
# 'social_core.backends.bitbucket.BitbucketOAuth',
|
|
||||||
'social_core.backends.suse.OpenSUSEOpenId',
|
|
||||||
'social_core.backends.ubuntu.UbuntuOpenId',
|
|
||||||
'social_core.backends.fedora.FedoraOpenId',
|
|
||||||
# 'social_core.backends.facebook.FacebookOAuth2',
|
|
||||||
'weblate.accounts.auth.WeblateUserBackend',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Social auth backends setup
|
|
||||||
SOCIAL_AUTH_GITHUB_KEY = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SECRET = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SCOPE = ['user:email']
|
|
||||||
|
|
||||||
SOCIAL_AUTH_BITBUCKET_KEY = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_SECRET = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_VERIFIED_EMAILS_ONLY = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_FACEBOOK_KEY = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SECRET = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email', 'public_profile']
|
|
||||||
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = ''
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = ''
|
|
||||||
|
|
||||||
# Social auth settings
|
|
||||||
SOCIAL_AUTH_PIPELINE = (
|
|
||||||
'social_core.pipeline.social_auth.social_details',
|
|
||||||
'social_core.pipeline.social_auth.social_uid',
|
|
||||||
'social_core.pipeline.social_auth.auth_allowed',
|
|
||||||
'social_core.pipeline.social_auth.social_user',
|
|
||||||
'weblate.accounts.pipeline.store_params',
|
|
||||||
'weblate.accounts.pipeline.verify_open',
|
|
||||||
'social_core.pipeline.user.get_username',
|
|
||||||
'weblate.accounts.pipeline.require_email',
|
|
||||||
'social_core.pipeline.mail.mail_validation',
|
|
||||||
'weblate.accounts.pipeline.revoke_mail_code',
|
|
||||||
'weblate.accounts.pipeline.ensure_valid',
|
|
||||||
'weblate.accounts.pipeline.reauthenticate',
|
|
||||||
'social_core.pipeline.social_auth.associate_by_email',
|
|
||||||
'weblate.accounts.pipeline.verify_username',
|
|
||||||
'social_core.pipeline.user.create_user',
|
|
||||||
'social_core.pipeline.social_auth.associate_user',
|
|
||||||
'social_core.pipeline.social_auth.load_extra_data',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
'weblate.accounts.pipeline.user_full_name',
|
|
||||||
'weblate.accounts.pipeline.store_email',
|
|
||||||
'weblate.accounts.pipeline.notify_connect',
|
|
||||||
'weblate.accounts.pipeline.password_reset',
|
|
||||||
)
|
|
||||||
SOCIAL_AUTH_DISCONNECT_PIPELINE = (
|
|
||||||
'social_core.pipeline.disconnect.allowed_to_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.get_entries',
|
|
||||||
'social_core.pipeline.disconnect.revoke_tokens',
|
|
||||||
'weblate.accounts.pipeline.cycle_session',
|
|
||||||
'weblate.accounts.pipeline.adjust_primary_mail',
|
|
||||||
'weblate.accounts.pipeline.notify_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.disconnect',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom authentication strategy
|
|
||||||
SOCIAL_AUTH_STRATEGY = 'weblate.accounts.strategy.WeblateStrategy'
|
|
||||||
|
|
||||||
# Raise exceptions so that we can handle them later
|
|
||||||
SOCIAL_AUTH_RAISE_EXCEPTIONS = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_FUNCTION = \
|
|
||||||
'weblate.accounts.pipeline.send_validation'
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_URL = \
|
|
||||||
'{0}/accounts/email-sent/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_LOGIN_ERROR_URL = \
|
|
||||||
'{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_EMAIL_FORM_URL = \
|
|
||||||
'{0}/accounts/email/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL = \
|
|
||||||
'{0}/accounts/profile/#auth'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_PROTECTED_USER_FIELDS = ('email',)
|
|
||||||
SOCIAL_AUTH_SLUGIFY_USERNAMES = True
|
|
||||||
SOCIAL_AUTH_SLUGIFY_FUNCTION = 'weblate.accounts.pipeline.slugify_username'
|
|
||||||
|
|
||||||
# Password validation configuration
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
||||||
'OPTIONS': {
|
|
||||||
'min_length': 6,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.CharsPasswordValidator',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
# Middleware
|
|
||||||
MIDDLEWARE_CLASSES = (
|
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
||||||
'django.middleware.common.CommonMiddleware',
|
|
||||||
'django.middleware.locale.LocaleMiddleware',
|
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
|
||||||
'weblate.accounts.middleware.AuthenticationMiddleware',
|
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
||||||
'social_django.middleware.SocialAuthExceptionMiddleware',
|
|
||||||
'weblate.accounts.middleware.RequireLoginMiddleware',
|
|
||||||
'weblate.middleware.SecurityMiddleware',
|
|
||||||
)
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'weblate.urls'
|
|
||||||
|
|
||||||
INSTALLED_APPS = (
|
|
||||||
# Has to be first to override Django admin templates:
|
|
||||||
'weblate.wladmin',
|
|
||||||
|
|
||||||
'django.contrib.auth',
|
|
||||||
'django.contrib.contenttypes',
|
|
||||||
'django.contrib.sessions',
|
|
||||||
'django.contrib.sites',
|
|
||||||
'django.contrib.messages',
|
|
||||||
'django.contrib.staticfiles',
|
|
||||||
'django.contrib.admin.apps.SimpleAdminConfig',
|
|
||||||
'django.contrib.admindocs',
|
|
||||||
'django.contrib.sitemaps',
|
|
||||||
'social_django',
|
|
||||||
'crispy_forms',
|
|
||||||
'compressor',
|
|
||||||
'rest_framework',
|
|
||||||
'rest_framework.authtoken',
|
|
||||||
'weblate.trans',
|
|
||||||
'weblate.lang',
|
|
||||||
'weblate.permissions',
|
|
||||||
'weblate.screenshots',
|
|
||||||
'weblate.accounts',
|
|
||||||
'weblate.utils',
|
|
||||||
|
|
||||||
# Optional: Git exporter
|
|
||||||
# 'weblate.gitexport',
|
|
||||||
|
|
||||||
# This application has to be placed last!
|
|
||||||
'weblate',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Path to locales
|
|
||||||
LOCALE_PATHS = (os.path.join(BASE_DIR, 'locale'), )
|
|
||||||
|
|
||||||
# Custom exception reporter to include some details
|
|
||||||
DEFAULT_EXCEPTION_REPORTER_FILTER = \
|
|
||||||
'weblate.trans.debug.WeblateExceptionReporterFilter'
|
|
||||||
|
|
||||||
# Default logging of Weblate messages
|
|
||||||
# - to syslog in production (if available)
|
|
||||||
# - otherwise to console
|
|
||||||
# - you can also choose 'logfile' to log into separate file
|
|
||||||
# after configuring it below
|
|
||||||
|
|
||||||
# Detect if we can connect to syslog
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
if platform.system() != 'Windows':
|
|
||||||
try:
|
|
||||||
SysLogHandler(address='/dev/log', facility=SysLogHandler.LOG_LOCAL2)
|
|
||||||
HAVE_SYSLOG = True
|
|
||||||
except IOError:
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
|
|
||||||
if DEBUG or not HAVE_SYSLOG:
|
|
||||||
DEFAULT_LOG = 'console'
|
|
||||||
else:
|
|
||||||
DEFAULT_LOG = 'syslog'
|
|
||||||
|
|
||||||
# A sample logging configuration. The only tangible logging
|
|
||||||
# performed by this configuration is to send an email to
|
|
||||||
# the site admins on every HTTP 500 error when DEBUG=False.
|
|
||||||
# See http://docs.djangoproject.com/en/stable/topics/logging for
|
|
||||||
# more details on how to customize your logging configuration.
|
|
||||||
LOGGING = {
|
|
||||||
'version': 1,
|
|
||||||
'disable_existing_loggers': False,
|
|
||||||
'filters': {
|
|
||||||
'require_debug_false': {
|
|
||||||
'()': 'django.utils.log.RequireDebugFalse'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'formatters': {
|
|
||||||
'syslog': {
|
|
||||||
'format': 'weblate[%(process)d]: %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'simple': {
|
|
||||||
'format': '%(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'logfile': {
|
|
||||||
'format': '%(asctime)s %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'handlers': {
|
|
||||||
'mail_admins': {
|
|
||||||
'level': 'ERROR',
|
|
||||||
'filters': ['require_debug_false'],
|
|
||||||
'class': 'django.utils.log.AdminEmailHandler',
|
|
||||||
'include_html': True,
|
|
||||||
},
|
|
||||||
'console': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'simple'
|
|
||||||
},
|
|
||||||
'syslog': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.handlers.SysLogHandler',
|
|
||||||
'formatter': 'syslog',
|
|
||||||
'address': '/dev/log',
|
|
||||||
'facility': SysLogHandler.LOG_LOCAL2,
|
|
||||||
},
|
|
||||||
# Logging to a file
|
|
||||||
# 'logfile': {
|
|
||||||
# 'level':'DEBUG',
|
|
||||||
# 'class':'logging.handlers.RotatingFileHandler',
|
|
||||||
# 'filename': "/var/log/weblate/weblate.log",
|
|
||||||
# 'maxBytes': 100000,
|
|
||||||
# 'backupCount': 3,
|
|
||||||
# 'formatter': 'logfile',
|
|
||||||
# },
|
|
||||||
},
|
|
||||||
'loggers': {
|
|
||||||
'django.request': {
|
|
||||||
'handlers': ['mail_admins', DEFAULT_LOG],
|
|
||||||
'level': 'ERROR',
|
|
||||||
'propagate': True,
|
|
||||||
},
|
|
||||||
# Logging database queries
|
|
||||||
# 'django.db.backends': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
'weblate': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'DEBUG',
|
|
||||||
},
|
|
||||||
# Logging VCS operations
|
|
||||||
# 'weblate-vcs': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
# Python Social Auth logging
|
|
||||||
# 'social': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Logging of management commands to console
|
|
||||||
if (os.environ.get('DJANGO_IS_MANAGEMENT_COMMAND', False) and
|
|
||||||
'console' not in LOGGING['loggers']['weblate']['handlers']):
|
|
||||||
LOGGING['loggers']['weblate']['handlers'].append('console')
|
|
||||||
|
|
||||||
# Remove syslog setup if it's not present
|
|
||||||
if not HAVE_SYSLOG:
|
|
||||||
del LOGGING['handlers']['syslog']
|
|
||||||
|
|
||||||
# List of machine translations
|
|
||||||
# MACHINE_TRANSLATION_SERVICES = (
|
|
||||||
# 'weblate.trans.machine.apertium.ApertiumAPYTranslation',
|
|
||||||
# 'weblate.trans.machine.glosbe.GlosbeTranslation',
|
|
||||||
# 'weblate.trans.machine.google.GoogleTranslation',
|
|
||||||
# 'weblate.trans.machine.microsoft.MicrosoftCognitiveTranslation',
|
|
||||||
# 'weblate.trans.machine.mymemory.MyMemoryTranslation',
|
|
||||||
# 'weblate.trans.machine.tmserver.AmagamaTranslation',
|
|
||||||
# 'weblate.trans.machine.tmserver.TMServerTranslation',
|
|
||||||
# 'weblate.trans.machine.yandex.YandexTranslation',
|
|
||||||
# 'weblate.trans.machine.weblatetm.WeblateSimilarTranslation',
|
|
||||||
# 'weblate.trans.machine.weblatetm.WeblateTranslation',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Machine translation API keys
|
|
||||||
|
|
||||||
# URL of the Apertium APy server
|
|
||||||
MT_APERTIUM_APY = None
|
|
||||||
|
|
||||||
# Microsoft Translator service, register at
|
|
||||||
# https://datamarket.azure.com/developer/applications/
|
|
||||||
MT_MICROSOFT_ID = None
|
|
||||||
MT_MICROSOFT_SECRET = None
|
|
||||||
|
|
||||||
# Microsoft Cognitive Services Translator API, register at
|
|
||||||
# https://portal.azure.com/
|
|
||||||
MT_MICROSOFT_COGNITIVE_KEY = None
|
|
||||||
|
|
||||||
# MyMemory identification email, see
|
|
||||||
# https://mymemory.translated.net/doc/spec.php
|
|
||||||
MT_MYMEMORY_EMAIL = None
|
|
||||||
|
|
||||||
# Optional MyMemory credentials to access private translation memory
|
|
||||||
MT_MYMEMORY_USER = None
|
|
||||||
MT_MYMEMORY_KEY = None
|
|
||||||
|
|
||||||
# Google API key for Google Translate API
|
|
||||||
MT_GOOGLE_KEY = None
|
|
||||||
|
|
||||||
# API key for Yandex Translate API
|
|
||||||
MT_YANDEX_KEY = None
|
|
||||||
|
|
||||||
# tmserver URL
|
|
||||||
MT_TMSERVER = None
|
|
||||||
|
|
||||||
# Title of site to use
|
|
||||||
SITE_TITLE = 'Weblate'
|
|
||||||
|
|
||||||
# Whether site uses https
|
|
||||||
ENABLE_HTTPS = True
|
|
||||||
|
|
||||||
# Use HTTPS when creating redirect URLs for social authentication, see
|
|
||||||
# documentation for more details:
|
|
||||||
# http://python-social-auth-docs.readthedocs.io/en/latest/configuration/settings.html#processing-redirects-and-urlopen
|
|
||||||
SOCIAL_AUTH_REDIRECT_IS_HTTPS = ENABLE_HTTPS
|
|
||||||
|
|
||||||
# Make CSRF cookie HttpOnly, see documentation for more details:
|
|
||||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#csrf-cookie-httponly
|
|
||||||
CSRF_COOKIE_HTTPONLY = True
|
|
||||||
CSRF_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# Store CSRF token in session (since Django 1.11)
|
|
||||||
CSRF_USE_SESSIONS = True
|
|
||||||
SESSION_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# Session cookie age (in seconds)
|
|
||||||
SESSION_COOKIE_AGE = 1209600
|
|
||||||
|
|
||||||
# URL of login
|
|
||||||
LOGIN_URL = '{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# URL of logout
|
|
||||||
LOGOUT_URL = '{0}/accounts/logout/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Default location for login
|
|
||||||
LOGIN_REDIRECT_URL = '{0}/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Anonymous user name
|
|
||||||
ANONYMOUS_USER_NAME = 'anonymous'
|
|
||||||
|
|
||||||
# Reverse proxy settings
|
|
||||||
IP_BEHIND_REVERSE_PROXY = False
|
|
||||||
IP_PROXY_HEADER = 'HTTP_X_FORWARDED_FOR'
|
|
||||||
IP_PROXY_OFFSET = 0
|
|
||||||
|
|
||||||
# Sending HTML in mails
|
|
||||||
EMAIL_SEND_HTML = True
|
|
||||||
|
|
||||||
# Subject of emails includes site title
|
|
||||||
EMAIL_SUBJECT_PREFIX = '[{0}] '.format(SITE_TITLE)
|
|
||||||
|
|
||||||
EMAIL_BACKEND = 'django_sendmail_backend.backends.EmailBackend'
|
|
||||||
|
|
||||||
# Enable remote hooks
|
|
||||||
ENABLE_HOOKS = True
|
|
||||||
|
|
||||||
# Whether to run hooks in background
|
|
||||||
BACKGROUND_HOOKS = True
|
|
||||||
|
|
||||||
# Number of nearby messages to show in each direction
|
|
||||||
NEARBY_MESSAGES = 5
|
|
||||||
|
|
||||||
# Enable lazy commits
|
|
||||||
LAZY_COMMITS = True
|
|
||||||
|
|
||||||
# Offload indexing
|
|
||||||
OFFLOAD_INDEXING = True
|
|
||||||
|
|
||||||
# Translation locking
|
|
||||||
AUTO_LOCK = True
|
|
||||||
AUTO_LOCK_TIME = 60
|
|
||||||
LOCK_TIME = 15 * 60
|
|
||||||
|
|
||||||
# Render forms using bootstrap
|
|
||||||
CRISPY_TEMPLATE_PACK = 'bootstrap3'
|
|
||||||
|
|
||||||
# List of quality checks
|
|
||||||
# CHECK_LIST = (
|
|
||||||
# 'weblate.trans.checks.same.SameCheck',
|
|
||||||
# 'weblate.trans.checks.chars.BeginNewlineCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndNewlineCheck',
|
|
||||||
# 'weblate.trans.checks.chars.BeginSpaceCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndSpaceCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndStopCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndColonCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndQuestionCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndExclamationCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndEllipsisCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndSemicolonCheck',
|
|
||||||
# 'weblate.trans.checks.chars.MaxLengthCheck',
|
|
||||||
# 'weblate.trans.checks.format.PythonFormatCheck',
|
|
||||||
# 'weblate.trans.checks.format.PythonBraceFormatCheck',
|
|
||||||
# 'weblate.trans.checks.format.PHPFormatCheck',
|
|
||||||
# 'weblate.trans.checks.format.CFormatCheck',
|
|
||||||
# 'weblate.trans.checks.format.PerlFormatCheck',
|
|
||||||
# 'weblate.trans.checks.format.JavascriptFormatCheck',
|
|
||||||
# 'weblate.trans.checks.consistency.PluralsCheck',
|
|
||||||
# 'weblate.trans.checks.consistency.SamePluralsCheck',
|
|
||||||
# 'weblate.trans.checks.consistency.ConsistencyCheck',
|
|
||||||
# 'weblate.trans.checks.consistency.TranslatedCheck',
|
|
||||||
# 'weblate.trans.checks.chars.NewlineCountingCheck',
|
|
||||||
# 'weblate.trans.checks.markup.BBCodeCheck',
|
|
||||||
# 'weblate.trans.checks.chars.ZeroWidthSpaceCheck',
|
|
||||||
# 'weblate.trans.checks.markup.XMLValidityCheck',
|
|
||||||
# 'weblate.trans.checks.markup.XMLTagsCheck',
|
|
||||||
# 'weblate.trans.checks.source.OptionalPluralCheck',
|
|
||||||
# 'weblate.trans.checks.source.EllipsisCheck',
|
|
||||||
# 'weblate.trans.checks.source.MultipleFailingCheck',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of automatic fixups
|
|
||||||
# AUTOFIX_LIST = (
|
|
||||||
# 'weblate.trans.autofixes.whitespace.SameBookendingWhitespace',
|
|
||||||
# 'weblate.trans.autofixes.chars.ReplaceTrailingDotsWithEllipsis',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveZeroSpace',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveControlChars',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of scripts to use in custom processing
|
|
||||||
# POST_UPDATE_SCRIPTS = (
|
|
||||||
# )
|
|
||||||
# PRE_COMMIT_SCRIPTS = (
|
|
||||||
# )
|
|
||||||
|
|
||||||
# E-mail address that error messages come from.
|
|
||||||
SERVER_EMAIL = 'noreply@__DOMAIN__'
|
|
||||||
|
|
||||||
# Default email address to use for various automated correspondence from
|
|
||||||
# the site managers. Used for registration emails.
|
|
||||||
DEFAULT_FROM_EMAIL = '__ADMINMAIL__'
|
|
||||||
|
|
||||||
# List of URLs your site is supposed to serve
|
|
||||||
ALLOWED_HOSTS = ['__DOMAIN__']
|
|
||||||
|
|
||||||
# Example configuration to use memcached for caching
|
|
||||||
CACHES = {
|
|
||||||
'default': {
|
|
||||||
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
|
||||||
'LOCATION': '127.0.0.1:__MEMCPORT__',
|
|
||||||
},
|
|
||||||
'avatar': {
|
|
||||||
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
|
||||||
'LOCATION': os.path.join(BASE_DIR, 'avatar-cache'),
|
|
||||||
'TIMEOUT': 3600,
|
|
||||||
'OPTIONS': {
|
|
||||||
'MAX_ENTRIES': 1000,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# REST framework settings for API
|
|
||||||
REST_FRAMEWORK = {
|
|
||||||
# Use Django's standard `django.contrib.auth` permissions,
|
|
||||||
# or allow read-only access for unauthenticated users.
|
|
||||||
'DEFAULT_PERMISSION_CLASSES': [
|
|
||||||
'rest_framework.permissions.IsAuthenticatedOrReadOnly'
|
|
||||||
],
|
|
||||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
|
||||||
'rest_framework.authentication.TokenAuthentication',
|
|
||||||
'rest_framework.authentication.SessionAuthentication',
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_CLASSES': (
|
|
||||||
'rest_framework.throttling.AnonRateThrottle',
|
|
||||||
'rest_framework.throttling.UserRateThrottle'
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_RATES': {
|
|
||||||
'anon': '100/day',
|
|
||||||
'user': '1000/day'
|
|
||||||
},
|
|
||||||
'DEFAULT_PAGINATION_CLASS': (
|
|
||||||
'rest_framework.pagination.PageNumberPagination'
|
|
||||||
),
|
|
||||||
'PAGE_SIZE': 20,
|
|
||||||
'VIEW_DESCRIPTION_FUNCTION': 'weblate.api.views.get_view_description',
|
|
||||||
'UNAUTHENTICATED_USER': 'weblate.accounts.models.get_anonymous',
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example for restricting access to logged in users
|
|
||||||
# LOGIN_REQUIRED_URLS = (
|
|
||||||
# r'/(.*)$',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# In such case you will want to include some of the exceptions
|
|
||||||
# LOGIN_REQUIRED_URLS_EXCEPTIONS = (
|
|
||||||
# r'/accounts/(.*)$', # Required for login
|
|
||||||
# r'/static/(.*)$', # Required for development mode
|
|
||||||
# r'/widgets/(.*)$', # Allowing public access to widgets
|
|
||||||
# r'/data/(.*)$', # Allowing public access to data exports
|
|
||||||
# r'/hooks/(.*)$', # Allowing public access to notification hooks
|
|
||||||
# r'/api/(.*)$', # Allowing access to API
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Force sane test runner
|
|
||||||
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
|
|
@ -1,708 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# Copyright © 2012 - 2017 Michal Čihař <michal@cihar.com>
|
|
||||||
#
|
|
||||||
# This file is part of Weblate <https://weblate.org/>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import platform
|
|
||||||
import os
|
|
||||||
from logging.handlers import SysLogHandler
|
|
||||||
|
|
||||||
#
|
|
||||||
# Django settings for Weblate project.
|
|
||||||
#
|
|
||||||
|
|
||||||
DEBUG = False
|
|
||||||
|
|
||||||
ADMINS = (
|
|
||||||
('__ADMIN__', '__ADMINMAIL__'),
|
|
||||||
)
|
|
||||||
|
|
||||||
MANAGERS = ADMINS
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
# Database engine
|
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
||||||
# Database name
|
|
||||||
'NAME': '__NAME__',
|
|
||||||
# Database user
|
|
||||||
'USER': '__NAME__',
|
|
||||||
# Database password
|
|
||||||
'PASSWORD': '__DB_PWD__',
|
|
||||||
# Set to empty string for localhost
|
|
||||||
'HOST': 'localhost',
|
|
||||||
# Set to empty string for default
|
|
||||||
'PORT': '5432',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BASE_DIR = '__FINALPATH__'
|
|
||||||
|
|
||||||
# Data directory
|
|
||||||
DATA_DIR = os.path.join(BASE_DIR, 'data')
|
|
||||||
|
|
||||||
# Local time zone for this installation. Choices can be found here:
|
|
||||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
|
||||||
# although not all choices may be available on all operating systems.
|
|
||||||
# In a Windows environment this must be set to your system time zone.
|
|
||||||
TIME_ZONE = 'UTC'
|
|
||||||
|
|
||||||
# Language code for this installation. All choices can be found here:
|
|
||||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
|
||||||
|
|
||||||
LANGUAGES = (
|
|
||||||
('az', 'Azərbaycan'),
|
|
||||||
('be', 'Беларуская'),
|
|
||||||
('be@latin', 'Biełaruskaja'),
|
|
||||||
('bg', 'Български'),
|
|
||||||
('br', 'Brezhoneg'),
|
|
||||||
('ca', 'Català'),
|
|
||||||
('cs', 'Čeština'),
|
|
||||||
('da', 'Dansk'),
|
|
||||||
('de', 'Deutsch'),
|
|
||||||
('en', 'English'),
|
|
||||||
('en-gb', 'English (United Kingdom)'),
|
|
||||||
('el', 'Ελληνικά'),
|
|
||||||
('es', 'Español'),
|
|
||||||
('fi', 'Suomi'),
|
|
||||||
('fr', 'Français'),
|
|
||||||
('fy', 'Frysk'),
|
|
||||||
('gl', 'Galego'),
|
|
||||||
('he', 'עברית'),
|
|
||||||
('hu', 'Magyar'),
|
|
||||||
('id', 'Indonesia'),
|
|
||||||
('it', 'Italiano'),
|
|
||||||
('ja', '日本語'),
|
|
||||||
('ko', '한국어'),
|
|
||||||
('ksh', 'Kölsch'),
|
|
||||||
('nb', 'Norsk bokmål'),
|
|
||||||
('nl', 'Nederlands'),
|
|
||||||
('pl', 'Polski'),
|
|
||||||
('pt', 'Português'),
|
|
||||||
('pt-br', 'Português brasileiro'),
|
|
||||||
('ru', 'Русский'),
|
|
||||||
('sk', 'Slovenčina'),
|
|
||||||
('sl', 'Slovenščina'),
|
|
||||||
('sr', 'Српски'),
|
|
||||||
('sv', 'Svenska'),
|
|
||||||
('tr', 'Türkçe'),
|
|
||||||
('uk', 'Українська'),
|
|
||||||
('zh-hans', '简体字'),
|
|
||||||
('zh-hant', '正體字'),
|
|
||||||
)
|
|
||||||
|
|
||||||
SITE_ID = 1
|
|
||||||
|
|
||||||
# If you set this to False, Django will make some optimizations so as not
|
|
||||||
# to load the internationalization machinery.
|
|
||||||
USE_I18N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not format dates, numbers and
|
|
||||||
# calendars according to the current locale.
|
|
||||||
USE_L10N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not use timezone-aware datetimes.
|
|
||||||
USE_TZ = True
|
|
||||||
|
|
||||||
# URL prefix to use, please see documentation for more details
|
|
||||||
URL_PREFIX = '__PATHURL__'
|
|
||||||
|
|
||||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
|
||||||
# Example: "/home/media/media.lawrence.com/media/"
|
|
||||||
MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
|
|
||||||
|
|
||||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
|
||||||
# trailing slash.
|
|
||||||
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
|
||||||
MEDIA_URL = '{0}/media/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Absolute path to the directory static files should be collected to.
|
|
||||||
# Don't put anything in this directory yourself; store your static files
|
|
||||||
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
|
|
||||||
# Example: "/home/media/media.lawrence.com/static/"
|
|
||||||
STATIC_ROOT = os.path.join(DATA_DIR, 'static')
|
|
||||||
|
|
||||||
# URL prefix for static files.
|
|
||||||
# Example: "http://media.lawrence.com/static/"
|
|
||||||
STATIC_URL = '{0}/static/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Additional locations of static files
|
|
||||||
STATICFILES_DIRS = (
|
|
||||||
# Put strings here, like "/home/html/static" or "C:/www/django/static".
|
|
||||||
# Always use forward slashes, even on Windows.
|
|
||||||
# Don't forget to use absolute paths, not relative paths.
|
|
||||||
)
|
|
||||||
|
|
||||||
# List of finder classes that know how to find static files in
|
|
||||||
# various locations.
|
|
||||||
STATICFILES_FINDERS = (
|
|
||||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
|
||||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
|
||||||
'compressor.finders.CompressorFinder',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Make this unique, and don't share it with anybody.
|
|
||||||
# You can generate it using examples/generate-secret-key
|
|
||||||
SECRET_KEY = '__KEY__' # noqa
|
|
||||||
|
|
||||||
TEMPLATES = [
|
|
||||||
{
|
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
||||||
'OPTIONS': {
|
|
||||||
'context_processors': [
|
|
||||||
'django.contrib.auth.context_processors.auth',
|
|
||||||
'django.template.context_processors.debug',
|
|
||||||
'django.template.context_processors.i18n',
|
|
||||||
'django.template.context_processors.request',
|
|
||||||
'django.template.context_processors.csrf',
|
|
||||||
'django.contrib.messages.context_processors.messages',
|
|
||||||
'weblate.trans.context_processors.weblate_context',
|
|
||||||
],
|
|
||||||
'loaders': [
|
|
||||||
('django.template.loaders.cached.Loader', [
|
|
||||||
'django.template.loaders.filesystem.Loader',
|
|
||||||
'django.template.loaders.app_directories.Loader',
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# GitHub username for sending pull requests.
|
|
||||||
# Please see the documentation for more details.
|
|
||||||
GITHUB_USERNAME = "__GITHUBUSER__"
|
|
||||||
|
|
||||||
# Authentication configuration
|
|
||||||
AUTHENTICATION_BACKENDS = (
|
|
||||||
'social_core.backends.email.EmailAuth',
|
|
||||||
# 'social_core.backends.google.GoogleOAuth2',
|
|
||||||
# 'social_core.backends.github.GithubOAuth2',
|
|
||||||
# 'social_core.backends.bitbucket.BitbucketOAuth',
|
|
||||||
'social_core.backends.suse.OpenSUSEOpenId',
|
|
||||||
'social_core.backends.ubuntu.UbuntuOpenId',
|
|
||||||
'social_core.backends.fedora.FedoraOpenId',
|
|
||||||
# 'social_core.backends.facebook.FacebookOAuth2',
|
|
||||||
'weblate.accounts.auth.WeblateUserBackend',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Social auth backends setup
|
|
||||||
SOCIAL_AUTH_GITHUB_KEY = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SECRET = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SCOPE = ['user:email']
|
|
||||||
|
|
||||||
SOCIAL_AUTH_BITBUCKET_KEY = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_SECRET = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_VERIFIED_EMAILS_ONLY = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_FACEBOOK_KEY = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SECRET = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email', 'public_profile']
|
|
||||||
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = ''
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = ''
|
|
||||||
|
|
||||||
# Social auth settings
|
|
||||||
SOCIAL_AUTH_PIPELINE = (
|
|
||||||
'social_core.pipeline.social_auth.social_details',
|
|
||||||
'social_core.pipeline.social_auth.social_uid',
|
|
||||||
'social_core.pipeline.social_auth.auth_allowed',
|
|
||||||
'social_core.pipeline.social_auth.social_user',
|
|
||||||
'weblate.accounts.pipeline.store_params',
|
|
||||||
'weblate.accounts.pipeline.verify_open',
|
|
||||||
'social_core.pipeline.user.get_username',
|
|
||||||
'weblate.accounts.pipeline.require_email',
|
|
||||||
'social_core.pipeline.mail.mail_validation',
|
|
||||||
'weblate.accounts.pipeline.revoke_mail_code',
|
|
||||||
'weblate.accounts.pipeline.ensure_valid',
|
|
||||||
'weblate.accounts.pipeline.remove_account',
|
|
||||||
'social_core.pipeline.social_auth.associate_by_email',
|
|
||||||
'weblate.accounts.pipeline.reauthenticate',
|
|
||||||
'weblate.accounts.pipeline.verify_username',
|
|
||||||
'social_core.pipeline.user.create_user',
|
|
||||||
'social_core.pipeline.social_auth.associate_user',
|
|
||||||
'social_core.pipeline.social_auth.load_extra_data',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
'weblate.accounts.pipeline.user_full_name',
|
|
||||||
'weblate.accounts.pipeline.store_email',
|
|
||||||
'weblate.accounts.pipeline.notify_connect',
|
|
||||||
'weblate.accounts.pipeline.password_reset',
|
|
||||||
)
|
|
||||||
SOCIAL_AUTH_DISCONNECT_PIPELINE = (
|
|
||||||
'social_core.pipeline.disconnect.allowed_to_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.get_entries',
|
|
||||||
'social_core.pipeline.disconnect.revoke_tokens',
|
|
||||||
'weblate.accounts.pipeline.cycle_session',
|
|
||||||
'weblate.accounts.pipeline.adjust_primary_mail',
|
|
||||||
'weblate.accounts.pipeline.notify_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.disconnect',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom authentication strategy
|
|
||||||
SOCIAL_AUTH_STRATEGY = 'weblate.accounts.strategy.WeblateStrategy'
|
|
||||||
|
|
||||||
# Raise exceptions so that we can handle them later
|
|
||||||
SOCIAL_AUTH_RAISE_EXCEPTIONS = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_FUNCTION = \
|
|
||||||
'weblate.accounts.pipeline.send_validation'
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_URL = \
|
|
||||||
'{0}/accounts/email-sent/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_LOGIN_ERROR_URL = \
|
|
||||||
'{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_EMAIL_FORM_URL = \
|
|
||||||
'{0}/accounts/email/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL = \
|
|
||||||
'{0}/accounts/profile/#auth'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_PROTECTED_USER_FIELDS = ('email',)
|
|
||||||
SOCIAL_AUTH_SLUGIFY_USERNAMES = True
|
|
||||||
SOCIAL_AUTH_SLUGIFY_FUNCTION = 'weblate.accounts.pipeline.slugify_username'
|
|
||||||
|
|
||||||
# Password validation configuration
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
||||||
'OPTIONS': {
|
|
||||||
'min_length': 6,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.CharsPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.PastPasswordsValidator',
|
|
||||||
},
|
|
||||||
# Optional password strength validation by django-zxcvbn-password
|
|
||||||
# {
|
|
||||||
# 'NAME': 'zxcvbn_password.ZXCVBNValidator',
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'min_score': 3,
|
|
||||||
# 'user_attributes': ('username', 'email', 'first_name')
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
]
|
|
||||||
|
|
||||||
# Middleware
|
|
||||||
MIDDLEWARE_CLASSES = (
|
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
||||||
'django.middleware.common.CommonMiddleware',
|
|
||||||
'django.middleware.locale.LocaleMiddleware',
|
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
|
||||||
'weblate.accounts.middleware.AuthenticationMiddleware',
|
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
||||||
'social_django.middleware.SocialAuthExceptionMiddleware',
|
|
||||||
'weblate.accounts.middleware.RequireLoginMiddleware',
|
|
||||||
'weblate.middleware.SecurityMiddleware',
|
|
||||||
)
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'weblate.urls'
|
|
||||||
|
|
||||||
# Django and Weblate apps
|
|
||||||
INSTALLED_APPS = (
|
|
||||||
'django.contrib.auth',
|
|
||||||
'django.contrib.contenttypes',
|
|
||||||
'django.contrib.sessions',
|
|
||||||
'django.contrib.sites',
|
|
||||||
'django.contrib.messages',
|
|
||||||
'django.contrib.staticfiles',
|
|
||||||
'django.contrib.admin.apps.SimpleAdminConfig',
|
|
||||||
'django.contrib.admindocs',
|
|
||||||
'django.contrib.sitemaps',
|
|
||||||
'social_django',
|
|
||||||
'crispy_forms',
|
|
||||||
'compressor',
|
|
||||||
'rest_framework',
|
|
||||||
'rest_framework.authtoken',
|
|
||||||
'weblate.trans',
|
|
||||||
'weblate.lang',
|
|
||||||
'weblate.permissions',
|
|
||||||
'weblate.screenshots',
|
|
||||||
'weblate.accounts',
|
|
||||||
'weblate.utils',
|
|
||||||
'weblate.wladmin',
|
|
||||||
'weblate',
|
|
||||||
|
|
||||||
# Optional: Git exporter
|
|
||||||
# 'weblate.gitexport',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Path to locales
|
|
||||||
LOCALE_PATHS = (os.path.join(BASE_DIR, 'weblate', 'locale'), )
|
|
||||||
|
|
||||||
# Custom exception reporter to include some details
|
|
||||||
DEFAULT_EXCEPTION_REPORTER_FILTER = \
|
|
||||||
'weblate.trans.debug.WeblateExceptionReporterFilter'
|
|
||||||
|
|
||||||
# Default logging of Weblate messages
|
|
||||||
# - to syslog in production (if available)
|
|
||||||
# - otherwise to console
|
|
||||||
# - you can also choose 'logfile' to log into separate file
|
|
||||||
# after configuring it below
|
|
||||||
|
|
||||||
# Detect if we can connect to syslog
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
if platform.system() != 'Windows':
|
|
||||||
try:
|
|
||||||
SysLogHandler(address='/dev/log', facility=SysLogHandler.LOG_LOCAL2)
|
|
||||||
HAVE_SYSLOG = True
|
|
||||||
except IOError:
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
|
|
||||||
if DEBUG or not HAVE_SYSLOG:
|
|
||||||
DEFAULT_LOG = 'console'
|
|
||||||
else:
|
|
||||||
DEFAULT_LOG = 'syslog'
|
|
||||||
|
|
||||||
# A sample logging configuration. The only tangible logging
|
|
||||||
# performed by this configuration is to send an email to
|
|
||||||
# the site admins on every HTTP 500 error when DEBUG=False.
|
|
||||||
# See http://docs.djangoproject.com/en/stable/topics/logging for
|
|
||||||
# more details on how to customize your logging configuration.
|
|
||||||
LOGGING = {
|
|
||||||
'version': 1,
|
|
||||||
'disable_existing_loggers': False,
|
|
||||||
'filters': {
|
|
||||||
'require_debug_false': {
|
|
||||||
'()': 'django.utils.log.RequireDebugFalse'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'formatters': {
|
|
||||||
'syslog': {
|
|
||||||
'format': 'weblate[%(process)d]: %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'simple': {
|
|
||||||
'format': '%(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'logfile': {
|
|
||||||
'format': '%(asctime)s %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'handlers': {
|
|
||||||
'mail_admins': {
|
|
||||||
'level': 'ERROR',
|
|
||||||
'filters': ['require_debug_false'],
|
|
||||||
'class': 'django.utils.log.AdminEmailHandler',
|
|
||||||
'include_html': True,
|
|
||||||
},
|
|
||||||
'console': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'simple'
|
|
||||||
},
|
|
||||||
'syslog': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.handlers.SysLogHandler',
|
|
||||||
'formatter': 'syslog',
|
|
||||||
'address': '/dev/log',
|
|
||||||
'facility': SysLogHandler.LOG_LOCAL2,
|
|
||||||
},
|
|
||||||
# Logging to a file
|
|
||||||
# 'logfile': {
|
|
||||||
# 'level':'DEBUG',
|
|
||||||
# 'class':'logging.handlers.RotatingFileHandler',
|
|
||||||
# 'filename': "/var/log/weblate/weblate.log",
|
|
||||||
# 'maxBytes': 100000,
|
|
||||||
# 'backupCount': 3,
|
|
||||||
# 'formatter': 'logfile',
|
|
||||||
# },
|
|
||||||
},
|
|
||||||
'loggers': {
|
|
||||||
'django.request': {
|
|
||||||
'handlers': ['mail_admins', DEFAULT_LOG],
|
|
||||||
'level': 'ERROR',
|
|
||||||
'propagate': True,
|
|
||||||
},
|
|
||||||
# Logging database queries
|
|
||||||
# 'django.db.backends': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
'weblate': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'DEBUG',
|
|
||||||
},
|
|
||||||
# Logging VCS operations
|
|
||||||
# 'weblate-vcs': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
# Python Social Auth logging
|
|
||||||
# 'social': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Logging of management commands to console
|
|
||||||
if (os.environ.get('DJANGO_IS_MANAGEMENT_COMMAND', False) and
|
|
||||||
'console' not in LOGGING['loggers']['weblate']['handlers']):
|
|
||||||
LOGGING['loggers']['weblate']['handlers'].append('console')
|
|
||||||
|
|
||||||
# Remove syslog setup if it's not present
|
|
||||||
if not HAVE_SYSLOG:
|
|
||||||
del LOGGING['handlers']['syslog']
|
|
||||||
|
|
||||||
# List of machine translations
|
|
||||||
# MACHINE_TRANSLATION_SERVICES = (
|
|
||||||
# 'weblate.trans.machine.apertium.ApertiumAPYTranslation',
|
|
||||||
# 'weblate.trans.machine.glosbe.GlosbeTranslation',
|
|
||||||
# 'weblate.trans.machine.google.GoogleTranslation',
|
|
||||||
# 'weblate.trans.machine.microsoft.MicrosoftCognitiveTranslation',
|
|
||||||
# 'weblate.trans.machine.mymemory.MyMemoryTranslation',
|
|
||||||
# 'weblate.trans.machine.tmserver.AmagamaTranslation',
|
|
||||||
# 'weblate.trans.machine.tmserver.TMServerTranslation',
|
|
||||||
# 'weblate.trans.machine.yandex.YandexTranslation',
|
|
||||||
# 'weblate.trans.machine.weblatetm.WeblateSimilarTranslation',
|
|
||||||
# 'weblate.trans.machine.weblatetm.WeblateTranslation',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Machine translation API keys
|
|
||||||
|
|
||||||
# URL of the Apertium APy server
|
|
||||||
MT_APERTIUM_APY = None
|
|
||||||
|
|
||||||
# Microsoft Translator service, register at
|
|
||||||
# https://datamarket.azure.com/developer/applications/
|
|
||||||
MT_MICROSOFT_ID = None
|
|
||||||
MT_MICROSOFT_SECRET = None
|
|
||||||
|
|
||||||
# Microsoft Cognitive Services Translator API, register at
|
|
||||||
# https://portal.azure.com/
|
|
||||||
MT_MICROSOFT_COGNITIVE_KEY = None
|
|
||||||
|
|
||||||
# MyMemory identification email, see
|
|
||||||
# https://mymemory.translated.net/doc/spec.php
|
|
||||||
MT_MYMEMORY_EMAIL = None
|
|
||||||
|
|
||||||
# Optional MyMemory credentials to access private translation memory
|
|
||||||
MT_MYMEMORY_USER = None
|
|
||||||
MT_MYMEMORY_KEY = None
|
|
||||||
|
|
||||||
# Google API key for Google Translate API
|
|
||||||
MT_GOOGLE_KEY = None
|
|
||||||
|
|
||||||
# API key for Yandex Translate API
|
|
||||||
MT_YANDEX_KEY = None
|
|
||||||
|
|
||||||
# tmserver URL
|
|
||||||
MT_TMSERVER = None
|
|
||||||
|
|
||||||
# Title of site to use
|
|
||||||
SITE_TITLE = 'Weblate'
|
|
||||||
|
|
||||||
# Whether site uses https
|
|
||||||
ENABLE_HTTPS = True
|
|
||||||
|
|
||||||
# Use HTTPS when creating redirect URLs for social authentication, see
|
|
||||||
# documentation for more details:
|
|
||||||
# http://python-social-auth-docs.readthedocs.io/en/latest/configuration/settings.html#processing-redirects-and-urlopen
|
|
||||||
SOCIAL_AUTH_REDIRECT_IS_HTTPS = ENABLE_HTTPS
|
|
||||||
|
|
||||||
# Make CSRF cookie HttpOnly, see documentation for more details:
|
|
||||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#csrf-cookie-httponly
|
|
||||||
CSRF_COOKIE_HTTPONLY = True
|
|
||||||
CSRF_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# Store CSRF token in session (since Django 1.11)
|
|
||||||
CSRF_USE_SESSIONS = True
|
|
||||||
SESSION_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# Session cookie age (in seconds)
|
|
||||||
SESSION_COOKIE_AGE = 1209600
|
|
||||||
|
|
||||||
# URL of login
|
|
||||||
LOGIN_URL = '{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# URL of logout
|
|
||||||
LOGOUT_URL = '{0}/accounts/logout/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Default location for login
|
|
||||||
LOGIN_REDIRECT_URL = '{0}/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Anonymous user name
|
|
||||||
ANONYMOUS_USER_NAME = 'anonymous'
|
|
||||||
|
|
||||||
# Reverse proxy settings
|
|
||||||
IP_BEHIND_REVERSE_PROXY = False
|
|
||||||
IP_PROXY_HEADER = 'HTTP_X_FORWARDED_FOR'
|
|
||||||
IP_PROXY_OFFSET = 0
|
|
||||||
|
|
||||||
# Sending HTML in mails
|
|
||||||
EMAIL_SEND_HTML = True
|
|
||||||
|
|
||||||
# Subject of emails includes site title
|
|
||||||
EMAIL_SUBJECT_PREFIX = '[{0}] '.format(SITE_TITLE)
|
|
||||||
|
|
||||||
EMAIL_BACKEND = 'django_sendmail_backend.backends.EmailBackend'
|
|
||||||
|
|
||||||
# Enable remote hooks
|
|
||||||
ENABLE_HOOKS = True
|
|
||||||
|
|
||||||
# Whether to run hooks in background
|
|
||||||
BACKGROUND_HOOKS = True
|
|
||||||
|
|
||||||
# Number of nearby messages to show in each direction
|
|
||||||
NEARBY_MESSAGES = 5
|
|
||||||
|
|
||||||
# Enable lazy commits
|
|
||||||
LAZY_COMMITS = True
|
|
||||||
|
|
||||||
# Offload indexing
|
|
||||||
OFFLOAD_INDEXING = True
|
|
||||||
|
|
||||||
# Translation locking
|
|
||||||
AUTO_LOCK = True
|
|
||||||
AUTO_LOCK_TIME = 60
|
|
||||||
LOCK_TIME = 15 * 60
|
|
||||||
|
|
||||||
# Use simple language codes for default language/country combinations
|
|
||||||
SIMPLIFY_LANGUAGES = True
|
|
||||||
|
|
||||||
# Render forms using bootstrap
|
|
||||||
CRISPY_TEMPLATE_PACK = 'bootstrap3'
|
|
||||||
|
|
||||||
# List of quality checks
|
|
||||||
# CHECK_LIST = (
|
|
||||||
# 'weblate.trans.checks.same.SameCheck',
|
|
||||||
# 'weblate.trans.checks.chars.BeginNewlineCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndNewlineCheck',
|
|
||||||
# 'weblate.trans.checks.chars.BeginSpaceCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndSpaceCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndStopCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndColonCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndQuestionCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndExclamationCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndEllipsisCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndSemicolonCheck',
|
|
||||||
# 'weblate.trans.checks.chars.MaxLengthCheck',
|
|
||||||
# 'weblate.trans.checks.format.PythonFormatCheck',
|
|
||||||
# 'weblate.trans.checks.format.PythonBraceFormatCheck',
|
|
||||||
# 'weblate.trans.checks.format.PHPFormatCheck',
|
|
||||||
# 'weblate.trans.checks.format.CFormatCheck',
|
|
||||||
# 'weblate.trans.checks.format.PerlFormatCheck',
|
|
||||||
# 'weblate.trans.checks.format.JavascriptFormatCheck',
|
|
||||||
# 'weblate.trans.checks.consistency.PluralsCheck',
|
|
||||||
# 'weblate.trans.checks.consistency.SamePluralsCheck',
|
|
||||||
# 'weblate.trans.checks.consistency.ConsistencyCheck',
|
|
||||||
# 'weblate.trans.checks.consistency.TranslatedCheck',
|
|
||||||
# 'weblate.trans.checks.chars.NewlineCountingCheck',
|
|
||||||
# 'weblate.trans.checks.markup.BBCodeCheck',
|
|
||||||
# 'weblate.trans.checks.chars.ZeroWidthSpaceCheck',
|
|
||||||
# 'weblate.trans.checks.markup.XMLValidityCheck',
|
|
||||||
# 'weblate.trans.checks.markup.XMLTagsCheck',
|
|
||||||
# 'weblate.trans.checks.source.OptionalPluralCheck',
|
|
||||||
# 'weblate.trans.checks.source.EllipsisCheck',
|
|
||||||
# 'weblate.trans.checks.source.MultipleFailingCheck',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of automatic fixups
|
|
||||||
# AUTOFIX_LIST = (
|
|
||||||
# 'weblate.trans.autofixes.whitespace.SameBookendingWhitespace',
|
|
||||||
# 'weblate.trans.autofixes.chars.ReplaceTrailingDotsWithEllipsis',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveZeroSpace',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveControlChars',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of scripts to use in custom processing
|
|
||||||
# POST_UPDATE_SCRIPTS = (
|
|
||||||
# )
|
|
||||||
# PRE_COMMIT_SCRIPTS = (
|
|
||||||
# )
|
|
||||||
|
|
||||||
# E-mail address that error messages come from.
|
|
||||||
SERVER_EMAIL = 'noreply@__DOMAIN__'
|
|
||||||
|
|
||||||
# Default email address to use for various automated correspondence from
|
|
||||||
# the site managers. Used for registration emails.
|
|
||||||
DEFAULT_FROM_EMAIL = '__ADMINMAIL__'
|
|
||||||
|
|
||||||
# List of URLs your site is supposed to serve
|
|
||||||
ALLOWED_HOSTS = ['__DOMAIN__']
|
|
||||||
|
|
||||||
# Example configuration to use memcached for caching
|
|
||||||
CACHES = {
|
|
||||||
'default': {
|
|
||||||
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
|
||||||
'LOCATION': '127.0.0.1:__MEMCPORT__',
|
|
||||||
},
|
|
||||||
'avatar': {
|
|
||||||
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
|
||||||
'LOCATION': os.path.join(BASE_DIR, 'avatar-cache'),
|
|
||||||
'TIMEOUT': 3600,
|
|
||||||
'OPTIONS': {
|
|
||||||
'MAX_ENTRIES': 1000,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# REST framework settings for API
|
|
||||||
REST_FRAMEWORK = {
|
|
||||||
# Use Django's standard `django.contrib.auth` permissions,
|
|
||||||
# or allow read-only access for unauthenticated users.
|
|
||||||
'DEFAULT_PERMISSION_CLASSES': [
|
|
||||||
'rest_framework.permissions.IsAuthenticatedOrReadOnly'
|
|
||||||
],
|
|
||||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
|
||||||
'rest_framework.authentication.TokenAuthentication',
|
|
||||||
'rest_framework.authentication.SessionAuthentication',
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_CLASSES': (
|
|
||||||
'rest_framework.throttling.AnonRateThrottle',
|
|
||||||
'rest_framework.throttling.UserRateThrottle'
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_RATES': {
|
|
||||||
'anon': '100/day',
|
|
||||||
'user': '1000/day'
|
|
||||||
},
|
|
||||||
'DEFAULT_PAGINATION_CLASS': (
|
|
||||||
'rest_framework.pagination.PageNumberPagination'
|
|
||||||
),
|
|
||||||
'PAGE_SIZE': 20,
|
|
||||||
'VIEW_DESCRIPTION_FUNCTION': 'weblate.api.views.get_view_description',
|
|
||||||
'UNAUTHENTICATED_USER': 'weblate.accounts.models.get_anonymous',
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example for restricting access to logged in users
|
|
||||||
# LOGIN_REQUIRED_URLS = (
|
|
||||||
# r'/(.*)$',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# In such case you will want to include some of the exceptions
|
|
||||||
# LOGIN_REQUIRED_URLS_EXCEPTIONS = (
|
|
||||||
# r'/accounts/(.*)$', # Required for login
|
|
||||||
# r'/static/(.*)$', # Required for development mode
|
|
||||||
# r'/widgets/(.*)$', # Allowing public access to widgets
|
|
||||||
# r'/data/(.*)$', # Allowing public access to data exports
|
|
||||||
# r'/hooks/(.*)$', # Allowing public access to notification hooks
|
|
||||||
# r'/api/(.*)$', # Allowing access to API
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Force sane test runner
|
|
||||||
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
|
|
@ -1,708 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# Copyright © 2012 - 2017 Michal Čihař <michal@cihar.com>
|
|
||||||
#
|
|
||||||
# This file is part of Weblate <https://weblate.org/>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import platform
|
|
||||||
import os
|
|
||||||
from logging.handlers import SysLogHandler
|
|
||||||
|
|
||||||
#
|
|
||||||
# Django settings for Weblate project.
|
|
||||||
#
|
|
||||||
|
|
||||||
DEBUG = False
|
|
||||||
|
|
||||||
ADMINS = (
|
|
||||||
('__ADMIN__', '__ADMINMAIL__'),
|
|
||||||
)
|
|
||||||
|
|
||||||
MANAGERS = ADMINS
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
# Database engine
|
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
||||||
# Database name
|
|
||||||
'NAME': '__NAME__',
|
|
||||||
# Database user
|
|
||||||
'USER': '__NAME__',
|
|
||||||
# Database password
|
|
||||||
'PASSWORD': '__DB_PWD__',
|
|
||||||
# Set to empty string for localhost
|
|
||||||
'HOST': 'localhost',
|
|
||||||
# Set to empty string for default
|
|
||||||
'PORT': '5432',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BASE_DIR = '__FINALPATH__'
|
|
||||||
|
|
||||||
# Data directory
|
|
||||||
DATA_DIR = os.path.join(BASE_DIR, 'data')
|
|
||||||
|
|
||||||
# Local time zone for this installation. Choices can be found here:
|
|
||||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
|
||||||
# although not all choices may be available on all operating systems.
|
|
||||||
# In a Windows environment this must be set to your system time zone.
|
|
||||||
TIME_ZONE = 'UTC'
|
|
||||||
|
|
||||||
# Language code for this installation. All choices can be found here:
|
|
||||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
|
||||||
|
|
||||||
LANGUAGES = (
|
|
||||||
('az', 'Azərbaycan'),
|
|
||||||
('be', 'Беларуская'),
|
|
||||||
('be@latin', 'Biełaruskaja'),
|
|
||||||
('bg', 'Български'),
|
|
||||||
('br', 'Brezhoneg'),
|
|
||||||
('ca', 'Català'),
|
|
||||||
('cs', 'Čeština'),
|
|
||||||
('da', 'Dansk'),
|
|
||||||
('de', 'Deutsch'),
|
|
||||||
('en', 'English'),
|
|
||||||
('en-gb', 'English (United Kingdom)'),
|
|
||||||
('el', 'Ελληνικά'),
|
|
||||||
('es', 'Español'),
|
|
||||||
('fi', 'Suomi'),
|
|
||||||
('fr', 'Français'),
|
|
||||||
('fy', 'Frysk'),
|
|
||||||
('gl', 'Galego'),
|
|
||||||
('he', 'עברית'),
|
|
||||||
('hu', 'Magyar'),
|
|
||||||
('id', 'Indonesia'),
|
|
||||||
('it', 'Italiano'),
|
|
||||||
('ja', '日本語'),
|
|
||||||
('ko', '한국어'),
|
|
||||||
('ksh', 'Kölsch'),
|
|
||||||
('nb', 'Norsk bokmål'),
|
|
||||||
('nl', 'Nederlands'),
|
|
||||||
('pl', 'Polski'),
|
|
||||||
('pt', 'Português'),
|
|
||||||
('pt-br', 'Português brasileiro'),
|
|
||||||
('ru', 'Русский'),
|
|
||||||
('sk', 'Slovenčina'),
|
|
||||||
('sl', 'Slovenščina'),
|
|
||||||
('sr', 'Српски'),
|
|
||||||
('sv', 'Svenska'),
|
|
||||||
('tr', 'Türkçe'),
|
|
||||||
('uk', 'Українська'),
|
|
||||||
('zh-hans', '简体字'),
|
|
||||||
('zh-hant', '正體字'),
|
|
||||||
)
|
|
||||||
|
|
||||||
SITE_ID = 1
|
|
||||||
|
|
||||||
# If you set this to False, Django will make some optimizations so as not
|
|
||||||
# to load the internationalization machinery.
|
|
||||||
USE_I18N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not format dates, numbers and
|
|
||||||
# calendars according to the current locale.
|
|
||||||
USE_L10N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not use timezone-aware datetimes.
|
|
||||||
USE_TZ = True
|
|
||||||
|
|
||||||
# URL prefix to use, please see documentation for more details
|
|
||||||
URL_PREFIX = '__PATHURL__'
|
|
||||||
|
|
||||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
|
||||||
# Example: "/home/media/media.lawrence.com/media/"
|
|
||||||
MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
|
|
||||||
|
|
||||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
|
||||||
# trailing slash.
|
|
||||||
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
|
||||||
MEDIA_URL = '{0}/media/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Absolute path to the directory static files should be collected to.
|
|
||||||
# Don't put anything in this directory yourself; store your static files
|
|
||||||
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
|
|
||||||
# Example: "/home/media/media.lawrence.com/static/"
|
|
||||||
STATIC_ROOT = os.path.join(DATA_DIR, 'static')
|
|
||||||
|
|
||||||
# URL prefix for static files.
|
|
||||||
# Example: "http://media.lawrence.com/static/"
|
|
||||||
STATIC_URL = '{0}/static/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Additional locations of static files
|
|
||||||
STATICFILES_DIRS = (
|
|
||||||
# Put strings here, like "/home/html/static" or "C:/www/django/static".
|
|
||||||
# Always use forward slashes, even on Windows.
|
|
||||||
# Don't forget to use absolute paths, not relative paths.
|
|
||||||
)
|
|
||||||
|
|
||||||
# List of finder classes that know how to find static files in
|
|
||||||
# various locations.
|
|
||||||
STATICFILES_FINDERS = (
|
|
||||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
|
||||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
|
||||||
'compressor.finders.CompressorFinder',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Make this unique, and don't share it with anybody.
|
|
||||||
# You can generate it using examples/generate-secret-key
|
|
||||||
SECRET_KEY = '__KEY__' # noqa
|
|
||||||
|
|
||||||
TEMPLATES = [
|
|
||||||
{
|
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
||||||
'DIRS': [
|
|
||||||
os.path.join(BASE_DIR, 'templates'),
|
|
||||||
],
|
|
||||||
'OPTIONS': {
|
|
||||||
'context_processors': [
|
|
||||||
'django.contrib.auth.context_processors.auth',
|
|
||||||
'django.template.context_processors.debug',
|
|
||||||
'django.template.context_processors.i18n',
|
|
||||||
'django.template.context_processors.request',
|
|
||||||
'django.template.context_processors.csrf',
|
|
||||||
'django.contrib.messages.context_processors.messages',
|
|
||||||
'weblate.trans.context_processors.weblate_context',
|
|
||||||
],
|
|
||||||
'loaders': [
|
|
||||||
('django.template.loaders.cached.Loader', [
|
|
||||||
'django.template.loaders.filesystem.Loader',
|
|
||||||
'django.template.loaders.app_directories.Loader',
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# GitHub username for sending pull requests.
|
|
||||||
# Please see the documentation for more details.
|
|
||||||
GITHUB_USERNAME = "__GITHUBUSER__"
|
|
||||||
|
|
||||||
# Authentication configuration
|
|
||||||
AUTHENTICATION_BACKENDS = (
|
|
||||||
'social_core.backends.email.EmailAuth',
|
|
||||||
# 'social_core.backends.google.GoogleOAuth2',
|
|
||||||
# 'social_core.backends.github.GithubOAuth2',
|
|
||||||
# 'social_core.backends.bitbucket.BitbucketOAuth',
|
|
||||||
'social_core.backends.suse.OpenSUSEOpenId',
|
|
||||||
'social_core.backends.ubuntu.UbuntuOpenId',
|
|
||||||
'social_core.backends.fedora.FedoraOpenId',
|
|
||||||
# 'social_core.backends.facebook.FacebookOAuth2',
|
|
||||||
'weblate.accounts.auth.WeblateUserBackend',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Social auth backends setup
|
|
||||||
SOCIAL_AUTH_GITHUB_KEY = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SECRET = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SCOPE = ['user:email']
|
|
||||||
|
|
||||||
SOCIAL_AUTH_BITBUCKET_KEY = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_SECRET = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_VERIFIED_EMAILS_ONLY = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_FACEBOOK_KEY = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SECRET = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email', 'public_profile']
|
|
||||||
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = ''
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = ''
|
|
||||||
|
|
||||||
# Social auth settings
|
|
||||||
SOCIAL_AUTH_PIPELINE = (
|
|
||||||
'social_core.pipeline.social_auth.social_details',
|
|
||||||
'social_core.pipeline.social_auth.social_uid',
|
|
||||||
'social_core.pipeline.social_auth.auth_allowed',
|
|
||||||
'social_core.pipeline.social_auth.social_user',
|
|
||||||
'weblate.accounts.pipeline.store_params',
|
|
||||||
'weblate.accounts.pipeline.verify_open',
|
|
||||||
'social_core.pipeline.user.get_username',
|
|
||||||
'weblate.accounts.pipeline.require_email',
|
|
||||||
'social_core.pipeline.mail.mail_validation',
|
|
||||||
'weblate.accounts.pipeline.revoke_mail_code',
|
|
||||||
'weblate.accounts.pipeline.ensure_valid',
|
|
||||||
'weblate.accounts.pipeline.remove_account',
|
|
||||||
'social_core.pipeline.social_auth.associate_by_email',
|
|
||||||
'weblate.accounts.pipeline.reauthenticate',
|
|
||||||
'weblate.accounts.pipeline.verify_username',
|
|
||||||
'social_core.pipeline.user.create_user',
|
|
||||||
'social_core.pipeline.social_auth.associate_user',
|
|
||||||
'social_core.pipeline.social_auth.load_extra_data',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
'weblate.accounts.pipeline.user_full_name',
|
|
||||||
'weblate.accounts.pipeline.store_email',
|
|
||||||
'weblate.accounts.pipeline.notify_connect',
|
|
||||||
'weblate.accounts.pipeline.password_reset',
|
|
||||||
)
|
|
||||||
SOCIAL_AUTH_DISCONNECT_PIPELINE = (
|
|
||||||
'social_core.pipeline.disconnect.allowed_to_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.get_entries',
|
|
||||||
'social_core.pipeline.disconnect.revoke_tokens',
|
|
||||||
'weblate.accounts.pipeline.cycle_session',
|
|
||||||
'weblate.accounts.pipeline.adjust_primary_mail',
|
|
||||||
'weblate.accounts.pipeline.notify_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.disconnect',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom authentication strategy
|
|
||||||
SOCIAL_AUTH_STRATEGY = 'weblate.accounts.strategy.WeblateStrategy'
|
|
||||||
|
|
||||||
# Raise exceptions so that we can handle them later
|
|
||||||
SOCIAL_AUTH_RAISE_EXCEPTIONS = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_FUNCTION = \
|
|
||||||
'weblate.accounts.pipeline.send_validation'
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_URL = \
|
|
||||||
'{0}/accounts/email-sent/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_LOGIN_ERROR_URL = \
|
|
||||||
'{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_EMAIL_FORM_URL = \
|
|
||||||
'{0}/accounts/email/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL = \
|
|
||||||
'{0}/accounts/profile/#auth'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_PROTECTED_USER_FIELDS = ('email',)
|
|
||||||
SOCIAL_AUTH_SLUGIFY_USERNAMES = True
|
|
||||||
SOCIAL_AUTH_SLUGIFY_FUNCTION = 'weblate.accounts.pipeline.slugify_username'
|
|
||||||
|
|
||||||
# Password validation configuration
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
||||||
'OPTIONS': {
|
|
||||||
'min_length': 6,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.CharsPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.PastPasswordsValidator',
|
|
||||||
},
|
|
||||||
# Optional password strength validation by django-zxcvbn-password
|
|
||||||
# {
|
|
||||||
# 'NAME': 'zxcvbn_password.ZXCVBNValidator',
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'min_score': 3,
|
|
||||||
# 'user_attributes': ('username', 'email', 'first_name')
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
]
|
|
||||||
|
|
||||||
# Middleware
|
|
||||||
MIDDLEWARE = [
|
|
||||||
'django.middleware.security.SecurityMiddleware',
|
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
||||||
'django.middleware.common.CommonMiddleware',
|
|
||||||
'django.middleware.locale.LocaleMiddleware',
|
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
|
||||||
'weblate.accounts.middleware.AuthenticationMiddleware',
|
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
||||||
'social_django.middleware.SocialAuthExceptionMiddleware',
|
|
||||||
'weblate.accounts.middleware.RequireLoginMiddleware',
|
|
||||||
'weblate.middleware.SecurityMiddleware',
|
|
||||||
]
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'weblate.urls'
|
|
||||||
|
|
||||||
# Django and Weblate apps
|
|
||||||
INSTALLED_APPS = (
|
|
||||||
'django.contrib.auth',
|
|
||||||
'django.contrib.contenttypes',
|
|
||||||
'django.contrib.sessions',
|
|
||||||
'django.contrib.sites',
|
|
||||||
'django.contrib.messages',
|
|
||||||
'django.contrib.staticfiles',
|
|
||||||
'django.contrib.admin.apps.SimpleAdminConfig',
|
|
||||||
'django.contrib.admindocs',
|
|
||||||
'django.contrib.sitemaps',
|
|
||||||
'social_django',
|
|
||||||
'crispy_forms',
|
|
||||||
'compressor',
|
|
||||||
'rest_framework',
|
|
||||||
'rest_framework.authtoken',
|
|
||||||
'weblate.trans',
|
|
||||||
'weblate.lang',
|
|
||||||
'weblate.permissions',
|
|
||||||
'weblate.screenshots',
|
|
||||||
'weblate.accounts',
|
|
||||||
'weblate.utils',
|
|
||||||
'weblate.wladmin',
|
|
||||||
'weblate',
|
|
||||||
|
|
||||||
# Optional: Git exporter
|
|
||||||
# 'weblate.gitexport',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Path to locales
|
|
||||||
LOCALE_PATHS = (os.path.join(BASE_DIR, 'weblate', 'locale'), )
|
|
||||||
|
|
||||||
# Custom exception reporter to include some details
|
|
||||||
DEFAULT_EXCEPTION_REPORTER_FILTER = \
|
|
||||||
'weblate.trans.debug.WeblateExceptionReporterFilter'
|
|
||||||
|
|
||||||
# Default logging of Weblate messages
|
|
||||||
# - to syslog in production (if available)
|
|
||||||
# - otherwise to console
|
|
||||||
# - you can also choose 'logfile' to log into separate file
|
|
||||||
# after configuring it below
|
|
||||||
|
|
||||||
# Detect if we can connect to syslog
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
if platform.system() != 'Windows':
|
|
||||||
try:
|
|
||||||
handler = SysLogHandler(
|
|
||||||
address='/dev/log', facility=SysLogHandler.LOG_LOCAL2
|
|
||||||
)
|
|
||||||
handler.close()
|
|
||||||
HAVE_SYSLOG = True
|
|
||||||
except IOError:
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
|
|
||||||
if DEBUG or not HAVE_SYSLOG:
|
|
||||||
DEFAULT_LOG = 'console'
|
|
||||||
else:
|
|
||||||
DEFAULT_LOG = 'syslog'
|
|
||||||
|
|
||||||
# A sample logging configuration. The only tangible logging
|
|
||||||
# performed by this configuration is to send an email to
|
|
||||||
# the site admins on every HTTP 500 error when DEBUG=False.
|
|
||||||
# See http://docs.djangoproject.com/en/stable/topics/logging for
|
|
||||||
# more details on how to customize your logging configuration.
|
|
||||||
LOGGING = {
|
|
||||||
'version': 1,
|
|
||||||
'disable_existing_loggers': False,
|
|
||||||
'filters': {
|
|
||||||
'require_debug_false': {
|
|
||||||
'()': 'django.utils.log.RequireDebugFalse'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'formatters': {
|
|
||||||
'syslog': {
|
|
||||||
'format': 'weblate[%(process)d]: %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'simple': {
|
|
||||||
'format': '%(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'logfile': {
|
|
||||||
'format': '%(asctime)s %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'handlers': {
|
|
||||||
'mail_admins': {
|
|
||||||
'level': 'ERROR',
|
|
||||||
'filters': ['require_debug_false'],
|
|
||||||
'class': 'django.utils.log.AdminEmailHandler',
|
|
||||||
'include_html': True,
|
|
||||||
},
|
|
||||||
'console': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'simple'
|
|
||||||
},
|
|
||||||
'syslog': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.handlers.SysLogHandler',
|
|
||||||
'formatter': 'syslog',
|
|
||||||
'address': '/dev/log',
|
|
||||||
'facility': SysLogHandler.LOG_LOCAL2,
|
|
||||||
},
|
|
||||||
# Logging to a file
|
|
||||||
# 'logfile': {
|
|
||||||
# 'level':'DEBUG',
|
|
||||||
# 'class':'logging.handlers.RotatingFileHandler',
|
|
||||||
# 'filename': "/var/log/weblate/weblate.log",
|
|
||||||
# 'maxBytes': 100000,
|
|
||||||
# 'backupCount': 3,
|
|
||||||
# 'formatter': 'logfile',
|
|
||||||
# },
|
|
||||||
},
|
|
||||||
'loggers': {
|
|
||||||
'django.request': {
|
|
||||||
'handlers': ['mail_admins', DEFAULT_LOG],
|
|
||||||
'level': 'ERROR',
|
|
||||||
'propagate': True,
|
|
||||||
},
|
|
||||||
# Logging database queries
|
|
||||||
# 'django.db.backends': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
'weblate': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'DEBUG',
|
|
||||||
},
|
|
||||||
# Logging VCS operations
|
|
||||||
# 'weblate-vcs': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
# Python Social Auth logging
|
|
||||||
# 'social': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Logging of management commands to console
|
|
||||||
if (os.environ.get('DJANGO_IS_MANAGEMENT_COMMAND', False) and
|
|
||||||
'console' not in LOGGING['loggers']['weblate']['handlers']):
|
|
||||||
LOGGING['loggers']['weblate']['handlers'].append('console')
|
|
||||||
|
|
||||||
# Remove syslog setup if it's not present
|
|
||||||
if not HAVE_SYSLOG:
|
|
||||||
del LOGGING['handlers']['syslog']
|
|
||||||
|
|
||||||
# List of machine translations
|
|
||||||
# MACHINE_TRANSLATION_SERVICES = (
|
|
||||||
# 'weblate.trans.machine.apertium.ApertiumAPYTranslation',
|
|
||||||
# 'weblate.trans.machine.glosbe.GlosbeTranslation',
|
|
||||||
# 'weblate.trans.machine.google.GoogleTranslation',
|
|
||||||
# 'weblate.trans.machine.microsoft.MicrosoftCognitiveTranslation',
|
|
||||||
# 'weblate.trans.machine.mymemory.MyMemoryTranslation',
|
|
||||||
# 'weblate.trans.machine.tmserver.AmagamaTranslation',
|
|
||||||
# 'weblate.trans.machine.tmserver.TMServerTranslation',
|
|
||||||
# 'weblate.trans.machine.yandex.YandexTranslation',
|
|
||||||
# 'weblate.trans.machine.weblatetm.WeblateSimilarTranslation',
|
|
||||||
# 'weblate.trans.machine.weblatetm.WeblateTranslation',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Machine translation API keys
|
|
||||||
|
|
||||||
# URL of the Apertium APy server
|
|
||||||
MT_APERTIUM_APY = None
|
|
||||||
|
|
||||||
# Microsoft Translator service, register at
|
|
||||||
# https://datamarket.azure.com/developer/applications/
|
|
||||||
MT_MICROSOFT_ID = None
|
|
||||||
MT_MICROSOFT_SECRET = None
|
|
||||||
|
|
||||||
# Microsoft Cognitive Services Translator API, register at
|
|
||||||
# https://portal.azure.com/
|
|
||||||
MT_MICROSOFT_COGNITIVE_KEY = None
|
|
||||||
|
|
||||||
# MyMemory identification email, see
|
|
||||||
# https://mymemory.translated.net/doc/spec.php
|
|
||||||
MT_MYMEMORY_EMAIL = None
|
|
||||||
|
|
||||||
# Optional MyMemory credentials to access private translation memory
|
|
||||||
MT_MYMEMORY_USER = None
|
|
||||||
MT_MYMEMORY_KEY = None
|
|
||||||
|
|
||||||
# Google API key for Google Translate API
|
|
||||||
MT_GOOGLE_KEY = None
|
|
||||||
|
|
||||||
# API key for Yandex Translate API
|
|
||||||
MT_YANDEX_KEY = None
|
|
||||||
|
|
||||||
# tmserver URL
|
|
||||||
MT_TMSERVER = None
|
|
||||||
|
|
||||||
# Title of site to use
|
|
||||||
SITE_TITLE = 'Weblate'
|
|
||||||
|
|
||||||
# Whether site uses https
|
|
||||||
ENABLE_HTTPS = True
|
|
||||||
|
|
||||||
# Use HTTPS when creating redirect URLs for social authentication, see
|
|
||||||
# documentation for more details:
|
|
||||||
# http://python-social-auth-docs.readthedocs.io/en/latest/configuration/settings.html#processing-redirects-and-urlopen
|
|
||||||
SOCIAL_AUTH_REDIRECT_IS_HTTPS = ENABLE_HTTPS
|
|
||||||
|
|
||||||
# Make CSRF cookie HttpOnly, see documentation for more details:
|
|
||||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#csrf-cookie-httponly
|
|
||||||
CSRF_COOKIE_HTTPONLY = True
|
|
||||||
CSRF_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# Store CSRF token in session (since Django 1.11)
|
|
||||||
CSRF_USE_SESSIONS = True
|
|
||||||
SESSION_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# Session cookie age (in seconds)
|
|
||||||
SESSION_COOKIE_AGE = 1209600
|
|
||||||
|
|
||||||
# URL of login
|
|
||||||
LOGIN_URL = '{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# URL of logout
|
|
||||||
LOGOUT_URL = '{0}/accounts/logout/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Default location for login
|
|
||||||
LOGIN_REDIRECT_URL = '{0}/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Anonymous user name
|
|
||||||
ANONYMOUS_USER_NAME = 'anonymous'
|
|
||||||
|
|
||||||
# Reverse proxy settings
|
|
||||||
IP_BEHIND_REVERSE_PROXY = False
|
|
||||||
IP_PROXY_HEADER = 'HTTP_X_FORWARDED_FOR'
|
|
||||||
IP_PROXY_OFFSET = 0
|
|
||||||
|
|
||||||
# Sending HTML in mails
|
|
||||||
EMAIL_SEND_HTML = True
|
|
||||||
|
|
||||||
# Subject of emails includes site title
|
|
||||||
EMAIL_SUBJECT_PREFIX = '[{0}] '.format(SITE_TITLE)
|
|
||||||
|
|
||||||
# Enable remote hooks
|
|
||||||
ENABLE_HOOKS = True
|
|
||||||
|
|
||||||
# Whether to run hooks in background
|
|
||||||
BACKGROUND_HOOKS = True
|
|
||||||
|
|
||||||
# Number of nearby messages to show in each direction
|
|
||||||
NEARBY_MESSAGES = 5
|
|
||||||
|
|
||||||
# Enable lazy commits
|
|
||||||
LAZY_COMMITS = True
|
|
||||||
|
|
||||||
# Offload indexing
|
|
||||||
OFFLOAD_INDEXING = True
|
|
||||||
|
|
||||||
# Use simple language codes for default language/country combinations
|
|
||||||
SIMPLIFY_LANGUAGES = True
|
|
||||||
|
|
||||||
# Render forms using bootstrap
|
|
||||||
CRISPY_TEMPLATE_PACK = 'bootstrap3'
|
|
||||||
|
|
||||||
# List of quality checks
|
|
||||||
# CHECK_LIST = (
|
|
||||||
# 'weblate.trans.checks.same.SameCheck',
|
|
||||||
# 'weblate.trans.checks.chars.BeginNewlineCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndNewlineCheck',
|
|
||||||
# 'weblate.trans.checks.chars.BeginSpaceCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndSpaceCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndStopCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndColonCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndQuestionCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndExclamationCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndEllipsisCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndSemicolonCheck',
|
|
||||||
# 'weblate.trans.checks.chars.MaxLengthCheck',
|
|
||||||
# 'weblate.trans.checks.format.PythonFormatCheck',
|
|
||||||
# 'weblate.trans.checks.format.PythonBraceFormatCheck',
|
|
||||||
# 'weblate.trans.checks.format.PHPFormatCheck',
|
|
||||||
# 'weblate.trans.checks.format.CFormatCheck',
|
|
||||||
# 'weblate.trans.checks.format.PerlFormatCheck',
|
|
||||||
# 'weblate.trans.checks.format.JavascriptFormatCheck',
|
|
||||||
# 'weblate.trans.checks.consistency.PluralsCheck',
|
|
||||||
# 'weblate.trans.checks.consistency.SamePluralsCheck',
|
|
||||||
# 'weblate.trans.checks.consistency.ConsistencyCheck',
|
|
||||||
# 'weblate.trans.checks.consistency.TranslatedCheck',
|
|
||||||
# 'weblate.trans.checks.chars.NewlineCountingCheck',
|
|
||||||
# 'weblate.trans.checks.markup.BBCodeCheck',
|
|
||||||
# 'weblate.trans.checks.chars.ZeroWidthSpaceCheck',
|
|
||||||
# 'weblate.trans.checks.markup.XMLValidityCheck',
|
|
||||||
# 'weblate.trans.checks.markup.XMLTagsCheck',
|
|
||||||
# 'weblate.trans.checks.source.OptionalPluralCheck',
|
|
||||||
# 'weblate.trans.checks.source.EllipsisCheck',
|
|
||||||
# 'weblate.trans.checks.source.MultipleFailingCheck',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of automatic fixups
|
|
||||||
# AUTOFIX_LIST = (
|
|
||||||
# 'weblate.trans.autofixes.whitespace.SameBookendingWhitespace',
|
|
||||||
# 'weblate.trans.autofixes.chars.ReplaceTrailingDotsWithEllipsis',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveZeroSpace',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveControlChars',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of scripts to use in custom processing
|
|
||||||
# POST_UPDATE_SCRIPTS = (
|
|
||||||
# )
|
|
||||||
# PRE_COMMIT_SCRIPTS = (
|
|
||||||
# )
|
|
||||||
|
|
||||||
# E-mail address that error messages come from.
|
|
||||||
SERVER_EMAIL = 'noreply@__DOMAIN__'
|
|
||||||
|
|
||||||
# Default email address to use for various automated correspondence from
|
|
||||||
# the site managers. Used for registration emails.
|
|
||||||
DEFAULT_FROM_EMAIL = '__ADMINMAIL__'
|
|
||||||
|
|
||||||
# List of URLs your site is supposed to serve
|
|
||||||
ALLOWED_HOSTS = ['__DOMAIN__']
|
|
||||||
|
|
||||||
# Example configuration to use memcached for caching
|
|
||||||
CACHES = {
|
|
||||||
'default': {
|
|
||||||
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
|
||||||
'LOCATION': '127.0.0.1:__MEMCPORT__',
|
|
||||||
},
|
|
||||||
'avatar': {
|
|
||||||
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
|
||||||
'LOCATION': os.path.join(BASE_DIR, 'avatar-cache'),
|
|
||||||
'TIMEOUT': 3600,
|
|
||||||
'OPTIONS': {
|
|
||||||
'MAX_ENTRIES': 1000,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# REST framework settings for API
|
|
||||||
REST_FRAMEWORK = {
|
|
||||||
# Use Django's standard `django.contrib.auth` permissions,
|
|
||||||
# or allow read-only access for unauthenticated users.
|
|
||||||
'DEFAULT_PERMISSION_CLASSES': [
|
|
||||||
'rest_framework.permissions.IsAuthenticatedOrReadOnly'
|
|
||||||
],
|
|
||||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
|
||||||
'rest_framework.authentication.TokenAuthentication',
|
|
||||||
'rest_framework.authentication.SessionAuthentication',
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_CLASSES': (
|
|
||||||
'rest_framework.throttling.AnonRateThrottle',
|
|
||||||
'rest_framework.throttling.UserRateThrottle'
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_RATES': {
|
|
||||||
'anon': '100/day',
|
|
||||||
'user': '1000/day'
|
|
||||||
},
|
|
||||||
'DEFAULT_PAGINATION_CLASS': (
|
|
||||||
'rest_framework.pagination.PageNumberPagination'
|
|
||||||
),
|
|
||||||
'PAGE_SIZE': 20,
|
|
||||||
'VIEW_DESCRIPTION_FUNCTION': 'weblate.api.views.get_view_description',
|
|
||||||
'UNAUTHENTICATED_USER': 'weblate.accounts.models.get_anonymous',
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example for restricting access to logged in users
|
|
||||||
# LOGIN_REQUIRED_URLS = (
|
|
||||||
# r'/(.*)$',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# In such case you will want to include some of the exceptions
|
|
||||||
# LOGIN_REQUIRED_URLS_EXCEPTIONS = (
|
|
||||||
# r'/accounts/(.*)$', # Required for login
|
|
||||||
# r'/static/(.*)$', # Required for development mode
|
|
||||||
# r'/widgets/(.*)$', # Allowing public access to widgets
|
|
||||||
# r'/data/(.*)$', # Allowing public access to data exports
|
|
||||||
# r'/hooks/(.*)$', # Allowing public access to notification hooks
|
|
||||||
# r'/api/(.*)$', # Allowing access to API
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Force sane test runner
|
|
||||||
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
|
|
@ -1,754 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# Copyright © 2012 - 2018 Michal Čihař <michal@cihar.com>
|
|
||||||
#
|
|
||||||
# This file is part of Weblate <https://weblate.org/>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import platform
|
|
||||||
import os
|
|
||||||
from logging.handlers import SysLogHandler
|
|
||||||
|
|
||||||
#
|
|
||||||
# Django settings for Weblate project.
|
|
||||||
#
|
|
||||||
|
|
||||||
DEBUG = False
|
|
||||||
|
|
||||||
ADMINS = (
|
|
||||||
('__ADMIN__', '__ADMINMAIL__'),
|
|
||||||
)
|
|
||||||
|
|
||||||
MANAGERS = ADMINS
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
# Database engine
|
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
||||||
# Database name
|
|
||||||
'NAME': '__NAME__',
|
|
||||||
# Database user
|
|
||||||
'USER': '__NAME__',
|
|
||||||
# Database password
|
|
||||||
'PASSWORD': '__DB_PWD__',
|
|
||||||
# Set to empty string for localhost
|
|
||||||
'HOST': 'localhost',
|
|
||||||
# Set to empty string for default
|
|
||||||
'PORT': '5432',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BASE_DIR = '__FINALPATH__'
|
|
||||||
|
|
||||||
# Data directory
|
|
||||||
DATA_DIR = os.path.join(BASE_DIR, 'data')
|
|
||||||
|
|
||||||
# Local time zone for this installation. Choices can be found here:
|
|
||||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
|
||||||
# although not all choices may be available on all operating systems.
|
|
||||||
# In a Windows environment this must be set to your system time zone.
|
|
||||||
TIME_ZONE = 'UTC'
|
|
||||||
|
|
||||||
# Language code for this installation. All choices can be found here:
|
|
||||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
|
||||||
|
|
||||||
LANGUAGES = (
|
|
||||||
('ar', 'العربية'),
|
|
||||||
('az', 'Azərbaycan'),
|
|
||||||
('be', 'Беларуская'),
|
|
||||||
('be@latin', 'Biełaruskaja'),
|
|
||||||
('bg', 'Български'),
|
|
||||||
('br', 'Brezhoneg'),
|
|
||||||
('ca', 'Català'),
|
|
||||||
('cs', 'Čeština'),
|
|
||||||
('da', 'Dansk'),
|
|
||||||
('de', 'Deutsch'),
|
|
||||||
('en', 'English'),
|
|
||||||
('en-gb', 'English (United Kingdom)'),
|
|
||||||
('el', 'Ελληνικά'),
|
|
||||||
('es', 'Español'),
|
|
||||||
('fi', 'Suomi'),
|
|
||||||
('fr', 'Français'),
|
|
||||||
('fy', 'Frysk'),
|
|
||||||
('gl', 'Galego'),
|
|
||||||
('he', 'עברית'),
|
|
||||||
('hu', 'Magyar'),
|
|
||||||
('id', 'Indonesia'),
|
|
||||||
('it', 'Italiano'),
|
|
||||||
('ja', '日本語'),
|
|
||||||
('ko', '한국어'),
|
|
||||||
('ksh', 'Kölsch'),
|
|
||||||
('nb', 'Norsk bokmål'),
|
|
||||||
('nl', 'Nederlands'),
|
|
||||||
('pl', 'Polski'),
|
|
||||||
('pt', 'Português'),
|
|
||||||
('pt-br', 'Português brasileiro'),
|
|
||||||
('ru', 'Русский'),
|
|
||||||
('sk', 'Slovenčina'),
|
|
||||||
('sl', 'Slovenščina'),
|
|
||||||
('sr', 'Српски'),
|
|
||||||
('sv', 'Svenska'),
|
|
||||||
('tr', 'Türkçe'),
|
|
||||||
('uk', 'Українська'),
|
|
||||||
('zh-hans', '简体字'),
|
|
||||||
('zh-hant', '正體字'),
|
|
||||||
)
|
|
||||||
|
|
||||||
SITE_ID = 1
|
|
||||||
|
|
||||||
# If you set this to False, Django will make some optimizations so as not
|
|
||||||
# to load the internationalization machinery.
|
|
||||||
USE_I18N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not format dates, numbers and
|
|
||||||
# calendars according to the current locale.
|
|
||||||
USE_L10N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not use timezone-aware datetimes.
|
|
||||||
USE_TZ = True
|
|
||||||
|
|
||||||
# URL prefix to use, please see documentation for more details
|
|
||||||
URL_PREFIX = '__PATHURL__'
|
|
||||||
|
|
||||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
|
||||||
# Example: "/home/media/media.lawrence.com/media/"
|
|
||||||
MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
|
|
||||||
|
|
||||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
|
||||||
# trailing slash.
|
|
||||||
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
|
||||||
MEDIA_URL = '{0}/media/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Absolute path to the directory static files should be collected to.
|
|
||||||
# Don't put anything in this directory yourself; store your static files
|
|
||||||
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
|
|
||||||
# Example: "/home/media/media.lawrence.com/static/"
|
|
||||||
STATIC_ROOT = os.path.join(DATA_DIR, 'static')
|
|
||||||
|
|
||||||
# URL prefix for static files.
|
|
||||||
# Example: "http://media.lawrence.com/static/"
|
|
||||||
STATIC_URL = '{0}/static/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Additional locations of static files
|
|
||||||
STATICFILES_DIRS = (
|
|
||||||
# Put strings here, like "/home/html/static" or "C:/www/django/static".
|
|
||||||
# Always use forward slashes, even on Windows.
|
|
||||||
# Don't forget to use absolute paths, not relative paths.
|
|
||||||
)
|
|
||||||
|
|
||||||
# List of finder classes that know how to find static files in
|
|
||||||
# various locations.
|
|
||||||
STATICFILES_FINDERS = (
|
|
||||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
|
||||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
|
||||||
'compressor.finders.CompressorFinder',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Make this unique, and don't share it with anybody.
|
|
||||||
# You can generate it using examples/generate-secret-key
|
|
||||||
SECRET_KEY = '__KEY__' # noqa
|
|
||||||
|
|
||||||
TEMPLATES = [
|
|
||||||
{
|
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
||||||
'DIRS': [
|
|
||||||
os.path.join(BASE_DIR, 'weblate', 'templates'),
|
|
||||||
],
|
|
||||||
'OPTIONS': {
|
|
||||||
'context_processors': [
|
|
||||||
'django.contrib.auth.context_processors.auth',
|
|
||||||
'django.template.context_processors.debug',
|
|
||||||
'django.template.context_processors.i18n',
|
|
||||||
'django.template.context_processors.request',
|
|
||||||
'django.template.context_processors.csrf',
|
|
||||||
'django.contrib.messages.context_processors.messages',
|
|
||||||
'weblate.trans.context_processors.weblate_context',
|
|
||||||
],
|
|
||||||
'loaders': [
|
|
||||||
('django.template.loaders.cached.Loader', [
|
|
||||||
'django.template.loaders.filesystem.Loader',
|
|
||||||
'django.template.loaders.app_directories.Loader',
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# GitHub username for sending pull requests.
|
|
||||||
# Please see the documentation for more details.
|
|
||||||
GITHUB_USERNAME = "__GITHUBUSER__"
|
|
||||||
|
|
||||||
# Authentication configuration
|
|
||||||
AUTHENTICATION_BACKENDS = (
|
|
||||||
'social_core.backends.email.EmailAuth',
|
|
||||||
# 'social_core.backends.google.GoogleOAuth2',
|
|
||||||
# 'social_core.backends.github.GithubOAuth2',
|
|
||||||
# 'social_core.backends.bitbucket.BitbucketOAuth',
|
|
||||||
'social_core.backends.suse.OpenSUSEOpenId',
|
|
||||||
'social_core.backends.ubuntu.UbuntuOpenId',
|
|
||||||
'social_core.backends.fedora.FedoraOpenId',
|
|
||||||
# 'social_core.backends.facebook.FacebookOAuth2',
|
|
||||||
'weblate.accounts.auth.WeblateUserBackend',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Social auth backends setup
|
|
||||||
SOCIAL_AUTH_GITHUB_KEY = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SECRET = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SCOPE = ['user:email']
|
|
||||||
|
|
||||||
SOCIAL_AUTH_BITBUCKET_KEY = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_SECRET = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_VERIFIED_EMAILS_ONLY = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_FACEBOOK_KEY = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SECRET = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email', 'public_profile']
|
|
||||||
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = ''
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = ''
|
|
||||||
|
|
||||||
# Social auth settings
|
|
||||||
SOCIAL_AUTH_PIPELINE = (
|
|
||||||
'social_core.pipeline.social_auth.social_details',
|
|
||||||
'social_core.pipeline.social_auth.social_uid',
|
|
||||||
'social_core.pipeline.social_auth.auth_allowed',
|
|
||||||
'social_core.pipeline.social_auth.social_user',
|
|
||||||
'weblate.accounts.pipeline.store_params',
|
|
||||||
'weblate.accounts.pipeline.verify_open',
|
|
||||||
'social_core.pipeline.user.get_username',
|
|
||||||
'weblate.accounts.pipeline.require_email',
|
|
||||||
'social_core.pipeline.mail.mail_validation',
|
|
||||||
'weblate.accounts.pipeline.revoke_mail_code',
|
|
||||||
'weblate.accounts.pipeline.ensure_valid',
|
|
||||||
'weblate.accounts.pipeline.remove_account',
|
|
||||||
'social_core.pipeline.social_auth.associate_by_email',
|
|
||||||
'weblate.accounts.pipeline.reauthenticate',
|
|
||||||
'weblate.accounts.pipeline.verify_username',
|
|
||||||
'social_core.pipeline.user.create_user',
|
|
||||||
'social_core.pipeline.social_auth.associate_user',
|
|
||||||
'social_core.pipeline.social_auth.load_extra_data',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
'weblate.accounts.pipeline.user_full_name',
|
|
||||||
'weblate.accounts.pipeline.store_email',
|
|
||||||
'weblate.accounts.pipeline.notify_connect',
|
|
||||||
'weblate.accounts.pipeline.password_reset',
|
|
||||||
)
|
|
||||||
SOCIAL_AUTH_DISCONNECT_PIPELINE = (
|
|
||||||
'social_core.pipeline.disconnect.allowed_to_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.get_entries',
|
|
||||||
'social_core.pipeline.disconnect.revoke_tokens',
|
|
||||||
'weblate.accounts.pipeline.cycle_session',
|
|
||||||
'weblate.accounts.pipeline.adjust_primary_mail',
|
|
||||||
'weblate.accounts.pipeline.notify_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.disconnect',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom authentication strategy
|
|
||||||
SOCIAL_AUTH_STRATEGY = 'weblate.accounts.strategy.WeblateStrategy'
|
|
||||||
|
|
||||||
# Raise exceptions so that we can handle them later
|
|
||||||
SOCIAL_AUTH_RAISE_EXCEPTIONS = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_FUNCTION = \
|
|
||||||
'weblate.accounts.pipeline.send_validation'
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_URL = \
|
|
||||||
'{0}/accounts/email-sent/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_LOGIN_ERROR_URL = \
|
|
||||||
'{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_EMAIL_FORM_URL = \
|
|
||||||
'{0}/accounts/email/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL = \
|
|
||||||
'{0}/accounts/profile/#auth'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_PROTECTED_USER_FIELDS = ('email',)
|
|
||||||
SOCIAL_AUTH_SLUGIFY_USERNAMES = True
|
|
||||||
SOCIAL_AUTH_SLUGIFY_FUNCTION = 'weblate.accounts.pipeline.slugify_username'
|
|
||||||
|
|
||||||
# Password validation configuration
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
||||||
'OPTIONS': {
|
|
||||||
'min_length': 6,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.CharsPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.PastPasswordsValidator',
|
|
||||||
},
|
|
||||||
# Optional password strength validation by django-zxcvbn-password
|
|
||||||
# {
|
|
||||||
# 'NAME': 'zxcvbn_password.ZXCVBNValidator',
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'min_score': 3,
|
|
||||||
# 'user_attributes': ('username', 'email', 'first_name')
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
]
|
|
||||||
|
|
||||||
# Middleware
|
|
||||||
MIDDLEWARE = [
|
|
||||||
'django.middleware.security.SecurityMiddleware',
|
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
||||||
'django.middleware.common.CommonMiddleware',
|
|
||||||
'django.middleware.locale.LocaleMiddleware',
|
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
|
||||||
'weblate.accounts.middleware.AuthenticationMiddleware',
|
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
||||||
'social_django.middleware.SocialAuthExceptionMiddleware',
|
|
||||||
'weblate.accounts.middleware.RequireLoginMiddleware',
|
|
||||||
'weblate.middleware.SecurityMiddleware',
|
|
||||||
'weblate.wladmin.middleware.ConfigurationErrorsMiddleware',
|
|
||||||
]
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'weblate.urls'
|
|
||||||
|
|
||||||
# Django and Weblate apps
|
|
||||||
INSTALLED_APPS = (
|
|
||||||
'django.contrib.auth',
|
|
||||||
'django.contrib.contenttypes',
|
|
||||||
'django.contrib.sessions',
|
|
||||||
'django.contrib.sites',
|
|
||||||
'django.contrib.messages',
|
|
||||||
'django.contrib.staticfiles',
|
|
||||||
'django.contrib.admin.apps.SimpleAdminConfig',
|
|
||||||
'django.contrib.admindocs',
|
|
||||||
'django.contrib.sitemaps',
|
|
||||||
'social_django',
|
|
||||||
'crispy_forms',
|
|
||||||
'compressor',
|
|
||||||
'rest_framework',
|
|
||||||
'rest_framework.authtoken',
|
|
||||||
'weblate.addons',
|
|
||||||
'weblate.trans',
|
|
||||||
'weblate.lang',
|
|
||||||
'weblate.langdata',
|
|
||||||
'weblate.memory',
|
|
||||||
'weblate.permissions',
|
|
||||||
'weblate.screenshots',
|
|
||||||
'weblate.accounts',
|
|
||||||
'weblate.utils',
|
|
||||||
'weblate.wladmin',
|
|
||||||
'weblate',
|
|
||||||
|
|
||||||
# Optional: Git exporter
|
|
||||||
# 'weblate.gitexport',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Path to locales
|
|
||||||
LOCALE_PATHS = (os.path.join(BASE_DIR, 'weblate', 'locale'), )
|
|
||||||
|
|
||||||
# Custom exception reporter to include some details
|
|
||||||
DEFAULT_EXCEPTION_REPORTER_FILTER = \
|
|
||||||
'weblate.trans.debug.WeblateExceptionReporterFilter'
|
|
||||||
|
|
||||||
# Default logging of Weblate messages
|
|
||||||
# - to syslog in production (if available)
|
|
||||||
# - otherwise to console
|
|
||||||
# - you can also choose 'logfile' to log into separate file
|
|
||||||
# after configuring it below
|
|
||||||
|
|
||||||
# Detect if we can connect to syslog
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
if platform.system() != 'Windows':
|
|
||||||
try:
|
|
||||||
handler = SysLogHandler(
|
|
||||||
address='/dev/log', facility=SysLogHandler.LOG_LOCAL2
|
|
||||||
)
|
|
||||||
handler.close()
|
|
||||||
HAVE_SYSLOG = True
|
|
||||||
except IOError:
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
|
|
||||||
if DEBUG or not HAVE_SYSLOG:
|
|
||||||
DEFAULT_LOG = 'console'
|
|
||||||
else:
|
|
||||||
DEFAULT_LOG = 'syslog'
|
|
||||||
|
|
||||||
# A sample logging configuration. The only tangible logging
|
|
||||||
# performed by this configuration is to send an email to
|
|
||||||
# the site admins on every HTTP 500 error when DEBUG=False.
|
|
||||||
# See http://docs.djangoproject.com/en/stable/topics/logging for
|
|
||||||
# more details on how to customize your logging configuration.
|
|
||||||
LOGGING = {
|
|
||||||
'version': 1,
|
|
||||||
'disable_existing_loggers': True,
|
|
||||||
'filters': {
|
|
||||||
'require_debug_false': {
|
|
||||||
'()': 'django.utils.log.RequireDebugFalse'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'formatters': {
|
|
||||||
'syslog': {
|
|
||||||
'format': 'weblate[%(process)d]: %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'simple': {
|
|
||||||
'format': '%(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'logfile': {
|
|
||||||
'format': '%(asctime)s %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'()': 'django.utils.log.ServerFormatter',
|
|
||||||
'format': '[%(server_time)s] %(message)s',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'handlers': {
|
|
||||||
'mail_admins': {
|
|
||||||
'level': 'ERROR',
|
|
||||||
'filters': ['require_debug_false'],
|
|
||||||
'class': 'django.utils.log.AdminEmailHandler',
|
|
||||||
'include_html': True,
|
|
||||||
},
|
|
||||||
'console': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'simple'
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'level': 'INFO',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'django.server',
|
|
||||||
},
|
|
||||||
'syslog': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.handlers.SysLogHandler',
|
|
||||||
'formatter': 'syslog',
|
|
||||||
'address': '/dev/log',
|
|
||||||
'facility': SysLogHandler.LOG_LOCAL2,
|
|
||||||
},
|
|
||||||
# Logging to a file
|
|
||||||
# 'logfile': {
|
|
||||||
# 'level':'DEBUG',
|
|
||||||
# 'class':'logging.handlers.RotatingFileHandler',
|
|
||||||
# 'filename': "/var/log/weblate/weblate.log",
|
|
||||||
# 'maxBytes': 100000,
|
|
||||||
# 'backupCount': 3,
|
|
||||||
# 'formatter': 'logfile',
|
|
||||||
# },
|
|
||||||
},
|
|
||||||
'loggers': {
|
|
||||||
'django.request': {
|
|
||||||
'handlers': ['mail_admins', DEFAULT_LOG],
|
|
||||||
'level': 'ERROR',
|
|
||||||
'propagate': True,
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'handlers': ['django.server'],
|
|
||||||
'level': 'INFO',
|
|
||||||
'propagate': False,
|
|
||||||
},
|
|
||||||
# Logging database queries
|
|
||||||
# 'django.db.backends': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
'weblate': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'DEBUG',
|
|
||||||
},
|
|
||||||
# Logging VCS operations
|
|
||||||
# 'weblate-vcs': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
# Python Social Auth logging
|
|
||||||
# 'social': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Logging of management commands to console
|
|
||||||
if (os.environ.get('DJANGO_IS_MANAGEMENT_COMMAND', False) and
|
|
||||||
'console' not in LOGGING['loggers']['weblate']['handlers']):
|
|
||||||
LOGGING['loggers']['weblate']['handlers'].append('console')
|
|
||||||
|
|
||||||
# Remove syslog setup if it's not present
|
|
||||||
if not HAVE_SYSLOG:
|
|
||||||
del LOGGING['handlers']['syslog']
|
|
||||||
|
|
||||||
# List of machine translations
|
|
||||||
# MACHINE_TRANSLATION_SERVICES = (
|
|
||||||
# 'weblate.trans.machine.apertium.ApertiumAPYTranslation',
|
|
||||||
# 'weblate.trans.machine.deepl.DeepLTranslation',
|
|
||||||
# 'weblate.trans.machine.glosbe.GlosbeTranslation',
|
|
||||||
# 'weblate.trans.machine.google.GoogleTranslation',
|
|
||||||
# 'weblate.trans.machine.microsoft.MicrosoftCognitiveTranslation',
|
|
||||||
# 'weblate.trans.machine.mymemory.MyMemoryTranslation',
|
|
||||||
# 'weblate.trans.machine.tmserver.AmagamaTranslation',
|
|
||||||
# 'weblate.trans.machine.tmserver.TMServerTranslation',
|
|
||||||
# 'weblate.trans.machine.yandex.YandexTranslation',
|
|
||||||
# 'weblate.trans.machine.weblatetm.WeblateTranslation',
|
|
||||||
# 'weblate.trans.machine.saptranslationhub.SAPTranslationHub',
|
|
||||||
# 'weblate.memory.machine.WeblateMemory',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Machine translation API keys
|
|
||||||
|
|
||||||
# URL of the Apertium APy server
|
|
||||||
MT_APERTIUM_APY = None
|
|
||||||
|
|
||||||
# DeepL API key
|
|
||||||
MT_DEEPL_KEY = None
|
|
||||||
|
|
||||||
# Microsoft Cognitive Services Translator API, register at
|
|
||||||
# https://portal.azure.com/
|
|
||||||
MT_MICROSOFT_COGNITIVE_KEY = None
|
|
||||||
|
|
||||||
# MyMemory identification email, see
|
|
||||||
# https://mymemory.translated.net/doc/spec.php
|
|
||||||
MT_MYMEMORY_EMAIL = None
|
|
||||||
|
|
||||||
# Optional MyMemory credentials to access private translation memory
|
|
||||||
MT_MYMEMORY_USER = None
|
|
||||||
MT_MYMEMORY_KEY = None
|
|
||||||
|
|
||||||
# Google API key for Google Translate API
|
|
||||||
MT_GOOGLE_KEY = None
|
|
||||||
|
|
||||||
# API key for Yandex Translate API
|
|
||||||
MT_YANDEX_KEY = None
|
|
||||||
|
|
||||||
# tmserver URL
|
|
||||||
MT_TMSERVER = None
|
|
||||||
|
|
||||||
# SAP Translation Hub
|
|
||||||
MT_SAP_BASE_URL = None
|
|
||||||
MT_SAP_SANDBOX_APIKEY = None
|
|
||||||
MT_SAP_USERNAME = None
|
|
||||||
MT_SAP_PASSWORD = None
|
|
||||||
MT_SAP_USE_MT = True
|
|
||||||
|
|
||||||
# Title of site to use
|
|
||||||
SITE_TITLE = 'Weblate'
|
|
||||||
|
|
||||||
# Whether site uses https
|
|
||||||
ENABLE_HTTPS = True
|
|
||||||
|
|
||||||
# Use HTTPS when creating redirect URLs for social authentication, see
|
|
||||||
# documentation for more details:
|
|
||||||
# http://python-social-auth-docs.readthedocs.io/en/latest/configuration/settings.html#processing-redirects-and-urlopen
|
|
||||||
SOCIAL_AUTH_REDIRECT_IS_HTTPS = ENABLE_HTTPS
|
|
||||||
|
|
||||||
# Make CSRF cookie HttpOnly, see documentation for more details:
|
|
||||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#csrf-cookie-httponly
|
|
||||||
CSRF_COOKIE_HTTPONLY = True
|
|
||||||
CSRF_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# Store CSRF token in session (since Django 1.11)
|
|
||||||
CSRF_USE_SESSIONS = True
|
|
||||||
SESSION_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# Session cookie age (in seconds)
|
|
||||||
SESSION_COOKIE_AGE = 1209600
|
|
||||||
|
|
||||||
# URL of login
|
|
||||||
LOGIN_URL = '{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# URL of logout
|
|
||||||
LOGOUT_URL = '{0}/accounts/logout/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Default location for login
|
|
||||||
LOGIN_REDIRECT_URL = '{0}/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Anonymous user name
|
|
||||||
ANONYMOUS_USER_NAME = 'anonymous'
|
|
||||||
|
|
||||||
# Reverse proxy settings
|
|
||||||
IP_BEHIND_REVERSE_PROXY = False
|
|
||||||
IP_PROXY_HEADER = 'HTTP_X_FORWARDED_FOR'
|
|
||||||
IP_PROXY_OFFSET = 0
|
|
||||||
|
|
||||||
# Sending HTML in mails
|
|
||||||
EMAIL_SEND_HTML = True
|
|
||||||
|
|
||||||
# Subject of emails includes site title
|
|
||||||
EMAIL_SUBJECT_PREFIX = '[{0}] '.format(SITE_TITLE)
|
|
||||||
|
|
||||||
EMAIL_BACKEND = 'django_sendmail_backend.backends.EmailBackend'
|
|
||||||
|
|
||||||
# Enable remote hooks
|
|
||||||
ENABLE_HOOKS = True
|
|
||||||
|
|
||||||
# Whether to run hooks in background
|
|
||||||
BACKGROUND_HOOKS = True
|
|
||||||
|
|
||||||
# Number of nearby messages to show in each direction
|
|
||||||
NEARBY_MESSAGES = 5
|
|
||||||
|
|
||||||
# Offload indexing
|
|
||||||
OFFLOAD_INDEXING = True
|
|
||||||
|
|
||||||
# Use simple language codes for default language/country combinations
|
|
||||||
SIMPLIFY_LANGUAGES = True
|
|
||||||
|
|
||||||
# Render forms using bootstrap
|
|
||||||
CRISPY_TEMPLATE_PACK = 'bootstrap3'
|
|
||||||
|
|
||||||
# List of quality checks
|
|
||||||
# CHECK_LIST = (
|
|
||||||
# 'weblate.trans.checks.same.SameCheck',
|
|
||||||
# 'weblate.trans.checks.chars.BeginNewlineCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndNewlineCheck',
|
|
||||||
# 'weblate.trans.checks.chars.BeginSpaceCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndSpaceCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndStopCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndColonCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndQuestionCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndExclamationCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndEllipsisCheck',
|
|
||||||
# 'weblate.trans.checks.chars.EndSemicolonCheck',
|
|
||||||
# 'weblate.trans.checks.chars.MaxLengthCheck',
|
|
||||||
# 'weblate.trans.checks.format.PythonFormatCheck',
|
|
||||||
# 'weblate.trans.checks.format.PythonBraceFormatCheck',
|
|
||||||
# 'weblate.trans.checks.format.PHPFormatCheck',
|
|
||||||
# 'weblate.trans.checks.format.CFormatCheck',
|
|
||||||
# 'weblate.trans.checks.format.PerlFormatCheck',
|
|
||||||
# 'weblate.trans.checks.format.JavascriptFormatCheck',
|
|
||||||
# 'weblate.trans.checks.consistency.PluralsCheck',
|
|
||||||
# 'weblate.trans.checks.consistency.SamePluralsCheck',
|
|
||||||
# 'weblate.trans.checks.consistency.ConsistencyCheck',
|
|
||||||
# 'weblate.trans.checks.consistency.TranslatedCheck',
|
|
||||||
# 'weblate.trans.checks.chars.NewlineCountingCheck',
|
|
||||||
# 'weblate.trans.checks.markup.BBCodeCheck',
|
|
||||||
# 'weblate.trans.checks.chars.ZeroWidthSpaceCheck',
|
|
||||||
# 'weblate.trans.checks.markup.XMLValidityCheck',
|
|
||||||
# 'weblate.trans.checks.markup.XMLTagsCheck',
|
|
||||||
# 'weblate.trans.checks.source.OptionalPluralCheck',
|
|
||||||
# 'weblate.trans.checks.source.EllipsisCheck',
|
|
||||||
# 'weblate.trans.checks.source.MultipleFailingCheck',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of automatic fixups
|
|
||||||
# AUTOFIX_LIST = (
|
|
||||||
# 'weblate.trans.autofixes.whitespace.SameBookendingWhitespace',
|
|
||||||
# 'weblate.trans.autofixes.chars.ReplaceTrailingDotsWithEllipsis',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveZeroSpace',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveControlChars',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of enabled addons
|
|
||||||
# WEBLATE_ADDONS = (
|
|
||||||
# 'weblate.addons.gettext.GenerateMoAddon',
|
|
||||||
# 'weblate.addons.gettext.UpdateLinguasAddon',
|
|
||||||
# 'weblate.addons.gettext.UpdateConfigureAddon',
|
|
||||||
# 'weblate.addons.gettext.MsgmergeAddon',
|
|
||||||
# 'weblate.addons.gettext.GettextCustomizeAddon',
|
|
||||||
# 'weblate.addons.cleanup.CleanupAddon',
|
|
||||||
# 'weblate.addons.flags.SourceEditAddon',
|
|
||||||
# 'weblate.addons.flags.TargetEditAddon',
|
|
||||||
# 'weblate.addons.json.JSONCustomizeAddon',
|
|
||||||
# 'weblate.addons.generate.GenerateFileAddon',
|
|
||||||
# 'weblate.addons.properties.PropertiesSortAddon',
|
|
||||||
# )
|
|
||||||
|
|
||||||
|
|
||||||
# List of scripts to use in custom processing
|
|
||||||
# POST_UPDATE_SCRIPTS = (
|
|
||||||
# )
|
|
||||||
# PRE_COMMIT_SCRIPTS = (
|
|
||||||
# )
|
|
||||||
|
|
||||||
# E-mail address that error messages come from.
|
|
||||||
SERVER_EMAIL = 'noreply@__DOMAIN__'
|
|
||||||
|
|
||||||
# Default email address to use for various automated correspondence from
|
|
||||||
# the site managers. Used for registration emails.
|
|
||||||
DEFAULT_FROM_EMAIL = '__ADMINMAIL__'
|
|
||||||
|
|
||||||
# List of URLs your site is supposed to serve
|
|
||||||
ALLOWED_HOSTS = ['__DOMAIN__']
|
|
||||||
|
|
||||||
# Example configuration to use memcached for caching
|
|
||||||
CACHES = {
|
|
||||||
'default': {
|
|
||||||
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
|
||||||
'LOCATION': '127.0.0.1:__MEMCPORT__',
|
|
||||||
},
|
|
||||||
'avatar': {
|
|
||||||
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
|
||||||
'LOCATION': os.path.join(BASE_DIR, 'avatar-cache'),
|
|
||||||
'TIMEOUT': 3600,
|
|
||||||
'OPTIONS': {
|
|
||||||
'MAX_ENTRIES': 1000,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# REST framework settings for API
|
|
||||||
REST_FRAMEWORK = {
|
|
||||||
# Use Django's standard `django.contrib.auth` permissions,
|
|
||||||
# or allow read-only access for unauthenticated users.
|
|
||||||
'DEFAULT_PERMISSION_CLASSES': [
|
|
||||||
'rest_framework.permissions.IsAuthenticatedOrReadOnly'
|
|
||||||
],
|
|
||||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
|
||||||
'rest_framework.authentication.TokenAuthentication',
|
|
||||||
'weblate.api.authentication.BearerAuthentication',
|
|
||||||
'rest_framework.authentication.SessionAuthentication',
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_CLASSES': (
|
|
||||||
'rest_framework.throttling.AnonRateThrottle',
|
|
||||||
'rest_framework.throttling.UserRateThrottle'
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_RATES': {
|
|
||||||
'anon': '100/day',
|
|
||||||
'user': '1000/day'
|
|
||||||
},
|
|
||||||
'DEFAULT_PAGINATION_CLASS': (
|
|
||||||
'rest_framework.pagination.PageNumberPagination'
|
|
||||||
),
|
|
||||||
'PAGE_SIZE': 20,
|
|
||||||
'VIEW_DESCRIPTION_FUNCTION': 'weblate.api.views.get_view_description',
|
|
||||||
'UNAUTHENTICATED_USER': 'weblate.accounts.models.get_anonymous',
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example for restricting access to logged in users
|
|
||||||
# LOGIN_REQUIRED_URLS = (
|
|
||||||
# r'/(.*)$',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# In such case you will want to include some of the exceptions
|
|
||||||
# LOGIN_REQUIRED_URLS_EXCEPTIONS = (
|
|
||||||
# r'/accounts/(.*)$', # Required for login
|
|
||||||
# r'/static/(.*)$', # Required for development mode
|
|
||||||
# r'/widgets/(.*)$', # Allowing public access to widgets
|
|
||||||
# r'/data/(.*)$', # Allowing public access to data exports
|
|
||||||
# r'/hooks/(.*)$', # Allowing public access to notification hooks
|
|
||||||
# r'/api/(.*)$', # Allowing access to API
|
|
||||||
# r'/js/i18n/$', # Javascript localization
|
|
||||||
# r'/contact/$', # Optional for contact form
|
|
||||||
# r'/legal/(.*)$', # Optional for legal app
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Force sane test runner
|
|
||||||
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
|
||||||
|
|
|
@ -1,757 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# Copyright © 2012 - 2018 Michal Čihař <michal@cihar.com>
|
|
||||||
#
|
|
||||||
# This file is part of Weblate <https://weblate.org/>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import platform
|
|
||||||
import os
|
|
||||||
from logging.handlers import SysLogHandler
|
|
||||||
|
|
||||||
#
|
|
||||||
# Django settings for Weblate project.
|
|
||||||
#
|
|
||||||
|
|
||||||
DEBUG = False
|
|
||||||
|
|
||||||
ADMINS = (
|
|
||||||
('__ADMIN__', '__ADMINMAIL__'),
|
|
||||||
)
|
|
||||||
|
|
||||||
MANAGERS = ADMINS
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
# Database engine
|
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
||||||
# Database name
|
|
||||||
'NAME': '__NAME__',
|
|
||||||
# Database user
|
|
||||||
'USER': '__NAME__',
|
|
||||||
# Database password
|
|
||||||
'PASSWORD': '__DB_PWD__',
|
|
||||||
# Set to empty string for localhost
|
|
||||||
'HOST': 'localhost',
|
|
||||||
# Set to empty string for default
|
|
||||||
'PORT': '5432',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BASE_DIR = '__FINALPATH__'
|
|
||||||
|
|
||||||
# Data directory
|
|
||||||
DATA_DIR = os.path.join(BASE_DIR, 'data')
|
|
||||||
|
|
||||||
# Local time zone for this installation. Choices can be found here:
|
|
||||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
|
||||||
# although not all choices may be available on all operating systems.
|
|
||||||
# In a Windows environment this must be set to your system time zone.
|
|
||||||
TIME_ZONE = 'UTC'
|
|
||||||
|
|
||||||
# Language code for this installation. All choices can be found here:
|
|
||||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
|
||||||
|
|
||||||
LANGUAGES = (
|
|
||||||
('ar', 'العربية'),
|
|
||||||
('az', 'Azərbaycan'),
|
|
||||||
('be', 'Беларуская'),
|
|
||||||
('be@latin', 'Biełaruskaja'),
|
|
||||||
('bg', 'Български'),
|
|
||||||
('br', 'Brezhoneg'),
|
|
||||||
('ca', 'Català'),
|
|
||||||
('cs', 'Čeština'),
|
|
||||||
('da', 'Dansk'),
|
|
||||||
('de', 'Deutsch'),
|
|
||||||
('en', 'English'),
|
|
||||||
('en-gb', 'English (United Kingdom)'),
|
|
||||||
('el', 'Ελληνικά'),
|
|
||||||
('es', 'Español'),
|
|
||||||
('fi', 'Suomi'),
|
|
||||||
('fr', 'Français'),
|
|
||||||
('fy', 'Frysk'),
|
|
||||||
('gl', 'Galego'),
|
|
||||||
('he', 'עברית'),
|
|
||||||
('hu', 'Magyar'),
|
|
||||||
('id', 'Indonesia'),
|
|
||||||
('it', 'Italiano'),
|
|
||||||
('ja', '日本語'),
|
|
||||||
('ko', '한국어'),
|
|
||||||
('ksh', 'Kölsch'),
|
|
||||||
('nb', 'Norsk bokmål'),
|
|
||||||
('nl', 'Nederlands'),
|
|
||||||
('pl', 'Polski'),
|
|
||||||
('pt', 'Português'),
|
|
||||||
('pt-br', 'Português brasileiro'),
|
|
||||||
('ru', 'Русский'),
|
|
||||||
('sk', 'Slovenčina'),
|
|
||||||
('sl', 'Slovenščina'),
|
|
||||||
('sr', 'Српски'),
|
|
||||||
('sv', 'Svenska'),
|
|
||||||
('tr', 'Türkçe'),
|
|
||||||
('uk', 'Українська'),
|
|
||||||
('zh-hans', '简体字'),
|
|
||||||
('zh-hant', '正體字'),
|
|
||||||
)
|
|
||||||
|
|
||||||
SITE_ID = 1
|
|
||||||
|
|
||||||
# If you set this to False, Django will make some optimizations so as not
|
|
||||||
# to load the internationalization machinery.
|
|
||||||
USE_I18N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not format dates, numbers and
|
|
||||||
# calendars according to the current locale.
|
|
||||||
USE_L10N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not use timezone-aware datetimes.
|
|
||||||
USE_TZ = True
|
|
||||||
|
|
||||||
# URL prefix to use, please see documentation for more details
|
|
||||||
URL_PREFIX = '__PATHURL__'
|
|
||||||
|
|
||||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
|
||||||
# Example: "/home/media/media.lawrence.com/media/"
|
|
||||||
MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
|
|
||||||
|
|
||||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
|
||||||
# trailing slash.
|
|
||||||
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
|
||||||
MEDIA_URL = '{0}/media/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Absolute path to the directory static files should be collected to.
|
|
||||||
# Don't put anything in this directory yourself; store your static files
|
|
||||||
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
|
|
||||||
# Example: "/home/media/media.lawrence.com/static/"
|
|
||||||
STATIC_ROOT = os.path.join(DATA_DIR, 'static')
|
|
||||||
|
|
||||||
# URL prefix for static files.
|
|
||||||
# Example: "http://media.lawrence.com/static/"
|
|
||||||
STATIC_URL = '{0}/static/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Additional locations of static files
|
|
||||||
STATICFILES_DIRS = (
|
|
||||||
# Put strings here, like "/home/html/static" or "C:/www/django/static".
|
|
||||||
# Always use forward slashes, even on Windows.
|
|
||||||
# Don't forget to use absolute paths, not relative paths.
|
|
||||||
)
|
|
||||||
|
|
||||||
# List of finder classes that know how to find static files in
|
|
||||||
# various locations.
|
|
||||||
STATICFILES_FINDERS = (
|
|
||||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
|
||||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
|
||||||
'compressor.finders.CompressorFinder',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Make this unique, and don't share it with anybody.
|
|
||||||
# You can generate it using examples/generate-secret-key
|
|
||||||
SECRET_KEY = '__KEY__' # noqa
|
|
||||||
|
|
||||||
TEMPLATES = [
|
|
||||||
{
|
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
||||||
'DIRS': [
|
|
||||||
os.path.join(BASE_DIR, 'weblate', 'templates'),
|
|
||||||
],
|
|
||||||
'OPTIONS': {
|
|
||||||
'context_processors': [
|
|
||||||
'django.contrib.auth.context_processors.auth',
|
|
||||||
'django.template.context_processors.debug',
|
|
||||||
'django.template.context_processors.i18n',
|
|
||||||
'django.template.context_processors.request',
|
|
||||||
'django.template.context_processors.csrf',
|
|
||||||
'django.contrib.messages.context_processors.messages',
|
|
||||||
'weblate.trans.context_processors.weblate_context',
|
|
||||||
],
|
|
||||||
'loaders': [
|
|
||||||
('django.template.loaders.cached.Loader', [
|
|
||||||
'django.template.loaders.filesystem.Loader',
|
|
||||||
'django.template.loaders.app_directories.Loader',
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# GitHub username for sending pull requests.
|
|
||||||
# Please see the documentation for more details.
|
|
||||||
GITHUB_USERNAME = "__GITHUBUSER__"
|
|
||||||
|
|
||||||
# Authentication configuration
|
|
||||||
AUTHENTICATION_BACKENDS = (
|
|
||||||
'social_core.backends.email.EmailAuth',
|
|
||||||
# 'social_core.backends.google.GoogleOAuth2',
|
|
||||||
# 'social_core.backends.github.GithubOAuth2',
|
|
||||||
# 'social_core.backends.bitbucket.BitbucketOAuth',
|
|
||||||
'social_core.backends.suse.OpenSUSEOpenId',
|
|
||||||
'social_core.backends.ubuntu.UbuntuOpenId',
|
|
||||||
'social_core.backends.fedora.FedoraOpenId',
|
|
||||||
# 'social_core.backends.facebook.FacebookOAuth2',
|
|
||||||
'weblate.accounts.auth.WeblateUserBackend',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom user model
|
|
||||||
AUTH_USER_MODEL = 'weblate_auth.User'
|
|
||||||
|
|
||||||
# Social auth backends setup
|
|
||||||
SOCIAL_AUTH_GITHUB_KEY = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SECRET = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SCOPE = ['user:email']
|
|
||||||
|
|
||||||
SOCIAL_AUTH_BITBUCKET_KEY = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_SECRET = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_VERIFIED_EMAILS_ONLY = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_FACEBOOK_KEY = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SECRET = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email', 'public_profile']
|
|
||||||
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = ''
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = ''
|
|
||||||
|
|
||||||
# Social auth settings
|
|
||||||
SOCIAL_AUTH_PIPELINE = (
|
|
||||||
'social_core.pipeline.social_auth.social_details',
|
|
||||||
'social_core.pipeline.social_auth.social_uid',
|
|
||||||
'social_core.pipeline.social_auth.auth_allowed',
|
|
||||||
'social_core.pipeline.social_auth.social_user',
|
|
||||||
'weblate.accounts.pipeline.store_params',
|
|
||||||
'weblate.accounts.pipeline.verify_open',
|
|
||||||
'social_core.pipeline.user.get_username',
|
|
||||||
'weblate.accounts.pipeline.require_email',
|
|
||||||
'social_core.pipeline.mail.mail_validation',
|
|
||||||
'weblate.accounts.pipeline.revoke_mail_code',
|
|
||||||
'weblate.accounts.pipeline.ensure_valid',
|
|
||||||
'weblate.accounts.pipeline.remove_account',
|
|
||||||
'social_core.pipeline.social_auth.associate_by_email',
|
|
||||||
'weblate.accounts.pipeline.reauthenticate',
|
|
||||||
'weblate.accounts.pipeline.verify_username',
|
|
||||||
'social_core.pipeline.user.create_user',
|
|
||||||
'social_core.pipeline.social_auth.associate_user',
|
|
||||||
'social_core.pipeline.social_auth.load_extra_data',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
'weblate.accounts.pipeline.user_full_name',
|
|
||||||
'weblate.accounts.pipeline.store_email',
|
|
||||||
'weblate.accounts.pipeline.notify_connect',
|
|
||||||
'weblate.accounts.pipeline.password_reset',
|
|
||||||
)
|
|
||||||
SOCIAL_AUTH_DISCONNECT_PIPELINE = (
|
|
||||||
'social_core.pipeline.disconnect.allowed_to_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.get_entries',
|
|
||||||
'social_core.pipeline.disconnect.revoke_tokens',
|
|
||||||
'weblate.accounts.pipeline.cycle_session',
|
|
||||||
'weblate.accounts.pipeline.adjust_primary_mail',
|
|
||||||
'weblate.accounts.pipeline.notify_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.disconnect',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom authentication strategy
|
|
||||||
SOCIAL_AUTH_STRATEGY = 'weblate.accounts.strategy.WeblateStrategy'
|
|
||||||
|
|
||||||
# Raise exceptions so that we can handle them later
|
|
||||||
SOCIAL_AUTH_RAISE_EXCEPTIONS = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_FUNCTION = \
|
|
||||||
'weblate.accounts.pipeline.send_validation'
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_URL = \
|
|
||||||
'{0}/accounts/email-sent/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_LOGIN_ERROR_URL = \
|
|
||||||
'{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_EMAIL_FORM_URL = \
|
|
||||||
'{0}/accounts/email/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL = \
|
|
||||||
'{0}/accounts/profile/#auth'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_PROTECTED_USER_FIELDS = ('email',)
|
|
||||||
SOCIAL_AUTH_SLUGIFY_USERNAMES = True
|
|
||||||
SOCIAL_AUTH_SLUGIFY_FUNCTION = 'weblate.accounts.pipeline.slugify_username'
|
|
||||||
|
|
||||||
# Password validation configuration
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
||||||
'OPTIONS': {
|
|
||||||
'min_length': 6,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.CharsPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.PastPasswordsValidator',
|
|
||||||
},
|
|
||||||
# Optional password strength validation by django-zxcvbn-password
|
|
||||||
# {
|
|
||||||
# 'NAME': 'zxcvbn_password.ZXCVBNValidator',
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'min_score': 3,
|
|
||||||
# 'user_attributes': ('username', 'email', 'full_name')
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
]
|
|
||||||
|
|
||||||
# Middleware
|
|
||||||
MIDDLEWARE = [
|
|
||||||
'django.middleware.security.SecurityMiddleware',
|
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
||||||
'django.middleware.common.CommonMiddleware',
|
|
||||||
'django.middleware.locale.LocaleMiddleware',
|
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
|
||||||
'weblate.accounts.middleware.AuthenticationMiddleware',
|
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
||||||
'social_django.middleware.SocialAuthExceptionMiddleware',
|
|
||||||
'weblate.accounts.middleware.RequireLoginMiddleware',
|
|
||||||
'weblate.middleware.SecurityMiddleware',
|
|
||||||
'weblate.wladmin.middleware.ConfigurationErrorsMiddleware',
|
|
||||||
]
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'weblate.urls'
|
|
||||||
|
|
||||||
# Django and Weblate apps
|
|
||||||
INSTALLED_APPS = (
|
|
||||||
'django.contrib.auth',
|
|
||||||
'django.contrib.contenttypes',
|
|
||||||
'django.contrib.sessions',
|
|
||||||
'django.contrib.sites',
|
|
||||||
'django.contrib.messages',
|
|
||||||
'django.contrib.staticfiles',
|
|
||||||
'django.contrib.admin.apps.SimpleAdminConfig',
|
|
||||||
'django.contrib.admindocs',
|
|
||||||
'django.contrib.sitemaps',
|
|
||||||
'social_django',
|
|
||||||
'crispy_forms',
|
|
||||||
'compressor',
|
|
||||||
'rest_framework',
|
|
||||||
'rest_framework.authtoken',
|
|
||||||
'weblate.addons',
|
|
||||||
'weblate.auth',
|
|
||||||
'weblate.checks',
|
|
||||||
'weblate.formats',
|
|
||||||
'weblate.machinery',
|
|
||||||
'weblate.trans',
|
|
||||||
'weblate.lang',
|
|
||||||
'weblate.langdata',
|
|
||||||
'weblate.memory',
|
|
||||||
'weblate.permissions',
|
|
||||||
'weblate.screenshots',
|
|
||||||
'weblate.accounts',
|
|
||||||
'weblate.utils',
|
|
||||||
'weblate.vcs',
|
|
||||||
'weblate.wladmin',
|
|
||||||
'weblate',
|
|
||||||
|
|
||||||
# Optional: Git exporter
|
|
||||||
# 'weblate.gitexport',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Path to locales
|
|
||||||
LOCALE_PATHS = (os.path.join(BASE_DIR, 'weblate', 'locale'), )
|
|
||||||
|
|
||||||
# Custom exception reporter to include some details
|
|
||||||
DEFAULT_EXCEPTION_REPORTER_FILTER = \
|
|
||||||
'weblate.trans.debug.WeblateExceptionReporterFilter'
|
|
||||||
|
|
||||||
# Default logging of Weblate messages
|
|
||||||
# - to syslog in production (if available)
|
|
||||||
# - otherwise to console
|
|
||||||
# - you can also choose 'logfile' to log into separate file
|
|
||||||
# after configuring it below
|
|
||||||
|
|
||||||
# Detect if we can connect to syslog
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
if platform.system() != 'Windows':
|
|
||||||
try:
|
|
||||||
handler = SysLogHandler(
|
|
||||||
address='/dev/log', facility=SysLogHandler.LOG_LOCAL2
|
|
||||||
)
|
|
||||||
handler.close()
|
|
||||||
HAVE_SYSLOG = True
|
|
||||||
except IOError:
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
|
|
||||||
if DEBUG or not HAVE_SYSLOG:
|
|
||||||
DEFAULT_LOG = 'console'
|
|
||||||
else:
|
|
||||||
DEFAULT_LOG = 'syslog'
|
|
||||||
|
|
||||||
# A sample logging configuration. The only tangible logging
|
|
||||||
# performed by this configuration is to send an email to
|
|
||||||
# the site admins on every HTTP 500 error when DEBUG=False.
|
|
||||||
# See http://docs.djangoproject.com/en/stable/topics/logging for
|
|
||||||
# more details on how to customize your logging configuration.
|
|
||||||
LOGGING = {
|
|
||||||
'version': 1,
|
|
||||||
'disable_existing_loggers': True,
|
|
||||||
'filters': {
|
|
||||||
'require_debug_false': {
|
|
||||||
'()': 'django.utils.log.RequireDebugFalse'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'formatters': {
|
|
||||||
'syslog': {
|
|
||||||
'format': 'weblate[%(process)d]: %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'simple': {
|
|
||||||
'format': '%(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'logfile': {
|
|
||||||
'format': '%(asctime)s %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'()': 'django.utils.log.ServerFormatter',
|
|
||||||
'format': '[%(server_time)s] %(message)s',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'handlers': {
|
|
||||||
'mail_admins': {
|
|
||||||
'level': 'ERROR',
|
|
||||||
'filters': ['require_debug_false'],
|
|
||||||
'class': 'django.utils.log.AdminEmailHandler',
|
|
||||||
'include_html': True,
|
|
||||||
},
|
|
||||||
'console': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'simple'
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'level': 'INFO',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'django.server',
|
|
||||||
},
|
|
||||||
'syslog': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.handlers.SysLogHandler',
|
|
||||||
'formatter': 'syslog',
|
|
||||||
'address': '/dev/log',
|
|
||||||
'facility': SysLogHandler.LOG_LOCAL2,
|
|
||||||
},
|
|
||||||
# Logging to a file
|
|
||||||
# 'logfile': {
|
|
||||||
# 'level':'DEBUG',
|
|
||||||
# 'class':'logging.handlers.RotatingFileHandler',
|
|
||||||
# 'filename': "/var/log/weblate/weblate.log",
|
|
||||||
# 'maxBytes': 100000,
|
|
||||||
# 'backupCount': 3,
|
|
||||||
# 'formatter': 'logfile',
|
|
||||||
# },
|
|
||||||
},
|
|
||||||
'loggers': {
|
|
||||||
'django.request': {
|
|
||||||
'handlers': ['mail_admins', DEFAULT_LOG],
|
|
||||||
'level': 'ERROR',
|
|
||||||
'propagate': True,
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'handlers': ['django.server'],
|
|
||||||
'level': 'INFO',
|
|
||||||
'propagate': False,
|
|
||||||
},
|
|
||||||
# Logging database queries
|
|
||||||
# 'django.db.backends': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
'weblate': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'DEBUG',
|
|
||||||
},
|
|
||||||
# Logging VCS operations
|
|
||||||
# 'weblate-vcs': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
# Python Social Auth logging
|
|
||||||
# 'social': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Logging of management commands to console
|
|
||||||
if (os.environ.get('DJANGO_IS_MANAGEMENT_COMMAND', False) and
|
|
||||||
'console' not in LOGGING['loggers']['weblate']['handlers']):
|
|
||||||
LOGGING['loggers']['weblate']['handlers'].append('console')
|
|
||||||
|
|
||||||
# Remove syslog setup if it's not present
|
|
||||||
if not HAVE_SYSLOG:
|
|
||||||
del LOGGING['handlers']['syslog']
|
|
||||||
|
|
||||||
# List of machine translations
|
|
||||||
# MT_SERVICES = (
|
|
||||||
# 'weblate.machinery.apertium.ApertiumAPYTranslation',
|
|
||||||
# 'weblate.machinery.deepl.DeepLTranslation',
|
|
||||||
# 'weblate.machinery.glosbe.GlosbeTranslation',
|
|
||||||
# 'weblate.machinery.google.GoogleTranslation',
|
|
||||||
# 'weblate.machinery.microsoft.MicrosoftCognitiveTranslation',
|
|
||||||
# 'weblate.machinery.mymemory.MyMemoryTranslation',
|
|
||||||
# 'weblate.machinery.tmserver.AmagamaTranslation',
|
|
||||||
# 'weblate.machinery.tmserver.TMServerTranslation',
|
|
||||||
# 'weblate.machinery.yandex.YandexTranslation',
|
|
||||||
# 'weblate.machinery.weblatetm.WeblateTranslation',
|
|
||||||
# 'weblate.machinery.saptranslationhub.SAPTranslationHub',
|
|
||||||
# 'weblate.memory.machine.WeblateMemory',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Machine translation API keys
|
|
||||||
|
|
||||||
# URL of the Apertium APy server
|
|
||||||
MT_APERTIUM_APY = None
|
|
||||||
|
|
||||||
# DeepL API key
|
|
||||||
MT_DEEPL_KEY = None
|
|
||||||
|
|
||||||
# Microsoft Cognitive Services Translator API, register at
|
|
||||||
# https://portal.azure.com/
|
|
||||||
MT_MICROSOFT_COGNITIVE_KEY = None
|
|
||||||
|
|
||||||
# MyMemory identification email, see
|
|
||||||
# https://mymemory.translated.net/doc/spec.php
|
|
||||||
MT_MYMEMORY_EMAIL = None
|
|
||||||
|
|
||||||
# Optional MyMemory credentials to access private translation memory
|
|
||||||
MT_MYMEMORY_USER = None
|
|
||||||
MT_MYMEMORY_KEY = None
|
|
||||||
|
|
||||||
# Google API key for Google Translate API
|
|
||||||
MT_GOOGLE_KEY = None
|
|
||||||
|
|
||||||
# API key for Yandex Translate API
|
|
||||||
MT_YANDEX_KEY = None
|
|
||||||
|
|
||||||
# tmserver URL
|
|
||||||
MT_TMSERVER = None
|
|
||||||
|
|
||||||
# SAP Translation Hub
|
|
||||||
MT_SAP_BASE_URL = None
|
|
||||||
MT_SAP_SANDBOX_APIKEY = None
|
|
||||||
MT_SAP_USERNAME = None
|
|
||||||
MT_SAP_PASSWORD = None
|
|
||||||
MT_SAP_USE_MT = True
|
|
||||||
|
|
||||||
# Title of site to use
|
|
||||||
SITE_TITLE = 'Weblate'
|
|
||||||
|
|
||||||
# Whether site uses https
|
|
||||||
ENABLE_HTTPS = True
|
|
||||||
|
|
||||||
# Use HTTPS when creating redirect URLs for social authentication, see
|
|
||||||
# documentation for more details:
|
|
||||||
# http://python-social-auth-docs.readthedocs.io/en/latest/configuration/settings.html#processing-redirects-and-urlopen
|
|
||||||
SOCIAL_AUTH_REDIRECT_IS_HTTPS = ENABLE_HTTPS
|
|
||||||
|
|
||||||
# Make CSRF cookie HttpOnly, see documentation for more details:
|
|
||||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#csrf-cookie-httponly
|
|
||||||
CSRF_COOKIE_HTTPONLY = True
|
|
||||||
CSRF_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# Store CSRF token in session (since Django 1.11)
|
|
||||||
CSRF_USE_SESSIONS = True
|
|
||||||
SESSION_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# Session cookie age (in seconds)
|
|
||||||
SESSION_COOKIE_AGE = 1209600
|
|
||||||
|
|
||||||
# URL of login
|
|
||||||
LOGIN_URL = '{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# URL of logout
|
|
||||||
LOGOUT_URL = '{0}/accounts/logout/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Default location for login
|
|
||||||
LOGIN_REDIRECT_URL = '{0}/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Anonymous user name
|
|
||||||
ANONYMOUS_USER_NAME = 'anonymous'
|
|
||||||
|
|
||||||
# Reverse proxy settings
|
|
||||||
IP_BEHIND_REVERSE_PROXY = False
|
|
||||||
IP_PROXY_HEADER = 'HTTP_X_FORWARDED_FOR'
|
|
||||||
IP_PROXY_OFFSET = 0
|
|
||||||
|
|
||||||
# Sending HTML in mails
|
|
||||||
EMAIL_SEND_HTML = True
|
|
||||||
|
|
||||||
# Subject of emails includes site title
|
|
||||||
EMAIL_SUBJECT_PREFIX = '[{0}] '.format(SITE_TITLE)
|
|
||||||
|
|
||||||
EMAIL_BACKEND = 'django_sendmail_backend.backends.EmailBackend'
|
|
||||||
|
|
||||||
# Enable remote hooks
|
|
||||||
ENABLE_HOOKS = True
|
|
||||||
|
|
||||||
# Whether to run hooks in background
|
|
||||||
BACKGROUND_HOOKS = True
|
|
||||||
|
|
||||||
# Number of nearby messages to show in each direction
|
|
||||||
NEARBY_MESSAGES = 5
|
|
||||||
|
|
||||||
# Offload indexing
|
|
||||||
OFFLOAD_INDEXING = True
|
|
||||||
|
|
||||||
# Use simple language codes for default language/country combinations
|
|
||||||
SIMPLIFY_LANGUAGES = True
|
|
||||||
|
|
||||||
# Render forms using bootstrap
|
|
||||||
CRISPY_TEMPLATE_PACK = 'bootstrap3'
|
|
||||||
|
|
||||||
# List of quality checks
|
|
||||||
# CHECK_LIST = (
|
|
||||||
# 'weblate.checks.same.SameCheck',
|
|
||||||
# 'weblate.checks.chars.BeginNewlineCheck',
|
|
||||||
# 'weblate.checks.chars.EndNewlineCheck',
|
|
||||||
# 'weblate.checks.chars.BeginSpaceCheck',
|
|
||||||
# 'weblate.checks.chars.EndSpaceCheck',
|
|
||||||
# 'weblate.checks.chars.EndStopCheck',
|
|
||||||
# 'weblate.checks.chars.EndColonCheck',
|
|
||||||
# 'weblate.checks.chars.EndQuestionCheck',
|
|
||||||
# 'weblate.checks.chars.EndExclamationCheck',
|
|
||||||
# 'weblate.checks.chars.EndEllipsisCheck',
|
|
||||||
# 'weblate.checks.chars.EndSemicolonCheck',
|
|
||||||
# 'weblate.checks.chars.MaxLengthCheck',
|
|
||||||
# 'weblate.checks.format.PythonFormatCheck',
|
|
||||||
# 'weblate.checks.format.PythonBraceFormatCheck',
|
|
||||||
# 'weblate.checks.format.PHPFormatCheck',
|
|
||||||
# 'weblate.checks.format.CFormatCheck',
|
|
||||||
# 'weblate.checks.format.PerlFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavascriptFormatCheck',
|
|
||||||
# 'weblate.checks.consistency.PluralsCheck',
|
|
||||||
# 'weblate.checks.consistency.SamePluralsCheck',
|
|
||||||
# 'weblate.checks.consistency.ConsistencyCheck',
|
|
||||||
# 'weblate.checks.consistency.TranslatedCheck',
|
|
||||||
# 'weblate.checks.chars.NewlineCountingCheck',
|
|
||||||
# 'weblate.checks.markup.BBCodeCheck',
|
|
||||||
# 'weblate.checks.chars.ZeroWidthSpaceCheck',
|
|
||||||
# 'weblate.checks.markup.XMLValidityCheck',
|
|
||||||
# 'weblate.checks.markup.XMLTagsCheck',
|
|
||||||
# 'weblate.checks.source.OptionalPluralCheck',
|
|
||||||
# 'weblate.checks.source.EllipsisCheck',
|
|
||||||
# 'weblate.checks.source.MultipleFailingCheck',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of automatic fixups
|
|
||||||
# AUTOFIX_LIST = (
|
|
||||||
# 'weblate.trans.autofixes.whitespace.SameBookendingWhitespace',
|
|
||||||
# 'weblate.trans.autofixes.chars.ReplaceTrailingDotsWithEllipsis',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveZeroSpace',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveControlChars',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of enabled addons
|
|
||||||
# WEBLATE_ADDONS = (
|
|
||||||
# 'weblate.addons.gettext.GenerateMoAddon',
|
|
||||||
# 'weblate.addons.gettext.UpdateLinguasAddon',
|
|
||||||
# 'weblate.addons.gettext.UpdateConfigureAddon',
|
|
||||||
# 'weblate.addons.gettext.MsgmergeAddon',
|
|
||||||
# 'weblate.addons.gettext.GettextCustomizeAddon',
|
|
||||||
# 'weblate.addons.gettext.GettextAuthorComments',
|
|
||||||
# 'weblate.addons.cleanup.CleanupAddon',
|
|
||||||
# 'weblate.addons.consistency.LangaugeConsistencyAddon',
|
|
||||||
# 'weblate.addons.discovery.DiscoveryAddon',
|
|
||||||
# 'weblate.addons.flags.SourceEditAddon',
|
|
||||||
# 'weblate.addons.flags.TargetEditAddon',
|
|
||||||
# 'weblate.addons.generate.GenerateFileAddon',
|
|
||||||
# 'weblate.addons.json.JSONCustomizeAddon',
|
|
||||||
# 'weblate.addons.properties.PropertiesSortAddon',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# E-mail address that error messages come from.
|
|
||||||
SERVER_EMAIL = 'noreply@__DOMAIN__'
|
|
||||||
|
|
||||||
# Default email address to use for various automated correspondence from
|
|
||||||
# the site managers. Used for registration emails.
|
|
||||||
DEFAULT_FROM_EMAIL = '__ADMINMAIL__'
|
|
||||||
|
|
||||||
# List of URLs your site is supposed to serve
|
|
||||||
ALLOWED_HOSTS = ['__DOMAIN__']
|
|
||||||
|
|
||||||
# Example configuration to use memcached for caching
|
|
||||||
CACHES = {
|
|
||||||
'default': {
|
|
||||||
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
|
||||||
'LOCATION': '127.0.0.1:__MEMCPORT__',
|
|
||||||
},
|
|
||||||
'avatar': {
|
|
||||||
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
|
||||||
'LOCATION': os.path.join(BASE_DIR, 'avatar-cache'),
|
|
||||||
'TIMEOUT': 3600,
|
|
||||||
'OPTIONS': {
|
|
||||||
'MAX_ENTRIES': 1000,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# REST framework settings for API
|
|
||||||
REST_FRAMEWORK = {
|
|
||||||
# Use Django's standard `django.contrib.auth` permissions,
|
|
||||||
# or allow read-only access for unauthenticated users.
|
|
||||||
'DEFAULT_PERMISSION_CLASSES': [
|
|
||||||
'rest_framework.permissions.IsAuthenticatedOrReadOnly'
|
|
||||||
],
|
|
||||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
|
||||||
'rest_framework.authentication.TokenAuthentication',
|
|
||||||
'weblate.api.authentication.BearerAuthentication',
|
|
||||||
'rest_framework.authentication.SessionAuthentication',
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_CLASSES': (
|
|
||||||
'rest_framework.throttling.AnonRateThrottle',
|
|
||||||
'rest_framework.throttling.UserRateThrottle'
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_RATES': {
|
|
||||||
'anon': '100/day',
|
|
||||||
'user': '1000/day'
|
|
||||||
},
|
|
||||||
'DEFAULT_PAGINATION_CLASS': (
|
|
||||||
'rest_framework.pagination.PageNumberPagination'
|
|
||||||
),
|
|
||||||
'PAGE_SIZE': 20,
|
|
||||||
'VIEW_DESCRIPTION_FUNCTION': 'weblate.api.views.get_view_description',
|
|
||||||
'UNAUTHENTICATED_USER': 'weblate.auth.models.get_anonymous',
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example for restricting access to logged in users
|
|
||||||
# LOGIN_REQUIRED_URLS = (
|
|
||||||
# r'/(.*)$',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# In such case you will want to include some of the exceptions
|
|
||||||
# LOGIN_REQUIRED_URLS_EXCEPTIONS = (
|
|
||||||
# r'/accounts/(.*)$', # Required for login
|
|
||||||
# r'/static/(.*)$', # Required for development mode
|
|
||||||
# r'/widgets/(.*)$', # Allowing public access to widgets
|
|
||||||
# r'/data/(.*)$', # Allowing public access to data exports
|
|
||||||
# r'/hooks/(.*)$', # Allowing public access to notification hooks
|
|
||||||
# r'/api/(.*)$', # Allowing access to API
|
|
||||||
# r'/js/i18n/$', # Javascript localization
|
|
||||||
# r'/contact/$', # Optional for contact form
|
|
||||||
# r'/legal/(.*)$', # Optional for legal app
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Force sane test runner
|
|
||||||
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
|
|
@ -1,757 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# Copyright © 2012 - 2018 Michal Čihař <michal@cihar.com>
|
|
||||||
#
|
|
||||||
# This file is part of Weblate <https://weblate.org/>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import platform
|
|
||||||
import os
|
|
||||||
from logging.handlers import SysLogHandler
|
|
||||||
|
|
||||||
#
|
|
||||||
# Django settings for Weblate project.
|
|
||||||
#
|
|
||||||
|
|
||||||
DEBUG = False
|
|
||||||
|
|
||||||
ADMINS = (
|
|
||||||
('__ADMIN__', '__ADMINMAIL__'),
|
|
||||||
)
|
|
||||||
|
|
||||||
MANAGERS = ADMINS
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
# Database engine
|
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
||||||
# Database name
|
|
||||||
'NAME': '__NAME__',
|
|
||||||
# Database user
|
|
||||||
'USER': '__NAME__',
|
|
||||||
# Database password
|
|
||||||
'PASSWORD': '__DB_PWD__',
|
|
||||||
# Set to empty string for localhost
|
|
||||||
'HOST': 'localhost',
|
|
||||||
# Set to empty string for default
|
|
||||||
'PORT': '5432',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BASE_DIR = '__FINALPATH__'
|
|
||||||
|
|
||||||
# Data directory
|
|
||||||
DATA_DIR = os.path.join(BASE_DIR, 'data')
|
|
||||||
|
|
||||||
# Local time zone for this installation. Choices can be found here:
|
|
||||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
|
||||||
# although not all choices may be available on all operating systems.
|
|
||||||
# In a Windows environment this must be set to your system time zone.
|
|
||||||
TIME_ZONE = 'UTC'
|
|
||||||
|
|
||||||
# Language code for this installation. All choices can be found here:
|
|
||||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
|
||||||
|
|
||||||
LANGUAGES = (
|
|
||||||
('ar', 'العربية'),
|
|
||||||
('az', 'Azərbaycan'),
|
|
||||||
('be', 'Беларуская'),
|
|
||||||
('be@latin', 'Biełaruskaja'),
|
|
||||||
('bg', 'Български'),
|
|
||||||
('br', 'Brezhoneg'),
|
|
||||||
('ca', 'Català'),
|
|
||||||
('cs', 'Čeština'),
|
|
||||||
('da', 'Dansk'),
|
|
||||||
('de', 'Deutsch'),
|
|
||||||
('en', 'English'),
|
|
||||||
('en-gb', 'English (United Kingdom)'),
|
|
||||||
('el', 'Ελληνικά'),
|
|
||||||
('es', 'Español'),
|
|
||||||
('fi', 'Suomi'),
|
|
||||||
('fr', 'Français'),
|
|
||||||
('fy', 'Frysk'),
|
|
||||||
('gl', 'Galego'),
|
|
||||||
('he', 'עברית'),
|
|
||||||
('hu', 'Magyar'),
|
|
||||||
('id', 'Indonesia'),
|
|
||||||
('it', 'Italiano'),
|
|
||||||
('ja', '日本語'),
|
|
||||||
('ko', '한국어'),
|
|
||||||
('ksh', 'Kölsch'),
|
|
||||||
('nb', 'Norsk bokmål'),
|
|
||||||
('nl', 'Nederlands'),
|
|
||||||
('pl', 'Polski'),
|
|
||||||
('pt', 'Português'),
|
|
||||||
('pt-br', 'Português brasileiro'),
|
|
||||||
('ru', 'Русский'),
|
|
||||||
('sk', 'Slovenčina'),
|
|
||||||
('sl', 'Slovenščina'),
|
|
||||||
('sr', 'Српски'),
|
|
||||||
('sv', 'Svenska'),
|
|
||||||
('tr', 'Türkçe'),
|
|
||||||
('uk', 'Українська'),
|
|
||||||
('zh-hans', '简体字'),
|
|
||||||
('zh-hant', '正體字'),
|
|
||||||
)
|
|
||||||
|
|
||||||
SITE_ID = 1
|
|
||||||
|
|
||||||
# If you set this to False, Django will make some optimizations so as not
|
|
||||||
# to load the internationalization machinery.
|
|
||||||
USE_I18N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not format dates, numbers and
|
|
||||||
# calendars according to the current locale.
|
|
||||||
USE_L10N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not use timezone-aware datetimes.
|
|
||||||
USE_TZ = True
|
|
||||||
|
|
||||||
# URL prefix to use, please see documentation for more details
|
|
||||||
URL_PREFIX = '__PATHURL__'
|
|
||||||
|
|
||||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
|
||||||
# Example: "/home/media/media.lawrence.com/media/"
|
|
||||||
MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
|
|
||||||
|
|
||||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
|
||||||
# trailing slash.
|
|
||||||
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
|
||||||
MEDIA_URL = '{0}/media/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Absolute path to the directory static files should be collected to.
|
|
||||||
# Don't put anything in this directory yourself; store your static files
|
|
||||||
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
|
|
||||||
# Example: "/home/media/media.lawrence.com/static/"
|
|
||||||
STATIC_ROOT = os.path.join(DATA_DIR, 'static')
|
|
||||||
|
|
||||||
# URL prefix for static files.
|
|
||||||
# Example: "http://media.lawrence.com/static/"
|
|
||||||
STATIC_URL = '{0}/static/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Additional locations of static files
|
|
||||||
STATICFILES_DIRS = (
|
|
||||||
# Put strings here, like "/home/html/static" or "C:/www/django/static".
|
|
||||||
# Always use forward slashes, even on Windows.
|
|
||||||
# Don't forget to use absolute paths, not relative paths.
|
|
||||||
)
|
|
||||||
|
|
||||||
# List of finder classes that know how to find static files in
|
|
||||||
# various locations.
|
|
||||||
STATICFILES_FINDERS = (
|
|
||||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
|
||||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
|
||||||
'compressor.finders.CompressorFinder',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Make this unique, and don't share it with anybody.
|
|
||||||
# You can generate it using examples/generate-secret-key
|
|
||||||
SECRET_KEY = '__KEY__' # noqa
|
|
||||||
|
|
||||||
TEMPLATES = [
|
|
||||||
{
|
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
||||||
'DIRS': [
|
|
||||||
os.path.join(BASE_DIR, 'weblate', 'templates'),
|
|
||||||
],
|
|
||||||
'OPTIONS': {
|
|
||||||
'context_processors': [
|
|
||||||
'django.contrib.auth.context_processors.auth',
|
|
||||||
'django.template.context_processors.debug',
|
|
||||||
'django.template.context_processors.i18n',
|
|
||||||
'django.template.context_processors.request',
|
|
||||||
'django.template.context_processors.csrf',
|
|
||||||
'django.contrib.messages.context_processors.messages',
|
|
||||||
'weblate.trans.context_processors.weblate_context',
|
|
||||||
],
|
|
||||||
'loaders': [
|
|
||||||
('django.template.loaders.cached.Loader', [
|
|
||||||
'django.template.loaders.filesystem.Loader',
|
|
||||||
'django.template.loaders.app_directories.Loader',
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# GitHub username for sending pull requests.
|
|
||||||
# Please see the documentation for more details.
|
|
||||||
GITHUB_USERNAME = "__GITHUBUSER__"
|
|
||||||
|
|
||||||
# Authentication configuration
|
|
||||||
AUTHENTICATION_BACKENDS = (
|
|
||||||
'social_core.backends.email.EmailAuth',
|
|
||||||
# 'social_core.backends.google.GoogleOAuth2',
|
|
||||||
# 'social_core.backends.github.GithubOAuth2',
|
|
||||||
# 'social_core.backends.bitbucket.BitbucketOAuth',
|
|
||||||
'social_core.backends.suse.OpenSUSEOpenId',
|
|
||||||
'social_core.backends.ubuntu.UbuntuOpenId',
|
|
||||||
'social_core.backends.fedora.FedoraOpenId',
|
|
||||||
# 'social_core.backends.facebook.FacebookOAuth2',
|
|
||||||
'weblate.accounts.auth.WeblateUserBackend',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom user model
|
|
||||||
AUTH_USER_MODEL = 'weblate_auth.User'
|
|
||||||
|
|
||||||
# Social auth backends setup
|
|
||||||
SOCIAL_AUTH_GITHUB_KEY = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SECRET = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SCOPE = ['user:email']
|
|
||||||
|
|
||||||
SOCIAL_AUTH_BITBUCKET_KEY = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_SECRET = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_VERIFIED_EMAILS_ONLY = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_FACEBOOK_KEY = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SECRET = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email', 'public_profile']
|
|
||||||
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = ''
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = ''
|
|
||||||
|
|
||||||
# Social auth settings
|
|
||||||
SOCIAL_AUTH_PIPELINE = (
|
|
||||||
'social_core.pipeline.social_auth.social_details',
|
|
||||||
'social_core.pipeline.social_auth.social_uid',
|
|
||||||
'social_core.pipeline.social_auth.auth_allowed',
|
|
||||||
'social_core.pipeline.social_auth.social_user',
|
|
||||||
'weblate.accounts.pipeline.store_params',
|
|
||||||
'weblate.accounts.pipeline.verify_open',
|
|
||||||
'social_core.pipeline.user.get_username',
|
|
||||||
'weblate.accounts.pipeline.require_email',
|
|
||||||
'social_core.pipeline.mail.mail_validation',
|
|
||||||
'weblate.accounts.pipeline.revoke_mail_code',
|
|
||||||
'weblate.accounts.pipeline.ensure_valid',
|
|
||||||
'weblate.accounts.pipeline.remove_account',
|
|
||||||
'social_core.pipeline.social_auth.associate_by_email',
|
|
||||||
'weblate.accounts.pipeline.reauthenticate',
|
|
||||||
'weblate.accounts.pipeline.verify_username',
|
|
||||||
'social_core.pipeline.user.create_user',
|
|
||||||
'social_core.pipeline.social_auth.associate_user',
|
|
||||||
'social_core.pipeline.social_auth.load_extra_data',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
'weblate.accounts.pipeline.user_full_name',
|
|
||||||
'weblate.accounts.pipeline.store_email',
|
|
||||||
'weblate.accounts.pipeline.notify_connect',
|
|
||||||
'weblate.accounts.pipeline.password_reset',
|
|
||||||
)
|
|
||||||
SOCIAL_AUTH_DISCONNECT_PIPELINE = (
|
|
||||||
'social_core.pipeline.disconnect.allowed_to_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.get_entries',
|
|
||||||
'social_core.pipeline.disconnect.revoke_tokens',
|
|
||||||
'weblate.accounts.pipeline.cycle_session',
|
|
||||||
'weblate.accounts.pipeline.adjust_primary_mail',
|
|
||||||
'weblate.accounts.pipeline.notify_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.disconnect',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom authentication strategy
|
|
||||||
SOCIAL_AUTH_STRATEGY = 'weblate.accounts.strategy.WeblateStrategy'
|
|
||||||
|
|
||||||
# Raise exceptions so that we can handle them later
|
|
||||||
SOCIAL_AUTH_RAISE_EXCEPTIONS = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_FUNCTION = \
|
|
||||||
'weblate.accounts.pipeline.send_validation'
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_URL = \
|
|
||||||
'{0}/accounts/email-sent/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_LOGIN_ERROR_URL = \
|
|
||||||
'{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_EMAIL_FORM_URL = \
|
|
||||||
'{0}/accounts/email/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL = \
|
|
||||||
'{0}/accounts/profile/#auth'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_PROTECTED_USER_FIELDS = ('email',)
|
|
||||||
SOCIAL_AUTH_SLUGIFY_USERNAMES = True
|
|
||||||
SOCIAL_AUTH_SLUGIFY_FUNCTION = 'weblate.accounts.pipeline.slugify_username'
|
|
||||||
|
|
||||||
# Password validation configuration
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
||||||
'OPTIONS': {
|
|
||||||
'min_length': 6,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.CharsPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.PastPasswordsValidator',
|
|
||||||
},
|
|
||||||
# Optional password strength validation by django-zxcvbn-password
|
|
||||||
# {
|
|
||||||
# 'NAME': 'zxcvbn_password.ZXCVBNValidator',
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'min_score': 3,
|
|
||||||
# 'user_attributes': ('username', 'email', 'full_name')
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
]
|
|
||||||
|
|
||||||
# Middleware
|
|
||||||
MIDDLEWARE = [
|
|
||||||
'django.middleware.security.SecurityMiddleware',
|
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
||||||
'django.middleware.common.CommonMiddleware',
|
|
||||||
'django.middleware.locale.LocaleMiddleware',
|
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
|
||||||
'weblate.accounts.middleware.AuthenticationMiddleware',
|
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
||||||
'social_django.middleware.SocialAuthExceptionMiddleware',
|
|
||||||
'weblate.accounts.middleware.RequireLoginMiddleware',
|
|
||||||
'weblate.middleware.SecurityMiddleware',
|
|
||||||
'weblate.wladmin.middleware.ConfigurationErrorsMiddleware',
|
|
||||||
]
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'weblate.urls'
|
|
||||||
|
|
||||||
# Django and Weblate apps
|
|
||||||
INSTALLED_APPS = (
|
|
||||||
'django.contrib.auth',
|
|
||||||
'django.contrib.contenttypes',
|
|
||||||
'django.contrib.sessions',
|
|
||||||
'django.contrib.sites',
|
|
||||||
'django.contrib.messages',
|
|
||||||
'django.contrib.staticfiles',
|
|
||||||
'django.contrib.admin.apps.SimpleAdminConfig',
|
|
||||||
'django.contrib.admindocs',
|
|
||||||
'django.contrib.sitemaps',
|
|
||||||
'social_django',
|
|
||||||
'crispy_forms',
|
|
||||||
'compressor',
|
|
||||||
'rest_framework',
|
|
||||||
'rest_framework.authtoken',
|
|
||||||
'weblate.addons',
|
|
||||||
'weblate.auth',
|
|
||||||
'weblate.checks',
|
|
||||||
'weblate.formats',
|
|
||||||
'weblate.machinery',
|
|
||||||
'weblate.trans',
|
|
||||||
'weblate.lang',
|
|
||||||
'weblate.langdata',
|
|
||||||
'weblate.memory',
|
|
||||||
'weblate.permissions',
|
|
||||||
'weblate.screenshots',
|
|
||||||
'weblate.accounts',
|
|
||||||
'weblate.utils',
|
|
||||||
'weblate.vcs',
|
|
||||||
'weblate.wladmin',
|
|
||||||
'weblate',
|
|
||||||
|
|
||||||
# Optional: Git exporter
|
|
||||||
# 'weblate.gitexport',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Path to locales
|
|
||||||
LOCALE_PATHS = (os.path.join(BASE_DIR, 'weblate', 'locale'), )
|
|
||||||
|
|
||||||
# Custom exception reporter to include some details
|
|
||||||
DEFAULT_EXCEPTION_REPORTER_FILTER = \
|
|
||||||
'weblate.trans.debug.WeblateExceptionReporterFilter'
|
|
||||||
|
|
||||||
# Default logging of Weblate messages
|
|
||||||
# - to syslog in production (if available)
|
|
||||||
# - otherwise to console
|
|
||||||
# - you can also choose 'logfile' to log into separate file
|
|
||||||
# after configuring it below
|
|
||||||
|
|
||||||
# Detect if we can connect to syslog
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
if platform.system() != 'Windows':
|
|
||||||
try:
|
|
||||||
handler = SysLogHandler(
|
|
||||||
address='/dev/log', facility=SysLogHandler.LOG_LOCAL2
|
|
||||||
)
|
|
||||||
handler.close()
|
|
||||||
HAVE_SYSLOG = True
|
|
||||||
except IOError:
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
|
|
||||||
if DEBUG or not HAVE_SYSLOG:
|
|
||||||
DEFAULT_LOG = 'console'
|
|
||||||
else:
|
|
||||||
DEFAULT_LOG = 'syslog'
|
|
||||||
|
|
||||||
# A sample logging configuration. The only tangible logging
|
|
||||||
# performed by this configuration is to send an email to
|
|
||||||
# the site admins on every HTTP 500 error when DEBUG=False.
|
|
||||||
# See http://docs.djangoproject.com/en/stable/topics/logging for
|
|
||||||
# more details on how to customize your logging configuration.
|
|
||||||
LOGGING = {
|
|
||||||
'version': 1,
|
|
||||||
'disable_existing_loggers': True,
|
|
||||||
'filters': {
|
|
||||||
'require_debug_false': {
|
|
||||||
'()': 'django.utils.log.RequireDebugFalse'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'formatters': {
|
|
||||||
'syslog': {
|
|
||||||
'format': 'weblate[%(process)d]: %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'simple': {
|
|
||||||
'format': '%(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'logfile': {
|
|
||||||
'format': '%(asctime)s %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'()': 'django.utils.log.ServerFormatter',
|
|
||||||
'format': '[%(server_time)s] %(message)s',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'handlers': {
|
|
||||||
'mail_admins': {
|
|
||||||
'level': 'ERROR',
|
|
||||||
'filters': ['require_debug_false'],
|
|
||||||
'class': 'django.utils.log.AdminEmailHandler',
|
|
||||||
'include_html': True,
|
|
||||||
},
|
|
||||||
'console': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'simple'
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'level': 'INFO',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'django.server',
|
|
||||||
},
|
|
||||||
'syslog': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.handlers.SysLogHandler',
|
|
||||||
'formatter': 'syslog',
|
|
||||||
'address': '/dev/log',
|
|
||||||
'facility': SysLogHandler.LOG_LOCAL2,
|
|
||||||
},
|
|
||||||
# Logging to a file
|
|
||||||
# 'logfile': {
|
|
||||||
# 'level':'DEBUG',
|
|
||||||
# 'class':'logging.handlers.RotatingFileHandler',
|
|
||||||
# 'filename': "/var/log/weblate/weblate.log",
|
|
||||||
# 'maxBytes': 100000,
|
|
||||||
# 'backupCount': 3,
|
|
||||||
# 'formatter': 'logfile',
|
|
||||||
# },
|
|
||||||
},
|
|
||||||
'loggers': {
|
|
||||||
'django.request': {
|
|
||||||
'handlers': ['mail_admins', DEFAULT_LOG],
|
|
||||||
'level': 'ERROR',
|
|
||||||
'propagate': True,
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'handlers': ['django.server'],
|
|
||||||
'level': 'INFO',
|
|
||||||
'propagate': False,
|
|
||||||
},
|
|
||||||
# Logging database queries
|
|
||||||
# 'django.db.backends': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
'weblate': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'DEBUG',
|
|
||||||
},
|
|
||||||
# Logging VCS operations
|
|
||||||
# 'weblate-vcs': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
# Python Social Auth logging
|
|
||||||
# 'social': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Logging of management commands to console
|
|
||||||
if (os.environ.get('DJANGO_IS_MANAGEMENT_COMMAND', False) and
|
|
||||||
'console' not in LOGGING['loggers']['weblate']['handlers']):
|
|
||||||
LOGGING['loggers']['weblate']['handlers'].append('console')
|
|
||||||
|
|
||||||
# Remove syslog setup if it's not present
|
|
||||||
if not HAVE_SYSLOG:
|
|
||||||
del LOGGING['handlers']['syslog']
|
|
||||||
|
|
||||||
# List of machine translations
|
|
||||||
# MT_SERVICES = (
|
|
||||||
# 'weblate.machinery.apertium.ApertiumAPYTranslation',
|
|
||||||
# 'weblate.machinery.deepl.DeepLTranslation',
|
|
||||||
# 'weblate.machinery.glosbe.GlosbeTranslation',
|
|
||||||
# 'weblate.machinery.google.GoogleTranslation',
|
|
||||||
# 'weblate.machinery.microsoft.MicrosoftCognitiveTranslation',
|
|
||||||
# 'weblate.machinery.mymemory.MyMemoryTranslation',
|
|
||||||
# 'weblate.machinery.tmserver.AmagamaTranslation',
|
|
||||||
# 'weblate.machinery.tmserver.TMServerTranslation',
|
|
||||||
# 'weblate.machinery.yandex.YandexTranslation',
|
|
||||||
# 'weblate.machinery.weblatetm.WeblateTranslation',
|
|
||||||
# 'weblate.machinery.saptranslationhub.SAPTranslationHub',
|
|
||||||
# 'weblate.memory.machine.WeblateMemory',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Machine translation API keys
|
|
||||||
|
|
||||||
# URL of the Apertium APy server
|
|
||||||
MT_APERTIUM_APY = None
|
|
||||||
|
|
||||||
# DeepL API key
|
|
||||||
MT_DEEPL_KEY = None
|
|
||||||
|
|
||||||
# Microsoft Cognitive Services Translator API, register at
|
|
||||||
# https://portal.azure.com/
|
|
||||||
MT_MICROSOFT_COGNITIVE_KEY = None
|
|
||||||
|
|
||||||
# MyMemory identification email, see
|
|
||||||
# https://mymemory.translated.net/doc/spec.php
|
|
||||||
MT_MYMEMORY_EMAIL = None
|
|
||||||
|
|
||||||
# Optional MyMemory credentials to access private translation memory
|
|
||||||
MT_MYMEMORY_USER = None
|
|
||||||
MT_MYMEMORY_KEY = None
|
|
||||||
|
|
||||||
# Google API key for Google Translate API
|
|
||||||
MT_GOOGLE_KEY = None
|
|
||||||
|
|
||||||
# API key for Yandex Translate API
|
|
||||||
MT_YANDEX_KEY = None
|
|
||||||
|
|
||||||
# tmserver URL
|
|
||||||
MT_TMSERVER = None
|
|
||||||
|
|
||||||
# SAP Translation Hub
|
|
||||||
MT_SAP_BASE_URL = None
|
|
||||||
MT_SAP_SANDBOX_APIKEY = None
|
|
||||||
MT_SAP_USERNAME = None
|
|
||||||
MT_SAP_PASSWORD = None
|
|
||||||
MT_SAP_USE_MT = True
|
|
||||||
|
|
||||||
# Title of site to use
|
|
||||||
SITE_TITLE = 'Weblate'
|
|
||||||
|
|
||||||
# Whether site uses https
|
|
||||||
ENABLE_HTTPS = True
|
|
||||||
|
|
||||||
# Use HTTPS when creating redirect URLs for social authentication, see
|
|
||||||
# documentation for more details:
|
|
||||||
# http://python-social-auth-docs.readthedocs.io/en/latest/configuration/settings.html#processing-redirects-and-urlopen
|
|
||||||
SOCIAL_AUTH_REDIRECT_IS_HTTPS = ENABLE_HTTPS
|
|
||||||
|
|
||||||
# Make CSRF cookie HttpOnly, see documentation for more details:
|
|
||||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#csrf-cookie-httponly
|
|
||||||
CSRF_COOKIE_HTTPONLY = True
|
|
||||||
CSRF_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# Store CSRF token in session (since Django 1.11)
|
|
||||||
CSRF_USE_SESSIONS = True
|
|
||||||
SESSION_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# Session cookie age (in seconds)
|
|
||||||
SESSION_COOKIE_AGE = 1209600
|
|
||||||
|
|
||||||
# URL of login
|
|
||||||
LOGIN_URL = '{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# URL of logout
|
|
||||||
LOGOUT_URL = '{0}/accounts/logout/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Default location for login
|
|
||||||
LOGIN_REDIRECT_URL = '{0}/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Anonymous user name
|
|
||||||
ANONYMOUS_USER_NAME = 'anonymous'
|
|
||||||
|
|
||||||
# Reverse proxy settings
|
|
||||||
IP_BEHIND_REVERSE_PROXY = False
|
|
||||||
IP_PROXY_HEADER = 'HTTP_X_FORWARDED_FOR'
|
|
||||||
IP_PROXY_OFFSET = 0
|
|
||||||
|
|
||||||
# Sending HTML in mails
|
|
||||||
EMAIL_SEND_HTML = True
|
|
||||||
|
|
||||||
# Subject of emails includes site title
|
|
||||||
EMAIL_SUBJECT_PREFIX = '[{0}] '.format(SITE_TITLE)
|
|
||||||
|
|
||||||
EMAIL_BACKEND = 'django_sendmail_backend.backends.EmailBackend'
|
|
||||||
|
|
||||||
# Enable remote hooks
|
|
||||||
ENABLE_HOOKS = True
|
|
||||||
|
|
||||||
# Whether to run hooks in background
|
|
||||||
BACKGROUND_HOOKS = True
|
|
||||||
|
|
||||||
# Number of nearby messages to show in each direction
|
|
||||||
NEARBY_MESSAGES = 5
|
|
||||||
|
|
||||||
# Offload indexing
|
|
||||||
OFFLOAD_INDEXING = True
|
|
||||||
|
|
||||||
# Use simple language codes for default language/country combinations
|
|
||||||
SIMPLIFY_LANGUAGES = True
|
|
||||||
|
|
||||||
# Render forms using bootstrap
|
|
||||||
CRISPY_TEMPLATE_PACK = 'bootstrap3'
|
|
||||||
|
|
||||||
# List of quality checks
|
|
||||||
# CHECK_LIST = (
|
|
||||||
# 'weblate.checks.same.SameCheck',
|
|
||||||
# 'weblate.checks.chars.BeginNewlineCheck',
|
|
||||||
# 'weblate.checks.chars.EndNewlineCheck',
|
|
||||||
# 'weblate.checks.chars.BeginSpaceCheck',
|
|
||||||
# 'weblate.checks.chars.EndSpaceCheck',
|
|
||||||
# 'weblate.checks.chars.EndStopCheck',
|
|
||||||
# 'weblate.checks.chars.EndColonCheck',
|
|
||||||
# 'weblate.checks.chars.EndQuestionCheck',
|
|
||||||
# 'weblate.checks.chars.EndExclamationCheck',
|
|
||||||
# 'weblate.checks.chars.EndEllipsisCheck',
|
|
||||||
# 'weblate.checks.chars.EndSemicolonCheck',
|
|
||||||
# 'weblate.checks.chars.MaxLengthCheck',
|
|
||||||
# 'weblate.checks.format.PythonFormatCheck',
|
|
||||||
# 'weblate.checks.format.PythonBraceFormatCheck',
|
|
||||||
# 'weblate.checks.format.PHPFormatCheck',
|
|
||||||
# 'weblate.checks.format.CFormatCheck',
|
|
||||||
# 'weblate.checks.format.PerlFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavascriptFormatCheck',
|
|
||||||
# 'weblate.checks.consistency.PluralsCheck',
|
|
||||||
# 'weblate.checks.consistency.SamePluralsCheck',
|
|
||||||
# 'weblate.checks.consistency.ConsistencyCheck',
|
|
||||||
# 'weblate.checks.consistency.TranslatedCheck',
|
|
||||||
# 'weblate.checks.chars.NewlineCountingCheck',
|
|
||||||
# 'weblate.checks.markup.BBCodeCheck',
|
|
||||||
# 'weblate.checks.chars.ZeroWidthSpaceCheck',
|
|
||||||
# 'weblate.checks.markup.XMLValidityCheck',
|
|
||||||
# 'weblate.checks.markup.XMLTagsCheck',
|
|
||||||
# 'weblate.checks.source.OptionalPluralCheck',
|
|
||||||
# 'weblate.checks.source.EllipsisCheck',
|
|
||||||
# 'weblate.checks.source.MultipleFailingCheck',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of automatic fixups
|
|
||||||
# AUTOFIX_LIST = (
|
|
||||||
# 'weblate.trans.autofixes.whitespace.SameBookendingWhitespace',
|
|
||||||
# 'weblate.trans.autofixes.chars.ReplaceTrailingDotsWithEllipsis',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveZeroSpace',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveControlChars',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of enabled addons
|
|
||||||
# WEBLATE_ADDONS = (
|
|
||||||
# 'weblate.addons.gettext.GenerateMoAddon',
|
|
||||||
# 'weblate.addons.gettext.UpdateLinguasAddon',
|
|
||||||
# 'weblate.addons.gettext.UpdateConfigureAddon',
|
|
||||||
# 'weblate.addons.gettext.MsgmergeAddon',
|
|
||||||
# 'weblate.addons.gettext.GettextCustomizeAddon',
|
|
||||||
# 'weblate.addons.gettext.GettextAuthorComments',
|
|
||||||
# 'weblate.addons.cleanup.CleanupAddon',
|
|
||||||
# 'weblate.addons.consistency.LangaugeConsistencyAddon',
|
|
||||||
# 'weblate.addons.discovery.DiscoveryAddon',
|
|
||||||
# 'weblate.addons.flags.SourceEditAddon',
|
|
||||||
# 'weblate.addons.flags.TargetEditAddon',
|
|
||||||
# 'weblate.addons.generate.GenerateFileAddon',
|
|
||||||
# 'weblate.addons.json.JSONCustomizeAddon',
|
|
||||||
# 'weblate.addons.properties.PropertiesSortAddon',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# E-mail address that error messages come from.
|
|
||||||
SERVER_EMAIL = 'noreply@__DOMAIN__'
|
|
||||||
|
|
||||||
# Default email address to use for various automated correspondence from
|
|
||||||
# the site managers. Used for registration emails.
|
|
||||||
DEFAULT_FROM_EMAIL = '__ADMINMAIL__'
|
|
||||||
|
|
||||||
# List of URLs your site is supposed to serve
|
|
||||||
ALLOWED_HOSTS = ['__DOMAIN__']
|
|
||||||
|
|
||||||
# Example configuration to use memcached for caching
|
|
||||||
CACHES = {
|
|
||||||
'default': {
|
|
||||||
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
|
||||||
'LOCATION': '127.0.0.1:__MEMCPORT__',
|
|
||||||
},
|
|
||||||
'avatar': {
|
|
||||||
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
|
||||||
'LOCATION': os.path.join(BASE_DIR, 'avatar-cache'),
|
|
||||||
'TIMEOUT': 3600,
|
|
||||||
'OPTIONS': {
|
|
||||||
'MAX_ENTRIES': 1000,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# REST framework settings for API
|
|
||||||
REST_FRAMEWORK = {
|
|
||||||
# Use Django's standard `django.contrib.auth` permissions,
|
|
||||||
# or allow read-only access for unauthenticated users.
|
|
||||||
'DEFAULT_PERMISSION_CLASSES': [
|
|
||||||
'rest_framework.permissions.IsAuthenticatedOrReadOnly'
|
|
||||||
],
|
|
||||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
|
||||||
'rest_framework.authentication.TokenAuthentication',
|
|
||||||
'weblate.api.authentication.BearerAuthentication',
|
|
||||||
'rest_framework.authentication.SessionAuthentication',
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_CLASSES': (
|
|
||||||
'rest_framework.throttling.AnonRateThrottle',
|
|
||||||
'rest_framework.throttling.UserRateThrottle'
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_RATES': {
|
|
||||||
'anon': '100/day',
|
|
||||||
'user': '1000/day'
|
|
||||||
},
|
|
||||||
'DEFAULT_PAGINATION_CLASS': (
|
|
||||||
'rest_framework.pagination.PageNumberPagination'
|
|
||||||
),
|
|
||||||
'PAGE_SIZE': 20,
|
|
||||||
'VIEW_DESCRIPTION_FUNCTION': 'weblate.api.views.get_view_description',
|
|
||||||
'UNAUTHENTICATED_USER': 'weblate.auth.models.get_anonymous',
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example for restricting access to logged in users
|
|
||||||
# LOGIN_REQUIRED_URLS = (
|
|
||||||
# r'/(.*)$',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# In such case you will want to include some of the exceptions
|
|
||||||
# LOGIN_REQUIRED_URLS_EXCEPTIONS = (
|
|
||||||
# r'/accounts/(.*)$', # Required for login
|
|
||||||
# r'/static/(.*)$', # Required for development mode
|
|
||||||
# r'/widgets/(.*)$', # Allowing public access to widgets
|
|
||||||
# r'/data/(.*)$', # Allowing public access to data exports
|
|
||||||
# r'/hooks/(.*)$', # Allowing public access to notification hooks
|
|
||||||
# r'/api/(.*)$', # Allowing access to API
|
|
||||||
# r'/js/i18n/$', # Javascript localization
|
|
||||||
# r'/contact/$', # Optional for contact form
|
|
||||||
# r'/legal/(.*)$', # Optional for legal app
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Force sane test runner
|
|
||||||
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
|
|
@ -1,770 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# Copyright © 2012 - 2018 Michal Čihař <michal@cihar.com>
|
|
||||||
#
|
|
||||||
# This file is part of Weblate <https://weblate.org/>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import platform
|
|
||||||
import os
|
|
||||||
from logging.handlers import SysLogHandler
|
|
||||||
|
|
||||||
#
|
|
||||||
# Django settings for Weblate project.
|
|
||||||
#
|
|
||||||
|
|
||||||
DEBUG = False
|
|
||||||
|
|
||||||
ADMINS = (
|
|
||||||
('__ADMIN__', '__ADMINMAIL__'),
|
|
||||||
)
|
|
||||||
|
|
||||||
MANAGERS = ADMINS
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
# Database engine
|
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
||||||
# Database name
|
|
||||||
'NAME': '__NAME__',
|
|
||||||
# Database user
|
|
||||||
'USER': '__NAME__',
|
|
||||||
# Database password
|
|
||||||
'PASSWORD': '__DB_PWD__',
|
|
||||||
# Set to empty string for localhost
|
|
||||||
'HOST': 'localhost',
|
|
||||||
# Set to empty string for default
|
|
||||||
'PORT': '5432',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BASE_DIR = '__FINALPATH__'
|
|
||||||
|
|
||||||
# Data directory
|
|
||||||
DATA_DIR = os.path.join(BASE_DIR, 'data')
|
|
||||||
|
|
||||||
# Local time zone for this installation. Choices can be found here:
|
|
||||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
|
||||||
# although not all choices may be available on all operating systems.
|
|
||||||
# In a Windows environment this must be set to your system time zone.
|
|
||||||
TIME_ZONE = 'UTC'
|
|
||||||
|
|
||||||
# Language code for this installation. All choices can be found here:
|
|
||||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
|
||||||
|
|
||||||
LANGUAGES = (
|
|
||||||
('ar', 'العربية'),
|
|
||||||
('az', 'Azərbaycan'),
|
|
||||||
('be', 'Беларуская'),
|
|
||||||
('be@latin', 'Biełaruskaja'),
|
|
||||||
('bg', 'Български'),
|
|
||||||
('br', 'Brezhoneg'),
|
|
||||||
('ca', 'Català'),
|
|
||||||
('cs', 'Čeština'),
|
|
||||||
('da', 'Dansk'),
|
|
||||||
('de', 'Deutsch'),
|
|
||||||
('en', 'English'),
|
|
||||||
('en-gb', 'English (United Kingdom)'),
|
|
||||||
('el', 'Ελληνικά'),
|
|
||||||
('es', 'Español'),
|
|
||||||
('fi', 'Suomi'),
|
|
||||||
('fr', 'Français'),
|
|
||||||
('fy', 'Frysk'),
|
|
||||||
('gl', 'Galego'),
|
|
||||||
('he', 'עברית'),
|
|
||||||
('hu', 'Magyar'),
|
|
||||||
('id', 'Indonesia'),
|
|
||||||
('it', 'Italiano'),
|
|
||||||
('ja', '日本語'),
|
|
||||||
('ko', '한국어'),
|
|
||||||
('ksh', 'Kölsch'),
|
|
||||||
('nb', 'Norsk bokmål'),
|
|
||||||
('nl', 'Nederlands'),
|
|
||||||
('pl', 'Polski'),
|
|
||||||
('pt', 'Português'),
|
|
||||||
('pt-br', 'Português brasileiro'),
|
|
||||||
('ru', 'Русский'),
|
|
||||||
('sk', 'Slovenčina'),
|
|
||||||
('sl', 'Slovenščina'),
|
|
||||||
('sr', 'Српски'),
|
|
||||||
('sv', 'Svenska'),
|
|
||||||
('tr', 'Türkçe'),
|
|
||||||
('uk', 'Українська'),
|
|
||||||
('zh-hans', '简体字'),
|
|
||||||
('zh-hant', '正體字'),
|
|
||||||
)
|
|
||||||
|
|
||||||
SITE_ID = 1
|
|
||||||
|
|
||||||
# If you set this to False, Django will make some optimizations so as not
|
|
||||||
# to load the internationalization machinery.
|
|
||||||
USE_I18N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not format dates, numbers and
|
|
||||||
# calendars according to the current locale.
|
|
||||||
USE_L10N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not use timezone-aware datetimes.
|
|
||||||
USE_TZ = True
|
|
||||||
|
|
||||||
# URL prefix to use, please see documentation for more details
|
|
||||||
URL_PREFIX = '__PATHURL__'
|
|
||||||
|
|
||||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
|
||||||
# Example: "/home/media/media.lawrence.com/media/"
|
|
||||||
MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
|
|
||||||
|
|
||||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
|
||||||
# trailing slash.
|
|
||||||
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
|
||||||
MEDIA_URL = '{0}/media/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Absolute path to the directory static files should be collected to.
|
|
||||||
# Don't put anything in this directory yourself; store your static files
|
|
||||||
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
|
|
||||||
# Example: "/home/media/media.lawrence.com/static/"
|
|
||||||
STATIC_ROOT = os.path.join(DATA_DIR, 'static')
|
|
||||||
|
|
||||||
# URL prefix for static files.
|
|
||||||
# Example: "http://media.lawrence.com/static/"
|
|
||||||
STATIC_URL = '{0}/static/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Additional locations of static files
|
|
||||||
STATICFILES_DIRS = (
|
|
||||||
# Put strings here, like "/home/html/static" or "C:/www/django/static".
|
|
||||||
# Always use forward slashes, even on Windows.
|
|
||||||
# Don't forget to use absolute paths, not relative paths.
|
|
||||||
)
|
|
||||||
|
|
||||||
# List of finder classes that know how to find static files in
|
|
||||||
# various locations.
|
|
||||||
STATICFILES_FINDERS = (
|
|
||||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
|
||||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
|
||||||
'compressor.finders.CompressorFinder',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Make this unique, and don't share it with anybody.
|
|
||||||
# You can generate it using examples/generate-secret-key
|
|
||||||
SECRET_KEY = '__KEY__' # noqa
|
|
||||||
|
|
||||||
TEMPLATES = [
|
|
||||||
{
|
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
||||||
'DIRS': [
|
|
||||||
os.path.join(BASE_DIR, 'weblate', 'templates'),
|
|
||||||
],
|
|
||||||
'OPTIONS': {
|
|
||||||
'context_processors': [
|
|
||||||
'django.contrib.auth.context_processors.auth',
|
|
||||||
'django.template.context_processors.debug',
|
|
||||||
'django.template.context_processors.i18n',
|
|
||||||
'django.template.context_processors.request',
|
|
||||||
'django.template.context_processors.csrf',
|
|
||||||
'django.contrib.messages.context_processors.messages',
|
|
||||||
'weblate.trans.context_processors.weblate_context',
|
|
||||||
],
|
|
||||||
'loaders': [
|
|
||||||
('django.template.loaders.cached.Loader', [
|
|
||||||
'django.template.loaders.filesystem.Loader',
|
|
||||||
'django.template.loaders.app_directories.Loader',
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# GitHub username for sending pull requests.
|
|
||||||
# Please see the documentation for more details.
|
|
||||||
GITHUB_USERNAME = "__GITHUBUSER__"
|
|
||||||
|
|
||||||
# Authentication configuration
|
|
||||||
AUTHENTICATION_BACKENDS = (
|
|
||||||
'social_core.backends.email.EmailAuth',
|
|
||||||
# 'social_core.backends.google.GoogleOAuth2',
|
|
||||||
# 'social_core.backends.github.GithubOAuth2',
|
|
||||||
# 'social_core.backends.bitbucket.BitbucketOAuth',
|
|
||||||
'social_core.backends.suse.OpenSUSEOpenId',
|
|
||||||
'social_core.backends.ubuntu.UbuntuOpenId',
|
|
||||||
'social_core.backends.fedora.FedoraOpenId',
|
|
||||||
# 'social_core.backends.facebook.FacebookOAuth2',
|
|
||||||
'weblate.accounts.auth.WeblateUserBackend',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom user model
|
|
||||||
AUTH_USER_MODEL = 'weblate_auth.User'
|
|
||||||
|
|
||||||
# Social auth backends setup
|
|
||||||
SOCIAL_AUTH_GITHUB_KEY = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SECRET = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SCOPE = ['user:email']
|
|
||||||
|
|
||||||
SOCIAL_AUTH_BITBUCKET_KEY = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_SECRET = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_VERIFIED_EMAILS_ONLY = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_FACEBOOK_KEY = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SECRET = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email', 'public_profile']
|
|
||||||
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = ''
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = ''
|
|
||||||
|
|
||||||
# Social auth settings
|
|
||||||
SOCIAL_AUTH_PIPELINE = (
|
|
||||||
'social_core.pipeline.social_auth.social_details',
|
|
||||||
'social_core.pipeline.social_auth.social_uid',
|
|
||||||
'social_core.pipeline.social_auth.auth_allowed',
|
|
||||||
'social_core.pipeline.social_auth.social_user',
|
|
||||||
'weblate.accounts.pipeline.store_params',
|
|
||||||
'weblate.accounts.pipeline.verify_open',
|
|
||||||
'social_core.pipeline.user.get_username',
|
|
||||||
'weblate.accounts.pipeline.require_email',
|
|
||||||
'social_core.pipeline.mail.mail_validation',
|
|
||||||
'weblate.accounts.pipeline.revoke_mail_code',
|
|
||||||
'weblate.accounts.pipeline.ensure_valid',
|
|
||||||
'weblate.accounts.pipeline.remove_account',
|
|
||||||
'social_core.pipeline.social_auth.associate_by_email',
|
|
||||||
'weblate.accounts.pipeline.reauthenticate',
|
|
||||||
'weblate.accounts.pipeline.verify_username',
|
|
||||||
'social_core.pipeline.user.create_user',
|
|
||||||
'social_core.pipeline.social_auth.associate_user',
|
|
||||||
'social_core.pipeline.social_auth.load_extra_data',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
'weblate.accounts.pipeline.user_full_name',
|
|
||||||
'weblate.accounts.pipeline.store_email',
|
|
||||||
'weblate.accounts.pipeline.notify_connect',
|
|
||||||
'weblate.accounts.pipeline.password_reset',
|
|
||||||
)
|
|
||||||
SOCIAL_AUTH_DISCONNECT_PIPELINE = (
|
|
||||||
'social_core.pipeline.disconnect.allowed_to_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.get_entries',
|
|
||||||
'social_core.pipeline.disconnect.revoke_tokens',
|
|
||||||
'weblate.accounts.pipeline.cycle_session',
|
|
||||||
'weblate.accounts.pipeline.adjust_primary_mail',
|
|
||||||
'weblate.accounts.pipeline.notify_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.disconnect',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom authentication strategy
|
|
||||||
SOCIAL_AUTH_STRATEGY = 'weblate.accounts.strategy.WeblateStrategy'
|
|
||||||
|
|
||||||
# Raise exceptions so that we can handle them later
|
|
||||||
SOCIAL_AUTH_RAISE_EXCEPTIONS = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_FUNCTION = \
|
|
||||||
'weblate.accounts.pipeline.send_validation'
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_URL = \
|
|
||||||
'{0}/accounts/email-sent/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_LOGIN_ERROR_URL = \
|
|
||||||
'{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_EMAIL_FORM_URL = \
|
|
||||||
'{0}/accounts/email/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL = \
|
|
||||||
'{0}/accounts/profile/#auth'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_PROTECTED_USER_FIELDS = ('email',)
|
|
||||||
SOCIAL_AUTH_SLUGIFY_USERNAMES = True
|
|
||||||
SOCIAL_AUTH_SLUGIFY_FUNCTION = 'weblate.accounts.pipeline.slugify_username'
|
|
||||||
|
|
||||||
# Password validation configuration
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
||||||
'OPTIONS': {
|
|
||||||
'min_length': 6,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.CharsPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.PastPasswordsValidator',
|
|
||||||
},
|
|
||||||
# Optional password strength validation by django-zxcvbn-password
|
|
||||||
# {
|
|
||||||
# 'NAME': 'zxcvbn_password.ZXCVBNValidator',
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'min_score': 3,
|
|
||||||
# 'user_attributes': ('username', 'email', 'full_name')
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
]
|
|
||||||
|
|
||||||
# Middleware
|
|
||||||
MIDDLEWARE = [
|
|
||||||
'django.middleware.security.SecurityMiddleware',
|
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
||||||
'django.middleware.common.CommonMiddleware',
|
|
||||||
'django.middleware.locale.LocaleMiddleware',
|
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
|
||||||
'weblate.accounts.middleware.AuthenticationMiddleware',
|
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
||||||
'social_django.middleware.SocialAuthExceptionMiddleware',
|
|
||||||
'weblate.accounts.middleware.RequireLoginMiddleware',
|
|
||||||
'weblate.middleware.SecurityMiddleware',
|
|
||||||
'weblate.wladmin.middleware.ConfigurationErrorsMiddleware',
|
|
||||||
]
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'weblate.urls'
|
|
||||||
|
|
||||||
# Django and Weblate apps
|
|
||||||
INSTALLED_APPS = (
|
|
||||||
'django.contrib.auth',
|
|
||||||
'django.contrib.contenttypes',
|
|
||||||
'django.contrib.sessions',
|
|
||||||
'django.contrib.sites',
|
|
||||||
'django.contrib.messages',
|
|
||||||
'django.contrib.staticfiles',
|
|
||||||
'django.contrib.admin.apps.SimpleAdminConfig',
|
|
||||||
'django.contrib.admindocs',
|
|
||||||
'django.contrib.sitemaps',
|
|
||||||
'social_django',
|
|
||||||
'crispy_forms',
|
|
||||||
'compressor',
|
|
||||||
'rest_framework',
|
|
||||||
'rest_framework.authtoken',
|
|
||||||
'weblate.addons',
|
|
||||||
'weblate.auth',
|
|
||||||
'weblate.checks',
|
|
||||||
'weblate.formats',
|
|
||||||
'weblate.machinery',
|
|
||||||
'weblate.trans',
|
|
||||||
'weblate.lang',
|
|
||||||
'weblate.langdata',
|
|
||||||
'weblate.memory',
|
|
||||||
'weblate.screenshots',
|
|
||||||
'weblate.accounts',
|
|
||||||
'weblate.utils',
|
|
||||||
'weblate.vcs',
|
|
||||||
'weblate.wladmin',
|
|
||||||
'weblate',
|
|
||||||
|
|
||||||
# Optional: Git exporter
|
|
||||||
# 'weblate.gitexport',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Path to locales
|
|
||||||
LOCALE_PATHS = (os.path.join(BASE_DIR, 'weblate', 'locale'), )
|
|
||||||
|
|
||||||
# Custom exception reporter to include some details
|
|
||||||
DEFAULT_EXCEPTION_REPORTER_FILTER = \
|
|
||||||
'weblate.trans.debug.WeblateExceptionReporterFilter'
|
|
||||||
|
|
||||||
# Default logging of Weblate messages
|
|
||||||
# - to syslog in production (if available)
|
|
||||||
# - otherwise to console
|
|
||||||
# - you can also choose 'logfile' to log into separate file
|
|
||||||
# after configuring it below
|
|
||||||
|
|
||||||
# Detect if we can connect to syslog
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
if platform.system() != 'Windows':
|
|
||||||
try:
|
|
||||||
handler = SysLogHandler(
|
|
||||||
address='/dev/log', facility=SysLogHandler.LOG_LOCAL2
|
|
||||||
)
|
|
||||||
handler.close()
|
|
||||||
HAVE_SYSLOG = True
|
|
||||||
except IOError:
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
|
|
||||||
if DEBUG or not HAVE_SYSLOG:
|
|
||||||
DEFAULT_LOG = 'console'
|
|
||||||
else:
|
|
||||||
DEFAULT_LOG = 'syslog'
|
|
||||||
|
|
||||||
# A sample logging configuration. The only tangible logging
|
|
||||||
# performed by this configuration is to send an email to
|
|
||||||
# the site admins on every HTTP 500 error when DEBUG=False.
|
|
||||||
# See http://docs.djangoproject.com/en/stable/topics/logging for
|
|
||||||
# more details on how to customize your logging configuration.
|
|
||||||
LOGGING = {
|
|
||||||
'version': 1,
|
|
||||||
'disable_existing_loggers': True,
|
|
||||||
'filters': {
|
|
||||||
'require_debug_false': {
|
|
||||||
'()': 'django.utils.log.RequireDebugFalse'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'formatters': {
|
|
||||||
'syslog': {
|
|
||||||
'format': 'weblate[%(process)d]: %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'simple': {
|
|
||||||
'format': '%(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'logfile': {
|
|
||||||
'format': '%(asctime)s %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'()': 'django.utils.log.ServerFormatter',
|
|
||||||
'format': '[%(server_time)s] %(message)s',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'handlers': {
|
|
||||||
'mail_admins': {
|
|
||||||
'level': 'ERROR',
|
|
||||||
'filters': ['require_debug_false'],
|
|
||||||
'class': 'django.utils.log.AdminEmailHandler',
|
|
||||||
'include_html': True,
|
|
||||||
},
|
|
||||||
'console': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'simple'
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'level': 'INFO',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'django.server',
|
|
||||||
},
|
|
||||||
'syslog': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.handlers.SysLogHandler',
|
|
||||||
'formatter': 'syslog',
|
|
||||||
'address': '/dev/log',
|
|
||||||
'facility': SysLogHandler.LOG_LOCAL2,
|
|
||||||
},
|
|
||||||
# Logging to a file
|
|
||||||
# 'logfile': {
|
|
||||||
# 'level':'DEBUG',
|
|
||||||
# 'class':'logging.handlers.RotatingFileHandler',
|
|
||||||
# 'filename': "/var/log/weblate/weblate.log",
|
|
||||||
# 'maxBytes': 100000,
|
|
||||||
# 'backupCount': 3,
|
|
||||||
# 'formatter': 'logfile',
|
|
||||||
# },
|
|
||||||
},
|
|
||||||
'loggers': {
|
|
||||||
'django.request': {
|
|
||||||
'handlers': ['mail_admins', DEFAULT_LOG],
|
|
||||||
'level': 'ERROR',
|
|
||||||
'propagate': True,
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'handlers': ['django.server'],
|
|
||||||
'level': 'INFO',
|
|
||||||
'propagate': False,
|
|
||||||
},
|
|
||||||
# Logging database queries
|
|
||||||
# 'django.db.backends': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
'weblate': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'DEBUG',
|
|
||||||
},
|
|
||||||
# Logging VCS operations
|
|
||||||
# 'weblate-vcs': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
# Python Social Auth logging
|
|
||||||
# 'social': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Logging of management commands to console
|
|
||||||
if (os.environ.get('DJANGO_IS_MANAGEMENT_COMMAND', False) and
|
|
||||||
'console' not in LOGGING['loggers']['weblate']['handlers']):
|
|
||||||
LOGGING['loggers']['weblate']['handlers'].append('console')
|
|
||||||
|
|
||||||
# Remove syslog setup if it's not present
|
|
||||||
if not HAVE_SYSLOG:
|
|
||||||
del LOGGING['handlers']['syslog']
|
|
||||||
|
|
||||||
# List of machine translations
|
|
||||||
# MT_SERVICES = (
|
|
||||||
# 'weblate.machinery.apertium.ApertiumAPYTranslation',
|
|
||||||
# 'weblate.machinery.deepl.DeepLTranslation',
|
|
||||||
# 'weblate.machinery.glosbe.GlosbeTranslation',
|
|
||||||
# 'weblate.machinery.google.GoogleTranslation',
|
|
||||||
# 'weblate.machinery.microsoft.MicrosoftCognitiveTranslation',
|
|
||||||
# 'weblate.machinery.mymemory.MyMemoryTranslation',
|
|
||||||
# 'weblate.machinery.tmserver.AmagamaTranslation',
|
|
||||||
# 'weblate.machinery.tmserver.TMServerTranslation',
|
|
||||||
# 'weblate.machinery.yandex.YandexTranslation',
|
|
||||||
# 'weblate.machinery.weblatetm.WeblateTranslation',
|
|
||||||
# 'weblate.machinery.saptranslationhub.SAPTranslationHub',
|
|
||||||
# 'weblate.memory.machine.WeblateMemory',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Machine translation API keys
|
|
||||||
|
|
||||||
# URL of the Apertium APy server
|
|
||||||
MT_APERTIUM_APY = None
|
|
||||||
|
|
||||||
# DeepL API key
|
|
||||||
MT_DEEPL_KEY = None
|
|
||||||
|
|
||||||
# Microsoft Cognitive Services Translator API, register at
|
|
||||||
# https://portal.azure.com/
|
|
||||||
MT_MICROSOFT_COGNITIVE_KEY = None
|
|
||||||
|
|
||||||
# MyMemory identification email, see
|
|
||||||
# https://mymemory.translated.net/doc/spec.php
|
|
||||||
MT_MYMEMORY_EMAIL = None
|
|
||||||
|
|
||||||
# Optional MyMemory credentials to access private translation memory
|
|
||||||
MT_MYMEMORY_USER = None
|
|
||||||
MT_MYMEMORY_KEY = None
|
|
||||||
|
|
||||||
# Google API key for Google Translate API
|
|
||||||
MT_GOOGLE_KEY = None
|
|
||||||
|
|
||||||
# API key for Yandex Translate API
|
|
||||||
MT_YANDEX_KEY = None
|
|
||||||
|
|
||||||
# tmserver URL
|
|
||||||
MT_TMSERVER = None
|
|
||||||
|
|
||||||
# SAP Translation Hub
|
|
||||||
MT_SAP_BASE_URL = None
|
|
||||||
MT_SAP_SANDBOX_APIKEY = None
|
|
||||||
MT_SAP_USERNAME = None
|
|
||||||
MT_SAP_PASSWORD = None
|
|
||||||
MT_SAP_USE_MT = True
|
|
||||||
|
|
||||||
# Title of site to use
|
|
||||||
SITE_TITLE = 'Weblate'
|
|
||||||
|
|
||||||
# Whether site uses https
|
|
||||||
ENABLE_HTTPS = True
|
|
||||||
|
|
||||||
# Use HTTPS when creating redirect URLs for social authentication, see
|
|
||||||
# documentation for more details:
|
|
||||||
# http://python-social-auth-docs.readthedocs.io/en/latest/configuration/settings.html#processing-redirects-and-urlopen
|
|
||||||
SOCIAL_AUTH_REDIRECT_IS_HTTPS = ENABLE_HTTPS
|
|
||||||
|
|
||||||
# Make CSRF cookie HttpOnly, see documentation for more details:
|
|
||||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#csrf-cookie-httponly
|
|
||||||
CSRF_COOKIE_HTTPONLY = True
|
|
||||||
CSRF_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# Store CSRF token in session (since Django 1.11)
|
|
||||||
CSRF_USE_SESSIONS = True
|
|
||||||
SESSION_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# SSL redirect
|
|
||||||
SECURE_SSL_REDIRECT = ENABLE_HTTPS
|
|
||||||
# Session cookie age (in seconds)
|
|
||||||
SESSION_COOKIE_AGE = 1209600
|
|
||||||
|
|
||||||
# Some security headers
|
|
||||||
SECURE_BROWSER_XSS_FILTER = True
|
|
||||||
X_FRAME_OPTIONS = 'DENY'
|
|
||||||
SECURE_CONTENT_TYPE_NOSNIFF = True
|
|
||||||
|
|
||||||
# Optionally enable HSTS
|
|
||||||
SECURE_HSTS_SECONDS = 0
|
|
||||||
SECURE_HSTS_PRELOAD = False
|
|
||||||
SECURE_HSTS_INCLUDE_SUBDOMAINS = False
|
|
||||||
|
|
||||||
# URL of login
|
|
||||||
LOGIN_URL = '{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# URL of logout
|
|
||||||
LOGOUT_URL = '{0}/accounts/logout/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Default location for login
|
|
||||||
LOGIN_REDIRECT_URL = '{0}/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Anonymous user name
|
|
||||||
ANONYMOUS_USER_NAME = 'anonymous'
|
|
||||||
|
|
||||||
# Reverse proxy settings
|
|
||||||
IP_BEHIND_REVERSE_PROXY = False
|
|
||||||
IP_PROXY_HEADER = 'HTTP_X_FORWARDED_FOR'
|
|
||||||
IP_PROXY_OFFSET = 0
|
|
||||||
|
|
||||||
# Sending HTML in mails
|
|
||||||
EMAIL_SEND_HTML = True
|
|
||||||
|
|
||||||
# Subject of emails includes site title
|
|
||||||
EMAIL_SUBJECT_PREFIX = '[{0}] '.format(SITE_TITLE)
|
|
||||||
|
|
||||||
EMAIL_BACKEND = 'django_sendmail_backend.backends.EmailBackend'
|
|
||||||
|
|
||||||
# Enable remote hooks
|
|
||||||
ENABLE_HOOKS = True
|
|
||||||
|
|
||||||
# Whether to run hooks in background
|
|
||||||
BACKGROUND_HOOKS = True
|
|
||||||
|
|
||||||
# Number of nearby messages to show in each direction
|
|
||||||
NEARBY_MESSAGES = 5
|
|
||||||
|
|
||||||
# Offload indexing
|
|
||||||
OFFLOAD_INDEXING = True
|
|
||||||
|
|
||||||
# Use simple language codes for default language/country combinations
|
|
||||||
SIMPLIFY_LANGUAGES = True
|
|
||||||
|
|
||||||
# Render forms using bootstrap
|
|
||||||
CRISPY_TEMPLATE_PACK = 'bootstrap3'
|
|
||||||
|
|
||||||
# List of quality checks
|
|
||||||
# CHECK_LIST = (
|
|
||||||
# 'weblate.checks.same.SameCheck',
|
|
||||||
# 'weblate.checks.chars.BeginNewlineCheck',
|
|
||||||
# 'weblate.checks.chars.EndNewlineCheck',
|
|
||||||
# 'weblate.checks.chars.BeginSpaceCheck',
|
|
||||||
# 'weblate.checks.chars.EndSpaceCheck',
|
|
||||||
# 'weblate.checks.chars.EndStopCheck',
|
|
||||||
# 'weblate.checks.chars.EndColonCheck',
|
|
||||||
# 'weblate.checks.chars.EndQuestionCheck',
|
|
||||||
# 'weblate.checks.chars.EndExclamationCheck',
|
|
||||||
# 'weblate.checks.chars.EndEllipsisCheck',
|
|
||||||
# 'weblate.checks.chars.EndSemicolonCheck',
|
|
||||||
# 'weblate.checks.chars.MaxLengthCheck',
|
|
||||||
# 'weblate.checks.format.PythonFormatCheck',
|
|
||||||
# 'weblate.checks.format.PythonBraceFormatCheck',
|
|
||||||
# 'weblate.checks.format.PHPFormatCheck',
|
|
||||||
# 'weblate.checks.format.CFormatCheck',
|
|
||||||
# 'weblate.checks.format.PerlFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavascriptFormatCheck',
|
|
||||||
# 'weblate.checks.consistency.PluralsCheck',
|
|
||||||
# 'weblate.checks.consistency.SamePluralsCheck',
|
|
||||||
# 'weblate.checks.consistency.ConsistencyCheck',
|
|
||||||
# 'weblate.checks.consistency.TranslatedCheck',
|
|
||||||
# 'weblate.checks.chars.NewlineCountingCheck',
|
|
||||||
# 'weblate.checks.markup.BBCodeCheck',
|
|
||||||
# 'weblate.checks.chars.ZeroWidthSpaceCheck',
|
|
||||||
# 'weblate.checks.markup.XMLValidityCheck',
|
|
||||||
# 'weblate.checks.markup.XMLTagsCheck',
|
|
||||||
# 'weblate.checks.source.OptionalPluralCheck',
|
|
||||||
# 'weblate.checks.source.EllipsisCheck',
|
|
||||||
# 'weblate.checks.source.MultipleFailingCheck',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of automatic fixups
|
|
||||||
# AUTOFIX_LIST = (
|
|
||||||
# 'weblate.trans.autofixes.whitespace.SameBookendingWhitespace',
|
|
||||||
# 'weblate.trans.autofixes.chars.ReplaceTrailingDotsWithEllipsis',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveZeroSpace',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveControlChars',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of enabled addons
|
|
||||||
# WEBLATE_ADDONS = (
|
|
||||||
# 'weblate.addons.gettext.GenerateMoAddon',
|
|
||||||
# 'weblate.addons.gettext.UpdateLinguasAddon',
|
|
||||||
# 'weblate.addons.gettext.UpdateConfigureAddon',
|
|
||||||
# 'weblate.addons.gettext.MsgmergeAddon',
|
|
||||||
# 'weblate.addons.gettext.GettextCustomizeAddon',
|
|
||||||
# 'weblate.addons.gettext.GettextAuthorComments',
|
|
||||||
# 'weblate.addons.cleanup.CleanupAddon',
|
|
||||||
# 'weblate.addons.consistency.LangaugeConsistencyAddon',
|
|
||||||
# 'weblate.addons.discovery.DiscoveryAddon',
|
|
||||||
# 'weblate.addons.flags.SourceEditAddon',
|
|
||||||
# 'weblate.addons.flags.TargetEditAddon',
|
|
||||||
# 'weblate.addons.generate.GenerateFileAddon',
|
|
||||||
# 'weblate.addons.json.JSONCustomizeAddon',
|
|
||||||
# 'weblate.addons.properties.PropertiesSortAddon',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# E-mail address that error messages come from.
|
|
||||||
SERVER_EMAIL = 'noreply@__DOMAIN__'
|
|
||||||
|
|
||||||
# Default email address to use for various automated correspondence from
|
|
||||||
# the site managers. Used for registration emails.
|
|
||||||
DEFAULT_FROM_EMAIL = '__ADMINMAIL__'
|
|
||||||
|
|
||||||
# List of URLs your site is supposed to serve
|
|
||||||
ALLOWED_HOSTS = ['__DOMAIN__']
|
|
||||||
|
|
||||||
# Example configuration to use memcached for caching
|
|
||||||
CACHES = {
|
|
||||||
'default': {
|
|
||||||
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
|
||||||
'LOCATION': '127.0.0.1:__MEMCPORT__',
|
|
||||||
},
|
|
||||||
'avatar': {
|
|
||||||
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
|
||||||
'LOCATION': os.path.join(BASE_DIR, 'avatar-cache'),
|
|
||||||
'TIMEOUT': 3600,
|
|
||||||
'OPTIONS': {
|
|
||||||
'MAX_ENTRIES': 1000,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# REST framework settings for API
|
|
||||||
REST_FRAMEWORK = {
|
|
||||||
# Use Django's standard `django.contrib.auth` permissions,
|
|
||||||
# or allow read-only access for unauthenticated users.
|
|
||||||
'DEFAULT_PERMISSION_CLASSES': [
|
|
||||||
'rest_framework.permissions.IsAuthenticatedOrReadOnly'
|
|
||||||
],
|
|
||||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
|
||||||
'rest_framework.authentication.TokenAuthentication',
|
|
||||||
'weblate.api.authentication.BearerAuthentication',
|
|
||||||
'rest_framework.authentication.SessionAuthentication',
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_CLASSES': (
|
|
||||||
'rest_framework.throttling.AnonRateThrottle',
|
|
||||||
'rest_framework.throttling.UserRateThrottle'
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_RATES': {
|
|
||||||
'anon': '100/day',
|
|
||||||
'user': '1000/day'
|
|
||||||
},
|
|
||||||
'DEFAULT_PAGINATION_CLASS': (
|
|
||||||
'rest_framework.pagination.PageNumberPagination'
|
|
||||||
),
|
|
||||||
'PAGE_SIZE': 20,
|
|
||||||
'VIEW_DESCRIPTION_FUNCTION': 'weblate.api.views.get_view_description',
|
|
||||||
'UNAUTHENTICATED_USER': 'weblate.auth.models.get_anonymous',
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example for restricting access to logged in users
|
|
||||||
# LOGIN_REQUIRED_URLS = (
|
|
||||||
# r'/(.*)$',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# In such case you will want to include some of the exceptions
|
|
||||||
# LOGIN_REQUIRED_URLS_EXCEPTIONS = (
|
|
||||||
# r'/accounts/(.*)$', # Required for login
|
|
||||||
# r'/admin/login/(.*)$', # Required for admin login
|
|
||||||
# r'/static/(.*)$', # Required for development mode
|
|
||||||
# r'/widgets/(.*)$', # Allowing public access to widgets
|
|
||||||
# r'/data/(.*)$', # Allowing public access to data exports
|
|
||||||
# r'/hooks/(.*)$', # Allowing public access to notification hooks
|
|
||||||
# r'/healthz/$', # Allowing public access to health check
|
|
||||||
# r'/api/(.*)$', # Allowing access to API
|
|
||||||
# r'/js/i18n/$', # Javascript localization
|
|
||||||
# r'/contact/$', # Optional for contact form
|
|
||||||
# r'/legal/(.*)$', # Optional for legal app
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Force sane test runner
|
|
||||||
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
|
|
@ -1,824 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# Copyright © 2012 - 2018 Michal Čihař <michal@cihar.com>
|
|
||||||
#
|
|
||||||
# This file is part of Weblate <https://weblate.org/>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import platform
|
|
||||||
import os
|
|
||||||
from logging.handlers import SysLogHandler
|
|
||||||
|
|
||||||
#
|
|
||||||
# Django settings for Weblate project.
|
|
||||||
#
|
|
||||||
|
|
||||||
DEBUG = False
|
|
||||||
|
|
||||||
ADMINS = (
|
|
||||||
('__ADMIN__', '__ADMINMAIL__'),
|
|
||||||
)
|
|
||||||
|
|
||||||
MANAGERS = ADMINS
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
# Database engine
|
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
||||||
# Database name
|
|
||||||
'NAME': '__NAME__',
|
|
||||||
# Database user
|
|
||||||
'USER': '__NAME__',
|
|
||||||
# Database password
|
|
||||||
'PASSWORD': '__DB_PWD__',
|
|
||||||
# Set to empty string for localhost
|
|
||||||
'HOST': 'localhost',
|
|
||||||
# Set to empty string for default
|
|
||||||
'PORT': '5432',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BASE_DIR = '__FINALPATH__'
|
|
||||||
|
|
||||||
# Data directory
|
|
||||||
DATA_DIR = os.path.join(BASE_DIR, 'data')
|
|
||||||
TTF_PATH = '__FINALPATH__/venv/lib/__PYTHONPATH__/site-packages/weblate/ttf/'
|
|
||||||
|
|
||||||
# Local time zone for this installation. Choices can be found here:
|
|
||||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
|
||||||
# although not all choices may be available on all operating systems.
|
|
||||||
# In a Windows environment this must be set to your system time zone.
|
|
||||||
TIME_ZONE = 'UTC'
|
|
||||||
|
|
||||||
# Language code for this installation. All choices can be found here:
|
|
||||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
|
||||||
|
|
||||||
LANGUAGES = (
|
|
||||||
('ar', 'العربية'),
|
|
||||||
('az', 'Azərbaycan'),
|
|
||||||
('be', 'Беларуская'),
|
|
||||||
('be@latin', 'Biełaruskaja'),
|
|
||||||
('bg', 'Български'),
|
|
||||||
('br', 'Brezhoneg'),
|
|
||||||
('ca', 'Català'),
|
|
||||||
('cs', 'Čeština'),
|
|
||||||
('da', 'Dansk'),
|
|
||||||
('de', 'Deutsch'),
|
|
||||||
('en', 'English'),
|
|
||||||
('en-gb', 'English (United Kingdom)'),
|
|
||||||
('el', 'Ελληνικά'),
|
|
||||||
('es', 'Español'),
|
|
||||||
('fi', 'Suomi'),
|
|
||||||
('fr', 'Français'),
|
|
||||||
('fy', 'Frysk'),
|
|
||||||
('gl', 'Galego'),
|
|
||||||
('he', 'עברית'),
|
|
||||||
('hu', 'Magyar'),
|
|
||||||
('id', 'Indonesia'),
|
|
||||||
('it', 'Italiano'),
|
|
||||||
('ja', '日本語'),
|
|
||||||
('ko', '한국어'),
|
|
||||||
('ksh', 'Kölsch'),
|
|
||||||
('nb', 'Norsk bokmål'),
|
|
||||||
('nl', 'Nederlands'),
|
|
||||||
('pl', 'Polski'),
|
|
||||||
('pt', 'Português'),
|
|
||||||
('pt-br', 'Português brasileiro'),
|
|
||||||
('ru', 'Русский'),
|
|
||||||
('sk', 'Slovenčina'),
|
|
||||||
('sl', 'Slovenščina'),
|
|
||||||
('sr', 'Српски'),
|
|
||||||
('sv', 'Svenska'),
|
|
||||||
('tr', 'Türkçe'),
|
|
||||||
('uk', 'Українська'),
|
|
||||||
('zh-hans', '简体字'),
|
|
||||||
('zh-hant', '正體字'),
|
|
||||||
)
|
|
||||||
|
|
||||||
SITE_ID = 1
|
|
||||||
|
|
||||||
# If you set this to False, Django will make some optimizations so as not
|
|
||||||
# to load the internationalization machinery.
|
|
||||||
USE_I18N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not format dates, numbers and
|
|
||||||
# calendars according to the current locale.
|
|
||||||
USE_L10N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not use timezone-aware datetimes.
|
|
||||||
USE_TZ = True
|
|
||||||
|
|
||||||
# URL prefix to use, please see documentation for more details
|
|
||||||
URL_PREFIX = '__PATHURL__'
|
|
||||||
|
|
||||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
|
||||||
# Example: "/home/media/media.lawrence.com/media/"
|
|
||||||
MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
|
|
||||||
|
|
||||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
|
||||||
# trailing slash.
|
|
||||||
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
|
||||||
MEDIA_URL = '{0}/media/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Absolute path to the directory static files should be collected to.
|
|
||||||
# Don't put anything in this directory yourself; store your static files
|
|
||||||
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
|
|
||||||
# Example: "/home/media/media.lawrence.com/static/"
|
|
||||||
STATIC_ROOT = os.path.join(DATA_DIR, 'static')
|
|
||||||
|
|
||||||
# URL prefix for static files.
|
|
||||||
# Example: "http://media.lawrence.com/static/"
|
|
||||||
STATIC_URL = '{0}/static/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Additional locations of static files
|
|
||||||
STATICFILES_DIRS = (
|
|
||||||
# Put strings here, like "/home/html/static" or "C:/www/django/static".
|
|
||||||
# Always use forward slashes, even on Windows.
|
|
||||||
# Don't forget to use absolute paths, not relative paths.
|
|
||||||
)
|
|
||||||
|
|
||||||
# List of finder classes that know how to find static files in
|
|
||||||
# various locations.
|
|
||||||
STATICFILES_FINDERS = (
|
|
||||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
|
||||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
|
||||||
'compressor.finders.CompressorFinder',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Make this unique, and don't share it with anybody.
|
|
||||||
# You can generate it using examples/generate-secret-key
|
|
||||||
SECRET_KEY = '__KEY__' # noqa
|
|
||||||
|
|
||||||
TEMPLATES = [
|
|
||||||
{
|
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
||||||
'DIRS': [
|
|
||||||
os.path.join(BASE_DIR, 'weblate', 'templates'),
|
|
||||||
],
|
|
||||||
'OPTIONS': {
|
|
||||||
'context_processors': [
|
|
||||||
'django.contrib.auth.context_processors.auth',
|
|
||||||
'django.template.context_processors.debug',
|
|
||||||
'django.template.context_processors.i18n',
|
|
||||||
'django.template.context_processors.request',
|
|
||||||
'django.template.context_processors.csrf',
|
|
||||||
'django.contrib.messages.context_processors.messages',
|
|
||||||
'weblate.trans.context_processors.weblate_context',
|
|
||||||
],
|
|
||||||
'loaders': [
|
|
||||||
('django.template.loaders.cached.Loader', [
|
|
||||||
'django.template.loaders.filesystem.Loader',
|
|
||||||
'django.template.loaders.app_directories.Loader',
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# GitHub username for sending pull requests.
|
|
||||||
# Please see the documentation for more details.
|
|
||||||
GITHUB_USERNAME = "__GITHUBUSER__"
|
|
||||||
|
|
||||||
# Authentication configuration
|
|
||||||
AUTHENTICATION_BACKENDS = (
|
|
||||||
'social_core.backends.email.EmailAuth',
|
|
||||||
# 'social_core.backends.google.GoogleOAuth2',
|
|
||||||
# 'social_core.backends.github.GithubOAuth2',
|
|
||||||
# 'social_core.backends.bitbucket.BitbucketOAuth',
|
|
||||||
'social_core.backends.suse.OpenSUSEOpenId',
|
|
||||||
'social_core.backends.ubuntu.UbuntuOpenId',
|
|
||||||
'social_core.backends.fedora.FedoraOpenId',
|
|
||||||
# 'social_core.backends.facebook.FacebookOAuth2',
|
|
||||||
'weblate.accounts.auth.WeblateUserBackend',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom user model
|
|
||||||
AUTH_USER_MODEL = 'weblate_auth.User'
|
|
||||||
|
|
||||||
# Social auth backends setup
|
|
||||||
SOCIAL_AUTH_GITHUB_KEY = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SECRET = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SCOPE = ['user:email']
|
|
||||||
|
|
||||||
SOCIAL_AUTH_BITBUCKET_KEY = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_SECRET = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_VERIFIED_EMAILS_ONLY = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_FACEBOOK_KEY = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SECRET = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email', 'public_profile']
|
|
||||||
SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {'fields': 'id,name,email'}
|
|
||||||
SOCIAL_AUTH_FACEBOOK_API_VERSION = '3.1'
|
|
||||||
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = ''
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = ''
|
|
||||||
|
|
||||||
# Social auth settings
|
|
||||||
SOCIAL_AUTH_PIPELINE = (
|
|
||||||
'social_core.pipeline.social_auth.social_details',
|
|
||||||
'social_core.pipeline.social_auth.social_uid',
|
|
||||||
'social_core.pipeline.social_auth.auth_allowed',
|
|
||||||
'social_core.pipeline.social_auth.social_user',
|
|
||||||
'weblate.accounts.pipeline.store_params',
|
|
||||||
'weblate.accounts.pipeline.verify_open',
|
|
||||||
'social_core.pipeline.user.get_username',
|
|
||||||
'weblate.accounts.pipeline.require_email',
|
|
||||||
'social_core.pipeline.mail.mail_validation',
|
|
||||||
'weblate.accounts.pipeline.revoke_mail_code',
|
|
||||||
'weblate.accounts.pipeline.ensure_valid',
|
|
||||||
'weblate.accounts.pipeline.remove_account',
|
|
||||||
'social_core.pipeline.social_auth.associate_by_email',
|
|
||||||
'weblate.accounts.pipeline.reauthenticate',
|
|
||||||
'weblate.accounts.pipeline.verify_username',
|
|
||||||
'social_core.pipeline.user.create_user',
|
|
||||||
'social_core.pipeline.social_auth.associate_user',
|
|
||||||
'social_core.pipeline.social_auth.load_extra_data',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
'weblate.accounts.pipeline.user_full_name',
|
|
||||||
'weblate.accounts.pipeline.store_email',
|
|
||||||
'weblate.accounts.pipeline.notify_connect',
|
|
||||||
'weblate.accounts.pipeline.password_reset',
|
|
||||||
)
|
|
||||||
SOCIAL_AUTH_DISCONNECT_PIPELINE = (
|
|
||||||
'social_core.pipeline.disconnect.allowed_to_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.get_entries',
|
|
||||||
'social_core.pipeline.disconnect.revoke_tokens',
|
|
||||||
'weblate.accounts.pipeline.cycle_session',
|
|
||||||
'weblate.accounts.pipeline.adjust_primary_mail',
|
|
||||||
'weblate.accounts.pipeline.notify_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.disconnect',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom authentication strategy
|
|
||||||
SOCIAL_AUTH_STRATEGY = 'weblate.accounts.strategy.WeblateStrategy'
|
|
||||||
|
|
||||||
# Raise exceptions so that we can handle them later
|
|
||||||
SOCIAL_AUTH_RAISE_EXCEPTIONS = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_FUNCTION = \
|
|
||||||
'weblate.accounts.pipeline.send_validation'
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_URL = \
|
|
||||||
'{0}/accounts/email-sent/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_LOGIN_ERROR_URL = \
|
|
||||||
'{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_EMAIL_FORM_URL = \
|
|
||||||
'{0}/accounts/email/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL = \
|
|
||||||
'{0}/accounts/profile/#auth'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_PROTECTED_USER_FIELDS = ('email',)
|
|
||||||
SOCIAL_AUTH_SLUGIFY_USERNAMES = True
|
|
||||||
SOCIAL_AUTH_SLUGIFY_FUNCTION = 'weblate.accounts.pipeline.slugify_username'
|
|
||||||
|
|
||||||
# Password validation configuration
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
||||||
'OPTIONS': {
|
|
||||||
'min_length': 6,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.CharsPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.PastPasswordsValidator',
|
|
||||||
},
|
|
||||||
# Optional password strength validation by django-zxcvbn-password
|
|
||||||
# {
|
|
||||||
# 'NAME': 'zxcvbn_password.ZXCVBNValidator',
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'min_score': 3,
|
|
||||||
# 'user_attributes': ('username', 'email', 'full_name')
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
]
|
|
||||||
|
|
||||||
# Middleware
|
|
||||||
MIDDLEWARE = [
|
|
||||||
'django.middleware.security.SecurityMiddleware',
|
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
||||||
'django.middleware.common.CommonMiddleware',
|
|
||||||
'django.middleware.locale.LocaleMiddleware',
|
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
|
||||||
'weblate.accounts.middleware.AuthenticationMiddleware',
|
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
||||||
'social_django.middleware.SocialAuthExceptionMiddleware',
|
|
||||||
'weblate.accounts.middleware.RequireLoginMiddleware',
|
|
||||||
'weblate.middleware.SecurityMiddleware',
|
|
||||||
]
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'weblate.urls'
|
|
||||||
|
|
||||||
# Django and Weblate apps
|
|
||||||
INSTALLED_APPS = (
|
|
||||||
'django.contrib.auth',
|
|
||||||
'django.contrib.contenttypes',
|
|
||||||
'django.contrib.sessions',
|
|
||||||
'django.contrib.sites',
|
|
||||||
'django.contrib.messages',
|
|
||||||
'django.contrib.staticfiles',
|
|
||||||
'django.contrib.admin.apps.SimpleAdminConfig',
|
|
||||||
'django.contrib.admindocs',
|
|
||||||
'django.contrib.sitemaps',
|
|
||||||
'social_django',
|
|
||||||
'crispy_forms',
|
|
||||||
'compressor',
|
|
||||||
'rest_framework',
|
|
||||||
'rest_framework.authtoken',
|
|
||||||
'weblate.addons',
|
|
||||||
'weblate.auth',
|
|
||||||
'weblate.checks',
|
|
||||||
'weblate.formats',
|
|
||||||
'weblate.machinery',
|
|
||||||
'weblate.trans',
|
|
||||||
'weblate.lang',
|
|
||||||
'weblate.langdata',
|
|
||||||
'weblate.memory',
|
|
||||||
'weblate.screenshots',
|
|
||||||
'weblate.accounts',
|
|
||||||
'weblate.utils',
|
|
||||||
'weblate.vcs',
|
|
||||||
'weblate.wladmin',
|
|
||||||
'weblate',
|
|
||||||
|
|
||||||
# Optional: Git exporter
|
|
||||||
# 'weblate.gitexport',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Path to locales
|
|
||||||
LOCALE_PATHS = (os.path.join(BASE_DIR, 'weblate', 'locale'), )
|
|
||||||
|
|
||||||
# Custom exception reporter to include some details
|
|
||||||
DEFAULT_EXCEPTION_REPORTER_FILTER = \
|
|
||||||
'weblate.trans.debug.WeblateExceptionReporterFilter'
|
|
||||||
|
|
||||||
# Default logging of Weblate messages
|
|
||||||
# - to syslog in production (if available)
|
|
||||||
# - otherwise to console
|
|
||||||
# - you can also choose 'logfile' to log into separate file
|
|
||||||
# after configuring it below
|
|
||||||
|
|
||||||
# Detect if we can connect to syslog
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
if platform.system() != 'Windows':
|
|
||||||
try:
|
|
||||||
handler = SysLogHandler(
|
|
||||||
address='/dev/log', facility=SysLogHandler.LOG_LOCAL2
|
|
||||||
)
|
|
||||||
handler.close()
|
|
||||||
HAVE_SYSLOG = True
|
|
||||||
except IOError:
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
|
|
||||||
if DEBUG or not HAVE_SYSLOG:
|
|
||||||
DEFAULT_LOG = 'console'
|
|
||||||
else:
|
|
||||||
DEFAULT_LOG = 'syslog'
|
|
||||||
|
|
||||||
# A sample logging configuration. The only tangible logging
|
|
||||||
# performed by this configuration is to send an email to
|
|
||||||
# the site admins on every HTTP 500 error when DEBUG=False.
|
|
||||||
# See http://docs.djangoproject.com/en/stable/topics/logging for
|
|
||||||
# more details on how to customize your logging configuration.
|
|
||||||
LOGGING = {
|
|
||||||
'version': 1,
|
|
||||||
'disable_existing_loggers': True,
|
|
||||||
'filters': {
|
|
||||||
'require_debug_false': {
|
|
||||||
'()': 'django.utils.log.RequireDebugFalse'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'formatters': {
|
|
||||||
'syslog': {
|
|
||||||
'format': 'weblate[%(process)d]: %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'simple': {
|
|
||||||
'format': '%(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'logfile': {
|
|
||||||
'format': '%(asctime)s %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'()': 'django.utils.log.ServerFormatter',
|
|
||||||
'format': '[%(server_time)s] %(message)s',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'handlers': {
|
|
||||||
'mail_admins': {
|
|
||||||
'level': 'ERROR',
|
|
||||||
'filters': ['require_debug_false'],
|
|
||||||
'class': 'django.utils.log.AdminEmailHandler',
|
|
||||||
'include_html': True,
|
|
||||||
},
|
|
||||||
'console': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'simple'
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'level': 'INFO',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'django.server',
|
|
||||||
},
|
|
||||||
'syslog': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.handlers.SysLogHandler',
|
|
||||||
'formatter': 'syslog',
|
|
||||||
'address': '/dev/log',
|
|
||||||
'facility': SysLogHandler.LOG_LOCAL2,
|
|
||||||
},
|
|
||||||
# Logging to a file
|
|
||||||
# 'logfile': {
|
|
||||||
# 'level':'DEBUG',
|
|
||||||
# 'class':'logging.handlers.RotatingFileHandler',
|
|
||||||
# 'filename': "/var/log/weblate/weblate.log",
|
|
||||||
# 'maxBytes': 100000,
|
|
||||||
# 'backupCount': 3,
|
|
||||||
# 'formatter': 'logfile',
|
|
||||||
# },
|
|
||||||
},
|
|
||||||
'loggers': {
|
|
||||||
'django.request': {
|
|
||||||
'handlers': ['mail_admins', DEFAULT_LOG],
|
|
||||||
'level': 'ERROR',
|
|
||||||
'propagate': True,
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'handlers': ['django.server'],
|
|
||||||
'level': 'INFO',
|
|
||||||
'propagate': False,
|
|
||||||
},
|
|
||||||
# Logging database queries
|
|
||||||
# 'django.db.backends': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
'weblate': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'DEBUG',
|
|
||||||
},
|
|
||||||
# Logging VCS operations
|
|
||||||
# 'weblate-vcs': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
# Python Social Auth logging
|
|
||||||
# 'social': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Logging of management commands to console
|
|
||||||
if (os.environ.get('DJANGO_IS_MANAGEMENT_COMMAND', False) and
|
|
||||||
'console' not in LOGGING['loggers']['weblate']['handlers']):
|
|
||||||
LOGGING['loggers']['weblate']['handlers'].append('console')
|
|
||||||
|
|
||||||
# Remove syslog setup if it's not present
|
|
||||||
if not HAVE_SYSLOG:
|
|
||||||
del LOGGING['handlers']['syslog']
|
|
||||||
|
|
||||||
# List of machine translations
|
|
||||||
# MT_SERVICES = (
|
|
||||||
# 'weblate.machinery.apertium.ApertiumAPYTranslation',
|
|
||||||
# 'weblate.machinery.baidu.BaiduTranslation',
|
|
||||||
# 'weblate.machinery.deepl.DeepLTranslation',
|
|
||||||
# 'weblate.machinery.glosbe.GlosbeTranslation',
|
|
||||||
# 'weblate.machinery.google.GoogleTranslation',
|
|
||||||
# 'weblate.machinery.microsoft.MicrosoftCognitiveTranslation',
|
|
||||||
# 'weblate.machinery.microsoftterminology.MicrosoftTerminologyService',
|
|
||||||
# 'weblate.machinery.mymemory.MyMemoryTranslation',
|
|
||||||
# 'weblate.machinery.tmserver.AmagamaTranslation',
|
|
||||||
# 'weblate.machinery.tmserver.TMServerTranslation',
|
|
||||||
# 'weblate.machinery.yandex.YandexTranslation',
|
|
||||||
# 'weblate.machinery.weblatetm.WeblateTranslation',
|
|
||||||
# 'weblate.machinery.saptranslationhub.SAPTranslationHub',
|
|
||||||
# 'weblate.machinery.youdao.YoudaoTranslation',
|
|
||||||
# 'weblate.memory.machine.WeblateMemory',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Machine translation API keys
|
|
||||||
|
|
||||||
# URL of the Apertium APy server
|
|
||||||
MT_APERTIUM_APY = None
|
|
||||||
|
|
||||||
# DeepL API key
|
|
||||||
MT_DEEPL_KEY = None
|
|
||||||
|
|
||||||
# Microsoft Cognitive Services Translator API, register at
|
|
||||||
# https://portal.azure.com/
|
|
||||||
MT_MICROSOFT_COGNITIVE_KEY = None
|
|
||||||
|
|
||||||
# MyMemory identification email, see
|
|
||||||
# https://mymemory.translated.net/doc/spec.php
|
|
||||||
MT_MYMEMORY_EMAIL = None
|
|
||||||
|
|
||||||
# Optional MyMemory credentials to access private translation memory
|
|
||||||
MT_MYMEMORY_USER = None
|
|
||||||
MT_MYMEMORY_KEY = None
|
|
||||||
|
|
||||||
# Google API key for Google Translate API
|
|
||||||
MT_GOOGLE_KEY = None
|
|
||||||
|
|
||||||
# Baidu app key and secret
|
|
||||||
MT_BAIDU_ID = None
|
|
||||||
MT_BAIDU_SECRET = None
|
|
||||||
|
|
||||||
# Youdao Zhiyun app key and secret
|
|
||||||
MT_YOUDAO_ID = None
|
|
||||||
MT_YOUDAO_SECRET = None
|
|
||||||
|
|
||||||
# API key for Yandex Translate API
|
|
||||||
MT_YANDEX_KEY = None
|
|
||||||
|
|
||||||
# tmserver URL
|
|
||||||
MT_TMSERVER = None
|
|
||||||
|
|
||||||
# SAP Translation Hub
|
|
||||||
MT_SAP_BASE_URL = None
|
|
||||||
MT_SAP_SANDBOX_APIKEY = None
|
|
||||||
MT_SAP_USERNAME = None
|
|
||||||
MT_SAP_PASSWORD = None
|
|
||||||
MT_SAP_USE_MT = True
|
|
||||||
|
|
||||||
# Title of site to use
|
|
||||||
SITE_TITLE = 'Weblate'
|
|
||||||
|
|
||||||
# Whether site uses https
|
|
||||||
ENABLE_HTTPS = True
|
|
||||||
|
|
||||||
# Use HTTPS when creating redirect URLs for social authentication, see
|
|
||||||
# documentation for more details:
|
|
||||||
# http://python-social-auth-docs.readthedocs.io/en/latest/configuration/settings.html#processing-redirects-and-urlopen
|
|
||||||
SOCIAL_AUTH_REDIRECT_IS_HTTPS = ENABLE_HTTPS
|
|
||||||
|
|
||||||
# Make CSRF cookie HttpOnly, see documentation for more details:
|
|
||||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#csrf-cookie-httponly
|
|
||||||
CSRF_COOKIE_HTTPONLY = True
|
|
||||||
CSRF_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# Store CSRF token in session (since Django 1.11)
|
|
||||||
CSRF_USE_SESSIONS = True
|
|
||||||
SESSION_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# SSL redirect
|
|
||||||
SECURE_SSL_REDIRECT = ENABLE_HTTPS
|
|
||||||
# Session cookie age (in seconds)
|
|
||||||
SESSION_COOKIE_AGE = 1209600
|
|
||||||
|
|
||||||
# Some security headers
|
|
||||||
SECURE_BROWSER_XSS_FILTER = True
|
|
||||||
X_FRAME_OPTIONS = 'DENY'
|
|
||||||
SECURE_CONTENT_TYPE_NOSNIFF = True
|
|
||||||
|
|
||||||
# Optionally enable HSTS
|
|
||||||
SECURE_HSTS_SECONDS = 0
|
|
||||||
SECURE_HSTS_PRELOAD = False
|
|
||||||
SECURE_HSTS_INCLUDE_SUBDOMAINS = False
|
|
||||||
|
|
||||||
# URL of login
|
|
||||||
LOGIN_URL = '{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# URL of logout
|
|
||||||
LOGOUT_URL = '{0}/accounts/logout/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Default location for login
|
|
||||||
LOGIN_REDIRECT_URL = '{0}/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Anonymous user name
|
|
||||||
ANONYMOUS_USER_NAME = 'anonymous'
|
|
||||||
|
|
||||||
# Reverse proxy settings
|
|
||||||
IP_BEHIND_REVERSE_PROXY = False
|
|
||||||
IP_PROXY_HEADER = 'HTTP_X_FORWARDED_FOR'
|
|
||||||
IP_PROXY_OFFSET = 0
|
|
||||||
|
|
||||||
# Sending HTML in mails
|
|
||||||
EMAIL_SEND_HTML = True
|
|
||||||
|
|
||||||
# Subject of emails includes site title
|
|
||||||
EMAIL_SUBJECT_PREFIX = '[{0}] '.format(SITE_TITLE)
|
|
||||||
|
|
||||||
EMAIL_BACKEND = 'django_sendmail_backend.backends.EmailBackend'
|
|
||||||
|
|
||||||
# Enable remote hooks
|
|
||||||
ENABLE_HOOKS = True
|
|
||||||
|
|
||||||
# Number of nearby messages to show in each direction
|
|
||||||
NEARBY_MESSAGES = 5
|
|
||||||
|
|
||||||
# Use simple language codes for default language/country combinations
|
|
||||||
SIMPLIFY_LANGUAGES = True
|
|
||||||
|
|
||||||
# Render forms using bootstrap
|
|
||||||
CRISPY_TEMPLATE_PACK = 'bootstrap3'
|
|
||||||
|
|
||||||
# List of quality checks
|
|
||||||
# CHECK_LIST = (
|
|
||||||
# 'weblate.checks.same.SameCheck',
|
|
||||||
# 'weblate.checks.chars.BeginNewlineCheck',
|
|
||||||
# 'weblate.checks.chars.EndNewlineCheck',
|
|
||||||
# 'weblate.checks.chars.BeginSpaceCheck',
|
|
||||||
# 'weblate.checks.chars.EndSpaceCheck',
|
|
||||||
# 'weblate.checks.chars.EndStopCheck',
|
|
||||||
# 'weblate.checks.chars.EndColonCheck',
|
|
||||||
# 'weblate.checks.chars.EndQuestionCheck',
|
|
||||||
# 'weblate.checks.chars.EndExclamationCheck',
|
|
||||||
# 'weblate.checks.chars.EndEllipsisCheck',
|
|
||||||
# 'weblate.checks.chars.EndSemicolonCheck',
|
|
||||||
# 'weblate.checks.chars.MaxLengthCheck',
|
|
||||||
# 'weblate.checks.format.PythonFormatCheck',
|
|
||||||
# 'weblate.checks.format.PythonBraceFormatCheck',
|
|
||||||
# 'weblate.checks.format.PHPFormatCheck',
|
|
||||||
# 'weblate.checks.format.CFormatCheck',
|
|
||||||
# 'weblate.checks.format.PerlFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavascriptFormatCheck',
|
|
||||||
# 'weblate.checks.format.CSharpFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavaFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavaMessageFormatCheck',
|
|
||||||
# 'weblate.checks.angularjs.AngularJSInterpolationCheck',
|
|
||||||
# 'weblate.checks.consistency.PluralsCheck',
|
|
||||||
# 'weblate.checks.consistency.SamePluralsCheck',
|
|
||||||
# 'weblate.checks.consistency.ConsistencyCheck',
|
|
||||||
# 'weblate.checks.consistency.TranslatedCheck',
|
|
||||||
# 'weblate.checks.chars.NewlineCountingCheck',
|
|
||||||
# 'weblate.checks.markup.BBCodeCheck',
|
|
||||||
# 'weblate.checks.chars.ZeroWidthSpaceCheck',
|
|
||||||
# 'weblate.checks.markup.XMLValidityCheck',
|
|
||||||
# 'weblate.checks.markup.XMLTagsCheck',
|
|
||||||
# 'weblate.checks.source.OptionalPluralCheck',
|
|
||||||
# 'weblate.checks.source.EllipsisCheck',
|
|
||||||
# 'weblate.checks.source.MultipleFailingCheck',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of automatic fixups
|
|
||||||
# AUTOFIX_LIST = (
|
|
||||||
# 'weblate.trans.autofixes.whitespace.SameBookendingWhitespace',
|
|
||||||
# 'weblate.trans.autofixes.chars.ReplaceTrailingDotsWithEllipsis',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveZeroSpace',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveControlChars',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of enabled addons
|
|
||||||
# WEBLATE_ADDONS = (
|
|
||||||
# 'weblate.addons.gettext.GenerateMoAddon',
|
|
||||||
# 'weblate.addons.gettext.UpdateLinguasAddon',
|
|
||||||
# 'weblate.addons.gettext.UpdateConfigureAddon',
|
|
||||||
# 'weblate.addons.gettext.MsgmergeAddon',
|
|
||||||
# 'weblate.addons.gettext.GettextCustomizeAddon',
|
|
||||||
# 'weblate.addons.gettext.GettextAuthorComments',
|
|
||||||
# 'weblate.addons.cleanup.CleanupAddon',
|
|
||||||
# 'weblate.addons.consistency.LangaugeConsistencyAddon',
|
|
||||||
# 'weblate.addons.discovery.DiscoveryAddon',
|
|
||||||
# 'weblate.addons.flags.SourceEditAddon',
|
|
||||||
# 'weblate.addons.flags.TargetEditAddon',
|
|
||||||
# 'weblate.addons.generate.GenerateFileAddon',
|
|
||||||
# 'weblate.addons.json.JSONCustomizeAddon',
|
|
||||||
# 'weblate.addons.properties.PropertiesSortAddon',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# E-mail address that error messages come from.
|
|
||||||
SERVER_EMAIL = 'noreply@__DOMAIN__'
|
|
||||||
|
|
||||||
# Default email address to use for various automated correspondence from
|
|
||||||
# the site managers. Used for registration emails.
|
|
||||||
DEFAULT_FROM_EMAIL = '__ADMINMAIL__'
|
|
||||||
|
|
||||||
# List of URLs your site is supposed to serve
|
|
||||||
ALLOWED_HOSTS = ['__DOMAIN__']
|
|
||||||
|
|
||||||
CACHES = {
|
|
||||||
'default': {
|
|
||||||
'BACKEND': 'django_redis.cache.RedisCache',
|
|
||||||
'LOCATION': 'redis://127.0.0.1:6379/__REDIS_DB__',
|
|
||||||
'OPTIONS': {
|
|
||||||
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
|
||||||
'PARSER_CLASS': 'redis.connection.HiredisParser',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'avatar': {
|
|
||||||
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
|
||||||
'LOCATION': os.path.join(BASE_DIR, 'avatar-cache'),
|
|
||||||
'TIMEOUT': 3600,
|
|
||||||
'OPTIONS': {
|
|
||||||
'MAX_ENTRIES': 1000,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example configuration for caching
|
|
||||||
# CACHES = {
|
|
||||||
# Recommended redis + hiredis:
|
|
||||||
# 'default': {
|
|
||||||
# 'BACKEND': 'django_redis.cache.RedisCache',
|
|
||||||
# 'LOCATION': 'redis://127.0.0.1:6379/0',
|
|
||||||
# # If redis is running on same host as Weblate, you might
|
|
||||||
# # want to use unix sockets instead:
|
|
||||||
# # 'LOCATION': 'unix:///var/run/redis/redis.sock?db=0',
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
|
||||||
# 'PARSER_CLASS': 'redis.connection.HiredisParser',
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
# Memcached alternative:
|
|
||||||
# 'default': {
|
|
||||||
# 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
|
||||||
# 'LOCATION': '127.0.0.1:11211',
|
|
||||||
# },
|
|
||||||
# 'avatar': {
|
|
||||||
# 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
|
||||||
# 'LOCATION': os.path.join(DATA_DIR, 'avatar-cache'),
|
|
||||||
# 'TIMEOUT': 3600,
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'MAX_ENTRIES': 1000,
|
|
||||||
# },
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
|
|
||||||
# REST framework settings for API
|
|
||||||
REST_FRAMEWORK = {
|
|
||||||
# Use Django's standard `django.contrib.auth` permissions,
|
|
||||||
# or allow read-only access for unauthenticated users.
|
|
||||||
'DEFAULT_PERMISSION_CLASSES': [
|
|
||||||
'rest_framework.permissions.IsAuthenticatedOrReadOnly'
|
|
||||||
],
|
|
||||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
|
||||||
'rest_framework.authentication.TokenAuthentication',
|
|
||||||
'weblate.api.authentication.BearerAuthentication',
|
|
||||||
'rest_framework.authentication.SessionAuthentication',
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_CLASSES': (
|
|
||||||
'rest_framework.throttling.AnonRateThrottle',
|
|
||||||
'rest_framework.throttling.UserRateThrottle'
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_RATES': {
|
|
||||||
'anon': '100/day',
|
|
||||||
'user': '1000/day'
|
|
||||||
},
|
|
||||||
'DEFAULT_PAGINATION_CLASS': (
|
|
||||||
'rest_framework.pagination.PageNumberPagination'
|
|
||||||
),
|
|
||||||
'PAGE_SIZE': 20,
|
|
||||||
'VIEW_DESCRIPTION_FUNCTION': 'weblate.api.views.get_view_description',
|
|
||||||
'UNAUTHENTICATED_USER': 'weblate.auth.models.get_anonymous',
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example for restricting access to logged in users
|
|
||||||
# LOGIN_REQUIRED_URLS = (
|
|
||||||
# r'/(.*)$',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# In such case you will want to include some of the exceptions
|
|
||||||
# LOGIN_REQUIRED_URLS_EXCEPTIONS = (
|
|
||||||
# r'/accounts/(.*)$', # Required for login
|
|
||||||
# r'/admin/login/(.*)$', # Required for admin login
|
|
||||||
# r'/static/(.*)$', # Required for development mode
|
|
||||||
# r'/widgets/(.*)$', # Allowing public access to widgets
|
|
||||||
# r'/data/(.*)$', # Allowing public access to data exports
|
|
||||||
# r'/hooks/(.*)$', # Allowing public access to notification hooks
|
|
||||||
# r'/healthz/$', # Allowing public access to health check
|
|
||||||
# r'/api/(.*)$', # Allowing access to API
|
|
||||||
# r'/js/i18n/$', # Javascript localization
|
|
||||||
# r'/contact/$', # Optional for contact form
|
|
||||||
# r'/legal/(.*)$', # Optional for legal app
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Celery worker configuration for testing
|
|
||||||
# CELERY_TASK_ALWAYS_EAGER = True
|
|
||||||
# CELERY_BROKER_URL = 'memory://'
|
|
||||||
# Celery worker configuration for production
|
|
||||||
CELERY_TASK_ALWAYS_EAGER = False
|
|
||||||
CELERY_BROKER_URL = 'redis://127.0.0.1:6379/__REDIS_DB__'
|
|
||||||
|
|
||||||
# Celery settings, it is not recommended to change these
|
|
||||||
CELERY_WORKER_PREFETCH_MULTIPLIER = 0
|
|
||||||
CELERY_BEAT_SCHEDULE_FILENAME = os.path.join(
|
|
||||||
DATA_DIR, 'celery', 'beat-schedule'
|
|
||||||
)
|
|
||||||
|
|
|
@ -1,834 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# Copyright © 2012 - 2018 Michal Čihař <michal@cihar.com>
|
|
||||||
#
|
|
||||||
# This file is part of Weblate <https://weblate.org/>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import platform
|
|
||||||
import os
|
|
||||||
from logging.handlers import SysLogHandler
|
|
||||||
|
|
||||||
#
|
|
||||||
# Django settings for Weblate project.
|
|
||||||
#
|
|
||||||
|
|
||||||
DEBUG = False
|
|
||||||
|
|
||||||
ADMINS = (
|
|
||||||
('__ADMIN__', '__ADMINMAIL__'),
|
|
||||||
)
|
|
||||||
|
|
||||||
MANAGERS = ADMINS
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
# Database engine
|
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
||||||
# Database name
|
|
||||||
'NAME': '__NAME__',
|
|
||||||
# Database user
|
|
||||||
'USER': '__NAME__',
|
|
||||||
# Database password
|
|
||||||
'PASSWORD': '__DB_PWD__',
|
|
||||||
# Set to empty string for localhost
|
|
||||||
'HOST': 'localhost',
|
|
||||||
# Set to empty string for default
|
|
||||||
'PORT': '5432',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BASE_DIR = '__FINALPATH__'
|
|
||||||
|
|
||||||
# Data directory
|
|
||||||
DATA_DIR = os.path.join(BASE_DIR, 'data')
|
|
||||||
TTF_PATH = '__FINALPATH__/venv/lib/__PYTHONPATH__/site-packages/weblate/ttf/'
|
|
||||||
|
|
||||||
# Local time zone for this installation. Choices can be found here:
|
|
||||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
|
||||||
# although not all choices may be available on all operating systems.
|
|
||||||
# In a Windows environment this must be set to your system time zone.
|
|
||||||
TIME_ZONE = 'UTC'
|
|
||||||
|
|
||||||
# Language code for this installation. All choices can be found here:
|
|
||||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
|
||||||
|
|
||||||
LANGUAGES = (
|
|
||||||
('ar', 'العربية'),
|
|
||||||
('az', 'Azərbaycan'),
|
|
||||||
('be', 'Беларуская'),
|
|
||||||
('be@latin', 'Biełaruskaja'),
|
|
||||||
('bg', 'Български'),
|
|
||||||
('br', 'Brezhoneg'),
|
|
||||||
('ca', 'Català'),
|
|
||||||
('cs', 'Čeština'),
|
|
||||||
('da', 'Dansk'),
|
|
||||||
('de', 'Deutsch'),
|
|
||||||
('en', 'English'),
|
|
||||||
('en-gb', 'English (United Kingdom)'),
|
|
||||||
('el', 'Ελληνικά'),
|
|
||||||
('es', 'Español'),
|
|
||||||
('fi', 'Suomi'),
|
|
||||||
('fr', 'Français'),
|
|
||||||
('fy', 'Frysk'),
|
|
||||||
('gl', 'Galego'),
|
|
||||||
('he', 'עברית'),
|
|
||||||
('hu', 'Magyar'),
|
|
||||||
('id', 'Indonesia'),
|
|
||||||
('it', 'Italiano'),
|
|
||||||
('ja', '日本語'),
|
|
||||||
('ko', '한국어'),
|
|
||||||
('ksh', 'Kölsch'),
|
|
||||||
('nb', 'Norsk bokmål'),
|
|
||||||
('nl', 'Nederlands'),
|
|
||||||
('pl', 'Polski'),
|
|
||||||
('pt', 'Português'),
|
|
||||||
('pt-br', 'Português brasileiro'),
|
|
||||||
('ru', 'Русский'),
|
|
||||||
('sk', 'Slovenčina'),
|
|
||||||
('sl', 'Slovenščina'),
|
|
||||||
('sr', 'Српски'),
|
|
||||||
('sv', 'Svenska'),
|
|
||||||
('tr', 'Türkçe'),
|
|
||||||
('uk', 'Українська'),
|
|
||||||
('zh-hans', '简体字'),
|
|
||||||
('zh-hant', '正體字'),
|
|
||||||
)
|
|
||||||
|
|
||||||
SITE_ID = 1
|
|
||||||
|
|
||||||
# If you set this to False, Django will make some optimizations so as not
|
|
||||||
# to load the internationalization machinery.
|
|
||||||
USE_I18N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not format dates, numbers and
|
|
||||||
# calendars according to the current locale.
|
|
||||||
USE_L10N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not use timezone-aware datetimes.
|
|
||||||
USE_TZ = True
|
|
||||||
|
|
||||||
# URL prefix to use, please see documentation for more details
|
|
||||||
URL_PREFIX = '__PATHURL__'
|
|
||||||
|
|
||||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
|
||||||
# Example: "/home/media/media.lawrence.com/media/"
|
|
||||||
MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
|
|
||||||
|
|
||||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
|
||||||
# trailing slash.
|
|
||||||
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
|
||||||
MEDIA_URL = '{0}/media/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Absolute path to the directory static files should be collected to.
|
|
||||||
# Don't put anything in this directory yourself; store your static files
|
|
||||||
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
|
|
||||||
# Example: "/home/media/media.lawrence.com/static/"
|
|
||||||
STATIC_ROOT = os.path.join(DATA_DIR, 'static')
|
|
||||||
|
|
||||||
# URL prefix for static files.
|
|
||||||
# Example: "http://media.lawrence.com/static/"
|
|
||||||
STATIC_URL = '{0}/static/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Additional locations of static files
|
|
||||||
STATICFILES_DIRS = (
|
|
||||||
# Put strings here, like "/home/html/static" or "C:/www/django/static".
|
|
||||||
# Always use forward slashes, even on Windows.
|
|
||||||
# Don't forget to use absolute paths, not relative paths.
|
|
||||||
)
|
|
||||||
|
|
||||||
# List of finder classes that know how to find static files in
|
|
||||||
# various locations.
|
|
||||||
STATICFILES_FINDERS = (
|
|
||||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
|
||||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
|
||||||
'compressor.finders.CompressorFinder',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Make this unique, and don't share it with anybody.
|
|
||||||
# You can generate it using examples/generate-secret-key
|
|
||||||
SECRET_KEY = '__KEY__' # noqa
|
|
||||||
|
|
||||||
TEMPLATES = [
|
|
||||||
{
|
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
||||||
'DIRS': [
|
|
||||||
os.path.join(BASE_DIR, 'weblate', 'templates'),
|
|
||||||
],
|
|
||||||
'OPTIONS': {
|
|
||||||
'context_processors': [
|
|
||||||
'django.contrib.auth.context_processors.auth',
|
|
||||||
'django.template.context_processors.debug',
|
|
||||||
'django.template.context_processors.i18n',
|
|
||||||
'django.template.context_processors.request',
|
|
||||||
'django.template.context_processors.csrf',
|
|
||||||
'django.contrib.messages.context_processors.messages',
|
|
||||||
'weblate.trans.context_processors.weblate_context',
|
|
||||||
],
|
|
||||||
'loaders': [
|
|
||||||
('django.template.loaders.cached.Loader', [
|
|
||||||
'django.template.loaders.filesystem.Loader',
|
|
||||||
'django.template.loaders.app_directories.Loader',
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# GitHub username for sending pull requests.
|
|
||||||
# Please see the documentation for more details.
|
|
||||||
GITHUB_USERNAME = "__GITHUBUSER__"
|
|
||||||
|
|
||||||
# Authentication configuration
|
|
||||||
AUTHENTICATION_BACKENDS = (
|
|
||||||
'social_core.backends.email.EmailAuth',
|
|
||||||
# 'social_core.backends.google.GoogleOAuth2',
|
|
||||||
# 'social_core.backends.github.GithubOAuth2',
|
|
||||||
# 'social_core.backends.bitbucket.BitbucketOAuth',
|
|
||||||
'social_core.backends.suse.OpenSUSEOpenId',
|
|
||||||
'social_core.backends.ubuntu.UbuntuOpenId',
|
|
||||||
'social_core.backends.fedora.FedoraOpenId',
|
|
||||||
# 'social_core.backends.facebook.FacebookOAuth2',
|
|
||||||
'weblate.accounts.auth.WeblateUserBackend',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom user model
|
|
||||||
AUTH_USER_MODEL = 'weblate_auth.User'
|
|
||||||
|
|
||||||
# Social auth backends setup
|
|
||||||
SOCIAL_AUTH_GITHUB_KEY = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SECRET = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SCOPE = ['user:email']
|
|
||||||
|
|
||||||
SOCIAL_AUTH_BITBUCKET_KEY = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_SECRET = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_VERIFIED_EMAILS_ONLY = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_FACEBOOK_KEY = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SECRET = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email', 'public_profile']
|
|
||||||
SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {'fields': 'id,name,email'}
|
|
||||||
SOCIAL_AUTH_FACEBOOK_API_VERSION = '3.1'
|
|
||||||
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = ''
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = ''
|
|
||||||
|
|
||||||
# Social auth settings
|
|
||||||
SOCIAL_AUTH_PIPELINE = (
|
|
||||||
'social_core.pipeline.social_auth.social_details',
|
|
||||||
'social_core.pipeline.social_auth.social_uid',
|
|
||||||
'social_core.pipeline.social_auth.auth_allowed',
|
|
||||||
'social_core.pipeline.social_auth.social_user',
|
|
||||||
'weblate.accounts.pipeline.store_params',
|
|
||||||
'weblate.accounts.pipeline.verify_open',
|
|
||||||
'social_core.pipeline.user.get_username',
|
|
||||||
'weblate.accounts.pipeline.require_email',
|
|
||||||
'social_core.pipeline.mail.mail_validation',
|
|
||||||
'weblate.accounts.pipeline.revoke_mail_code',
|
|
||||||
'weblate.accounts.pipeline.ensure_valid',
|
|
||||||
'weblate.accounts.pipeline.remove_account',
|
|
||||||
'social_core.pipeline.social_auth.associate_by_email',
|
|
||||||
'weblate.accounts.pipeline.reauthenticate',
|
|
||||||
'weblate.accounts.pipeline.verify_username',
|
|
||||||
'social_core.pipeline.user.create_user',
|
|
||||||
'social_core.pipeline.social_auth.associate_user',
|
|
||||||
'social_core.pipeline.social_auth.load_extra_data',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
'weblate.accounts.pipeline.user_full_name',
|
|
||||||
'weblate.accounts.pipeline.store_email',
|
|
||||||
'weblate.accounts.pipeline.notify_connect',
|
|
||||||
'weblate.accounts.pipeline.password_reset',
|
|
||||||
)
|
|
||||||
SOCIAL_AUTH_DISCONNECT_PIPELINE = (
|
|
||||||
'social_core.pipeline.disconnect.allowed_to_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.get_entries',
|
|
||||||
'social_core.pipeline.disconnect.revoke_tokens',
|
|
||||||
'weblate.accounts.pipeline.cycle_session',
|
|
||||||
'weblate.accounts.pipeline.adjust_primary_mail',
|
|
||||||
'weblate.accounts.pipeline.notify_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.disconnect',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom authentication strategy
|
|
||||||
SOCIAL_AUTH_STRATEGY = 'weblate.accounts.strategy.WeblateStrategy'
|
|
||||||
|
|
||||||
# Raise exceptions so that we can handle them later
|
|
||||||
SOCIAL_AUTH_RAISE_EXCEPTIONS = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_FUNCTION = \
|
|
||||||
'weblate.accounts.pipeline.send_validation'
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_URL = \
|
|
||||||
'{0}/accounts/email-sent/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_LOGIN_ERROR_URL = \
|
|
||||||
'{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_EMAIL_FORM_URL = \
|
|
||||||
'{0}/accounts/email/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL = \
|
|
||||||
'{0}/accounts/profile/#auth'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_PROTECTED_USER_FIELDS = ('email',)
|
|
||||||
SOCIAL_AUTH_SLUGIFY_USERNAMES = True
|
|
||||||
SOCIAL_AUTH_SLUGIFY_FUNCTION = 'weblate.accounts.pipeline.slugify_username'
|
|
||||||
|
|
||||||
# Password validation configuration
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
||||||
'OPTIONS': {
|
|
||||||
'min_length': 6,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.CharsPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.PastPasswordsValidator',
|
|
||||||
},
|
|
||||||
# Optional password strength validation by django-zxcvbn-password
|
|
||||||
# {
|
|
||||||
# 'NAME': 'zxcvbn_password.ZXCVBNValidator',
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'min_score': 3,
|
|
||||||
# 'user_attributes': ('username', 'email', 'full_name')
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
]
|
|
||||||
|
|
||||||
# Allow new user registrations
|
|
||||||
REGISTRATION_OPEN = True
|
|
||||||
|
|
||||||
# Middleware
|
|
||||||
MIDDLEWARE = [
|
|
||||||
'weblate.middleware.ProxyMiddleware',
|
|
||||||
'django.middleware.security.SecurityMiddleware',
|
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
||||||
'django.middleware.common.CommonMiddleware',
|
|
||||||
'django.middleware.locale.LocaleMiddleware',
|
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
|
||||||
'weblate.accounts.middleware.AuthenticationMiddleware',
|
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
||||||
'social_django.middleware.SocialAuthExceptionMiddleware',
|
|
||||||
'weblate.accounts.middleware.RequireLoginMiddleware',
|
|
||||||
'weblate.middleware.SecurityMiddleware',
|
|
||||||
]
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'weblate.urls'
|
|
||||||
|
|
||||||
# Django and Weblate apps
|
|
||||||
INSTALLED_APPS = (
|
|
||||||
'django.contrib.auth',
|
|
||||||
'django.contrib.contenttypes',
|
|
||||||
'django.contrib.sessions',
|
|
||||||
'django.contrib.sites',
|
|
||||||
'django.contrib.messages',
|
|
||||||
'django.contrib.staticfiles',
|
|
||||||
'django.contrib.admin.apps.SimpleAdminConfig',
|
|
||||||
'django.contrib.admindocs',
|
|
||||||
'django.contrib.sitemaps',
|
|
||||||
'social_django',
|
|
||||||
'crispy_forms',
|
|
||||||
'compressor',
|
|
||||||
'rest_framework',
|
|
||||||
'rest_framework.authtoken',
|
|
||||||
'weblate.addons',
|
|
||||||
'weblate.auth',
|
|
||||||
'weblate.checks',
|
|
||||||
'weblate.formats',
|
|
||||||
'weblate.machinery',
|
|
||||||
'weblate.trans',
|
|
||||||
'weblate.lang',
|
|
||||||
'weblate.langdata',
|
|
||||||
'weblate.memory',
|
|
||||||
'weblate.screenshots',
|
|
||||||
'weblate.accounts',
|
|
||||||
'weblate.utils',
|
|
||||||
'weblate.vcs',
|
|
||||||
'weblate.wladmin',
|
|
||||||
'weblate',
|
|
||||||
|
|
||||||
# Optional: Git exporter
|
|
||||||
# 'weblate.gitexport',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Path to locales
|
|
||||||
LOCALE_PATHS = (os.path.join(BASE_DIR, 'weblate', 'locale'), )
|
|
||||||
|
|
||||||
# Custom exception reporter to include some details
|
|
||||||
DEFAULT_EXCEPTION_REPORTER_FILTER = \
|
|
||||||
'weblate.trans.debug.WeblateExceptionReporterFilter'
|
|
||||||
|
|
||||||
# Default logging of Weblate messages
|
|
||||||
# - to syslog in production (if available)
|
|
||||||
# - otherwise to console
|
|
||||||
# - you can also choose 'logfile' to log into separate file
|
|
||||||
# after configuring it below
|
|
||||||
|
|
||||||
# Detect if we can connect to syslog
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
if platform.system() != 'Windows':
|
|
||||||
try:
|
|
||||||
handler = SysLogHandler(
|
|
||||||
address='/dev/log', facility=SysLogHandler.LOG_LOCAL2
|
|
||||||
)
|
|
||||||
handler.close()
|
|
||||||
HAVE_SYSLOG = True
|
|
||||||
except IOError:
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
|
|
||||||
if DEBUG or not HAVE_SYSLOG:
|
|
||||||
DEFAULT_LOG = 'console'
|
|
||||||
else:
|
|
||||||
DEFAULT_LOG = 'syslog'
|
|
||||||
|
|
||||||
# A sample logging configuration. The only tangible logging
|
|
||||||
# performed by this configuration is to send an email to
|
|
||||||
# the site admins on every HTTP 500 error when DEBUG=False.
|
|
||||||
# See http://docs.djangoproject.com/en/stable/topics/logging for
|
|
||||||
# more details on how to customize your logging configuration.
|
|
||||||
LOGGING = {
|
|
||||||
'version': 1,
|
|
||||||
'disable_existing_loggers': True,
|
|
||||||
'filters': {
|
|
||||||
'require_debug_false': {
|
|
||||||
'()': 'django.utils.log.RequireDebugFalse'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'formatters': {
|
|
||||||
'syslog': {
|
|
||||||
'format': 'weblate[%(process)d]: %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'simple': {
|
|
||||||
'format': '%(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'logfile': {
|
|
||||||
'format': '%(asctime)s %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'()': 'django.utils.log.ServerFormatter',
|
|
||||||
'format': '[%(server_time)s] %(message)s',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'handlers': {
|
|
||||||
'mail_admins': {
|
|
||||||
'level': 'ERROR',
|
|
||||||
'filters': ['require_debug_false'],
|
|
||||||
'class': 'django.utils.log.AdminEmailHandler',
|
|
||||||
'include_html': True,
|
|
||||||
},
|
|
||||||
'console': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'simple'
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'level': 'INFO',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'django.server',
|
|
||||||
},
|
|
||||||
'syslog': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.handlers.SysLogHandler',
|
|
||||||
'formatter': 'syslog',
|
|
||||||
'address': '/dev/log',
|
|
||||||
'facility': SysLogHandler.LOG_LOCAL2,
|
|
||||||
},
|
|
||||||
# Logging to a file
|
|
||||||
# 'logfile': {
|
|
||||||
# 'level':'DEBUG',
|
|
||||||
# 'class':'logging.handlers.RotatingFileHandler',
|
|
||||||
# 'filename': "/var/log/weblate/weblate.log",
|
|
||||||
# 'maxBytes': 100000,
|
|
||||||
# 'backupCount': 3,
|
|
||||||
# 'formatter': 'logfile',
|
|
||||||
# },
|
|
||||||
},
|
|
||||||
'loggers': {
|
|
||||||
'django.request': {
|
|
||||||
'handlers': ['mail_admins', DEFAULT_LOG],
|
|
||||||
'level': 'ERROR',
|
|
||||||
'propagate': True,
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'handlers': ['django.server'],
|
|
||||||
'level': 'INFO',
|
|
||||||
'propagate': False,
|
|
||||||
},
|
|
||||||
# Logging database queries
|
|
||||||
# 'django.db.backends': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
'weblate': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'DEBUG',
|
|
||||||
},
|
|
||||||
# Logging VCS operations
|
|
||||||
# 'weblate-vcs': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
# Python Social Auth logging
|
|
||||||
# 'social': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Logging of management commands to console
|
|
||||||
if (os.environ.get('DJANGO_IS_MANAGEMENT_COMMAND', False) and
|
|
||||||
'console' not in LOGGING['loggers']['weblate']['handlers']):
|
|
||||||
LOGGING['loggers']['weblate']['handlers'].append('console')
|
|
||||||
|
|
||||||
# Remove syslog setup if it's not present
|
|
||||||
if not HAVE_SYSLOG:
|
|
||||||
del LOGGING['handlers']['syslog']
|
|
||||||
|
|
||||||
# List of machine translations
|
|
||||||
# MT_SERVICES = (
|
|
||||||
# 'weblate.machinery.apertium.ApertiumAPYTranslation',
|
|
||||||
# 'weblate.machinery.baidu.BaiduTranslation',
|
|
||||||
# 'weblate.machinery.deepl.DeepLTranslation',
|
|
||||||
# 'weblate.machinery.glosbe.GlosbeTranslation',
|
|
||||||
# 'weblate.machinery.google.GoogleTranslation',
|
|
||||||
# 'weblate.machinery.microsoft.MicrosoftCognitiveTranslation',
|
|
||||||
# 'weblate.machinery.microsoftterminology.MicrosoftTerminologyService',
|
|
||||||
# 'weblate.machinery.mymemory.MyMemoryTranslation',
|
|
||||||
# 'weblate.machinery.netease.NeteaseSightTranslation',
|
|
||||||
# 'weblate.machinery.tmserver.AmagamaTranslation',
|
|
||||||
# 'weblate.machinery.tmserver.TMServerTranslation',
|
|
||||||
# 'weblate.machinery.yandex.YandexTranslation',
|
|
||||||
# 'weblate.machinery.weblatetm.WeblateTranslation',
|
|
||||||
# 'weblate.machinery.saptranslationhub.SAPTranslationHub',
|
|
||||||
# 'weblate.machinery.youdao.YoudaoTranslation',
|
|
||||||
# 'weblate.memory.machine.WeblateMemory',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Machine translation API keys
|
|
||||||
|
|
||||||
# URL of the Apertium APy server
|
|
||||||
MT_APERTIUM_APY = None
|
|
||||||
|
|
||||||
# DeepL API key
|
|
||||||
MT_DEEPL_KEY = None
|
|
||||||
|
|
||||||
# Microsoft Cognitive Services Translator API, register at
|
|
||||||
# https://portal.azure.com/
|
|
||||||
MT_MICROSOFT_COGNITIVE_KEY = None
|
|
||||||
|
|
||||||
# MyMemory identification email, see
|
|
||||||
# https://mymemory.translated.net/doc/spec.php
|
|
||||||
MT_MYMEMORY_EMAIL = None
|
|
||||||
|
|
||||||
# Optional MyMemory credentials to access private translation memory
|
|
||||||
MT_MYMEMORY_USER = None
|
|
||||||
MT_MYMEMORY_KEY = None
|
|
||||||
|
|
||||||
# Google API key for Google Translate API
|
|
||||||
MT_GOOGLE_KEY = None
|
|
||||||
|
|
||||||
# Baidu app key and secret
|
|
||||||
MT_BAIDU_ID = None
|
|
||||||
MT_BAIDU_SECRET = None
|
|
||||||
|
|
||||||
# Youdao Zhiyun app key and secret
|
|
||||||
MT_YOUDAO_ID = None
|
|
||||||
MT_YOUDAO_SECRET = None
|
|
||||||
|
|
||||||
# Netease Sight (Jianwai) app key and secret
|
|
||||||
MT_NETEASE_KEY = None
|
|
||||||
MT_NETEASE_SECRET = None
|
|
||||||
|
|
||||||
# API key for Yandex Translate API
|
|
||||||
MT_YANDEX_KEY = None
|
|
||||||
|
|
||||||
# tmserver URL
|
|
||||||
MT_TMSERVER = None
|
|
||||||
|
|
||||||
# SAP Translation Hub
|
|
||||||
MT_SAP_BASE_URL = None
|
|
||||||
MT_SAP_SANDBOX_APIKEY = None
|
|
||||||
MT_SAP_USERNAME = None
|
|
||||||
MT_SAP_PASSWORD = None
|
|
||||||
MT_SAP_USE_MT = True
|
|
||||||
|
|
||||||
# Title of site to use
|
|
||||||
SITE_TITLE = 'Weblate'
|
|
||||||
|
|
||||||
# Whether site uses https
|
|
||||||
ENABLE_HTTPS = True
|
|
||||||
|
|
||||||
# Use HTTPS when creating redirect URLs for social authentication, see
|
|
||||||
# documentation for more details:
|
|
||||||
# https://python-social-auth-docs.readthedocs.io/en/latest/configuration/settings.html#processing-redirects-and-urlopen
|
|
||||||
SOCIAL_AUTH_REDIRECT_IS_HTTPS = ENABLE_HTTPS
|
|
||||||
|
|
||||||
# Make CSRF cookie HttpOnly, see documentation for more details:
|
|
||||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#csrf-cookie-httponly
|
|
||||||
CSRF_COOKIE_HTTPONLY = True
|
|
||||||
CSRF_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# Store CSRF token in session (since Django 1.11)
|
|
||||||
CSRF_USE_SESSIONS = True
|
|
||||||
SESSION_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# SSL redirect
|
|
||||||
SECURE_SSL_REDIRECT = ENABLE_HTTPS
|
|
||||||
# Session cookie age (in seconds)
|
|
||||||
SESSION_COOKIE_AGE = 1209600
|
|
||||||
|
|
||||||
# Some security headers
|
|
||||||
SECURE_BROWSER_XSS_FILTER = True
|
|
||||||
X_FRAME_OPTIONS = 'DENY'
|
|
||||||
SECURE_CONTENT_TYPE_NOSNIFF = True
|
|
||||||
|
|
||||||
# Optionally enable HSTS
|
|
||||||
SECURE_HSTS_SECONDS = 0
|
|
||||||
SECURE_HSTS_PRELOAD = False
|
|
||||||
SECURE_HSTS_INCLUDE_SUBDOMAINS = False
|
|
||||||
|
|
||||||
# URL of login
|
|
||||||
LOGIN_URL = '{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# URL of logout
|
|
||||||
LOGOUT_URL = '{0}/accounts/logout/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Default location for login
|
|
||||||
LOGIN_REDIRECT_URL = '{0}/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Anonymous user name
|
|
||||||
ANONYMOUS_USER_NAME = 'anonymous'
|
|
||||||
|
|
||||||
# Reverse proxy settings
|
|
||||||
IP_PROXY_HEADER = 'HTTP_X_FORWARDED_FOR'
|
|
||||||
IP_BEHIND_REVERSE_PROXY = False
|
|
||||||
IP_PROXY_OFFSET = 0
|
|
||||||
|
|
||||||
# Sending HTML in mails
|
|
||||||
EMAIL_SEND_HTML = True
|
|
||||||
|
|
||||||
# Subject of emails includes site title
|
|
||||||
EMAIL_SUBJECT_PREFIX = '[{0}] '.format(SITE_TITLE)
|
|
||||||
|
|
||||||
EMAIL_BACKEND = 'django_sendmail_backend.backends.EmailBackend'
|
|
||||||
|
|
||||||
# Enable remote hooks
|
|
||||||
ENABLE_HOOKS = True
|
|
||||||
|
|
||||||
# Number of nearby messages to show in each direction
|
|
||||||
NEARBY_MESSAGES = 5
|
|
||||||
|
|
||||||
# Use simple language codes for default language/country combinations
|
|
||||||
SIMPLIFY_LANGUAGES = True
|
|
||||||
|
|
||||||
# Render forms using bootstrap
|
|
||||||
CRISPY_TEMPLATE_PACK = 'bootstrap3'
|
|
||||||
|
|
||||||
# List of quality checks
|
|
||||||
# CHECK_LIST = (
|
|
||||||
# 'weblate.checks.same.SameCheck',
|
|
||||||
# 'weblate.checks.chars.BeginNewlineCheck',
|
|
||||||
# 'weblate.checks.chars.EndNewlineCheck',
|
|
||||||
# 'weblate.checks.chars.BeginSpaceCheck',
|
|
||||||
# 'weblate.checks.chars.EndSpaceCheck',
|
|
||||||
# 'weblate.checks.chars.EndStopCheck',
|
|
||||||
# 'weblate.checks.chars.EndColonCheck',
|
|
||||||
# 'weblate.checks.chars.EndQuestionCheck',
|
|
||||||
# 'weblate.checks.chars.EndExclamationCheck',
|
|
||||||
# 'weblate.checks.chars.EndEllipsisCheck',
|
|
||||||
# 'weblate.checks.chars.EndSemicolonCheck',
|
|
||||||
# 'weblate.checks.chars.MaxLengthCheck',
|
|
||||||
# 'weblate.checks.format.PythonFormatCheck',
|
|
||||||
# 'weblate.checks.format.PythonBraceFormatCheck',
|
|
||||||
# 'weblate.checks.format.PHPFormatCheck',
|
|
||||||
# 'weblate.checks.format.CFormatCheck',
|
|
||||||
# 'weblate.checks.format.PerlFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavascriptFormatCheck',
|
|
||||||
# 'weblate.checks.format.CSharpFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavaFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavaMessageFormatCheck',
|
|
||||||
# 'weblate.checks.angularjs.AngularJSInterpolationCheck',
|
|
||||||
# 'weblate.checks.consistency.PluralsCheck',
|
|
||||||
# 'weblate.checks.consistency.SamePluralsCheck',
|
|
||||||
# 'weblate.checks.consistency.ConsistencyCheck',
|
|
||||||
# 'weblate.checks.consistency.TranslatedCheck',
|
|
||||||
# 'weblate.checks.chars.NewlineCountingCheck',
|
|
||||||
# 'weblate.checks.markup.BBCodeCheck',
|
|
||||||
# 'weblate.checks.chars.ZeroWidthSpaceCheck',
|
|
||||||
# 'weblate.checks.markup.XMLValidityCheck',
|
|
||||||
# 'weblate.checks.markup.XMLTagsCheck',
|
|
||||||
# 'weblate.checks.source.OptionalPluralCheck',
|
|
||||||
# 'weblate.checks.source.EllipsisCheck',
|
|
||||||
# 'weblate.checks.source.MultipleFailingCheck',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of automatic fixups
|
|
||||||
# AUTOFIX_LIST = (
|
|
||||||
# 'weblate.trans.autofixes.whitespace.SameBookendingWhitespace',
|
|
||||||
# 'weblate.trans.autofixes.chars.ReplaceTrailingDotsWithEllipsis',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveZeroSpace',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveControlChars',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of enabled addons
|
|
||||||
# WEBLATE_ADDONS = (
|
|
||||||
# 'weblate.addons.gettext.GenerateMoAddon',
|
|
||||||
# 'weblate.addons.gettext.UpdateLinguasAddon',
|
|
||||||
# 'weblate.addons.gettext.UpdateConfigureAddon',
|
|
||||||
# 'weblate.addons.gettext.MsgmergeAddon',
|
|
||||||
# 'weblate.addons.gettext.GettextCustomizeAddon',
|
|
||||||
# 'weblate.addons.gettext.GettextAuthorComments',
|
|
||||||
# 'weblate.addons.cleanup.CleanupAddon',
|
|
||||||
# 'weblate.addons.consistency.LangaugeConsistencyAddon',
|
|
||||||
# 'weblate.addons.discovery.DiscoveryAddon',
|
|
||||||
# 'weblate.addons.flags.SourceEditAddon',
|
|
||||||
# 'weblate.addons.flags.TargetEditAddon',
|
|
||||||
# 'weblate.addons.generate.GenerateFileAddon',
|
|
||||||
# 'weblate.addons.json.JSONCustomizeAddon',
|
|
||||||
# 'weblate.addons.properties.PropertiesSortAddon',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# E-mail address that error messages come from.
|
|
||||||
SERVER_EMAIL = 'noreply@__DOMAIN__'
|
|
||||||
|
|
||||||
# Default email address to use for various automated correspondence from
|
|
||||||
# the site managers. Used for registration emails.
|
|
||||||
DEFAULT_FROM_EMAIL = '__ADMINMAIL__'
|
|
||||||
|
|
||||||
# List of URLs your site is supposed to serve
|
|
||||||
ALLOWED_HOSTS = ['__DOMAIN__']
|
|
||||||
|
|
||||||
CACHES = {
|
|
||||||
'default': {
|
|
||||||
'BACKEND': 'django_redis.cache.RedisCache',
|
|
||||||
'LOCATION': 'redis://127.0.0.1:6379/__REDIS_DB__',
|
|
||||||
'OPTIONS': {
|
|
||||||
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
|
||||||
'PARSER_CLASS': 'redis.connection.HiredisParser',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'avatar': {
|
|
||||||
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
|
||||||
'LOCATION': os.path.join(BASE_DIR, 'avatar-cache'),
|
|
||||||
'TIMEOUT': 3600,
|
|
||||||
'OPTIONS': {
|
|
||||||
'MAX_ENTRIES': 1000,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example configuration for caching
|
|
||||||
# CACHES = {
|
|
||||||
# Recommended redis + hiredis:
|
|
||||||
# 'default': {
|
|
||||||
# 'BACKEND': 'django_redis.cache.RedisCache',
|
|
||||||
# 'LOCATION': 'redis://127.0.0.1:6379/0',
|
|
||||||
# # If redis is running on same host as Weblate, you might
|
|
||||||
# # want to use unix sockets instead:
|
|
||||||
# # 'LOCATION': 'unix:///var/run/redis/redis.sock?db=0',
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
|
||||||
# 'PARSER_CLASS': 'redis.connection.HiredisParser',
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
# Memcached alternative:
|
|
||||||
# 'default': {
|
|
||||||
# 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
|
||||||
# 'LOCATION': '127.0.0.1:11211',
|
|
||||||
# },
|
|
||||||
# 'avatar': {
|
|
||||||
# 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
|
||||||
# 'LOCATION': os.path.join(DATA_DIR, 'avatar-cache'),
|
|
||||||
# 'TIMEOUT': 3600,
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'MAX_ENTRIES': 1000,
|
|
||||||
# },
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
|
|
||||||
# REST framework settings for API
|
|
||||||
REST_FRAMEWORK = {
|
|
||||||
# Use Django's standard `django.contrib.auth` permissions,
|
|
||||||
# or allow read-only access for unauthenticated users.
|
|
||||||
'DEFAULT_PERMISSION_CLASSES': [
|
|
||||||
'rest_framework.permissions.IsAuthenticatedOrReadOnly'
|
|
||||||
],
|
|
||||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
|
||||||
'rest_framework.authentication.TokenAuthentication',
|
|
||||||
'weblate.api.authentication.BearerAuthentication',
|
|
||||||
'rest_framework.authentication.SessionAuthentication',
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_CLASSES': (
|
|
||||||
'rest_framework.throttling.AnonRateThrottle',
|
|
||||||
'rest_framework.throttling.UserRateThrottle'
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_RATES': {
|
|
||||||
'anon': '100/day',
|
|
||||||
'user': '1000/day'
|
|
||||||
},
|
|
||||||
'DEFAULT_PAGINATION_CLASS': (
|
|
||||||
'rest_framework.pagination.PageNumberPagination'
|
|
||||||
),
|
|
||||||
'PAGE_SIZE': 20,
|
|
||||||
'VIEW_DESCRIPTION_FUNCTION': 'weblate.api.views.get_view_description',
|
|
||||||
'UNAUTHENTICATED_USER': 'weblate.auth.models.get_anonymous',
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example for restricting access to logged in users
|
|
||||||
# LOGIN_REQUIRED_URLS = (
|
|
||||||
# r'/(.*)$',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# In such case you will want to include some of the exceptions
|
|
||||||
# LOGIN_REQUIRED_URLS_EXCEPTIONS = (
|
|
||||||
# r'/accounts/(.*)$', # Required for login
|
|
||||||
# r'/admin/login/(.*)$', # Required for admin login
|
|
||||||
# r'/static/(.*)$', # Required for development mode
|
|
||||||
# r'/widgets/(.*)$', # Allowing public access to widgets
|
|
||||||
# r'/data/(.*)$', # Allowing public access to data exports
|
|
||||||
# r'/hooks/(.*)$', # Allowing public access to notification hooks
|
|
||||||
# r'/healthz/$', # Allowing public access to health check
|
|
||||||
# r'/api/(.*)$', # Allowing access to API
|
|
||||||
# r'/js/i18n/$', # Javascript localization
|
|
||||||
# r'/contact/$', # Optional for contact form
|
|
||||||
# r'/legal/(.*)$', # Optional for legal app
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Celery worker configuration for testing
|
|
||||||
# CELERY_TASK_ALWAYS_EAGER = True
|
|
||||||
# CELERY_BROKER_URL = 'memory://'
|
|
||||||
# CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
|
|
||||||
# Celery worker configuration for production
|
|
||||||
CELERY_TASK_ALWAYS_EAGER = False
|
|
||||||
CELERY_BROKER_URL = 'redis://127.0.0.1:6379/__REDIS_DB__'
|
|
||||||
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
|
|
||||||
|
|
||||||
# Celery settings, it is not recommended to change these
|
|
||||||
CELERY_WORKER_PREFETCH_MULTIPLIER = 0
|
|
||||||
CELERY_BEAT_SCHEDULE_FILENAME = os.path.join(
|
|
||||||
DATA_DIR, 'celery', 'beat-schedule'
|
|
||||||
)
|
|
|
@ -1,855 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# Copyright © 2012 - 2019 Michal Čihař <michal@cihar.com>
|
|
||||||
#
|
|
||||||
# This file is part of Weblate <https://weblate.org/>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import platform
|
|
||||||
import os
|
|
||||||
from logging.handlers import SysLogHandler
|
|
||||||
|
|
||||||
#
|
|
||||||
# Django settings for Weblate project.
|
|
||||||
#
|
|
||||||
|
|
||||||
DEBUG = False
|
|
||||||
|
|
||||||
ADMINS = (
|
|
||||||
('__ADMIN__', '__ADMINMAIL__'),
|
|
||||||
)
|
|
||||||
|
|
||||||
MANAGERS = ADMINS
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
# Database engine
|
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
||||||
# Database name
|
|
||||||
'NAME': '__NAME__',
|
|
||||||
# Database user
|
|
||||||
'USER': '__NAME__',
|
|
||||||
# Database password
|
|
||||||
'PASSWORD': '__DB_PWD__',
|
|
||||||
# Set to empty string for localhost
|
|
||||||
'HOST': 'localhost',
|
|
||||||
# Set to empty string for default
|
|
||||||
'PORT': '5432',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BASE_DIR = '__FINALPATH__'
|
|
||||||
|
|
||||||
# Data directory
|
|
||||||
DATA_DIR = os.path.join(BASE_DIR, 'data')
|
|
||||||
TTF_PATH = '__FINALPATH__/venv/lib/__PYTHONPATH__/site-packages/weblate/ttf/'
|
|
||||||
|
|
||||||
# Local time zone for this installation. Choices can be found here:
|
|
||||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
|
||||||
# although not all choices may be available on all operating systems.
|
|
||||||
# In a Windows environment this must be set to your system time zone.
|
|
||||||
TIME_ZONE = 'UTC'
|
|
||||||
|
|
||||||
# Language code for this installation. All choices can be found here:
|
|
||||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
|
||||||
|
|
||||||
LANGUAGES = (
|
|
||||||
('ar', 'العربية'),
|
|
||||||
('az', 'Azərbaycan'),
|
|
||||||
('be', 'Беларуская'),
|
|
||||||
('be@latin', 'Biełaruskaja'),
|
|
||||||
('bg', 'Български'),
|
|
||||||
('br', 'Brezhoneg'),
|
|
||||||
('ca', 'Català'),
|
|
||||||
('cs', 'Čeština'),
|
|
||||||
('da', 'Dansk'),
|
|
||||||
('de', 'Deutsch'),
|
|
||||||
('en', 'English'),
|
|
||||||
('en-gb', 'English (United Kingdom)'),
|
|
||||||
('el', 'Ελληνικά'),
|
|
||||||
('es', 'Español'),
|
|
||||||
('fi', 'Suomi'),
|
|
||||||
('fr', 'Français'),
|
|
||||||
('fy', 'Frysk'),
|
|
||||||
('gl', 'Galego'),
|
|
||||||
('he', 'עברית'),
|
|
||||||
('hu', 'Magyar'),
|
|
||||||
('id', 'Indonesia'),
|
|
||||||
('it', 'Italiano'),
|
|
||||||
('ja', '日本語'),
|
|
||||||
('ko', '한국어'),
|
|
||||||
('ksh', 'Kölsch'),
|
|
||||||
('nb', 'Norsk bokmål'),
|
|
||||||
('nl', 'Nederlands'),
|
|
||||||
('pl', 'Polski'),
|
|
||||||
('pt', 'Português'),
|
|
||||||
('pt-br', 'Português brasileiro'),
|
|
||||||
('ru', 'Русский'),
|
|
||||||
('sk', 'Slovenčina'),
|
|
||||||
('sl', 'Slovenščina'),
|
|
||||||
('sr', 'Српски'),
|
|
||||||
('sv', 'Svenska'),
|
|
||||||
('tr', 'Türkçe'),
|
|
||||||
('uk', 'Українська'),
|
|
||||||
('zh-hans', '简体字'),
|
|
||||||
('zh-hant', '正體字'),
|
|
||||||
)
|
|
||||||
|
|
||||||
SITE_ID = 1
|
|
||||||
|
|
||||||
# If you set this to False, Django will make some optimizations so as not
|
|
||||||
# to load the internationalization machinery.
|
|
||||||
USE_I18N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not format dates, numbers and
|
|
||||||
# calendars according to the current locale.
|
|
||||||
USE_L10N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not use timezone-aware datetimes.
|
|
||||||
USE_TZ = True
|
|
||||||
|
|
||||||
# URL prefix to use, please see documentation for more details
|
|
||||||
URL_PREFIX = '__PATHURL__'
|
|
||||||
|
|
||||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
|
||||||
# Example: "/home/media/media.lawrence.com/media/"
|
|
||||||
MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
|
|
||||||
|
|
||||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
|
||||||
# trailing slash.
|
|
||||||
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
|
||||||
MEDIA_URL = '{0}/media/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Absolute path to the directory static files should be collected to.
|
|
||||||
# Don't put anything in this directory yourself; store your static files
|
|
||||||
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
|
|
||||||
# Example: "/home/media/media.lawrence.com/static/"
|
|
||||||
STATIC_ROOT = os.path.join(DATA_DIR, 'static')
|
|
||||||
|
|
||||||
# URL prefix for static files.
|
|
||||||
# Example: "http://media.lawrence.com/static/"
|
|
||||||
STATIC_URL = '{0}/static/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Additional locations of static files
|
|
||||||
STATICFILES_DIRS = (
|
|
||||||
# Put strings here, like "/home/html/static" or "C:/www/django/static".
|
|
||||||
# Always use forward slashes, even on Windows.
|
|
||||||
# Don't forget to use absolute paths, not relative paths.
|
|
||||||
)
|
|
||||||
|
|
||||||
# List of finder classes that know how to find static files in
|
|
||||||
# various locations.
|
|
||||||
STATICFILES_FINDERS = (
|
|
||||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
|
||||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
|
||||||
'compressor.finders.CompressorFinder',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Make this unique, and don't share it with anybody.
|
|
||||||
# You can generate it using examples/generate-secret-key
|
|
||||||
SECRET_KEY = '__KEY__' # noqa
|
|
||||||
|
|
||||||
TEMPLATES = [
|
|
||||||
{
|
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
||||||
'DIRS': [
|
|
||||||
os.path.join(BASE_DIR, 'weblate', 'templates'),
|
|
||||||
],
|
|
||||||
'OPTIONS': {
|
|
||||||
'context_processors': [
|
|
||||||
'django.contrib.auth.context_processors.auth',
|
|
||||||
'django.template.context_processors.debug',
|
|
||||||
'django.template.context_processors.i18n',
|
|
||||||
'django.template.context_processors.request',
|
|
||||||
'django.template.context_processors.csrf',
|
|
||||||
'django.contrib.messages.context_processors.messages',
|
|
||||||
'weblate.trans.context_processors.weblate_context',
|
|
||||||
],
|
|
||||||
'loaders': [
|
|
||||||
('django.template.loaders.cached.Loader', [
|
|
||||||
'django.template.loaders.filesystem.Loader',
|
|
||||||
'django.template.loaders.app_directories.Loader',
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# GitHub username for sending pull requests.
|
|
||||||
# Please see the documentation for more details.
|
|
||||||
GITHUB_USERNAME = "__GITHUBUSER__"
|
|
||||||
|
|
||||||
# Authentication configuration
|
|
||||||
AUTHENTICATION_BACKENDS = (
|
|
||||||
'social_core.backends.email.EmailAuth',
|
|
||||||
# 'social_core.backends.google.GoogleOAuth2',
|
|
||||||
# 'social_core.backends.github.GithubOAuth2',
|
|
||||||
# 'social_core.backends.bitbucket.BitbucketOAuth',
|
|
||||||
'social_core.backends.suse.OpenSUSEOpenId',
|
|
||||||
'social_core.backends.ubuntu.UbuntuOpenId',
|
|
||||||
'social_core.backends.fedora.FedoraOpenId',
|
|
||||||
# 'social_core.backends.facebook.FacebookOAuth2',
|
|
||||||
'weblate.accounts.auth.WeblateUserBackend',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom user model
|
|
||||||
AUTH_USER_MODEL = 'weblate_auth.User'
|
|
||||||
|
|
||||||
# Social auth backends setup
|
|
||||||
SOCIAL_AUTH_GITHUB_KEY = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SECRET = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SCOPE = ['user:email']
|
|
||||||
|
|
||||||
SOCIAL_AUTH_BITBUCKET_KEY = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_SECRET = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_VERIFIED_EMAILS_ONLY = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_FACEBOOK_KEY = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SECRET = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email', 'public_profile']
|
|
||||||
SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {'fields': 'id,name,email'}
|
|
||||||
SOCIAL_AUTH_FACEBOOK_API_VERSION = '3.1'
|
|
||||||
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = ''
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = ''
|
|
||||||
|
|
||||||
# Social auth settings
|
|
||||||
SOCIAL_AUTH_PIPELINE = (
|
|
||||||
'social_core.pipeline.social_auth.social_details',
|
|
||||||
'social_core.pipeline.social_auth.social_uid',
|
|
||||||
'social_core.pipeline.social_auth.auth_allowed',
|
|
||||||
'social_core.pipeline.social_auth.social_user',
|
|
||||||
'weblate.accounts.pipeline.store_params',
|
|
||||||
'weblate.accounts.pipeline.verify_open',
|
|
||||||
'social_core.pipeline.user.get_username',
|
|
||||||
'weblate.accounts.pipeline.require_email',
|
|
||||||
'social_core.pipeline.mail.mail_validation',
|
|
||||||
'weblate.accounts.pipeline.revoke_mail_code',
|
|
||||||
'weblate.accounts.pipeline.ensure_valid',
|
|
||||||
'weblate.accounts.pipeline.remove_account',
|
|
||||||
'social_core.pipeline.social_auth.associate_by_email',
|
|
||||||
'weblate.accounts.pipeline.reauthenticate',
|
|
||||||
'weblate.accounts.pipeline.verify_username',
|
|
||||||
'social_core.pipeline.user.create_user',
|
|
||||||
'social_core.pipeline.social_auth.associate_user',
|
|
||||||
'social_core.pipeline.social_auth.load_extra_data',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
'weblate.accounts.pipeline.user_full_name',
|
|
||||||
'weblate.accounts.pipeline.store_email',
|
|
||||||
'weblate.accounts.pipeline.notify_connect',
|
|
||||||
'weblate.accounts.pipeline.password_reset',
|
|
||||||
)
|
|
||||||
SOCIAL_AUTH_DISCONNECT_PIPELINE = (
|
|
||||||
'social_core.pipeline.disconnect.allowed_to_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.get_entries',
|
|
||||||
'social_core.pipeline.disconnect.revoke_tokens',
|
|
||||||
'weblate.accounts.pipeline.cycle_session',
|
|
||||||
'weblate.accounts.pipeline.adjust_primary_mail',
|
|
||||||
'weblate.accounts.pipeline.notify_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.disconnect',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom authentication strategy
|
|
||||||
SOCIAL_AUTH_STRATEGY = 'weblate.accounts.strategy.WeblateStrategy'
|
|
||||||
|
|
||||||
# Raise exceptions so that we can handle them later
|
|
||||||
SOCIAL_AUTH_RAISE_EXCEPTIONS = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_FUNCTION = \
|
|
||||||
'weblate.accounts.pipeline.send_validation'
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_URL = \
|
|
||||||
'{0}/accounts/email-sent/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_LOGIN_ERROR_URL = \
|
|
||||||
'{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_EMAIL_FORM_URL = \
|
|
||||||
'{0}/accounts/email/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL = \
|
|
||||||
'{0}/accounts/profile/#auth'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_PROTECTED_USER_FIELDS = ('email',)
|
|
||||||
SOCIAL_AUTH_SLUGIFY_USERNAMES = True
|
|
||||||
SOCIAL_AUTH_SLUGIFY_FUNCTION = 'weblate.accounts.pipeline.slugify_username'
|
|
||||||
|
|
||||||
# Password validation configuration
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
||||||
'OPTIONS': {
|
|
||||||
'min_length': 6,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.CharsPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.PastPasswordsValidator',
|
|
||||||
},
|
|
||||||
# Optional password strength validation by django-zxcvbn-password
|
|
||||||
# {
|
|
||||||
# 'NAME': 'zxcvbn_password.ZXCVBNValidator',
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'min_score': 3,
|
|
||||||
# 'user_attributes': ('username', 'email', 'full_name')
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
]
|
|
||||||
|
|
||||||
# Allow new user registrations
|
|
||||||
REGISTRATION_OPEN = True
|
|
||||||
|
|
||||||
# Middleware
|
|
||||||
MIDDLEWARE = [
|
|
||||||
'weblate.middleware.ProxyMiddleware',
|
|
||||||
'django.middleware.security.SecurityMiddleware',
|
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
||||||
'django.middleware.common.CommonMiddleware',
|
|
||||||
'django.middleware.locale.LocaleMiddleware',
|
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
|
||||||
'weblate.accounts.middleware.AuthenticationMiddleware',
|
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
||||||
'social_django.middleware.SocialAuthExceptionMiddleware',
|
|
||||||
'weblate.accounts.middleware.RequireLoginMiddleware',
|
|
||||||
'weblate.middleware.SecurityMiddleware',
|
|
||||||
]
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'weblate.urls'
|
|
||||||
|
|
||||||
# Django and Weblate apps
|
|
||||||
INSTALLED_APPS = (
|
|
||||||
'django.contrib.auth',
|
|
||||||
'django.contrib.contenttypes',
|
|
||||||
'django.contrib.sessions',
|
|
||||||
'django.contrib.sites',
|
|
||||||
'django.contrib.messages',
|
|
||||||
'django.contrib.staticfiles',
|
|
||||||
'django.contrib.admin.apps.SimpleAdminConfig',
|
|
||||||
'django.contrib.admindocs',
|
|
||||||
'django.contrib.sitemaps',
|
|
||||||
'social_django',
|
|
||||||
'crispy_forms',
|
|
||||||
'compressor',
|
|
||||||
'rest_framework',
|
|
||||||
'rest_framework.authtoken',
|
|
||||||
'weblate.addons',
|
|
||||||
'weblate.auth',
|
|
||||||
'weblate.checks',
|
|
||||||
'weblate.formats',
|
|
||||||
'weblate.machinery',
|
|
||||||
'weblate.trans',
|
|
||||||
'weblate.lang',
|
|
||||||
'weblate.langdata',
|
|
||||||
'weblate.memory',
|
|
||||||
'weblate.screenshots',
|
|
||||||
'weblate.accounts',
|
|
||||||
'weblate.utils',
|
|
||||||
'weblate.vcs',
|
|
||||||
'weblate.wladmin',
|
|
||||||
'weblate',
|
|
||||||
|
|
||||||
# Optional: Git exporter
|
|
||||||
# 'weblate.gitexport',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Path to locales
|
|
||||||
LOCALE_PATHS = (os.path.join(BASE_DIR, 'weblate', 'locale'), )
|
|
||||||
|
|
||||||
# Custom exception reporter to include some details
|
|
||||||
DEFAULT_EXCEPTION_REPORTER_FILTER = \
|
|
||||||
'weblate.trans.debug.WeblateExceptionReporterFilter'
|
|
||||||
|
|
||||||
# Default logging of Weblate messages
|
|
||||||
# - to syslog in production (if available)
|
|
||||||
# - otherwise to console
|
|
||||||
# - you can also choose 'logfile' to log into separate file
|
|
||||||
# after configuring it below
|
|
||||||
|
|
||||||
# Detect if we can connect to syslog
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
if platform.system() != 'Windows':
|
|
||||||
try:
|
|
||||||
handler = SysLogHandler(
|
|
||||||
address='/dev/log', facility=SysLogHandler.LOG_LOCAL2
|
|
||||||
)
|
|
||||||
handler.close()
|
|
||||||
HAVE_SYSLOG = True
|
|
||||||
except IOError:
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
|
|
||||||
if DEBUG or not HAVE_SYSLOG:
|
|
||||||
DEFAULT_LOG = 'console'
|
|
||||||
else:
|
|
||||||
DEFAULT_LOG = 'syslog'
|
|
||||||
|
|
||||||
# A sample logging configuration. The only tangible logging
|
|
||||||
# performed by this configuration is to send an email to
|
|
||||||
# the site admins on every HTTP 500 error when DEBUG=False.
|
|
||||||
# See http://docs.djangoproject.com/en/stable/topics/logging for
|
|
||||||
# more details on how to customize your logging configuration.
|
|
||||||
LOGGING = {
|
|
||||||
'version': 1,
|
|
||||||
'disable_existing_loggers': True,
|
|
||||||
'filters': {
|
|
||||||
'require_debug_false': {
|
|
||||||
'()': 'django.utils.log.RequireDebugFalse'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'formatters': {
|
|
||||||
'syslog': {
|
|
||||||
'format': 'weblate[%(process)d]: %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'simple': {
|
|
||||||
'format': '%(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'logfile': {
|
|
||||||
'format': '%(asctime)s %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'()': 'django.utils.log.ServerFormatter',
|
|
||||||
'format': '[%(server_time)s] %(message)s',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'handlers': {
|
|
||||||
'mail_admins': {
|
|
||||||
'level': 'ERROR',
|
|
||||||
'filters': ['require_debug_false'],
|
|
||||||
'class': 'django.utils.log.AdminEmailHandler',
|
|
||||||
'include_html': True,
|
|
||||||
},
|
|
||||||
'console': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'simple'
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'level': 'INFO',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'django.server',
|
|
||||||
},
|
|
||||||
'syslog': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.handlers.SysLogHandler',
|
|
||||||
'formatter': 'syslog',
|
|
||||||
'address': '/dev/log',
|
|
||||||
'facility': SysLogHandler.LOG_LOCAL2,
|
|
||||||
},
|
|
||||||
# Logging to a file
|
|
||||||
# 'logfile': {
|
|
||||||
# 'level':'DEBUG',
|
|
||||||
# 'class':'logging.handlers.RotatingFileHandler',
|
|
||||||
# 'filename': "/var/log/weblate/weblate.log",
|
|
||||||
# 'maxBytes': 100000,
|
|
||||||
# 'backupCount': 3,
|
|
||||||
# 'formatter': 'logfile',
|
|
||||||
# },
|
|
||||||
},
|
|
||||||
'loggers': {
|
|
||||||
'django.request': {
|
|
||||||
'handlers': ['mail_admins', DEFAULT_LOG],
|
|
||||||
'level': 'ERROR',
|
|
||||||
'propagate': True,
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'handlers': ['django.server'],
|
|
||||||
'level': 'INFO',
|
|
||||||
'propagate': False,
|
|
||||||
},
|
|
||||||
# Logging database queries
|
|
||||||
# 'django.db.backends': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
'weblate': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'DEBUG',
|
|
||||||
},
|
|
||||||
# Logging search operations
|
|
||||||
'weblate.search': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'INFO',
|
|
||||||
},
|
|
||||||
# Logging VCS operations
|
|
||||||
'weblate.vcs': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'WARNING',
|
|
||||||
},
|
|
||||||
# Python Social Auth logging
|
|
||||||
# 'social': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Logging of management commands to console
|
|
||||||
if (os.environ.get('DJANGO_IS_MANAGEMENT_COMMAND', False) and
|
|
||||||
'console' not in LOGGING['loggers']['weblate']['handlers']):
|
|
||||||
LOGGING['loggers']['weblate']['handlers'].append('console')
|
|
||||||
|
|
||||||
# Remove syslog setup if it's not present
|
|
||||||
if not HAVE_SYSLOG:
|
|
||||||
del LOGGING['handlers']['syslog']
|
|
||||||
|
|
||||||
# List of machine translations
|
|
||||||
# MT_SERVICES = (
|
|
||||||
# 'weblate.machinery.apertium.ApertiumAPYTranslation',
|
|
||||||
# 'weblate.machinery.baidu.BaiduTranslation',
|
|
||||||
# 'weblate.machinery.deepl.DeepLTranslation',
|
|
||||||
# 'weblate.machinery.glosbe.GlosbeTranslation',
|
|
||||||
# 'weblate.machinery.google.GoogleTranslation',
|
|
||||||
# 'weblate.machinery.microsoft.MicrosoftCognitiveTranslation',
|
|
||||||
# 'weblate.machinery.microsoftterminology.MicrosoftTerminologyService',
|
|
||||||
# 'weblate.machinery.mymemory.MyMemoryTranslation',
|
|
||||||
# 'weblate.machinery.netease.NeteaseSightTranslation',
|
|
||||||
# 'weblate.machinery.tmserver.AmagamaTranslation',
|
|
||||||
# 'weblate.machinery.tmserver.TMServerTranslation',
|
|
||||||
# 'weblate.machinery.yandex.YandexTranslation',
|
|
||||||
# 'weblate.machinery.weblatetm.WeblateTranslation',
|
|
||||||
# 'weblate.machinery.saptranslationhub.SAPTranslationHub',
|
|
||||||
# 'weblate.machinery.youdao.YoudaoTranslation',
|
|
||||||
# 'weblate.memory.machine.WeblateMemory',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Machine translation API keys
|
|
||||||
|
|
||||||
# URL of the Apertium APy server
|
|
||||||
MT_APERTIUM_APY = None
|
|
||||||
|
|
||||||
# DeepL API key
|
|
||||||
MT_DEEPL_KEY = None
|
|
||||||
|
|
||||||
# Microsoft Cognitive Services Translator API, register at
|
|
||||||
# https://portal.azure.com/
|
|
||||||
MT_MICROSOFT_COGNITIVE_KEY = None
|
|
||||||
|
|
||||||
# MyMemory identification email, see
|
|
||||||
# https://mymemory.translated.net/doc/spec.php
|
|
||||||
MT_MYMEMORY_EMAIL = None
|
|
||||||
|
|
||||||
# Optional MyMemory credentials to access private translation memory
|
|
||||||
MT_MYMEMORY_USER = None
|
|
||||||
MT_MYMEMORY_KEY = None
|
|
||||||
|
|
||||||
# Google API key for Google Translate API
|
|
||||||
MT_GOOGLE_KEY = None
|
|
||||||
|
|
||||||
# Baidu app key and secret
|
|
||||||
MT_BAIDU_ID = None
|
|
||||||
MT_BAIDU_SECRET = None
|
|
||||||
|
|
||||||
# Youdao Zhiyun app key and secret
|
|
||||||
MT_YOUDAO_ID = None
|
|
||||||
MT_YOUDAO_SECRET = None
|
|
||||||
|
|
||||||
# Netease Sight (Jianwai) app key and secret
|
|
||||||
MT_NETEASE_KEY = None
|
|
||||||
MT_NETEASE_SECRET = None
|
|
||||||
|
|
||||||
# API key for Yandex Translate API
|
|
||||||
MT_YANDEX_KEY = None
|
|
||||||
|
|
||||||
# tmserver URL
|
|
||||||
MT_TMSERVER = None
|
|
||||||
|
|
||||||
# SAP Translation Hub
|
|
||||||
MT_SAP_BASE_URL = None
|
|
||||||
MT_SAP_SANDBOX_APIKEY = None
|
|
||||||
MT_SAP_USERNAME = None
|
|
||||||
MT_SAP_PASSWORD = None
|
|
||||||
MT_SAP_USE_MT = True
|
|
||||||
|
|
||||||
# Title of site to use
|
|
||||||
SITE_TITLE = 'Weblate'
|
|
||||||
|
|
||||||
# Whether site uses https
|
|
||||||
ENABLE_HTTPS = True
|
|
||||||
|
|
||||||
# Use HTTPS when creating redirect URLs for social authentication, see
|
|
||||||
# documentation for more details:
|
|
||||||
# https://python-social-auth-docs.readthedocs.io/en/latest/configuration/settings.html#processing-redirects-and-urlopen
|
|
||||||
SOCIAL_AUTH_REDIRECT_IS_HTTPS = ENABLE_HTTPS
|
|
||||||
|
|
||||||
# Make CSRF cookie HttpOnly, see documentation for more details:
|
|
||||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#csrf-cookie-httponly
|
|
||||||
CSRF_COOKIE_HTTPONLY = True
|
|
||||||
CSRF_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# Store CSRF token in session (since Django 1.11)
|
|
||||||
CSRF_USE_SESSIONS = True
|
|
||||||
SESSION_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# SSL redirect
|
|
||||||
SECURE_SSL_REDIRECT = ENABLE_HTTPS
|
|
||||||
# Session cookie age (in seconds)
|
|
||||||
SESSION_COOKIE_AGE = 1209600
|
|
||||||
|
|
||||||
# Some security headers
|
|
||||||
SECURE_BROWSER_XSS_FILTER = True
|
|
||||||
X_FRAME_OPTIONS = 'DENY'
|
|
||||||
SECURE_CONTENT_TYPE_NOSNIFF = True
|
|
||||||
|
|
||||||
# Optionally enable HSTS
|
|
||||||
SECURE_HSTS_SECONDS = 0
|
|
||||||
SECURE_HSTS_PRELOAD = False
|
|
||||||
SECURE_HSTS_INCLUDE_SUBDOMAINS = False
|
|
||||||
|
|
||||||
# URL of login
|
|
||||||
LOGIN_URL = '{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# URL of logout
|
|
||||||
LOGOUT_URL = '{0}/accounts/logout/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Default location for login
|
|
||||||
LOGIN_REDIRECT_URL = '{0}/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Anonymous user name
|
|
||||||
ANONYMOUS_USER_NAME = 'anonymous'
|
|
||||||
|
|
||||||
# Reverse proxy settings
|
|
||||||
IP_PROXY_HEADER = 'HTTP_X_FORWARDED_FOR'
|
|
||||||
IP_BEHIND_REVERSE_PROXY = False
|
|
||||||
IP_PROXY_OFFSET = 0
|
|
||||||
|
|
||||||
# Sending HTML in mails
|
|
||||||
EMAIL_SEND_HTML = True
|
|
||||||
|
|
||||||
# Subject of emails includes site title
|
|
||||||
EMAIL_SUBJECT_PREFIX = '[{0}] '.format(SITE_TITLE)
|
|
||||||
|
|
||||||
EMAIL_BACKEND = 'django_sendmail_backend.backends.EmailBackend'
|
|
||||||
|
|
||||||
# Enable remote hooks
|
|
||||||
ENABLE_HOOKS = True
|
|
||||||
|
|
||||||
# Number of nearby messages to show in each direction
|
|
||||||
NEARBY_MESSAGES = 5
|
|
||||||
|
|
||||||
# Use simple language codes for default language/country combinations
|
|
||||||
SIMPLIFY_LANGUAGES = True
|
|
||||||
|
|
||||||
# Render forms using bootstrap
|
|
||||||
CRISPY_TEMPLATE_PACK = 'bootstrap3'
|
|
||||||
|
|
||||||
# List of quality checks
|
|
||||||
# CHECK_LIST = (
|
|
||||||
# 'weblate.checks.same.SameCheck',
|
|
||||||
# 'weblate.checks.chars.BeginNewlineCheck',
|
|
||||||
# 'weblate.checks.chars.EndNewlineCheck',
|
|
||||||
# 'weblate.checks.chars.BeginSpaceCheck',
|
|
||||||
# 'weblate.checks.chars.EndSpaceCheck',
|
|
||||||
# 'weblate.checks.chars.EndStopCheck',
|
|
||||||
# 'weblate.checks.chars.EndColonCheck',
|
|
||||||
# 'weblate.checks.chars.EndQuestionCheck',
|
|
||||||
# 'weblate.checks.chars.EndExclamationCheck',
|
|
||||||
# 'weblate.checks.chars.EndEllipsisCheck',
|
|
||||||
# 'weblate.checks.chars.EndSemicolonCheck',
|
|
||||||
# 'weblate.checks.chars.MaxLengthCheck',
|
|
||||||
# 'weblate.checks.format.PythonFormatCheck',
|
|
||||||
# 'weblate.checks.format.PythonBraceFormatCheck',
|
|
||||||
# 'weblate.checks.format.PHPFormatCheck',
|
|
||||||
# 'weblate.checks.format.CFormatCheck',
|
|
||||||
# 'weblate.checks.format.PerlFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavascriptFormatCheck',
|
|
||||||
# 'weblate.checks.format.CSharpFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavaFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavaMessageFormatCheck',
|
|
||||||
# 'weblate.checks.angularjs.AngularJSInterpolationCheck',
|
|
||||||
# 'weblate.checks.consistency.PluralsCheck',
|
|
||||||
# 'weblate.checks.consistency.SamePluralsCheck',
|
|
||||||
# 'weblate.checks.consistency.ConsistencyCheck',
|
|
||||||
# 'weblate.checks.consistency.TranslatedCheck',
|
|
||||||
# 'weblate.checks.chars.NewlineCountingCheck',
|
|
||||||
# 'weblate.checks.markup.BBCodeCheck',
|
|
||||||
# 'weblate.checks.chars.ZeroWidthSpaceCheck',
|
|
||||||
# 'weblate.checks.markup.XMLValidityCheck',
|
|
||||||
# 'weblate.checks.markup.XMLTagsCheck',
|
|
||||||
# 'weblate.checks.source.OptionalPluralCheck',
|
|
||||||
# 'weblate.checks.source.EllipsisCheck',
|
|
||||||
# 'weblate.checks.source.MultipleFailingCheck',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of automatic fixups
|
|
||||||
# AUTOFIX_LIST = (
|
|
||||||
# 'weblate.trans.autofixes.whitespace.SameBookendingWhitespace',
|
|
||||||
# 'weblate.trans.autofixes.chars.ReplaceTrailingDotsWithEllipsis',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveZeroSpace',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveControlChars',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of enabled addons
|
|
||||||
# WEBLATE_ADDONS = (
|
|
||||||
# 'weblate.addons.gettext.GenerateMoAddon',
|
|
||||||
# 'weblate.addons.gettext.UpdateLinguasAddon',
|
|
||||||
# 'weblate.addons.gettext.UpdateConfigureAddon',
|
|
||||||
# 'weblate.addons.gettext.MsgmergeAddon',
|
|
||||||
# 'weblate.addons.gettext.GettextCustomizeAddon',
|
|
||||||
# 'weblate.addons.gettext.GettextAuthorComments',
|
|
||||||
# 'weblate.addons.cleanup.CleanupAddon',
|
|
||||||
# 'weblate.addons.consistency.LangaugeConsistencyAddon',
|
|
||||||
# 'weblate.addons.discovery.DiscoveryAddon',
|
|
||||||
# 'weblate.addons.flags.SourceEditAddon',
|
|
||||||
# 'weblate.addons.flags.TargetEditAddon',
|
|
||||||
# 'weblate.addons.generate.GenerateFileAddon',
|
|
||||||
# 'weblate.addons.json.JSONCustomizeAddon',
|
|
||||||
# 'weblate.addons.properties.PropertiesSortAddon',
|
|
||||||
# 'weblate.addons.git.GitSquashAddon',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# E-mail address that error messages come from.
|
|
||||||
SERVER_EMAIL = 'noreply@__DOMAIN__'
|
|
||||||
|
|
||||||
# Default email address to use for various automated correspondence from
|
|
||||||
# the site managers. Used for registration emails.
|
|
||||||
DEFAULT_FROM_EMAIL = '__ADMINMAIL__'
|
|
||||||
|
|
||||||
# List of URLs your site is supposed to serve
|
|
||||||
ALLOWED_HOSTS = ['__DOMAIN__']
|
|
||||||
|
|
||||||
CACHES = {
|
|
||||||
'default': {
|
|
||||||
'BACKEND': 'django_redis.cache.RedisCache',
|
|
||||||
'LOCATION': 'redis://127.0.0.1:6379/__REDIS_DB__',
|
|
||||||
'OPTIONS': {
|
|
||||||
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
|
||||||
'PARSER_CLASS': 'redis.connection.HiredisParser',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'avatar': {
|
|
||||||
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
|
||||||
'LOCATION': os.path.join(BASE_DIR, 'avatar-cache'),
|
|
||||||
'TIMEOUT': 3600,
|
|
||||||
'OPTIONS': {
|
|
||||||
'MAX_ENTRIES': 1000,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example configuration for caching
|
|
||||||
# CACHES = {
|
|
||||||
# Recommended redis + hiredis:
|
|
||||||
# 'default': {
|
|
||||||
# 'BACKEND': 'django_redis.cache.RedisCache',
|
|
||||||
# 'LOCATION': 'redis://127.0.0.1:6379/0',
|
|
||||||
# # If redis is running on same host as Weblate, you might
|
|
||||||
# # want to use unix sockets instead:
|
|
||||||
# # 'LOCATION': 'unix:///var/run/redis/redis.sock?db=0',
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
|
||||||
# 'PARSER_CLASS': 'redis.connection.HiredisParser',
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
# Memcached alternative:
|
|
||||||
# 'default': {
|
|
||||||
# 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
|
||||||
# 'LOCATION': '127.0.0.1:11211',
|
|
||||||
# },
|
|
||||||
# 'avatar': {
|
|
||||||
# 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
|
||||||
# 'LOCATION': os.path.join(DATA_DIR, 'avatar-cache'),
|
|
||||||
# 'TIMEOUT': 3600,
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'MAX_ENTRIES': 1000,
|
|
||||||
# },
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
|
|
||||||
# REST framework settings for API
|
|
||||||
REST_FRAMEWORK = {
|
|
||||||
# Use Django's standard `django.contrib.auth` permissions,
|
|
||||||
# or allow read-only access for unauthenticated users.
|
|
||||||
'DEFAULT_PERMISSION_CLASSES': [
|
|
||||||
'rest_framework.permissions.IsAuthenticatedOrReadOnly'
|
|
||||||
],
|
|
||||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
|
||||||
'rest_framework.authentication.TokenAuthentication',
|
|
||||||
'weblate.api.authentication.BearerAuthentication',
|
|
||||||
'rest_framework.authentication.SessionAuthentication',
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_CLASSES': (
|
|
||||||
'rest_framework.throttling.AnonRateThrottle',
|
|
||||||
'rest_framework.throttling.UserRateThrottle'
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_RATES': {
|
|
||||||
'anon': '100/day',
|
|
||||||
'user': '1000/day'
|
|
||||||
},
|
|
||||||
'DEFAULT_PAGINATION_CLASS': (
|
|
||||||
'rest_framework.pagination.PageNumberPagination'
|
|
||||||
),
|
|
||||||
'PAGE_SIZE': 20,
|
|
||||||
'VIEW_DESCRIPTION_FUNCTION': 'weblate.api.views.get_view_description',
|
|
||||||
'UNAUTHENTICATED_USER': 'weblate.auth.models.get_anonymous',
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example for restricting access to logged in users
|
|
||||||
# LOGIN_REQUIRED_URLS = (
|
|
||||||
# r'/(.*)$',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# In such case you will want to include some of the exceptions
|
|
||||||
# LOGIN_REQUIRED_URLS_EXCEPTIONS = (
|
|
||||||
# r'/accounts/(.*)$', # Required for login
|
|
||||||
# r'/admin/login/(.*)$', # Required for admin login
|
|
||||||
# r'/static/(.*)$', # Required for development mode
|
|
||||||
# r'/widgets/(.*)$', # Allowing public access to widgets
|
|
||||||
# r'/data/(.*)$', # Allowing public access to data exports
|
|
||||||
# r'/hooks/(.*)$', # Allowing public access to notification hooks
|
|
||||||
# r'/healthz/$', # Allowing public access to health check
|
|
||||||
# r'/api/(.*)$', # Allowing access to API
|
|
||||||
# r'/js/i18n/$', # Javascript localization
|
|
||||||
# r'/contact/$', # Optional for contact form
|
|
||||||
# r'/legal/(.*)$', # Optional for legal app
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Silence some of the Django system checks
|
|
||||||
SILENCED_SYSTEM_CHECKS = [
|
|
||||||
# We have modified django.contrib.auth.middleware.AuthenticationMiddleware
|
|
||||||
# as weblate.accounts.middleware.AuthenticationMiddleware
|
|
||||||
'admin.E408',
|
|
||||||
]
|
|
||||||
|
|
||||||
# Celery worker configuration for testing
|
|
||||||
# CELERY_TASK_ALWAYS_EAGER = True
|
|
||||||
# CELERY_BROKER_URL = 'memory://'
|
|
||||||
# CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
|
|
||||||
# Celery worker configuration for production
|
|
||||||
CELERY_TASK_ALWAYS_EAGER = False
|
|
||||||
CELERY_BROKER_URL = 'redis://127.0.0.1:6379/__REDIS_DB__'
|
|
||||||
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
|
|
||||||
|
|
||||||
# Celery settings, it is not recommended to change these
|
|
||||||
CELERY_WORKER_PREFETCH_MULTIPLIER = 0
|
|
||||||
CELERY_BEAT_SCHEDULE_FILENAME = os.path.join(
|
|
||||||
DATA_DIR, 'celery', 'beat-schedule'
|
|
||||||
)
|
|
||||||
|
|
||||||
CELERY_TASK_ROUTES = {
|
|
||||||
'weblate.trans.search.*': {'queue': 'search'},
|
|
||||||
'weblate.trans.tasks.optimize_fulltext': {'queue': 'search'},
|
|
||||||
'weblate.trans.tasks.cleanup_fulltext': {'queue': 'search'},
|
|
||||||
'weblate.memory.tasks.*': {'queue': 'memory'},
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,867 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# Copyright © 2012 - 2019 Michal Čihař <michal@cihar.com>
|
|
||||||
#
|
|
||||||
# This file is part of Weblate <https://weblate.org/>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import platform
|
|
||||||
import os
|
|
||||||
from logging.handlers import SysLogHandler
|
|
||||||
|
|
||||||
#
|
|
||||||
# Django settings for Weblate project.
|
|
||||||
#
|
|
||||||
|
|
||||||
DEBUG = False
|
|
||||||
|
|
||||||
ADMINS = (
|
|
||||||
('__ADMIN__', '__ADMINMAIL__'),
|
|
||||||
)
|
|
||||||
|
|
||||||
MANAGERS = ADMINS
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
# Database engine
|
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
||||||
# Database name
|
|
||||||
'NAME': '__NAME__',
|
|
||||||
# Database user
|
|
||||||
'USER': '__NAME__',
|
|
||||||
# Database password
|
|
||||||
'PASSWORD': '__DB_PWD__',
|
|
||||||
# Set to empty string for localhost
|
|
||||||
'HOST': 'localhost',
|
|
||||||
# Set to empty string for default
|
|
||||||
'PORT': '5432',
|
|
||||||
'OPTIONS': {
|
|
||||||
'sslmode': 'disable'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BASE_DIR = '__FINALPATH__'
|
|
||||||
|
|
||||||
# Data directory
|
|
||||||
DATA_DIR = os.path.join(BASE_DIR, 'data')
|
|
||||||
TTF_PATH = '__FINALPATH__/venv/lib/__PYTHONPATH__/site-packages/weblate/ttf/'
|
|
||||||
|
|
||||||
# Local time zone for this installation. Choices can be found here:
|
|
||||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
|
||||||
# although not all choices may be available on all operating systems.
|
|
||||||
# In a Windows environment this must be set to your system time zone.
|
|
||||||
TIME_ZONE = 'UTC'
|
|
||||||
|
|
||||||
# Language code for this installation. All choices can be found here:
|
|
||||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
|
||||||
|
|
||||||
LANGUAGES = (
|
|
||||||
('ar', 'العربية'),
|
|
||||||
('az', 'Azərbaycan'),
|
|
||||||
('be', 'Беларуская'),
|
|
||||||
('be@latin', 'Biełaruskaja'),
|
|
||||||
('bg', 'Български'),
|
|
||||||
('br', 'Brezhoneg'),
|
|
||||||
('ca', 'Català'),
|
|
||||||
('cs', 'Čeština'),
|
|
||||||
('da', 'Dansk'),
|
|
||||||
('de', 'Deutsch'),
|
|
||||||
('en', 'English'),
|
|
||||||
('en-gb', 'English (United Kingdom)'),
|
|
||||||
('el', 'Ελληνικά'),
|
|
||||||
('es', 'Español'),
|
|
||||||
('fi', 'Suomi'),
|
|
||||||
('fr', 'Français'),
|
|
||||||
('fy', 'Frysk'),
|
|
||||||
('gl', 'Galego'),
|
|
||||||
('he', 'עברית'),
|
|
||||||
('hu', 'Magyar'),
|
|
||||||
('id', 'Indonesia'),
|
|
||||||
('it', 'Italiano'),
|
|
||||||
('ja', '日本語'),
|
|
||||||
('ko', '한국어'),
|
|
||||||
('ksh', 'Kölsch'),
|
|
||||||
('nb', 'Norsk bokmål'),
|
|
||||||
('nl', 'Nederlands'),
|
|
||||||
('pl', 'Polski'),
|
|
||||||
('pt', 'Português'),
|
|
||||||
('pt-br', 'Português brasileiro'),
|
|
||||||
('ru', 'Русский'),
|
|
||||||
('sk', 'Slovenčina'),
|
|
||||||
('sl', 'Slovenščina'),
|
|
||||||
('sr', 'Српски'),
|
|
||||||
('sv', 'Svenska'),
|
|
||||||
('tr', 'Türkçe'),
|
|
||||||
('uk', 'Українська'),
|
|
||||||
('zh-hans', '简体字'),
|
|
||||||
('zh-hant', '正體字'),
|
|
||||||
)
|
|
||||||
|
|
||||||
SITE_ID = 1
|
|
||||||
|
|
||||||
# If you set this to False, Django will make some optimizations so as not
|
|
||||||
# to load the internationalization machinery.
|
|
||||||
USE_I18N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not format dates, numbers and
|
|
||||||
# calendars according to the current locale.
|
|
||||||
USE_L10N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not use timezone-aware datetimes.
|
|
||||||
USE_TZ = True
|
|
||||||
|
|
||||||
# URL prefix to use, please see documentation for more details
|
|
||||||
URL_PREFIX = '__PATHURL__'
|
|
||||||
|
|
||||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
|
||||||
# Example: "/home/media/media.lawrence.com/media/"
|
|
||||||
MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
|
|
||||||
|
|
||||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
|
||||||
# trailing slash.
|
|
||||||
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
|
||||||
MEDIA_URL = '{0}/media/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Absolute path to the directory static files should be collected to.
|
|
||||||
# Don't put anything in this directory yourself; store your static files
|
|
||||||
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
|
|
||||||
# Example: "/home/media/media.lawrence.com/static/"
|
|
||||||
STATIC_ROOT = os.path.join(DATA_DIR, 'static')
|
|
||||||
|
|
||||||
# URL prefix for static files.
|
|
||||||
# Example: "http://media.lawrence.com/static/"
|
|
||||||
STATIC_URL = '{0}/static/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Additional locations of static files
|
|
||||||
STATICFILES_DIRS = (
|
|
||||||
# Put strings here, like "/home/html/static" or "C:/www/django/static".
|
|
||||||
# Always use forward slashes, even on Windows.
|
|
||||||
# Don't forget to use absolute paths, not relative paths.
|
|
||||||
)
|
|
||||||
|
|
||||||
# List of finder classes that know how to find static files in
|
|
||||||
# various locations.
|
|
||||||
STATICFILES_FINDERS = (
|
|
||||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
|
||||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
|
||||||
'compressor.finders.CompressorFinder',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Make this unique, and don't share it with anybody.
|
|
||||||
# You can generate it using examples/generate-secret-key
|
|
||||||
SECRET_KEY = '__KEY__' # noqa
|
|
||||||
|
|
||||||
TEMPLATES = [
|
|
||||||
{
|
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
||||||
'DIRS': [
|
|
||||||
os.path.join(BASE_DIR, 'weblate', 'templates'),
|
|
||||||
],
|
|
||||||
'OPTIONS': {
|
|
||||||
'context_processors': [
|
|
||||||
'django.contrib.auth.context_processors.auth',
|
|
||||||
'django.template.context_processors.debug',
|
|
||||||
'django.template.context_processors.i18n',
|
|
||||||
'django.template.context_processors.request',
|
|
||||||
'django.template.context_processors.csrf',
|
|
||||||
'django.contrib.messages.context_processors.messages',
|
|
||||||
'weblate.trans.context_processors.weblate_context',
|
|
||||||
],
|
|
||||||
'loaders': [
|
|
||||||
('django.template.loaders.cached.Loader', [
|
|
||||||
'django.template.loaders.filesystem.Loader',
|
|
||||||
'django.template.loaders.app_directories.Loader',
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# GitHub username for sending pull requests.
|
|
||||||
# Please see the documentation for more details.
|
|
||||||
GITHUB_USERNAME = "__GITHUBUSER__"
|
|
||||||
|
|
||||||
# Authentication configuration
|
|
||||||
AUTHENTICATION_BACKENDS = (
|
|
||||||
'social_core.backends.email.EmailAuth',
|
|
||||||
# 'social_core.backends.google.GoogleOAuth2',
|
|
||||||
# 'social_core.backends.github.GithubOAuth2',
|
|
||||||
# 'social_core.backends.bitbucket.BitbucketOAuth',
|
|
||||||
'social_core.backends.suse.OpenSUSEOpenId',
|
|
||||||
'social_core.backends.ubuntu.UbuntuOpenId',
|
|
||||||
'social_core.backends.fedora.FedoraOpenId',
|
|
||||||
# 'social_core.backends.facebook.FacebookOAuth2',
|
|
||||||
'weblate.accounts.auth.WeblateUserBackend',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom user model
|
|
||||||
AUTH_USER_MODEL = 'weblate_auth.User'
|
|
||||||
|
|
||||||
# Social auth backends setup
|
|
||||||
SOCIAL_AUTH_GITHUB_KEY = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SECRET = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SCOPE = ['user:email']
|
|
||||||
|
|
||||||
SOCIAL_AUTH_BITBUCKET_KEY = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_SECRET = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_VERIFIED_EMAILS_ONLY = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_FACEBOOK_KEY = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SECRET = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email', 'public_profile']
|
|
||||||
SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {'fields': 'id,name,email'}
|
|
||||||
SOCIAL_AUTH_FACEBOOK_API_VERSION = '3.1'
|
|
||||||
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = ''
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = ''
|
|
||||||
|
|
||||||
# Social auth settings
|
|
||||||
SOCIAL_AUTH_PIPELINE = (
|
|
||||||
'social_core.pipeline.social_auth.social_details',
|
|
||||||
'social_core.pipeline.social_auth.social_uid',
|
|
||||||
'social_core.pipeline.social_auth.auth_allowed',
|
|
||||||
'social_core.pipeline.social_auth.social_user',
|
|
||||||
'weblate.accounts.pipeline.store_params',
|
|
||||||
'weblate.accounts.pipeline.verify_open',
|
|
||||||
'social_core.pipeline.user.get_username',
|
|
||||||
'weblate.accounts.pipeline.require_email',
|
|
||||||
'social_core.pipeline.mail.mail_validation',
|
|
||||||
'weblate.accounts.pipeline.revoke_mail_code',
|
|
||||||
'weblate.accounts.pipeline.ensure_valid',
|
|
||||||
'weblate.accounts.pipeline.remove_account',
|
|
||||||
'social_core.pipeline.social_auth.associate_by_email',
|
|
||||||
'weblate.accounts.pipeline.reauthenticate',
|
|
||||||
'weblate.accounts.pipeline.verify_username',
|
|
||||||
'social_core.pipeline.user.create_user',
|
|
||||||
'social_core.pipeline.social_auth.associate_user',
|
|
||||||
'social_core.pipeline.social_auth.load_extra_data',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
'weblate.accounts.pipeline.user_full_name',
|
|
||||||
'weblate.accounts.pipeline.store_email',
|
|
||||||
'weblate.accounts.pipeline.notify_connect',
|
|
||||||
'weblate.accounts.pipeline.password_reset',
|
|
||||||
)
|
|
||||||
SOCIAL_AUTH_DISCONNECT_PIPELINE = (
|
|
||||||
'social_core.pipeline.disconnect.allowed_to_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.get_entries',
|
|
||||||
'social_core.pipeline.disconnect.revoke_tokens',
|
|
||||||
'weblate.accounts.pipeline.cycle_session',
|
|
||||||
'weblate.accounts.pipeline.adjust_primary_mail',
|
|
||||||
'weblate.accounts.pipeline.notify_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.disconnect',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom authentication strategy
|
|
||||||
SOCIAL_AUTH_STRATEGY = 'weblate.accounts.strategy.WeblateStrategy'
|
|
||||||
|
|
||||||
# Raise exceptions so that we can handle them later
|
|
||||||
SOCIAL_AUTH_RAISE_EXCEPTIONS = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_FUNCTION = \
|
|
||||||
'weblate.accounts.pipeline.send_validation'
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_URL = \
|
|
||||||
'{0}/accounts/email-sent/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_LOGIN_ERROR_URL = \
|
|
||||||
'{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_EMAIL_FORM_URL = \
|
|
||||||
'{0}/accounts/email/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL = \
|
|
||||||
'{0}/accounts/profile/#auth'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_PROTECTED_USER_FIELDS = ('email',)
|
|
||||||
SOCIAL_AUTH_SLUGIFY_USERNAMES = True
|
|
||||||
SOCIAL_AUTH_SLUGIFY_FUNCTION = 'weblate.accounts.pipeline.slugify_username'
|
|
||||||
|
|
||||||
# Password validation configuration
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
||||||
'OPTIONS': {
|
|
||||||
'min_length': 6,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.CharsPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.PastPasswordsValidator',
|
|
||||||
},
|
|
||||||
# Optional password strength validation by django-zxcvbn-password
|
|
||||||
# {
|
|
||||||
# 'NAME': 'zxcvbn_password.ZXCVBNValidator',
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'min_score': 3,
|
|
||||||
# 'user_attributes': ('username', 'email', 'full_name')
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
]
|
|
||||||
|
|
||||||
# Allow new user registrations
|
|
||||||
REGISTRATION_OPEN = True
|
|
||||||
|
|
||||||
# Middleware
|
|
||||||
MIDDLEWARE = [
|
|
||||||
'weblate.middleware.ProxyMiddleware',
|
|
||||||
'django.middleware.security.SecurityMiddleware',
|
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
||||||
'django.middleware.common.CommonMiddleware',
|
|
||||||
'django.middleware.locale.LocaleMiddleware',
|
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
|
||||||
'weblate.accounts.middleware.AuthenticationMiddleware',
|
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
||||||
'social_django.middleware.SocialAuthExceptionMiddleware',
|
|
||||||
'weblate.accounts.middleware.RequireLoginMiddleware',
|
|
||||||
'weblate.middleware.SecurityMiddleware',
|
|
||||||
]
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'weblate.urls'
|
|
||||||
|
|
||||||
# Django and Weblate apps
|
|
||||||
INSTALLED_APPS = (
|
|
||||||
'django.contrib.auth',
|
|
||||||
'django.contrib.contenttypes',
|
|
||||||
'django.contrib.sessions',
|
|
||||||
'django.contrib.sites',
|
|
||||||
'django.contrib.messages',
|
|
||||||
'django.contrib.staticfiles',
|
|
||||||
'django.contrib.admin.apps.SimpleAdminConfig',
|
|
||||||
'django.contrib.admindocs',
|
|
||||||
'django.contrib.sitemaps',
|
|
||||||
'social_django',
|
|
||||||
'crispy_forms',
|
|
||||||
'compressor',
|
|
||||||
'rest_framework',
|
|
||||||
'rest_framework.authtoken',
|
|
||||||
'weblate.addons',
|
|
||||||
'weblate.auth',
|
|
||||||
'weblate.checks',
|
|
||||||
'weblate.formats',
|
|
||||||
'weblate.machinery',
|
|
||||||
'weblate.trans',
|
|
||||||
'weblate.lang',
|
|
||||||
'weblate.langdata',
|
|
||||||
'weblate.memory',
|
|
||||||
'weblate.screenshots',
|
|
||||||
'weblate.accounts',
|
|
||||||
'weblate.utils',
|
|
||||||
'weblate.vcs',
|
|
||||||
'weblate.wladmin',
|
|
||||||
'weblate',
|
|
||||||
|
|
||||||
# Optional: Git exporter
|
|
||||||
# 'weblate.gitexport',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Path to locales
|
|
||||||
LOCALE_PATHS = (os.path.join(BASE_DIR, 'weblate', 'locale'), )
|
|
||||||
|
|
||||||
# Custom exception reporter to include some details
|
|
||||||
DEFAULT_EXCEPTION_REPORTER_FILTER = \
|
|
||||||
'weblate.trans.debug.WeblateExceptionReporterFilter'
|
|
||||||
|
|
||||||
# Default logging of Weblate messages
|
|
||||||
# - to syslog in production (if available)
|
|
||||||
# - otherwise to console
|
|
||||||
# - you can also choose 'logfile' to log into separate file
|
|
||||||
# after configuring it below
|
|
||||||
|
|
||||||
# Detect if we can connect to syslog
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
if platform.system() != 'Windows':
|
|
||||||
try:
|
|
||||||
handler = SysLogHandler(
|
|
||||||
address='/dev/log', facility=SysLogHandler.LOG_LOCAL2
|
|
||||||
)
|
|
||||||
handler.close()
|
|
||||||
HAVE_SYSLOG = True
|
|
||||||
except IOError:
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
|
|
||||||
if DEBUG or not HAVE_SYSLOG:
|
|
||||||
DEFAULT_LOG = 'console'
|
|
||||||
else:
|
|
||||||
DEFAULT_LOG = 'syslog'
|
|
||||||
|
|
||||||
# A sample logging configuration. The only tangible logging
|
|
||||||
# performed by this configuration is to send an email to
|
|
||||||
# the site admins on every HTTP 500 error when DEBUG=False.
|
|
||||||
# See http://docs.djangoproject.com/en/stable/topics/logging for
|
|
||||||
# more details on how to customize your logging configuration.
|
|
||||||
LOGGING = {
|
|
||||||
'version': 1,
|
|
||||||
'disable_existing_loggers': True,
|
|
||||||
'filters': {
|
|
||||||
'require_debug_false': {
|
|
||||||
'()': 'django.utils.log.RequireDebugFalse'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'formatters': {
|
|
||||||
'syslog': {
|
|
||||||
'format': 'weblate[%(process)d]: %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'simple': {
|
|
||||||
'format': '%(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'logfile': {
|
|
||||||
'format': '%(asctime)s %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'()': 'django.utils.log.ServerFormatter',
|
|
||||||
'format': '[%(server_time)s] %(message)s',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'handlers': {
|
|
||||||
'mail_admins': {
|
|
||||||
'level': 'ERROR',
|
|
||||||
'filters': ['require_debug_false'],
|
|
||||||
'class': 'django.utils.log.AdminEmailHandler',
|
|
||||||
'include_html': True,
|
|
||||||
},
|
|
||||||
'console': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'simple'
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'level': 'INFO',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'django.server',
|
|
||||||
},
|
|
||||||
'syslog': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.handlers.SysLogHandler',
|
|
||||||
'formatter': 'syslog',
|
|
||||||
'address': '/dev/log',
|
|
||||||
'facility': SysLogHandler.LOG_LOCAL2,
|
|
||||||
},
|
|
||||||
# Logging to a file
|
|
||||||
# 'logfile': {
|
|
||||||
# 'level':'DEBUG',
|
|
||||||
# 'class':'logging.handlers.RotatingFileHandler',
|
|
||||||
# 'filename': "/var/log/weblate/weblate.log",
|
|
||||||
# 'maxBytes': 100000,
|
|
||||||
# 'backupCount': 3,
|
|
||||||
# 'formatter': 'logfile',
|
|
||||||
# },
|
|
||||||
},
|
|
||||||
'loggers': {
|
|
||||||
'django.request': {
|
|
||||||
'handlers': ['mail_admins', DEFAULT_LOG],
|
|
||||||
'level': 'ERROR',
|
|
||||||
'propagate': True,
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'handlers': ['django.server'],
|
|
||||||
'level': 'INFO',
|
|
||||||
'propagate': False,
|
|
||||||
},
|
|
||||||
# Logging database queries
|
|
||||||
# 'django.db.backends': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
'weblate': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'DEBUG',
|
|
||||||
},
|
|
||||||
# Logging search operations
|
|
||||||
'weblate.search': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'INFO',
|
|
||||||
},
|
|
||||||
# Logging VCS operations
|
|
||||||
'weblate.vcs': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'WARNING',
|
|
||||||
},
|
|
||||||
# Python Social Auth logging
|
|
||||||
# 'social': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Logging of management commands to console
|
|
||||||
if (os.environ.get('DJANGO_IS_MANAGEMENT_COMMAND', False) and
|
|
||||||
'console' not in LOGGING['loggers']['weblate']['handlers']):
|
|
||||||
LOGGING['loggers']['weblate']['handlers'].append('console')
|
|
||||||
|
|
||||||
# Remove syslog setup if it's not present
|
|
||||||
if not HAVE_SYSLOG:
|
|
||||||
del LOGGING['handlers']['syslog']
|
|
||||||
|
|
||||||
# List of machine translations
|
|
||||||
# MT_SERVICES = (
|
|
||||||
# 'weblate.machinery.apertium.ApertiumAPYTranslation',
|
|
||||||
# 'weblate.machinery.baidu.BaiduTranslation',
|
|
||||||
# 'weblate.machinery.deepl.DeepLTranslation',
|
|
||||||
# 'weblate.machinery.glosbe.GlosbeTranslation',
|
|
||||||
# 'weblate.machinery.google.GoogleTranslation',
|
|
||||||
# 'weblate.machinery.microsoft.MicrosoftCognitiveTranslation',
|
|
||||||
# 'weblate.machinery.microsoftterminology.MicrosoftTerminologyService',
|
|
||||||
# 'weblate.machinery.mymemory.MyMemoryTranslation',
|
|
||||||
# 'weblate.machinery.netease.NeteaseSightTranslation',
|
|
||||||
# 'weblate.machinery.tmserver.AmagamaTranslation',
|
|
||||||
# 'weblate.machinery.tmserver.TMServerTranslation',
|
|
||||||
# 'weblate.machinery.yandex.YandexTranslation',
|
|
||||||
# 'weblate.machinery.weblatetm.WeblateTranslation',
|
|
||||||
# 'weblate.machinery.saptranslationhub.SAPTranslationHub',
|
|
||||||
# 'weblate.machinery.youdao.YoudaoTranslation',
|
|
||||||
# 'weblate.memory.machine.WeblateMemory',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Machine translation API keys
|
|
||||||
|
|
||||||
# URL of the Apertium APy server
|
|
||||||
MT_APERTIUM_APY = None
|
|
||||||
|
|
||||||
# DeepL API key
|
|
||||||
MT_DEEPL_KEY = None
|
|
||||||
|
|
||||||
# Microsoft Cognitive Services Translator API, register at
|
|
||||||
# https://portal.azure.com/
|
|
||||||
MT_MICROSOFT_COGNITIVE_KEY = None
|
|
||||||
|
|
||||||
# MyMemory identification email, see
|
|
||||||
# https://mymemory.translated.net/doc/spec.php
|
|
||||||
MT_MYMEMORY_EMAIL = None
|
|
||||||
|
|
||||||
# Optional MyMemory credentials to access private translation memory
|
|
||||||
MT_MYMEMORY_USER = None
|
|
||||||
MT_MYMEMORY_KEY = None
|
|
||||||
|
|
||||||
# Google API key for Google Translate API
|
|
||||||
MT_GOOGLE_KEY = None
|
|
||||||
|
|
||||||
# Baidu app key and secret
|
|
||||||
MT_BAIDU_ID = None
|
|
||||||
MT_BAIDU_SECRET = None
|
|
||||||
|
|
||||||
# Youdao Zhiyun app key and secret
|
|
||||||
MT_YOUDAO_ID = None
|
|
||||||
MT_YOUDAO_SECRET = None
|
|
||||||
|
|
||||||
# Netease Sight (Jianwai) app key and secret
|
|
||||||
MT_NETEASE_KEY = None
|
|
||||||
MT_NETEASE_SECRET = None
|
|
||||||
|
|
||||||
# API key for Yandex Translate API
|
|
||||||
MT_YANDEX_KEY = None
|
|
||||||
|
|
||||||
# tmserver URL
|
|
||||||
MT_TMSERVER = None
|
|
||||||
|
|
||||||
# SAP Translation Hub
|
|
||||||
MT_SAP_BASE_URL = None
|
|
||||||
MT_SAP_SANDBOX_APIKEY = None
|
|
||||||
MT_SAP_USERNAME = None
|
|
||||||
MT_SAP_PASSWORD = None
|
|
||||||
MT_SAP_USE_MT = True
|
|
||||||
|
|
||||||
# Title of site to use
|
|
||||||
SITE_TITLE = 'Weblate'
|
|
||||||
|
|
||||||
# Whether site uses https
|
|
||||||
ENABLE_HTTPS = True
|
|
||||||
|
|
||||||
# Use HTTPS when creating redirect URLs for social authentication, see
|
|
||||||
# documentation for more details:
|
|
||||||
# https://python-social-auth-docs.readthedocs.io/en/latest/configuration/settings.html#processing-redirects-and-urlopen
|
|
||||||
SOCIAL_AUTH_REDIRECT_IS_HTTPS = ENABLE_HTTPS
|
|
||||||
|
|
||||||
# Make CSRF cookie HttpOnly, see documentation for more details:
|
|
||||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#csrf-cookie-httponly
|
|
||||||
CSRF_COOKIE_HTTPONLY = True
|
|
||||||
CSRF_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# Store CSRF token in session (since Django 1.11)
|
|
||||||
CSRF_USE_SESSIONS = True
|
|
||||||
SESSION_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# SSL redirect
|
|
||||||
SECURE_SSL_REDIRECT = ENABLE_HTTPS
|
|
||||||
# Session cookie age (in seconds)
|
|
||||||
SESSION_COOKIE_AGE = 1209600
|
|
||||||
|
|
||||||
# Some security headers
|
|
||||||
SECURE_BROWSER_XSS_FILTER = True
|
|
||||||
X_FRAME_OPTIONS = 'DENY'
|
|
||||||
SECURE_CONTENT_TYPE_NOSNIFF = True
|
|
||||||
|
|
||||||
# Optionally enable HSTS
|
|
||||||
SECURE_HSTS_SECONDS = 0
|
|
||||||
SECURE_HSTS_PRELOAD = False
|
|
||||||
SECURE_HSTS_INCLUDE_SUBDOMAINS = False
|
|
||||||
|
|
||||||
# URL of login
|
|
||||||
LOGIN_URL = '{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# URL of logout
|
|
||||||
LOGOUT_URL = '{0}/accounts/logout/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Default location for login
|
|
||||||
LOGIN_REDIRECT_URL = '{0}/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Anonymous user name
|
|
||||||
ANONYMOUS_USER_NAME = 'anonymous'
|
|
||||||
|
|
||||||
# Reverse proxy settings
|
|
||||||
IP_PROXY_HEADER = 'HTTP_X_FORWARDED_FOR'
|
|
||||||
IP_BEHIND_REVERSE_PROXY = False
|
|
||||||
IP_PROXY_OFFSET = 0
|
|
||||||
|
|
||||||
# Sending HTML in mails
|
|
||||||
EMAIL_SEND_HTML = True
|
|
||||||
|
|
||||||
# Subject of emails includes site title
|
|
||||||
EMAIL_SUBJECT_PREFIX = '[{0}] '.format(SITE_TITLE)
|
|
||||||
|
|
||||||
EMAIL_BACKEND = 'django_sendmail_backend.backends.EmailBackend'
|
|
||||||
|
|
||||||
# Enable remote hooks
|
|
||||||
ENABLE_HOOKS = True
|
|
||||||
|
|
||||||
# Number of nearby messages to show in each direction
|
|
||||||
NEARBY_MESSAGES = 5
|
|
||||||
|
|
||||||
# By default the length of a given translation is limited to the length of
|
|
||||||
# the source string * 10 characters. Set this option to False to allow longer
|
|
||||||
# translations (up to 10.000 characters)
|
|
||||||
LIMIT_TRANSLATION_LENGTH_BY_SOURCE_LENGTH = True
|
|
||||||
|
|
||||||
# Use simple language codes for default language/country combinations
|
|
||||||
SIMPLIFY_LANGUAGES = True
|
|
||||||
|
|
||||||
# Render forms using bootstrap
|
|
||||||
CRISPY_TEMPLATE_PACK = 'bootstrap3'
|
|
||||||
|
|
||||||
# List of quality checks
|
|
||||||
# CHECK_LIST = (
|
|
||||||
# 'weblate.checks.same.SameCheck',
|
|
||||||
# 'weblate.checks.chars.BeginNewlineCheck',
|
|
||||||
# 'weblate.checks.chars.EndNewlineCheck',
|
|
||||||
# 'weblate.checks.chars.BeginSpaceCheck',
|
|
||||||
# 'weblate.checks.chars.EndSpaceCheck',
|
|
||||||
# 'weblate.checks.chars.EndStopCheck',
|
|
||||||
# 'weblate.checks.chars.EndColonCheck',
|
|
||||||
# 'weblate.checks.chars.EndQuestionCheck',
|
|
||||||
# 'weblate.checks.chars.EndExclamationCheck',
|
|
||||||
# 'weblate.checks.chars.EndEllipsisCheck',
|
|
||||||
# 'weblate.checks.chars.EndSemicolonCheck',
|
|
||||||
# 'weblate.checks.chars.MaxLengthCheck',
|
|
||||||
# 'weblate.checks.chars.KashidaCheck',
|
|
||||||
# 'weblate.checks.format.PythonFormatCheck',
|
|
||||||
# 'weblate.checks.format.PythonBraceFormatCheck',
|
|
||||||
# 'weblate.checks.format.PHPFormatCheck',
|
|
||||||
# 'weblate.checks.format.CFormatCheck',
|
|
||||||
# 'weblate.checks.format.PerlFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavascriptFormatCheck',
|
|
||||||
# 'weblate.checks.format.CSharpFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavaFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavaMessageFormatCheck',
|
|
||||||
# 'weblate.checks.angularjs.AngularJSInterpolationCheck',
|
|
||||||
# 'weblate.checks.consistency.PluralsCheck',
|
|
||||||
# 'weblate.checks.consistency.SamePluralsCheck',
|
|
||||||
# 'weblate.checks.consistency.ConsistencyCheck',
|
|
||||||
# 'weblate.checks.consistency.TranslatedCheck',
|
|
||||||
# 'weblate.checks.chars.NewlineCountingCheck',
|
|
||||||
# 'weblate.checks.markup.BBCodeCheck',
|
|
||||||
# 'weblate.checks.chars.ZeroWidthSpaceCheck',
|
|
||||||
# 'weblate.checks.markup.XMLValidityCheck',
|
|
||||||
# 'weblate.checks.markup.XMLTagsCheck',
|
|
||||||
# 'weblate.checks.markup.MarkdownRefLinkCheck',
|
|
||||||
# 'weblate.checks.markup.MarkdownLinkCheck',
|
|
||||||
# 'weblate.checks.markup.MarkdownSyntaxCheck',
|
|
||||||
# 'weblate.checks.markup.URLCheck',
|
|
||||||
# 'weblate.checks.source.OptionalPluralCheck',
|
|
||||||
# 'weblate.checks.source.EllipsisCheck',
|
|
||||||
# 'weblate.checks.source.MultipleFailingCheck',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of automatic fixups
|
|
||||||
# AUTOFIX_LIST = (
|
|
||||||
# 'weblate.trans.autofixes.whitespace.SameBookendingWhitespace',
|
|
||||||
# 'weblate.trans.autofixes.chars.ReplaceTrailingDotsWithEllipsis',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveZeroSpace',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveControlChars',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of enabled addons
|
|
||||||
# WEBLATE_ADDONS = (
|
|
||||||
# 'weblate.addons.gettext.GenerateMoAddon',
|
|
||||||
# 'weblate.addons.gettext.UpdateLinguasAddon',
|
|
||||||
# 'weblate.addons.gettext.UpdateConfigureAddon',
|
|
||||||
# 'weblate.addons.gettext.MsgmergeAddon',
|
|
||||||
# 'weblate.addons.gettext.GettextCustomizeAddon',
|
|
||||||
# 'weblate.addons.gettext.GettextAuthorComments',
|
|
||||||
# 'weblate.addons.cleanup.CleanupAddon',
|
|
||||||
# 'weblate.addons.consistency.LangaugeConsistencyAddon',
|
|
||||||
# 'weblate.addons.discovery.DiscoveryAddon',
|
|
||||||
# 'weblate.addons.flags.SourceEditAddon',
|
|
||||||
# 'weblate.addons.flags.TargetEditAddon',
|
|
||||||
# 'weblate.addons.generate.GenerateFileAddon',
|
|
||||||
# 'weblate.addons.json.JSONCustomizeAddon',
|
|
||||||
# 'weblate.addons.properties.PropertiesSortAddon',
|
|
||||||
# 'weblate.addons.git.GitSquashAddon',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# E-mail address that error messages come from.
|
|
||||||
SERVER_EMAIL = 'noreply@__DOMAIN__'
|
|
||||||
|
|
||||||
# Default email address to use for various automated correspondence from
|
|
||||||
# the site managers. Used for registration emails.
|
|
||||||
DEFAULT_FROM_EMAIL = '__ADMINMAIL__'
|
|
||||||
|
|
||||||
# List of URLs your site is supposed to serve
|
|
||||||
ALLOWED_HOSTS = ['__DOMAIN__']
|
|
||||||
|
|
||||||
CACHES = {
|
|
||||||
'default': {
|
|
||||||
'BACKEND': 'django_redis.cache.RedisCache',
|
|
||||||
'LOCATION': 'redis://127.0.0.1:6379/__REDIS_DB__',
|
|
||||||
'OPTIONS': {
|
|
||||||
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
|
||||||
'PARSER_CLASS': 'redis.connection.HiredisParser',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'avatar': {
|
|
||||||
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
|
||||||
'LOCATION': os.path.join(BASE_DIR, 'avatar-cache'),
|
|
||||||
'TIMEOUT': 3600,
|
|
||||||
'OPTIONS': {
|
|
||||||
'MAX_ENTRIES': 1000,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example configuration for caching
|
|
||||||
# CACHES = {
|
|
||||||
# Recommended redis + hiredis:
|
|
||||||
# 'default': {
|
|
||||||
# 'BACKEND': 'django_redis.cache.RedisCache',
|
|
||||||
# 'LOCATION': 'redis://127.0.0.1:6379/0',
|
|
||||||
# # If redis is running on same host as Weblate, you might
|
|
||||||
# # want to use unix sockets instead:
|
|
||||||
# # 'LOCATION': 'unix:///var/run/redis/redis.sock?db=0',
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
|
||||||
# 'PARSER_CLASS': 'redis.connection.HiredisParser',
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
# Memcached alternative:
|
|
||||||
# 'default': {
|
|
||||||
# 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
|
||||||
# 'LOCATION': '127.0.0.1:11211',
|
|
||||||
# },
|
|
||||||
# 'avatar': {
|
|
||||||
# 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
|
||||||
# 'LOCATION': os.path.join(DATA_DIR, 'avatar-cache'),
|
|
||||||
# 'TIMEOUT': 3600,
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'MAX_ENTRIES': 1000,
|
|
||||||
# },
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
|
|
||||||
# REST framework settings for API
|
|
||||||
REST_FRAMEWORK = {
|
|
||||||
# Use Django's standard `django.contrib.auth` permissions,
|
|
||||||
# or allow read-only access for unauthenticated users.
|
|
||||||
'DEFAULT_PERMISSION_CLASSES': [
|
|
||||||
'rest_framework.permissions.IsAuthenticatedOrReadOnly'
|
|
||||||
],
|
|
||||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
|
||||||
'rest_framework.authentication.TokenAuthentication',
|
|
||||||
'weblate.api.authentication.BearerAuthentication',
|
|
||||||
'rest_framework.authentication.SessionAuthentication',
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_CLASSES': (
|
|
||||||
'rest_framework.throttling.AnonRateThrottle',
|
|
||||||
'rest_framework.throttling.UserRateThrottle'
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_RATES': {
|
|
||||||
'anon': '100/day',
|
|
||||||
'user': '1000/day'
|
|
||||||
},
|
|
||||||
'DEFAULT_PAGINATION_CLASS': (
|
|
||||||
'rest_framework.pagination.PageNumberPagination'
|
|
||||||
),
|
|
||||||
'PAGE_SIZE': 20,
|
|
||||||
'VIEW_DESCRIPTION_FUNCTION': 'weblate.api.views.get_view_description',
|
|
||||||
'UNAUTHENTICATED_USER': 'weblate.auth.models.get_anonymous',
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example for restricting access to logged in users
|
|
||||||
# LOGIN_REQUIRED_URLS = (
|
|
||||||
# r'/(.*)$',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# In such case you will want to include some of the exceptions
|
|
||||||
# LOGIN_REQUIRED_URLS_EXCEPTIONS = (
|
|
||||||
# r'/accounts/(.*)$', # Required for login
|
|
||||||
# r'/admin/login/(.*)$', # Required for admin login
|
|
||||||
# r'/static/(.*)$', # Required for development mode
|
|
||||||
# r'/widgets/(.*)$', # Allowing public access to widgets
|
|
||||||
# r'/data/(.*)$', # Allowing public access to data exports
|
|
||||||
# r'/hooks/(.*)$', # Allowing public access to notification hooks
|
|
||||||
# r'/healthz/$', # Allowing public access to health check
|
|
||||||
# r'/api/(.*)$', # Allowing access to API
|
|
||||||
# r'/js/i18n/$', # Javascript localization
|
|
||||||
# r'/contact/$', # Optional for contact form
|
|
||||||
# r'/legal/(.*)$', # Optional for legal app
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Silence some of the Django system checks
|
|
||||||
SILENCED_SYSTEM_CHECKS = [
|
|
||||||
# We have modified django.contrib.auth.middleware.AuthenticationMiddleware
|
|
||||||
# as weblate.accounts.middleware.AuthenticationMiddleware
|
|
||||||
'admin.E408',
|
|
||||||
]
|
|
||||||
|
|
||||||
# Celery worker configuration for testing
|
|
||||||
# CELERY_TASK_ALWAYS_EAGER = True
|
|
||||||
# CELERY_BROKER_URL = 'memory://'
|
|
||||||
# CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
|
|
||||||
# Celery worker configuration for production
|
|
||||||
CELERY_TASK_ALWAYS_EAGER = False
|
|
||||||
CELERY_BROKER_URL = 'redis://127.0.0.1:6379/__REDIS_DB__'
|
|
||||||
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
|
|
||||||
|
|
||||||
# Celery settings, it is not recommended to change these
|
|
||||||
CELERY_WORKER_PREFETCH_MULTIPLIER = 0
|
|
||||||
CELERY_WORKER_MAX_MEMORY_PER_CHILD = 200000
|
|
||||||
CELERY_BEAT_SCHEDULE_FILENAME = os.path.join(
|
|
||||||
DATA_DIR, 'celery', 'beat-schedule'
|
|
||||||
)
|
|
||||||
CELERY_TASK_ROUTES = {
|
|
||||||
'weblate.trans.search.*': {'queue': 'search'},
|
|
||||||
'weblate.trans.tasks.optimize_fulltext': {'queue': 'search'},
|
|
||||||
'weblate.trans.tasks.cleanup_fulltext': {'queue': 'search'},
|
|
||||||
'weblate.memory.tasks.*': {'queue': 'memory'},
|
|
||||||
}
|
|
|
@ -1,867 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# Copyright © 2012 - 2019 Michal Čihař <michal@cihar.com>
|
|
||||||
#
|
|
||||||
# This file is part of Weblate <https://weblate.org/>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import platform
|
|
||||||
import os
|
|
||||||
from logging.handlers import SysLogHandler
|
|
||||||
|
|
||||||
#
|
|
||||||
# Django settings for Weblate project.
|
|
||||||
#
|
|
||||||
|
|
||||||
DEBUG = False
|
|
||||||
|
|
||||||
ADMINS = (
|
|
||||||
('__ADMIN__', '__ADMINMAIL__'),
|
|
||||||
)
|
|
||||||
|
|
||||||
MANAGERS = ADMINS
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
# Database engine
|
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
||||||
# Database name
|
|
||||||
'NAME': '__NAME__',
|
|
||||||
# Database user
|
|
||||||
'USER': '__NAME__',
|
|
||||||
# Database password
|
|
||||||
'PASSWORD': '__DB_PWD__',
|
|
||||||
# Set to empty string for localhost
|
|
||||||
'HOST': 'localhost',
|
|
||||||
# Set to empty string for default
|
|
||||||
'PORT': '5432',
|
|
||||||
'OPTIONS': {
|
|
||||||
'sslmode': 'disable'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BASE_DIR = '__FINALPATH__'
|
|
||||||
|
|
||||||
# Data directory
|
|
||||||
DATA_DIR = os.path.join(BASE_DIR, 'data')
|
|
||||||
TTF_PATH = '__FINALPATH__/venv/lib/__PYTHONPATH__/site-packages/weblate/ttf/'
|
|
||||||
|
|
||||||
# Local time zone for this installation. Choices can be found here:
|
|
||||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
|
||||||
# although not all choices may be available on all operating systems.
|
|
||||||
# In a Windows environment this must be set to your system time zone.
|
|
||||||
TIME_ZONE = 'UTC'
|
|
||||||
|
|
||||||
# Language code for this installation. All choices can be found here:
|
|
||||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
|
||||||
|
|
||||||
LANGUAGES = (
|
|
||||||
('ar', 'العربية'),
|
|
||||||
('az', 'Azərbaycan'),
|
|
||||||
('be', 'Беларуская'),
|
|
||||||
('be@latin', 'Biełaruskaja'),
|
|
||||||
('bg', 'Български'),
|
|
||||||
('br', 'Brezhoneg'),
|
|
||||||
('ca', 'Català'),
|
|
||||||
('cs', 'Čeština'),
|
|
||||||
('da', 'Dansk'),
|
|
||||||
('de', 'Deutsch'),
|
|
||||||
('en', 'English'),
|
|
||||||
('en-gb', 'English (United Kingdom)'),
|
|
||||||
('el', 'Ελληνικά'),
|
|
||||||
('es', 'Español'),
|
|
||||||
('fi', 'Suomi'),
|
|
||||||
('fr', 'Français'),
|
|
||||||
('fy', 'Frysk'),
|
|
||||||
('gl', 'Galego'),
|
|
||||||
('he', 'עברית'),
|
|
||||||
('hu', 'Magyar'),
|
|
||||||
('id', 'Indonesia'),
|
|
||||||
('it', 'Italiano'),
|
|
||||||
('ja', '日本語'),
|
|
||||||
('ko', '한국어'),
|
|
||||||
('ksh', 'Kölsch'),
|
|
||||||
('nb', 'Norsk bokmål'),
|
|
||||||
('nl', 'Nederlands'),
|
|
||||||
('pl', 'Polski'),
|
|
||||||
('pt', 'Português'),
|
|
||||||
('pt-br', 'Português brasileiro'),
|
|
||||||
('ru', 'Русский'),
|
|
||||||
('sk', 'Slovenčina'),
|
|
||||||
('sl', 'Slovenščina'),
|
|
||||||
('sr', 'Српски'),
|
|
||||||
('sv', 'Svenska'),
|
|
||||||
('tr', 'Türkçe'),
|
|
||||||
('uk', 'Українська'),
|
|
||||||
('zh-hans', '简体字'),
|
|
||||||
('zh-hant', '正體字'),
|
|
||||||
)
|
|
||||||
|
|
||||||
SITE_ID = 1
|
|
||||||
|
|
||||||
# If you set this to False, Django will make some optimizations so as not
|
|
||||||
# to load the internationalization machinery.
|
|
||||||
USE_I18N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not format dates, numbers and
|
|
||||||
# calendars according to the current locale.
|
|
||||||
USE_L10N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not use timezone-aware datetimes.
|
|
||||||
USE_TZ = True
|
|
||||||
|
|
||||||
# URL prefix to use, please see documentation for more details
|
|
||||||
URL_PREFIX = '__PATHURL__'
|
|
||||||
|
|
||||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
|
||||||
# Example: "/home/media/media.lawrence.com/media/"
|
|
||||||
MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
|
|
||||||
|
|
||||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
|
||||||
# trailing slash.
|
|
||||||
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
|
||||||
MEDIA_URL = '{0}/media/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Absolute path to the directory static files should be collected to.
|
|
||||||
# Don't put anything in this directory yourself; store your static files
|
|
||||||
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
|
|
||||||
# Example: "/home/media/media.lawrence.com/static/"
|
|
||||||
STATIC_ROOT = os.path.join(DATA_DIR, 'static')
|
|
||||||
|
|
||||||
# URL prefix for static files.
|
|
||||||
# Example: "http://media.lawrence.com/static/"
|
|
||||||
STATIC_URL = '{0}/static/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Additional locations of static files
|
|
||||||
STATICFILES_DIRS = (
|
|
||||||
# Put strings here, like "/home/html/static" or "C:/www/django/static".
|
|
||||||
# Always use forward slashes, even on Windows.
|
|
||||||
# Don't forget to use absolute paths, not relative paths.
|
|
||||||
)
|
|
||||||
|
|
||||||
# List of finder classes that know how to find static files in
|
|
||||||
# various locations.
|
|
||||||
STATICFILES_FINDERS = (
|
|
||||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
|
||||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
|
||||||
'compressor.finders.CompressorFinder',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Make this unique, and don't share it with anybody.
|
|
||||||
# You can generate it using examples/generate-secret-key
|
|
||||||
SECRET_KEY = '__KEY__' # noqa
|
|
||||||
|
|
||||||
TEMPLATES = [
|
|
||||||
{
|
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
||||||
'DIRS': [
|
|
||||||
os.path.join(BASE_DIR, 'weblate', 'templates'),
|
|
||||||
],
|
|
||||||
'OPTIONS': {
|
|
||||||
'context_processors': [
|
|
||||||
'django.contrib.auth.context_processors.auth',
|
|
||||||
'django.template.context_processors.debug',
|
|
||||||
'django.template.context_processors.i18n',
|
|
||||||
'django.template.context_processors.request',
|
|
||||||
'django.template.context_processors.csrf',
|
|
||||||
'django.contrib.messages.context_processors.messages',
|
|
||||||
'weblate.trans.context_processors.weblate_context',
|
|
||||||
],
|
|
||||||
'loaders': [
|
|
||||||
('django.template.loaders.cached.Loader', [
|
|
||||||
'django.template.loaders.filesystem.Loader',
|
|
||||||
'django.template.loaders.app_directories.Loader',
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# GitHub username for sending pull requests.
|
|
||||||
# Please see the documentation for more details.
|
|
||||||
GITHUB_USERNAME = "__GITHUBUSER__"
|
|
||||||
|
|
||||||
# Authentication configuration
|
|
||||||
AUTHENTICATION_BACKENDS = (
|
|
||||||
'social_core.backends.email.EmailAuth',
|
|
||||||
# 'social_core.backends.google.GoogleOAuth2',
|
|
||||||
# 'social_core.backends.github.GithubOAuth2',
|
|
||||||
# 'social_core.backends.bitbucket.BitbucketOAuth',
|
|
||||||
'social_core.backends.suse.OpenSUSEOpenId',
|
|
||||||
'social_core.backends.ubuntu.UbuntuOpenId',
|
|
||||||
'social_core.backends.fedora.FedoraOpenId',
|
|
||||||
# 'social_core.backends.facebook.FacebookOAuth2',
|
|
||||||
'weblate.accounts.auth.WeblateUserBackend',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom user model
|
|
||||||
AUTH_USER_MODEL = 'weblate_auth.User'
|
|
||||||
|
|
||||||
# Social auth backends setup
|
|
||||||
SOCIAL_AUTH_GITHUB_KEY = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SECRET = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SCOPE = ['user:email']
|
|
||||||
|
|
||||||
SOCIAL_AUTH_BITBUCKET_KEY = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_SECRET = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_VERIFIED_EMAILS_ONLY = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_FACEBOOK_KEY = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SECRET = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email', 'public_profile']
|
|
||||||
SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {'fields': 'id,name,email'}
|
|
||||||
SOCIAL_AUTH_FACEBOOK_API_VERSION = '3.1'
|
|
||||||
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = ''
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = ''
|
|
||||||
|
|
||||||
# Social auth settings
|
|
||||||
SOCIAL_AUTH_PIPELINE = (
|
|
||||||
'social_core.pipeline.social_auth.social_details',
|
|
||||||
'social_core.pipeline.social_auth.social_uid',
|
|
||||||
'social_core.pipeline.social_auth.auth_allowed',
|
|
||||||
'social_core.pipeline.social_auth.social_user',
|
|
||||||
'weblate.accounts.pipeline.store_params',
|
|
||||||
'weblate.accounts.pipeline.verify_open',
|
|
||||||
'social_core.pipeline.user.get_username',
|
|
||||||
'weblate.accounts.pipeline.require_email',
|
|
||||||
'social_core.pipeline.mail.mail_validation',
|
|
||||||
'weblate.accounts.pipeline.revoke_mail_code',
|
|
||||||
'weblate.accounts.pipeline.ensure_valid',
|
|
||||||
'weblate.accounts.pipeline.remove_account',
|
|
||||||
'social_core.pipeline.social_auth.associate_by_email',
|
|
||||||
'weblate.accounts.pipeline.reauthenticate',
|
|
||||||
'weblate.accounts.pipeline.verify_username',
|
|
||||||
'social_core.pipeline.user.create_user',
|
|
||||||
'social_core.pipeline.social_auth.associate_user',
|
|
||||||
'social_core.pipeline.social_auth.load_extra_data',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
'weblate.accounts.pipeline.user_full_name',
|
|
||||||
'weblate.accounts.pipeline.store_email',
|
|
||||||
'weblate.accounts.pipeline.notify_connect',
|
|
||||||
'weblate.accounts.pipeline.password_reset',
|
|
||||||
)
|
|
||||||
SOCIAL_AUTH_DISCONNECT_PIPELINE = (
|
|
||||||
'social_core.pipeline.disconnect.allowed_to_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.get_entries',
|
|
||||||
'social_core.pipeline.disconnect.revoke_tokens',
|
|
||||||
'weblate.accounts.pipeline.cycle_session',
|
|
||||||
'weblate.accounts.pipeline.adjust_primary_mail',
|
|
||||||
'weblate.accounts.pipeline.notify_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.disconnect',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom authentication strategy
|
|
||||||
SOCIAL_AUTH_STRATEGY = 'weblate.accounts.strategy.WeblateStrategy'
|
|
||||||
|
|
||||||
# Raise exceptions so that we can handle them later
|
|
||||||
SOCIAL_AUTH_RAISE_EXCEPTIONS = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_FUNCTION = \
|
|
||||||
'weblate.accounts.pipeline.send_validation'
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_URL = \
|
|
||||||
'{0}/accounts/email-sent/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_LOGIN_ERROR_URL = \
|
|
||||||
'{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_EMAIL_FORM_URL = \
|
|
||||||
'{0}/accounts/email/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL = \
|
|
||||||
'{0}/accounts/profile/#auth'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_PROTECTED_USER_FIELDS = ('email',)
|
|
||||||
SOCIAL_AUTH_SLUGIFY_USERNAMES = True
|
|
||||||
SOCIAL_AUTH_SLUGIFY_FUNCTION = 'weblate.accounts.pipeline.slugify_username'
|
|
||||||
|
|
||||||
# Password validation configuration
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
||||||
'OPTIONS': {
|
|
||||||
'min_length': 6,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.CharsPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.PastPasswordsValidator',
|
|
||||||
},
|
|
||||||
# Optional password strength validation by django-zxcvbn-password
|
|
||||||
# {
|
|
||||||
# 'NAME': 'zxcvbn_password.ZXCVBNValidator',
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'min_score': 3,
|
|
||||||
# 'user_attributes': ('username', 'email', 'full_name')
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
]
|
|
||||||
|
|
||||||
# Allow new user registrations
|
|
||||||
REGISTRATION_OPEN = True
|
|
||||||
|
|
||||||
# Middleware
|
|
||||||
MIDDLEWARE = [
|
|
||||||
'weblate.middleware.ProxyMiddleware',
|
|
||||||
'django.middleware.security.SecurityMiddleware',
|
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
||||||
'django.middleware.common.CommonMiddleware',
|
|
||||||
'django.middleware.locale.LocaleMiddleware',
|
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
|
||||||
'weblate.accounts.middleware.AuthenticationMiddleware',
|
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
||||||
'social_django.middleware.SocialAuthExceptionMiddleware',
|
|
||||||
'weblate.accounts.middleware.RequireLoginMiddleware',
|
|
||||||
'weblate.middleware.SecurityMiddleware',
|
|
||||||
]
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'weblate.urls'
|
|
||||||
|
|
||||||
# Django and Weblate apps
|
|
||||||
INSTALLED_APPS = (
|
|
||||||
'django.contrib.auth',
|
|
||||||
'django.contrib.contenttypes',
|
|
||||||
'django.contrib.sessions',
|
|
||||||
'django.contrib.sites',
|
|
||||||
'django.contrib.messages',
|
|
||||||
'django.contrib.staticfiles',
|
|
||||||
'django.contrib.admin.apps.SimpleAdminConfig',
|
|
||||||
'django.contrib.admindocs',
|
|
||||||
'django.contrib.sitemaps',
|
|
||||||
'social_django',
|
|
||||||
'crispy_forms',
|
|
||||||
'compressor',
|
|
||||||
'rest_framework',
|
|
||||||
'rest_framework.authtoken',
|
|
||||||
'weblate.addons',
|
|
||||||
'weblate.auth',
|
|
||||||
'weblate.checks',
|
|
||||||
'weblate.formats',
|
|
||||||
'weblate.machinery',
|
|
||||||
'weblate.trans',
|
|
||||||
'weblate.lang',
|
|
||||||
'weblate.langdata',
|
|
||||||
'weblate.memory',
|
|
||||||
'weblate.screenshots',
|
|
||||||
'weblate.accounts',
|
|
||||||
'weblate.utils',
|
|
||||||
'weblate.vcs',
|
|
||||||
'weblate.wladmin',
|
|
||||||
'weblate',
|
|
||||||
|
|
||||||
# Optional: Git exporter
|
|
||||||
# 'weblate.gitexport',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Path to locales
|
|
||||||
LOCALE_PATHS = (os.path.join(BASE_DIR, 'weblate', 'locale'), )
|
|
||||||
|
|
||||||
# Custom exception reporter to include some details
|
|
||||||
DEFAULT_EXCEPTION_REPORTER_FILTER = \
|
|
||||||
'weblate.trans.debug.WeblateExceptionReporterFilter'
|
|
||||||
|
|
||||||
# Default logging of Weblate messages
|
|
||||||
# - to syslog in production (if available)
|
|
||||||
# - otherwise to console
|
|
||||||
# - you can also choose 'logfile' to log into separate file
|
|
||||||
# after configuring it below
|
|
||||||
|
|
||||||
# Detect if we can connect to syslog
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
if platform.system() != 'Windows':
|
|
||||||
try:
|
|
||||||
handler = SysLogHandler(
|
|
||||||
address='/dev/log', facility=SysLogHandler.LOG_LOCAL2
|
|
||||||
)
|
|
||||||
handler.close()
|
|
||||||
HAVE_SYSLOG = True
|
|
||||||
except IOError:
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
|
|
||||||
if DEBUG or not HAVE_SYSLOG:
|
|
||||||
DEFAULT_LOG = 'console'
|
|
||||||
else:
|
|
||||||
DEFAULT_LOG = 'syslog'
|
|
||||||
|
|
||||||
# A sample logging configuration. The only tangible logging
|
|
||||||
# performed by this configuration is to send an email to
|
|
||||||
# the site admins on every HTTP 500 error when DEBUG=False.
|
|
||||||
# See http://docs.djangoproject.com/en/stable/topics/logging for
|
|
||||||
# more details on how to customize your logging configuration.
|
|
||||||
LOGGING = {
|
|
||||||
'version': 1,
|
|
||||||
'disable_existing_loggers': True,
|
|
||||||
'filters': {
|
|
||||||
'require_debug_false': {
|
|
||||||
'()': 'django.utils.log.RequireDebugFalse'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'formatters': {
|
|
||||||
'syslog': {
|
|
||||||
'format': 'weblate[%(process)d]: %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'simple': {
|
|
||||||
'format': '%(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'logfile': {
|
|
||||||
'format': '%(asctime)s %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'()': 'django.utils.log.ServerFormatter',
|
|
||||||
'format': '[%(server_time)s] %(message)s',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'handlers': {
|
|
||||||
'mail_admins': {
|
|
||||||
'level': 'ERROR',
|
|
||||||
'filters': ['require_debug_false'],
|
|
||||||
'class': 'django.utils.log.AdminEmailHandler',
|
|
||||||
'include_html': True,
|
|
||||||
},
|
|
||||||
'console': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'simple'
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'level': 'INFO',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'django.server',
|
|
||||||
},
|
|
||||||
'syslog': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.handlers.SysLogHandler',
|
|
||||||
'formatter': 'syslog',
|
|
||||||
'address': '/dev/log',
|
|
||||||
'facility': SysLogHandler.LOG_LOCAL2,
|
|
||||||
},
|
|
||||||
# Logging to a file
|
|
||||||
# 'logfile': {
|
|
||||||
# 'level':'DEBUG',
|
|
||||||
# 'class':'logging.handlers.RotatingFileHandler',
|
|
||||||
# 'filename': "/var/log/weblate/weblate.log",
|
|
||||||
# 'maxBytes': 100000,
|
|
||||||
# 'backupCount': 3,
|
|
||||||
# 'formatter': 'logfile',
|
|
||||||
# },
|
|
||||||
},
|
|
||||||
'loggers': {
|
|
||||||
'django.request': {
|
|
||||||
'handlers': ['mail_admins', DEFAULT_LOG],
|
|
||||||
'level': 'ERROR',
|
|
||||||
'propagate': True,
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'handlers': ['django.server'],
|
|
||||||
'level': 'INFO',
|
|
||||||
'propagate': False,
|
|
||||||
},
|
|
||||||
# Logging database queries
|
|
||||||
# 'django.db.backends': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
'weblate': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'DEBUG',
|
|
||||||
},
|
|
||||||
# Logging search operations
|
|
||||||
'weblate.search': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'INFO',
|
|
||||||
},
|
|
||||||
# Logging VCS operations
|
|
||||||
'weblate.vcs': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'WARNING',
|
|
||||||
},
|
|
||||||
# Python Social Auth logging
|
|
||||||
# 'social': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Logging of management commands to console
|
|
||||||
if (os.environ.get('DJANGO_IS_MANAGEMENT_COMMAND', False) and
|
|
||||||
'console' not in LOGGING['loggers']['weblate']['handlers']):
|
|
||||||
LOGGING['loggers']['weblate']['handlers'].append('console')
|
|
||||||
|
|
||||||
# Remove syslog setup if it's not present
|
|
||||||
if not HAVE_SYSLOG:
|
|
||||||
del LOGGING['handlers']['syslog']
|
|
||||||
|
|
||||||
# List of machine translations
|
|
||||||
# MT_SERVICES = (
|
|
||||||
# 'weblate.machinery.apertium.ApertiumAPYTranslation',
|
|
||||||
# 'weblate.machinery.baidu.BaiduTranslation',
|
|
||||||
# 'weblate.machinery.deepl.DeepLTranslation',
|
|
||||||
# 'weblate.machinery.glosbe.GlosbeTranslation',
|
|
||||||
# 'weblate.machinery.google.GoogleTranslation',
|
|
||||||
# 'weblate.machinery.microsoft.MicrosoftCognitiveTranslation',
|
|
||||||
# 'weblate.machinery.microsoftterminology.MicrosoftTerminologyService',
|
|
||||||
# 'weblate.machinery.mymemory.MyMemoryTranslation',
|
|
||||||
# 'weblate.machinery.netease.NeteaseSightTranslation',
|
|
||||||
# 'weblate.machinery.tmserver.AmagamaTranslation',
|
|
||||||
# 'weblate.machinery.tmserver.TMServerTranslation',
|
|
||||||
# 'weblate.machinery.yandex.YandexTranslation',
|
|
||||||
# 'weblate.machinery.weblatetm.WeblateTranslation',
|
|
||||||
# 'weblate.machinery.saptranslationhub.SAPTranslationHub',
|
|
||||||
# 'weblate.machinery.youdao.YoudaoTranslation',
|
|
||||||
# 'weblate.memory.machine.WeblateMemory',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Machine translation API keys
|
|
||||||
|
|
||||||
# URL of the Apertium APy server
|
|
||||||
MT_APERTIUM_APY = None
|
|
||||||
|
|
||||||
# DeepL API key
|
|
||||||
MT_DEEPL_KEY = None
|
|
||||||
|
|
||||||
# Microsoft Cognitive Services Translator API, register at
|
|
||||||
# https://portal.azure.com/
|
|
||||||
MT_MICROSOFT_COGNITIVE_KEY = None
|
|
||||||
|
|
||||||
# MyMemory identification email, see
|
|
||||||
# https://mymemory.translated.net/doc/spec.php
|
|
||||||
MT_MYMEMORY_EMAIL = None
|
|
||||||
|
|
||||||
# Optional MyMemory credentials to access private translation memory
|
|
||||||
MT_MYMEMORY_USER = None
|
|
||||||
MT_MYMEMORY_KEY = None
|
|
||||||
|
|
||||||
# Google API key for Google Translate API
|
|
||||||
MT_GOOGLE_KEY = None
|
|
||||||
|
|
||||||
# Baidu app key and secret
|
|
||||||
MT_BAIDU_ID = None
|
|
||||||
MT_BAIDU_SECRET = None
|
|
||||||
|
|
||||||
# Youdao Zhiyun app key and secret
|
|
||||||
MT_YOUDAO_ID = None
|
|
||||||
MT_YOUDAO_SECRET = None
|
|
||||||
|
|
||||||
# Netease Sight (Jianwai) app key and secret
|
|
||||||
MT_NETEASE_KEY = None
|
|
||||||
MT_NETEASE_SECRET = None
|
|
||||||
|
|
||||||
# API key for Yandex Translate API
|
|
||||||
MT_YANDEX_KEY = None
|
|
||||||
|
|
||||||
# tmserver URL
|
|
||||||
MT_TMSERVER = None
|
|
||||||
|
|
||||||
# SAP Translation Hub
|
|
||||||
MT_SAP_BASE_URL = None
|
|
||||||
MT_SAP_SANDBOX_APIKEY = None
|
|
||||||
MT_SAP_USERNAME = None
|
|
||||||
MT_SAP_PASSWORD = None
|
|
||||||
MT_SAP_USE_MT = True
|
|
||||||
|
|
||||||
# Title of site to use
|
|
||||||
SITE_TITLE = 'Weblate'
|
|
||||||
|
|
||||||
# Whether site uses https
|
|
||||||
ENABLE_HTTPS = True
|
|
||||||
|
|
||||||
# Use HTTPS when creating redirect URLs for social authentication, see
|
|
||||||
# documentation for more details:
|
|
||||||
# https://python-social-auth-docs.readthedocs.io/en/latest/configuration/settings.html#processing-redirects-and-urlopen
|
|
||||||
SOCIAL_AUTH_REDIRECT_IS_HTTPS = ENABLE_HTTPS
|
|
||||||
|
|
||||||
# Make CSRF cookie HttpOnly, see documentation for more details:
|
|
||||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#csrf-cookie-httponly
|
|
||||||
CSRF_COOKIE_HTTPONLY = True
|
|
||||||
CSRF_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# Store CSRF token in session (since Django 1.11)
|
|
||||||
CSRF_USE_SESSIONS = True
|
|
||||||
SESSION_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# SSL redirect
|
|
||||||
SECURE_SSL_REDIRECT = ENABLE_HTTPS
|
|
||||||
# Session cookie age (in seconds)
|
|
||||||
SESSION_COOKIE_AGE = 1209600
|
|
||||||
|
|
||||||
# Some security headers
|
|
||||||
SECURE_BROWSER_XSS_FILTER = True
|
|
||||||
X_FRAME_OPTIONS = 'DENY'
|
|
||||||
SECURE_CONTENT_TYPE_NOSNIFF = True
|
|
||||||
|
|
||||||
# Optionally enable HSTS
|
|
||||||
SECURE_HSTS_SECONDS = 0
|
|
||||||
SECURE_HSTS_PRELOAD = False
|
|
||||||
SECURE_HSTS_INCLUDE_SUBDOMAINS = False
|
|
||||||
|
|
||||||
# URL of login
|
|
||||||
LOGIN_URL = '{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# URL of logout
|
|
||||||
LOGOUT_URL = '{0}/accounts/logout/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Default location for login
|
|
||||||
LOGIN_REDIRECT_URL = '{0}/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Anonymous user name
|
|
||||||
ANONYMOUS_USER_NAME = 'anonymous'
|
|
||||||
|
|
||||||
# Reverse proxy settings
|
|
||||||
IP_PROXY_HEADER = 'HTTP_X_FORWARDED_FOR'
|
|
||||||
IP_BEHIND_REVERSE_PROXY = False
|
|
||||||
IP_PROXY_OFFSET = 0
|
|
||||||
|
|
||||||
# Sending HTML in mails
|
|
||||||
EMAIL_SEND_HTML = True
|
|
||||||
|
|
||||||
# Subject of emails includes site title
|
|
||||||
EMAIL_SUBJECT_PREFIX = '[{0}] '.format(SITE_TITLE)
|
|
||||||
|
|
||||||
EMAIL_BACKEND = 'django_sendmail_backend.backends.EmailBackend'
|
|
||||||
|
|
||||||
# Enable remote hooks
|
|
||||||
ENABLE_HOOKS = True
|
|
||||||
|
|
||||||
# Number of nearby messages to show in each direction
|
|
||||||
NEARBY_MESSAGES = 5
|
|
||||||
|
|
||||||
# By default the length of a given translation is limited to the length of
|
|
||||||
# the source string * 10 characters. Set this option to False to allow longer
|
|
||||||
# translations (up to 10.000 characters)
|
|
||||||
LIMIT_TRANSLATION_LENGTH_BY_SOURCE_LENGTH = True
|
|
||||||
|
|
||||||
# Use simple language codes for default language/country combinations
|
|
||||||
SIMPLIFY_LANGUAGES = True
|
|
||||||
|
|
||||||
# Render forms using bootstrap
|
|
||||||
CRISPY_TEMPLATE_PACK = 'bootstrap3'
|
|
||||||
|
|
||||||
# List of quality checks
|
|
||||||
# CHECK_LIST = (
|
|
||||||
# 'weblate.checks.same.SameCheck',
|
|
||||||
# 'weblate.checks.chars.BeginNewlineCheck',
|
|
||||||
# 'weblate.checks.chars.EndNewlineCheck',
|
|
||||||
# 'weblate.checks.chars.BeginSpaceCheck',
|
|
||||||
# 'weblate.checks.chars.EndSpaceCheck',
|
|
||||||
# 'weblate.checks.chars.EndStopCheck',
|
|
||||||
# 'weblate.checks.chars.EndColonCheck',
|
|
||||||
# 'weblate.checks.chars.EndQuestionCheck',
|
|
||||||
# 'weblate.checks.chars.EndExclamationCheck',
|
|
||||||
# 'weblate.checks.chars.EndEllipsisCheck',
|
|
||||||
# 'weblate.checks.chars.EndSemicolonCheck',
|
|
||||||
# 'weblate.checks.chars.MaxLengthCheck',
|
|
||||||
# 'weblate.checks.chars.KashidaCheck',
|
|
||||||
# 'weblate.checks.format.PythonFormatCheck',
|
|
||||||
# 'weblate.checks.format.PythonBraceFormatCheck',
|
|
||||||
# 'weblate.checks.format.PHPFormatCheck',
|
|
||||||
# 'weblate.checks.format.CFormatCheck',
|
|
||||||
# 'weblate.checks.format.PerlFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavascriptFormatCheck',
|
|
||||||
# 'weblate.checks.format.CSharpFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavaFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavaMessageFormatCheck',
|
|
||||||
# 'weblate.checks.angularjs.AngularJSInterpolationCheck',
|
|
||||||
# 'weblate.checks.consistency.PluralsCheck',
|
|
||||||
# 'weblate.checks.consistency.SamePluralsCheck',
|
|
||||||
# 'weblate.checks.consistency.ConsistencyCheck',
|
|
||||||
# 'weblate.checks.consistency.TranslatedCheck',
|
|
||||||
# 'weblate.checks.chars.NewlineCountingCheck',
|
|
||||||
# 'weblate.checks.markup.BBCodeCheck',
|
|
||||||
# 'weblate.checks.chars.ZeroWidthSpaceCheck',
|
|
||||||
# 'weblate.checks.markup.XMLValidityCheck',
|
|
||||||
# 'weblate.checks.markup.XMLTagsCheck',
|
|
||||||
# 'weblate.checks.markup.MarkdownRefLinkCheck',
|
|
||||||
# 'weblate.checks.markup.MarkdownLinkCheck',
|
|
||||||
# 'weblate.checks.markup.MarkdownSyntaxCheck',
|
|
||||||
# 'weblate.checks.markup.URLCheck',
|
|
||||||
# 'weblate.checks.source.OptionalPluralCheck',
|
|
||||||
# 'weblate.checks.source.EllipsisCheck',
|
|
||||||
# 'weblate.checks.source.MultipleFailingCheck',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of automatic fixups
|
|
||||||
# AUTOFIX_LIST = (
|
|
||||||
# 'weblate.trans.autofixes.whitespace.SameBookendingWhitespace',
|
|
||||||
# 'weblate.trans.autofixes.chars.ReplaceTrailingDotsWithEllipsis',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveZeroSpace',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveControlChars',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of enabled addons
|
|
||||||
# WEBLATE_ADDONS = (
|
|
||||||
# 'weblate.addons.gettext.GenerateMoAddon',
|
|
||||||
# 'weblate.addons.gettext.UpdateLinguasAddon',
|
|
||||||
# 'weblate.addons.gettext.UpdateConfigureAddon',
|
|
||||||
# 'weblate.addons.gettext.MsgmergeAddon',
|
|
||||||
# 'weblate.addons.gettext.GettextCustomizeAddon',
|
|
||||||
# 'weblate.addons.gettext.GettextAuthorComments',
|
|
||||||
# 'weblate.addons.cleanup.CleanupAddon',
|
|
||||||
# 'weblate.addons.consistency.LangaugeConsistencyAddon',
|
|
||||||
# 'weblate.addons.discovery.DiscoveryAddon',
|
|
||||||
# 'weblate.addons.flags.SourceEditAddon',
|
|
||||||
# 'weblate.addons.flags.TargetEditAddon',
|
|
||||||
# 'weblate.addons.generate.GenerateFileAddon',
|
|
||||||
# 'weblate.addons.json.JSONCustomizeAddon',
|
|
||||||
# 'weblate.addons.properties.PropertiesSortAddon',
|
|
||||||
# 'weblate.addons.git.GitSquashAddon',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# E-mail address that error messages come from.
|
|
||||||
SERVER_EMAIL = 'noreply@__DOMAIN__'
|
|
||||||
|
|
||||||
# Default email address to use for various automated correspondence from
|
|
||||||
# the site managers. Used for registration emails.
|
|
||||||
DEFAULT_FROM_EMAIL = '__ADMINMAIL__'
|
|
||||||
|
|
||||||
# List of URLs your site is supposed to serve
|
|
||||||
ALLOWED_HOSTS = ['__DOMAIN__']
|
|
||||||
|
|
||||||
CACHES = {
|
|
||||||
'default': {
|
|
||||||
'BACKEND': 'django_redis.cache.RedisCache',
|
|
||||||
'LOCATION': 'redis://127.0.0.1:6379/__REDIS_DB__',
|
|
||||||
'OPTIONS': {
|
|
||||||
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
|
||||||
'PARSER_CLASS': 'redis.connection.HiredisParser',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'avatar': {
|
|
||||||
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
|
||||||
'LOCATION': os.path.join(BASE_DIR, 'avatar-cache'),
|
|
||||||
'TIMEOUT': 3600,
|
|
||||||
'OPTIONS': {
|
|
||||||
'MAX_ENTRIES': 1000,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example configuration for caching
|
|
||||||
# CACHES = {
|
|
||||||
# Recommended redis + hiredis:
|
|
||||||
# 'default': {
|
|
||||||
# 'BACKEND': 'django_redis.cache.RedisCache',
|
|
||||||
# 'LOCATION': 'redis://127.0.0.1:6379/0',
|
|
||||||
# # If redis is running on same host as Weblate, you might
|
|
||||||
# # want to use unix sockets instead:
|
|
||||||
# # 'LOCATION': 'unix:///var/run/redis/redis.sock?db=0',
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
|
||||||
# 'PARSER_CLASS': 'redis.connection.HiredisParser',
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
# Memcached alternative:
|
|
||||||
# 'default': {
|
|
||||||
# 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
|
||||||
# 'LOCATION': '127.0.0.1:11211',
|
|
||||||
# },
|
|
||||||
# 'avatar': {
|
|
||||||
# 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
|
||||||
# 'LOCATION': os.path.join(DATA_DIR, 'avatar-cache'),
|
|
||||||
# 'TIMEOUT': 3600,
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'MAX_ENTRIES': 1000,
|
|
||||||
# },
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
|
|
||||||
# REST framework settings for API
|
|
||||||
REST_FRAMEWORK = {
|
|
||||||
# Use Django's standard `django.contrib.auth` permissions,
|
|
||||||
# or allow read-only access for unauthenticated users.
|
|
||||||
'DEFAULT_PERMISSION_CLASSES': [
|
|
||||||
'rest_framework.permissions.IsAuthenticatedOrReadOnly'
|
|
||||||
],
|
|
||||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
|
||||||
'rest_framework.authentication.TokenAuthentication',
|
|
||||||
'weblate.api.authentication.BearerAuthentication',
|
|
||||||
'rest_framework.authentication.SessionAuthentication',
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_CLASSES': (
|
|
||||||
'rest_framework.throttling.AnonRateThrottle',
|
|
||||||
'rest_framework.throttling.UserRateThrottle'
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_RATES': {
|
|
||||||
'anon': '100/day',
|
|
||||||
'user': '1000/day'
|
|
||||||
},
|
|
||||||
'DEFAULT_PAGINATION_CLASS': (
|
|
||||||
'rest_framework.pagination.PageNumberPagination'
|
|
||||||
),
|
|
||||||
'PAGE_SIZE': 20,
|
|
||||||
'VIEW_DESCRIPTION_FUNCTION': 'weblate.api.views.get_view_description',
|
|
||||||
'UNAUTHENTICATED_USER': 'weblate.auth.models.get_anonymous',
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example for restricting access to logged in users
|
|
||||||
# LOGIN_REQUIRED_URLS = (
|
|
||||||
# r'/(.*)$',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# In such case you will want to include some of the exceptions
|
|
||||||
# LOGIN_REQUIRED_URLS_EXCEPTIONS = (
|
|
||||||
# r'/accounts/(.*)$', # Required for login
|
|
||||||
# r'/admin/login/(.*)$', # Required for admin login
|
|
||||||
# r'/static/(.*)$', # Required for development mode
|
|
||||||
# r'/widgets/(.*)$', # Allowing public access to widgets
|
|
||||||
# r'/data/(.*)$', # Allowing public access to data exports
|
|
||||||
# r'/hooks/(.*)$', # Allowing public access to notification hooks
|
|
||||||
# r'/healthz/$', # Allowing public access to health check
|
|
||||||
# r'/api/(.*)$', # Allowing access to API
|
|
||||||
# r'/js/i18n/$', # Javascript localization
|
|
||||||
# r'/contact/$', # Optional for contact form
|
|
||||||
# r'/legal/(.*)$', # Optional for legal app
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Silence some of the Django system checks
|
|
||||||
SILENCED_SYSTEM_CHECKS = [
|
|
||||||
# We have modified django.contrib.auth.middleware.AuthenticationMiddleware
|
|
||||||
# as weblate.accounts.middleware.AuthenticationMiddleware
|
|
||||||
'admin.E408',
|
|
||||||
]
|
|
||||||
|
|
||||||
# Celery worker configuration for testing
|
|
||||||
# CELERY_TASK_ALWAYS_EAGER = True
|
|
||||||
# CELERY_BROKER_URL = 'memory://'
|
|
||||||
# CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
|
|
||||||
# Celery worker configuration for production
|
|
||||||
CELERY_TASK_ALWAYS_EAGER = False
|
|
||||||
CELERY_BROKER_URL = 'redis://127.0.0.1:6379/__REDIS_DB__'
|
|
||||||
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
|
|
||||||
|
|
||||||
# Celery settings, it is not recommended to change these
|
|
||||||
CELERY_WORKER_PREFETCH_MULTIPLIER = 0
|
|
||||||
CELERY_WORKER_MAX_MEMORY_PER_CHILD = 200000
|
|
||||||
CELERY_BEAT_SCHEDULE_FILENAME = os.path.join(
|
|
||||||
DATA_DIR, 'celery', 'beat-schedule'
|
|
||||||
)
|
|
||||||
CELERY_TASK_ROUTES = {
|
|
||||||
'weblate.trans.search.*': {'queue': 'search'},
|
|
||||||
'weblate.trans.tasks.optimize_fulltext': {'queue': 'search'},
|
|
||||||
'weblate.trans.tasks.cleanup_fulltext': {'queue': 'search'},
|
|
||||||
'weblate.memory.tasks.*': {'queue': 'memory'},
|
|
||||||
}
|
|
|
@ -1,870 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# Copyright © 2012 - 2019 Michal Čihař <michal@cihar.com>
|
|
||||||
#
|
|
||||||
# This file is part of Weblate <https://weblate.org/>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import platform
|
|
||||||
import os
|
|
||||||
from logging.handlers import SysLogHandler
|
|
||||||
|
|
||||||
#
|
|
||||||
# Django settings for Weblate project.
|
|
||||||
#
|
|
||||||
|
|
||||||
DEBUG = True
|
|
||||||
|
|
||||||
ADMINS = (
|
|
||||||
# ('Your Name', 'your_email@example.com'),
|
|
||||||
)
|
|
||||||
|
|
||||||
MANAGERS = ADMINS
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
# Use 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
|
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
||||||
# Database name or path to database file if using sqlite3.
|
|
||||||
'NAME': '__NAME__',
|
|
||||||
# Database user, not used with sqlite3.
|
|
||||||
'USER': '__NAME__',
|
|
||||||
# Database password, not used with sqlite3.
|
|
||||||
'PASSWORD': '__DB_PWD__',
|
|
||||||
# Set to empty string for localhost. Not used with sqlite3.
|
|
||||||
'HOST': 'localhost',
|
|
||||||
# Set to empty string for default. Not used with sqlite3.
|
|
||||||
'PORT': '5432',
|
|
||||||
# Customizations for databases
|
|
||||||
'OPTIONS': {
|
|
||||||
# In case of using an older MySQL server, which has MyISAM as a default storage
|
|
||||||
# 'init_command': 'SET storage_engine=INNODB',
|
|
||||||
# Uncomment for MySQL older than 5.7:
|
|
||||||
# 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
|
|
||||||
# Set emoji capable charset for MySQL:
|
|
||||||
# 'charset': 'utf8mb4',
|
|
||||||
'sslmode': 'disable'
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BASE_DIR = '__FINALPATH__'
|
|
||||||
|
|
||||||
# Data directory
|
|
||||||
DATA_DIR = os.path.join(BASE_DIR, 'data')
|
|
||||||
TTF_PATH = '__FINALPATH__/venv/lib/__PYTHONPATH__/site-packages/weblate/ttf/'
|
|
||||||
|
|
||||||
# Local time zone for this installation. Choices can be found here:
|
|
||||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
|
||||||
# although not all choices may be available on all operating systems.
|
|
||||||
# In a Windows environment this must be set to your system time zone.
|
|
||||||
TIME_ZONE = 'UTC'
|
|
||||||
|
|
||||||
# Language code for this installation. All choices can be found here:
|
|
||||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
|
||||||
|
|
||||||
LANGUAGES = (
|
|
||||||
('ar', 'العربية'),
|
|
||||||
('az', 'Azərbaycan'),
|
|
||||||
('be', 'Беларуская'),
|
|
||||||
('be@latin', 'Biełaruskaja'),
|
|
||||||
('bg', 'Български'),
|
|
||||||
('br', 'Brezhoneg'),
|
|
||||||
('ca', 'Català'),
|
|
||||||
('cs', 'Čeština'),
|
|
||||||
('da', 'Dansk'),
|
|
||||||
('de', 'Deutsch'),
|
|
||||||
('en', 'English'),
|
|
||||||
('en-gb', 'English (United Kingdom)'),
|
|
||||||
('el', 'Ελληνικά'),
|
|
||||||
('es', 'Español'),
|
|
||||||
('fi', 'Suomi'),
|
|
||||||
('fr', 'Français'),
|
|
||||||
('fy', 'Frysk'),
|
|
||||||
('gl', 'Galego'),
|
|
||||||
('he', 'עברית'),
|
|
||||||
('hu', 'Magyar'),
|
|
||||||
('id', 'Indonesia'),
|
|
||||||
('it', 'Italiano'),
|
|
||||||
('ja', '日本語'),
|
|
||||||
('kk', 'Қазақ тілі'),
|
|
||||||
('ko', '한국어'),
|
|
||||||
('ksh', 'Kölsch'),
|
|
||||||
('nb', 'Norsk bokmål'),
|
|
||||||
('nl', 'Nederlands'),
|
|
||||||
('pl', 'Polski'),
|
|
||||||
('pt', 'Português'),
|
|
||||||
('pt-br', 'Português brasileiro'),
|
|
||||||
('ru', 'Русский'),
|
|
||||||
('sk', 'Slovenčina'),
|
|
||||||
('sl', 'Slovenščina'),
|
|
||||||
('sr', 'Српски'),
|
|
||||||
('sv', 'Svenska'),
|
|
||||||
('tr', 'Türkçe'),
|
|
||||||
('uk', 'Українська'),
|
|
||||||
('zh-hans', '简体字'),
|
|
||||||
('zh-hant', '正體字'),
|
|
||||||
)
|
|
||||||
|
|
||||||
SITE_ID = 1
|
|
||||||
|
|
||||||
# If you set this to False, Django will make some optimizations so as not
|
|
||||||
# to load the internationalization machinery.
|
|
||||||
USE_I18N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not format dates, numbers and
|
|
||||||
# calendars according to the current locale.
|
|
||||||
USE_L10N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not use timezone-aware datetimes.
|
|
||||||
USE_TZ = True
|
|
||||||
|
|
||||||
# URL prefix to use, please see documentation for more details
|
|
||||||
URL_PREFIX = '__PATHURL__'
|
|
||||||
|
|
||||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
|
||||||
# Example: "/home/media/media.lawrence.com/media/"
|
|
||||||
MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
|
|
||||||
|
|
||||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
|
||||||
# trailing slash.
|
|
||||||
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
|
||||||
MEDIA_URL = '{0}/media/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Absolute path to the directory static files should be collected to.
|
|
||||||
# Don't put anything in this directory yourself; store your static files
|
|
||||||
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
|
|
||||||
# Example: "/home/media/media.lawrence.com/static/"
|
|
||||||
STATIC_ROOT = os.path.join(DATA_DIR, 'static')
|
|
||||||
|
|
||||||
# URL prefix for static files.
|
|
||||||
# Example: "http://media.lawrence.com/static/"
|
|
||||||
STATIC_URL = '{0}/static/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Additional locations of static files
|
|
||||||
STATICFILES_DIRS = (
|
|
||||||
# Put strings here, like "/home/html/static" or "C:/www/django/static".
|
|
||||||
# Always use forward slashes, even on Windows.
|
|
||||||
# Don't forget to use absolute paths, not relative paths.
|
|
||||||
)
|
|
||||||
|
|
||||||
# List of finder classes that know how to find static files in
|
|
||||||
# various locations.
|
|
||||||
STATICFILES_FINDERS = (
|
|
||||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
|
||||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
|
||||||
'compressor.finders.CompressorFinder',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Make this unique, and don't share it with anybody.
|
|
||||||
# You can generate it using examples/generate-secret-key
|
|
||||||
SECRET_KEY = '__KEY__' # noqa
|
|
||||||
|
|
||||||
TEMPLATES = [
|
|
||||||
{
|
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
||||||
'DIRS': [
|
|
||||||
os.path.join(BASE_DIR, 'weblate', 'templates'),
|
|
||||||
],
|
|
||||||
'OPTIONS': {
|
|
||||||
'context_processors': [
|
|
||||||
'django.contrib.auth.context_processors.auth',
|
|
||||||
'django.template.context_processors.debug',
|
|
||||||
'django.template.context_processors.i18n',
|
|
||||||
'django.template.context_processors.request',
|
|
||||||
'django.template.context_processors.csrf',
|
|
||||||
'django.contrib.messages.context_processors.messages',
|
|
||||||
'weblate.trans.context_processors.weblate_context',
|
|
||||||
],
|
|
||||||
'loaders': [
|
|
||||||
('django.template.loaders.cached.Loader', [
|
|
||||||
'django.template.loaders.filesystem.Loader',
|
|
||||||
'django.template.loaders.app_directories.Loader',
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# GitHub username for sending pull requests.
|
|
||||||
# Please see the documentation for more details.
|
|
||||||
GITHUB_USERNAME = "__GITHUBUSER__"
|
|
||||||
|
|
||||||
# Authentication configuration
|
|
||||||
AUTHENTICATION_BACKENDS = (
|
|
||||||
'social_core.backends.email.EmailAuth',
|
|
||||||
# 'social_core.backends.google.GoogleOAuth2',
|
|
||||||
# 'social_core.backends.github.GithubOAuth2',
|
|
||||||
# 'social_core.backends.bitbucket.BitbucketOAuth',
|
|
||||||
'social_core.backends.suse.OpenSUSEOpenId',
|
|
||||||
'social_core.backends.ubuntu.UbuntuOpenId',
|
|
||||||
'social_core.backends.fedora.FedoraOpenId',
|
|
||||||
# 'social_core.backends.facebook.FacebookOAuth2',
|
|
||||||
'weblate.accounts.auth.WeblateUserBackend',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom user model
|
|
||||||
AUTH_USER_MODEL = 'weblate_auth.User'
|
|
||||||
|
|
||||||
# Social auth backends setup
|
|
||||||
SOCIAL_AUTH_GITHUB_KEY = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SECRET = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SCOPE = ['user:email']
|
|
||||||
|
|
||||||
SOCIAL_AUTH_BITBUCKET_KEY = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_SECRET = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_VERIFIED_EMAILS_ONLY = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_FACEBOOK_KEY = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SECRET = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email', 'public_profile']
|
|
||||||
SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {'fields': 'id,name,email'}
|
|
||||||
SOCIAL_AUTH_FACEBOOK_API_VERSION = '3.1'
|
|
||||||
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = ''
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = ''
|
|
||||||
|
|
||||||
# Social auth settings
|
|
||||||
SOCIAL_AUTH_PIPELINE = (
|
|
||||||
'social_core.pipeline.social_auth.social_details',
|
|
||||||
'social_core.pipeline.social_auth.social_uid',
|
|
||||||
'social_core.pipeline.social_auth.auth_allowed',
|
|
||||||
'social_core.pipeline.social_auth.social_user',
|
|
||||||
'weblate.accounts.pipeline.store_params',
|
|
||||||
'weblate.accounts.pipeline.verify_open',
|
|
||||||
'social_core.pipeline.user.get_username',
|
|
||||||
'weblate.accounts.pipeline.require_email',
|
|
||||||
'social_core.pipeline.mail.mail_validation',
|
|
||||||
'weblate.accounts.pipeline.revoke_mail_code',
|
|
||||||
'weblate.accounts.pipeline.ensure_valid',
|
|
||||||
'weblate.accounts.pipeline.remove_account',
|
|
||||||
'social_core.pipeline.social_auth.associate_by_email',
|
|
||||||
'weblate.accounts.pipeline.reauthenticate',
|
|
||||||
'weblate.accounts.pipeline.verify_username',
|
|
||||||
'social_core.pipeline.user.create_user',
|
|
||||||
'social_core.pipeline.social_auth.associate_user',
|
|
||||||
'social_core.pipeline.social_auth.load_extra_data',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
'weblate.accounts.pipeline.user_full_name',
|
|
||||||
'weblate.accounts.pipeline.store_email',
|
|
||||||
'weblate.accounts.pipeline.notify_connect',
|
|
||||||
'weblate.accounts.pipeline.password_reset',
|
|
||||||
)
|
|
||||||
SOCIAL_AUTH_DISCONNECT_PIPELINE = (
|
|
||||||
'social_core.pipeline.disconnect.allowed_to_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.get_entries',
|
|
||||||
'social_core.pipeline.disconnect.revoke_tokens',
|
|
||||||
'weblate.accounts.pipeline.cycle_session',
|
|
||||||
'weblate.accounts.pipeline.adjust_primary_mail',
|
|
||||||
'weblate.accounts.pipeline.notify_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.disconnect',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom authentication strategy
|
|
||||||
SOCIAL_AUTH_STRATEGY = 'weblate.accounts.strategy.WeblateStrategy'
|
|
||||||
|
|
||||||
# Raise exceptions so that we can handle them later
|
|
||||||
SOCIAL_AUTH_RAISE_EXCEPTIONS = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_FUNCTION = \
|
|
||||||
'weblate.accounts.pipeline.send_validation'
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_URL = \
|
|
||||||
'{0}/accounts/email-sent/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_LOGIN_ERROR_URL = \
|
|
||||||
'{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_EMAIL_FORM_URL = \
|
|
||||||
'{0}/accounts/email/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL = \
|
|
||||||
'{0}/accounts/profile/#account'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_PROTECTED_USER_FIELDS = ('email',)
|
|
||||||
SOCIAL_AUTH_SLUGIFY_USERNAMES = True
|
|
||||||
SOCIAL_AUTH_SLUGIFY_FUNCTION = 'weblate.accounts.pipeline.slugify_username'
|
|
||||||
|
|
||||||
# Password validation configuration
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
||||||
'OPTIONS': {
|
|
||||||
'min_length': 6,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.CharsPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.PastPasswordsValidator',
|
|
||||||
},
|
|
||||||
# Optional password strength validation by django-zxcvbn-password
|
|
||||||
# {
|
|
||||||
# 'NAME': 'zxcvbn_password.ZXCVBNValidator',
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'min_score': 3,
|
|
||||||
# 'user_attributes': ('username', 'email', 'full_name')
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
]
|
|
||||||
|
|
||||||
# Allow new user registrations
|
|
||||||
REGISTRATION_OPEN = True
|
|
||||||
|
|
||||||
# Middleware
|
|
||||||
MIDDLEWARE = [
|
|
||||||
'weblate.middleware.ProxyMiddleware',
|
|
||||||
'django.middleware.security.SecurityMiddleware',
|
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
||||||
'django.middleware.common.CommonMiddleware',
|
|
||||||
'django.middleware.locale.LocaleMiddleware',
|
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
|
||||||
'weblate.accounts.middleware.AuthenticationMiddleware',
|
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
||||||
'social_django.middleware.SocialAuthExceptionMiddleware',
|
|
||||||
'weblate.accounts.middleware.RequireLoginMiddleware',
|
|
||||||
'weblate.middleware.SecurityMiddleware',
|
|
||||||
]
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'weblate.urls'
|
|
||||||
|
|
||||||
# Django and Weblate apps
|
|
||||||
INSTALLED_APPS = (
|
|
||||||
'django.contrib.auth',
|
|
||||||
'django.contrib.contenttypes',
|
|
||||||
'django.contrib.sessions',
|
|
||||||
'django.contrib.sites',
|
|
||||||
'django.contrib.messages',
|
|
||||||
'django.contrib.staticfiles',
|
|
||||||
'django.contrib.admin.apps.SimpleAdminConfig',
|
|
||||||
'django.contrib.admindocs',
|
|
||||||
'django.contrib.sitemaps',
|
|
||||||
'social_django',
|
|
||||||
'crispy_forms',
|
|
||||||
'compressor',
|
|
||||||
'rest_framework',
|
|
||||||
'rest_framework.authtoken',
|
|
||||||
'weblate.addons',
|
|
||||||
'weblate.auth',
|
|
||||||
'weblate.checks',
|
|
||||||
'weblate.formats',
|
|
||||||
'weblate.machinery',
|
|
||||||
'weblate.trans',
|
|
||||||
'weblate.lang',
|
|
||||||
'weblate.langdata',
|
|
||||||
'weblate.memory',
|
|
||||||
'weblate.screenshots',
|
|
||||||
'weblate.accounts',
|
|
||||||
'weblate.utils',
|
|
||||||
'weblate.vcs',
|
|
||||||
'weblate.wladmin',
|
|
||||||
'weblate',
|
|
||||||
|
|
||||||
# Optional: Git exporter
|
|
||||||
# 'weblate.gitexport',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Path to locales
|
|
||||||
LOCALE_PATHS = (os.path.join(BASE_DIR, 'weblate', 'locale'), )
|
|
||||||
|
|
||||||
# Custom exception reporter to include some details
|
|
||||||
DEFAULT_EXCEPTION_REPORTER_FILTER = \
|
|
||||||
'weblate.trans.debug.WeblateExceptionReporterFilter'
|
|
||||||
|
|
||||||
# Default logging of Weblate messages
|
|
||||||
# - to syslog in production (if available)
|
|
||||||
# - otherwise to console
|
|
||||||
# - you can also choose 'logfile' to log into separate file
|
|
||||||
# after configuring it below
|
|
||||||
|
|
||||||
# Detect if we can connect to syslog
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
if platform.system() != 'Windows':
|
|
||||||
try:
|
|
||||||
handler = SysLogHandler(
|
|
||||||
address='/dev/log', facility=SysLogHandler.LOG_LOCAL2
|
|
||||||
)
|
|
||||||
handler.close()
|
|
||||||
HAVE_SYSLOG = True
|
|
||||||
except IOError:
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
|
|
||||||
if DEBUG or not HAVE_SYSLOG:
|
|
||||||
DEFAULT_LOG = 'console'
|
|
||||||
else:
|
|
||||||
DEFAULT_LOG = 'syslog'
|
|
||||||
|
|
||||||
# A sample logging configuration. The only tangible logging
|
|
||||||
# performed by this configuration is to send an email to
|
|
||||||
# the site admins on every HTTP 500 error when DEBUG=False.
|
|
||||||
# See http://docs.djangoproject.com/en/stable/topics/logging for
|
|
||||||
# more details on how to customize your logging configuration.
|
|
||||||
LOGGING = {
|
|
||||||
'version': 1,
|
|
||||||
'disable_existing_loggers': True,
|
|
||||||
'filters': {
|
|
||||||
'require_debug_false': {
|
|
||||||
'()': 'django.utils.log.RequireDebugFalse'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'formatters': {
|
|
||||||
'syslog': {
|
|
||||||
'format': 'weblate[%(process)d]: %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'simple': {
|
|
||||||
'format': '%(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'logfile': {
|
|
||||||
'format': '%(asctime)s %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'()': 'django.utils.log.ServerFormatter',
|
|
||||||
'format': '[%(server_time)s] %(message)s',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'handlers': {
|
|
||||||
'mail_admins': {
|
|
||||||
'level': 'ERROR',
|
|
||||||
'filters': ['require_debug_false'],
|
|
||||||
'class': 'django.utils.log.AdminEmailHandler',
|
|
||||||
'include_html': True,
|
|
||||||
},
|
|
||||||
'console': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'simple'
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'level': 'INFO',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'django.server',
|
|
||||||
},
|
|
||||||
'syslog': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.handlers.SysLogHandler',
|
|
||||||
'formatter': 'syslog',
|
|
||||||
'address': '/dev/log',
|
|
||||||
'facility': SysLogHandler.LOG_LOCAL2,
|
|
||||||
},
|
|
||||||
# Logging to a file
|
|
||||||
# 'logfile': {
|
|
||||||
# 'level':'DEBUG',
|
|
||||||
# 'class':'logging.handlers.RotatingFileHandler',
|
|
||||||
# 'filename': "/var/log/weblate/weblate.log",
|
|
||||||
# 'maxBytes': 100000,
|
|
||||||
# 'backupCount': 3,
|
|
||||||
# 'formatter': 'logfile',
|
|
||||||
# },
|
|
||||||
},
|
|
||||||
'loggers': {
|
|
||||||
'django.request': {
|
|
||||||
'handlers': ['mail_admins', DEFAULT_LOG],
|
|
||||||
'level': 'ERROR',
|
|
||||||
'propagate': True,
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'handlers': ['django.server'],
|
|
||||||
'level': 'INFO',
|
|
||||||
'propagate': False,
|
|
||||||
},
|
|
||||||
# Logging database queries
|
|
||||||
# 'django.db.backends': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
'weblate': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'DEBUG',
|
|
||||||
},
|
|
||||||
# Logging search operations
|
|
||||||
'weblate.search': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'INFO',
|
|
||||||
},
|
|
||||||
# Logging VCS operations
|
|
||||||
'weblate.vcs': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'WARNING',
|
|
||||||
},
|
|
||||||
# Python Social Auth logging
|
|
||||||
# 'social': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Logging of management commands to console
|
|
||||||
if (os.environ.get('DJANGO_IS_MANAGEMENT_COMMAND', False) and
|
|
||||||
'console' not in LOGGING['loggers']['weblate']['handlers']):
|
|
||||||
LOGGING['loggers']['weblate']['handlers'].append('console')
|
|
||||||
|
|
||||||
# Remove syslog setup if it's not present
|
|
||||||
if not HAVE_SYSLOG:
|
|
||||||
del LOGGING['handlers']['syslog']
|
|
||||||
|
|
||||||
# List of machine translations
|
|
||||||
# MT_SERVICES = (
|
|
||||||
# 'weblate.machinery.apertium.ApertiumAPYTranslation',
|
|
||||||
# 'weblate.machinery.baidu.BaiduTranslation',
|
|
||||||
# 'weblate.machinery.deepl.DeepLTranslation',
|
|
||||||
# 'weblate.machinery.glosbe.GlosbeTranslation',
|
|
||||||
# 'weblate.machinery.google.GoogleTranslation',
|
|
||||||
# 'weblate.machinery.microsoft.MicrosoftCognitiveTranslation',
|
|
||||||
# 'weblate.machinery.microsoftterminology.MicrosoftTerminologyService',
|
|
||||||
# 'weblate.machinery.mymemory.MyMemoryTranslation',
|
|
||||||
# 'weblate.machinery.netease.NeteaseSightTranslation',
|
|
||||||
# 'weblate.machinery.tmserver.AmagamaTranslation',
|
|
||||||
# 'weblate.machinery.tmserver.TMServerTranslation',
|
|
||||||
# 'weblate.machinery.yandex.YandexTranslation',
|
|
||||||
# 'weblate.machinery.weblatetm.WeblateTranslation',
|
|
||||||
# 'weblate.machinery.saptranslationhub.SAPTranslationHub',
|
|
||||||
# 'weblate.machinery.youdao.YoudaoTranslation',
|
|
||||||
# 'weblate.memory.machine.WeblateMemory',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Machine translation API keys
|
|
||||||
|
|
||||||
# URL of the Apertium APy server
|
|
||||||
MT_APERTIUM_APY = None
|
|
||||||
|
|
||||||
# DeepL API key
|
|
||||||
MT_DEEPL_KEY = None
|
|
||||||
|
|
||||||
# Microsoft Cognitive Services Translator API, register at
|
|
||||||
# https://portal.azure.com/
|
|
||||||
MT_MICROSOFT_COGNITIVE_KEY = None
|
|
||||||
|
|
||||||
# MyMemory identification email, see
|
|
||||||
# https://mymemory.translated.net/doc/spec.php
|
|
||||||
MT_MYMEMORY_EMAIL = None
|
|
||||||
|
|
||||||
# Optional MyMemory credentials to access private translation memory
|
|
||||||
MT_MYMEMORY_USER = None
|
|
||||||
MT_MYMEMORY_KEY = None
|
|
||||||
|
|
||||||
# Google API key for Google Translate API
|
|
||||||
MT_GOOGLE_KEY = None
|
|
||||||
|
|
||||||
# Baidu app key and secret
|
|
||||||
MT_BAIDU_ID = None
|
|
||||||
MT_BAIDU_SECRET = None
|
|
||||||
|
|
||||||
# Youdao Zhiyun app key and secret
|
|
||||||
MT_YOUDAO_ID = None
|
|
||||||
MT_YOUDAO_SECRET = None
|
|
||||||
|
|
||||||
# Netease Sight (Jianwai) app key and secret
|
|
||||||
MT_NETEASE_KEY = None
|
|
||||||
MT_NETEASE_SECRET = None
|
|
||||||
|
|
||||||
# API key for Yandex Translate API
|
|
||||||
MT_YANDEX_KEY = None
|
|
||||||
|
|
||||||
# tmserver URL
|
|
||||||
MT_TMSERVER = None
|
|
||||||
|
|
||||||
# SAP Translation Hub
|
|
||||||
MT_SAP_BASE_URL = None
|
|
||||||
MT_SAP_SANDBOX_APIKEY = None
|
|
||||||
MT_SAP_USERNAME = None
|
|
||||||
MT_SAP_PASSWORD = None
|
|
||||||
MT_SAP_USE_MT = True
|
|
||||||
|
|
||||||
# Title of site to use
|
|
||||||
SITE_TITLE = 'Weblate'
|
|
||||||
|
|
||||||
# Whether site uses https
|
|
||||||
ENABLE_HTTPS = True
|
|
||||||
|
|
||||||
# Use HTTPS when creating redirect URLs for social authentication, see
|
|
||||||
# documentation for more details:
|
|
||||||
# https://python-social-auth-docs.readthedocs.io/en/latest/configuration/settings.html#processing-redirects-and-urlopen
|
|
||||||
SOCIAL_AUTH_REDIRECT_IS_HTTPS = ENABLE_HTTPS
|
|
||||||
|
|
||||||
# Make CSRF cookie HttpOnly, see documentation for more details:
|
|
||||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#csrf-cookie-httponly
|
|
||||||
CSRF_COOKIE_HTTPONLY = True
|
|
||||||
CSRF_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# Store CSRF token in session (since Django 1.11)
|
|
||||||
CSRF_USE_SESSIONS = True
|
|
||||||
SESSION_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# SSL redirect
|
|
||||||
SECURE_SSL_REDIRECT = ENABLE_HTTPS
|
|
||||||
# Session cookie age (in seconds)
|
|
||||||
SESSION_COOKIE_AGE = 1209600
|
|
||||||
|
|
||||||
# Some security headers
|
|
||||||
SECURE_BROWSER_XSS_FILTER = True
|
|
||||||
X_FRAME_OPTIONS = 'DENY'
|
|
||||||
SECURE_CONTENT_TYPE_NOSNIFF = True
|
|
||||||
|
|
||||||
# Optionally enable HSTS
|
|
||||||
SECURE_HSTS_SECONDS = 0
|
|
||||||
SECURE_HSTS_PRELOAD = False
|
|
||||||
SECURE_HSTS_INCLUDE_SUBDOMAINS = False
|
|
||||||
|
|
||||||
# URL of login
|
|
||||||
LOGIN_URL = '{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# URL of logout
|
|
||||||
LOGOUT_URL = '{0}/accounts/logout/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Default location for login
|
|
||||||
LOGIN_REDIRECT_URL = '{0}/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Anonymous user name
|
|
||||||
ANONYMOUS_USER_NAME = 'anonymous'
|
|
||||||
|
|
||||||
# Reverse proxy settings
|
|
||||||
IP_PROXY_HEADER = 'HTTP_X_FORWARDED_FOR'
|
|
||||||
IP_BEHIND_REVERSE_PROXY = False
|
|
||||||
IP_PROXY_OFFSET = 0
|
|
||||||
|
|
||||||
# Sending HTML in mails
|
|
||||||
EMAIL_SEND_HTML = True
|
|
||||||
|
|
||||||
# Subject of emails includes site title
|
|
||||||
EMAIL_SUBJECT_PREFIX = '[{0}] '.format(SITE_TITLE)
|
|
||||||
|
|
||||||
EMAIL_BACKEND = 'django_sendmail_backend.backends.EmailBackend'
|
|
||||||
|
|
||||||
# Enable remote hooks
|
|
||||||
ENABLE_HOOKS = True
|
|
||||||
|
|
||||||
# Number of nearby messages to show in each direction
|
|
||||||
NEARBY_MESSAGES = 5
|
|
||||||
|
|
||||||
# By default the length of a given translation is limited to the length of
|
|
||||||
# the source string * 10 characters. Set this option to False to allow longer
|
|
||||||
# translations (up to 10.000 characters)
|
|
||||||
LIMIT_TRANSLATION_LENGTH_BY_SOURCE_LENGTH = True
|
|
||||||
|
|
||||||
# Use simple language codes for default language/country combinations
|
|
||||||
SIMPLIFY_LANGUAGES = True
|
|
||||||
|
|
||||||
# Render forms using bootstrap
|
|
||||||
CRISPY_TEMPLATE_PACK = 'bootstrap3'
|
|
||||||
|
|
||||||
# List of quality checks
|
|
||||||
# CHECK_LIST = (
|
|
||||||
# 'weblate.checks.same.SameCheck',
|
|
||||||
# 'weblate.checks.chars.BeginNewlineCheck',
|
|
||||||
# 'weblate.checks.chars.EndNewlineCheck',
|
|
||||||
# 'weblate.checks.chars.BeginSpaceCheck',
|
|
||||||
# 'weblate.checks.chars.EndSpaceCheck',
|
|
||||||
# 'weblate.checks.chars.EndStopCheck',
|
|
||||||
# 'weblate.checks.chars.EndColonCheck',
|
|
||||||
# 'weblate.checks.chars.EndQuestionCheck',
|
|
||||||
# 'weblate.checks.chars.EndExclamationCheck',
|
|
||||||
# 'weblate.checks.chars.EndEllipsisCheck',
|
|
||||||
# 'weblate.checks.chars.EndSemicolonCheck',
|
|
||||||
# 'weblate.checks.chars.MaxLengthCheck',
|
|
||||||
# 'weblate.checks.chars.KashidaCheck',
|
|
||||||
# 'weblate.checks.format.PythonFormatCheck',
|
|
||||||
# 'weblate.checks.format.PythonBraceFormatCheck',
|
|
||||||
# 'weblate.checks.format.PHPFormatCheck',
|
|
||||||
# 'weblate.checks.format.CFormatCheck',
|
|
||||||
# 'weblate.checks.format.PerlFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavaScriptFormatCheck',
|
|
||||||
# 'weblate.checks.format.CSharpFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavaFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavaMessageFormatCheck',
|
|
||||||
# 'weblate.checks.angularjs.AngularJSInterpolationCheck',
|
|
||||||
# 'weblate.checks.consistency.PluralsCheck',
|
|
||||||
# 'weblate.checks.consistency.SamePluralsCheck',
|
|
||||||
# 'weblate.checks.consistency.ConsistencyCheck',
|
|
||||||
# 'weblate.checks.consistency.TranslatedCheck',
|
|
||||||
# 'weblate.checks.chars.NewlineCountingCheck',
|
|
||||||
# 'weblate.checks.markup.BBCodeCheck',
|
|
||||||
# 'weblate.checks.chars.ZeroWidthSpaceCheck',
|
|
||||||
# 'weblate.checks.markup.XMLValidityCheck',
|
|
||||||
# 'weblate.checks.markup.XMLTagsCheck',
|
|
||||||
# 'weblate.checks.markup.MarkdownRefLinkCheck',
|
|
||||||
# 'weblate.checks.markup.MarkdownLinkCheck',
|
|
||||||
# 'weblate.checks.markup.MarkdownSyntaxCheck',
|
|
||||||
# 'weblate.checks.markup.URLCheck',
|
|
||||||
# 'weblate.checks.source.OptionalPluralCheck',
|
|
||||||
# 'weblate.checks.source.EllipsisCheck',
|
|
||||||
# 'weblate.checks.source.MultipleFailingCheck',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of automatic fixups
|
|
||||||
# AUTOFIX_LIST = (
|
|
||||||
# 'weblate.trans.autofixes.whitespace.SameBookendingWhitespace',
|
|
||||||
# 'weblate.trans.autofixes.chars.ReplaceTrailingDotsWithEllipsis',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveZeroSpace',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveControlChars',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of enabled addons
|
|
||||||
# WEBLATE_ADDONS = (
|
|
||||||
# 'weblate.addons.gettext.GenerateMoAddon',
|
|
||||||
# 'weblate.addons.gettext.UpdateLinguasAddon',
|
|
||||||
# 'weblate.addons.gettext.UpdateConfigureAddon',
|
|
||||||
# 'weblate.addons.gettext.MsgmergeAddon',
|
|
||||||
# 'weblate.addons.gettext.GettextCustomizeAddon',
|
|
||||||
# 'weblate.addons.gettext.GettextAuthorComments',
|
|
||||||
# 'weblate.addons.cleanup.CleanupAddon',
|
|
||||||
# 'weblate.addons.consistency.LangaugeConsistencyAddon',
|
|
||||||
# 'weblate.addons.discovery.DiscoveryAddon',
|
|
||||||
# 'weblate.addons.flags.SourceEditAddon',
|
|
||||||
# 'weblate.addons.flags.TargetEditAddon',
|
|
||||||
# 'weblate.addons.generate.GenerateFileAddon',
|
|
||||||
# 'weblate.addons.json.JSONCustomizeAddon',
|
|
||||||
# 'weblate.addons.properties.PropertiesSortAddon',
|
|
||||||
# 'weblate.addons.git.GitSquashAddon',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# E-mail address that error messages come from.
|
|
||||||
SERVER_EMAIL = 'noreply@__DOMAIN__'
|
|
||||||
|
|
||||||
# Default email address to use for various automated correspondence from
|
|
||||||
# the site managers. Used for registration emails.
|
|
||||||
DEFAULT_FROM_EMAIL = '__ADMINMAIL__'
|
|
||||||
|
|
||||||
# List of URLs your site is supposed to serve
|
|
||||||
ALLOWED_HOSTS = ['__DOMAIN__']
|
|
||||||
|
|
||||||
CACHES = {
|
|
||||||
'default': {
|
|
||||||
'BACKEND': 'django_redis.cache.RedisCache',
|
|
||||||
'LOCATION': 'redis://127.0.0.1:6379/__REDIS_DB__',
|
|
||||||
'OPTIONS': {
|
|
||||||
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
|
||||||
'PARSER_CLASS': 'redis.connection.HiredisParser',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'avatar': {
|
|
||||||
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
|
||||||
'LOCATION': os.path.join(BASE_DIR, 'avatar-cache'),
|
|
||||||
'TIMEOUT': 3600,
|
|
||||||
'OPTIONS': {
|
|
||||||
'MAX_ENTRIES': 1000,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example configuration for caching
|
|
||||||
# CACHES = {
|
|
||||||
# 'default': {
|
|
||||||
# 'BACKEND': 'django_redis.cache.RedisCache',
|
|
||||||
# 'LOCATION': 'redis://127.0.0.1:6379/0',
|
|
||||||
# # If redis is running on same host as Weblate, you might
|
|
||||||
# # want to use unix sockets instead:
|
|
||||||
# # 'LOCATION': 'unix:///var/run/redis/redis.sock?db=0',
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
|
||||||
# 'PARSER_CLASS': 'redis.connection.HiredisParser',
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
# 'avatar': {
|
|
||||||
# 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
|
||||||
# 'LOCATION': os.path.join(DATA_DIR, 'avatar-cache'),
|
|
||||||
# 'TIMEOUT': 3600,
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'MAX_ENTRIES': 1000,
|
|
||||||
# },
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
|
|
||||||
# REST framework settings for API
|
|
||||||
REST_FRAMEWORK = {
|
|
||||||
# Use Django's standard `django.contrib.auth` permissions,
|
|
||||||
# or allow read-only access for unauthenticated users.
|
|
||||||
'DEFAULT_PERMISSION_CLASSES': [
|
|
||||||
'rest_framework.permissions.IsAuthenticatedOrReadOnly'
|
|
||||||
],
|
|
||||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
|
||||||
'rest_framework.authentication.TokenAuthentication',
|
|
||||||
'weblate.api.authentication.BearerAuthentication',
|
|
||||||
'rest_framework.authentication.SessionAuthentication',
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_CLASSES': (
|
|
||||||
'rest_framework.throttling.AnonRateThrottle',
|
|
||||||
'rest_framework.throttling.UserRateThrottle'
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_RATES': {
|
|
||||||
'anon': '100/day',
|
|
||||||
'user': '1000/day'
|
|
||||||
},
|
|
||||||
'DEFAULT_PAGINATION_CLASS': (
|
|
||||||
'rest_framework.pagination.PageNumberPagination'
|
|
||||||
),
|
|
||||||
'PAGE_SIZE': 20,
|
|
||||||
'VIEW_DESCRIPTION_FUNCTION': 'weblate.api.views.get_view_description',
|
|
||||||
'UNAUTHENTICATED_USER': 'weblate.auth.models.get_anonymous',
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example for restricting access to logged in users
|
|
||||||
# LOGIN_REQUIRED_URLS = (
|
|
||||||
# r'/(.*)$',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# In such case you will want to include some of the exceptions
|
|
||||||
# LOGIN_REQUIRED_URLS_EXCEPTIONS = (
|
|
||||||
# r'/accounts/(.*)$', # Required for login
|
|
||||||
# r'/admin/login/(.*)$', # Required for admin login
|
|
||||||
# r'/static/(.*)$', # Required for development mode
|
|
||||||
# r'/widgets/(.*)$', # Allowing public access to widgets
|
|
||||||
# r'/data/(.*)$', # Allowing public access to data exports
|
|
||||||
# r'/hooks/(.*)$', # Allowing public access to notification hooks
|
|
||||||
# r'/healthz/$', # Allowing public access to health check
|
|
||||||
# r'/api/(.*)$', # Allowing access to API
|
|
||||||
# r'/js/i18n/$', # JavaScript localization
|
|
||||||
# r'/contact/$', # Optional for contact form
|
|
||||||
# r'/legal/(.*)$', # Optional for legal app
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Silence some of the Django system checks
|
|
||||||
SILENCED_SYSTEM_CHECKS = [
|
|
||||||
# We have modified django.contrib.auth.middleware.AuthenticationMiddleware
|
|
||||||
# as weblate.accounts.middleware.AuthenticationMiddleware
|
|
||||||
'admin.E408',
|
|
||||||
]
|
|
||||||
|
|
||||||
# Celery worker configuration for testing
|
|
||||||
# CELERY_TASK_ALWAYS_EAGER = True
|
|
||||||
# CELERY_BROKER_URL = 'memory://'
|
|
||||||
# CELERY_TASK_EAGER_PROPAGATES = True
|
|
||||||
# Celery worker configuration for production
|
|
||||||
CELERY_TASK_ALWAYS_EAGER = False
|
|
||||||
CELERY_BROKER_URL = 'redis://127.0.0.1:6379/__REDIS_DB__'
|
|
||||||
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
|
|
||||||
|
|
||||||
# Celery settings, it is not recommended to change these
|
|
||||||
CELERY_WORKER_PREFETCH_MULTIPLIER = 0
|
|
||||||
CELERY_WORKER_MAX_MEMORY_PER_CHILD = 200000
|
|
||||||
CELERY_BEAT_SCHEDULE_FILENAME = os.path.join(
|
|
||||||
DATA_DIR, 'celery', 'beat-schedule'
|
|
||||||
)
|
|
||||||
CELERY_TASK_ROUTES = {
|
|
||||||
'weblate.trans.search.*': {'queue': 'search'},
|
|
||||||
'weblate.trans.tasks.optimize_fulltext': {'queue': 'search'},
|
|
||||||
'weblate.trans.tasks.cleanup_fulltext': {'queue': 'search'},
|
|
||||||
'weblate.memory.tasks.*': {'queue': 'memory'},
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,879 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# Copyright © 2012 - 2019 Michal Čihař <michal@cihar.com>
|
|
||||||
#
|
|
||||||
# This file is part of Weblate <https://weblate.org/>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import os
|
|
||||||
import platform
|
|
||||||
from logging.handlers import SysLogHandler
|
|
||||||
|
|
||||||
#
|
|
||||||
# Django settings for Weblate project.
|
|
||||||
#
|
|
||||||
|
|
||||||
DEBUG = True
|
|
||||||
|
|
||||||
ADMINS = (
|
|
||||||
# ('Your Name', 'your_email@example.com'),
|
|
||||||
)
|
|
||||||
|
|
||||||
MANAGERS = ADMINS
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
# Use 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
|
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
||||||
# Database name or path to database file if using sqlite3.
|
|
||||||
'NAME': '__NAME__',
|
|
||||||
# Database user, not used with sqlite3.
|
|
||||||
'USER': '__NAME__',
|
|
||||||
# Database password, not used with sqlite3.
|
|
||||||
'PASSWORD': '__DB_PWD__',
|
|
||||||
# Set to empty string for localhost. Not used with sqlite3.
|
|
||||||
'HOST': 'localhost',
|
|
||||||
# Set to empty string for default. Not used with sqlite3.
|
|
||||||
'PORT': '5432',
|
|
||||||
# Customizations for databases
|
|
||||||
'OPTIONS': {
|
|
||||||
# In case of using an older MySQL server, which has MyISAM as a default storage
|
|
||||||
# 'init_command': 'SET storage_engine=INNODB',
|
|
||||||
# Uncomment for MySQL older than 5.7:
|
|
||||||
# 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
|
|
||||||
# Set emoji capable charset for MySQL:
|
|
||||||
# 'charset': 'utf8mb4',
|
|
||||||
'sslmode': 'disable'
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BASE_DIR = '__FINALPATH__'
|
|
||||||
|
|
||||||
# Data directory
|
|
||||||
DATA_DIR = os.path.join(BASE_DIR, 'data')
|
|
||||||
TTF_PATH = '__FINALPATH__/venv/lib/__PYTHONPATH__/site-packages/weblate/ttf/'
|
|
||||||
|
|
||||||
# Local time zone for this installation. Choices can be found here:
|
|
||||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
|
||||||
# although not all choices may be available on all operating systems.
|
|
||||||
# In a Windows environment this must be set to your system time zone.
|
|
||||||
TIME_ZONE = 'UTC'
|
|
||||||
|
|
||||||
# Language code for this installation. All choices can be found here:
|
|
||||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
|
||||||
|
|
||||||
LANGUAGES = (
|
|
||||||
('ar', 'العربية'),
|
|
||||||
('az', 'Azərbaycan'),
|
|
||||||
('be', 'Беларуская'),
|
|
||||||
('be@latin', 'Biełaruskaja'),
|
|
||||||
('bg', 'Български'),
|
|
||||||
('br', 'Brezhoneg'),
|
|
||||||
('ca', 'Català'),
|
|
||||||
('cs', 'Čeština'),
|
|
||||||
('da', 'Dansk'),
|
|
||||||
('de', 'Deutsch'),
|
|
||||||
('en', 'English'),
|
|
||||||
('en-gb', 'English (United Kingdom)'),
|
|
||||||
('el', 'Ελληνικά'),
|
|
||||||
('es', 'Español'),
|
|
||||||
('fi', 'Suomi'),
|
|
||||||
('fr', 'Français'),
|
|
||||||
('fy', 'Frysk'),
|
|
||||||
('gl', 'Galego'),
|
|
||||||
('he', 'עברית'),
|
|
||||||
('hu', 'Magyar'),
|
|
||||||
('id', 'Indonesia'),
|
|
||||||
('it', 'Italiano'),
|
|
||||||
('ja', '日本語'),
|
|
||||||
('kk', 'Қазақ тілі'),
|
|
||||||
('ko', '한국어'),
|
|
||||||
('ksh', 'Kölsch'),
|
|
||||||
('nb', 'Norsk bokmål'),
|
|
||||||
('nl', 'Nederlands'),
|
|
||||||
('pl', 'Polski'),
|
|
||||||
('pt', 'Português'),
|
|
||||||
('pt-br', 'Português brasileiro'),
|
|
||||||
('ru', 'Русский'),
|
|
||||||
('sk', 'Slovenčina'),
|
|
||||||
('sl', 'Slovenščina'),
|
|
||||||
('sr', 'Српски'),
|
|
||||||
('sv', 'Svenska'),
|
|
||||||
('tr', 'Türkçe'),
|
|
||||||
('uk', 'Українська'),
|
|
||||||
('zh-hans', '简体字'),
|
|
||||||
('zh-hant', '正體字'),
|
|
||||||
)
|
|
||||||
|
|
||||||
SITE_ID = 1
|
|
||||||
|
|
||||||
# If you set this to False, Django will make some optimizations so as not
|
|
||||||
# to load the internationalization machinery.
|
|
||||||
USE_I18N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not format dates, numbers and
|
|
||||||
# calendars according to the current locale.
|
|
||||||
USE_L10N = True
|
|
||||||
|
|
||||||
# If you set this to False, Django will not use timezone-aware datetimes.
|
|
||||||
USE_TZ = True
|
|
||||||
|
|
||||||
# URL prefix to use, please see documentation for more details
|
|
||||||
URL_PREFIX = '__PATHURL__'
|
|
||||||
|
|
||||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
|
||||||
# Example: "/home/media/media.lawrence.com/media/"
|
|
||||||
MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
|
|
||||||
|
|
||||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
|
||||||
# trailing slash.
|
|
||||||
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
|
||||||
MEDIA_URL = '{0}/media/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Absolute path to the directory static files should be collected to.
|
|
||||||
# Don't put anything in this directory yourself; store your static files
|
|
||||||
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
|
|
||||||
# Example: "/home/media/media.lawrence.com/static/"
|
|
||||||
STATIC_ROOT = os.path.join(DATA_DIR, 'static')
|
|
||||||
|
|
||||||
# URL prefix for static files.
|
|
||||||
# Example: "http://media.lawrence.com/static/"
|
|
||||||
STATIC_URL = '{0}/static/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Additional locations of static files
|
|
||||||
STATICFILES_DIRS = (
|
|
||||||
# Put strings here, like "/home/html/static" or "C:/www/django/static".
|
|
||||||
# Always use forward slashes, even on Windows.
|
|
||||||
# Don't forget to use absolute paths, not relative paths.
|
|
||||||
)
|
|
||||||
|
|
||||||
# List of finder classes that know how to find static files in
|
|
||||||
# various locations.
|
|
||||||
STATICFILES_FINDERS = (
|
|
||||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
|
||||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
|
||||||
'compressor.finders.CompressorFinder',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Make this unique, and don't share it with anybody.
|
|
||||||
# You can generate it using weblate/examples/generate-secret-key
|
|
||||||
SECRET_KEY = '__KEY__' # noqa
|
|
||||||
|
|
||||||
TEMPLATES = [
|
|
||||||
{
|
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
||||||
'DIRS': [
|
|
||||||
os.path.join(BASE_DIR, 'weblate', 'templates'),
|
|
||||||
],
|
|
||||||
'OPTIONS': {
|
|
||||||
'context_processors': [
|
|
||||||
'django.contrib.auth.context_processors.auth',
|
|
||||||
'django.template.context_processors.debug',
|
|
||||||
'django.template.context_processors.i18n',
|
|
||||||
'django.template.context_processors.request',
|
|
||||||
'django.template.context_processors.csrf',
|
|
||||||
'django.contrib.messages.context_processors.messages',
|
|
||||||
'weblate.trans.context_processors.weblate_context',
|
|
||||||
],
|
|
||||||
'loaders': [
|
|
||||||
('django.template.loaders.cached.Loader', [
|
|
||||||
'django.template.loaders.filesystem.Loader',
|
|
||||||
'django.template.loaders.app_directories.Loader',
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# GitHub username for sending pull requests.
|
|
||||||
# Please see the documentation for more details.
|
|
||||||
GITHUB_USERNAME = "__GITHUBUSER__"
|
|
||||||
|
|
||||||
# Authentication configuration
|
|
||||||
AUTHENTICATION_BACKENDS = (
|
|
||||||
'social_core.backends.email.EmailAuth',
|
|
||||||
# 'social_core.backends.google.GoogleOAuth2',
|
|
||||||
# 'social_core.backends.github.GithubOAuth2',
|
|
||||||
# 'social_core.backends.bitbucket.BitbucketOAuth',
|
|
||||||
'social_core.backends.suse.OpenSUSEOpenId',
|
|
||||||
'social_core.backends.ubuntu.UbuntuOpenId',
|
|
||||||
'social_core.backends.fedora.FedoraOpenId',
|
|
||||||
# 'social_core.backends.facebook.FacebookOAuth2',
|
|
||||||
'weblate.accounts.auth.WeblateUserBackend',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom user model
|
|
||||||
AUTH_USER_MODEL = 'weblate_auth.User'
|
|
||||||
|
|
||||||
# Social auth backends setup
|
|
||||||
SOCIAL_AUTH_GITHUB_KEY = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SECRET = ''
|
|
||||||
SOCIAL_AUTH_GITHUB_SCOPE = ['user:email']
|
|
||||||
|
|
||||||
SOCIAL_AUTH_BITBUCKET_KEY = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_SECRET = ''
|
|
||||||
SOCIAL_AUTH_BITBUCKET_VERIFIED_EMAILS_ONLY = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_FACEBOOK_KEY = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SECRET = ''
|
|
||||||
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email', 'public_profile']
|
|
||||||
SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {'fields': 'id,name,email'}
|
|
||||||
SOCIAL_AUTH_FACEBOOK_API_VERSION = '3.1'
|
|
||||||
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = ''
|
|
||||||
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = ''
|
|
||||||
|
|
||||||
# Social auth settings
|
|
||||||
SOCIAL_AUTH_PIPELINE = (
|
|
||||||
'social_core.pipeline.social_auth.social_details',
|
|
||||||
'social_core.pipeline.social_auth.social_uid',
|
|
||||||
'social_core.pipeline.social_auth.auth_allowed',
|
|
||||||
'social_core.pipeline.social_auth.social_user',
|
|
||||||
'weblate.accounts.pipeline.store_params',
|
|
||||||
'weblate.accounts.pipeline.verify_open',
|
|
||||||
'social_core.pipeline.user.get_username',
|
|
||||||
'weblate.accounts.pipeline.require_email',
|
|
||||||
'social_core.pipeline.mail.mail_validation',
|
|
||||||
'weblate.accounts.pipeline.revoke_mail_code',
|
|
||||||
'weblate.accounts.pipeline.ensure_valid',
|
|
||||||
'weblate.accounts.pipeline.remove_account',
|
|
||||||
'social_core.pipeline.social_auth.associate_by_email',
|
|
||||||
'weblate.accounts.pipeline.reauthenticate',
|
|
||||||
'weblate.accounts.pipeline.verify_username',
|
|
||||||
'social_core.pipeline.user.create_user',
|
|
||||||
'social_core.pipeline.social_auth.associate_user',
|
|
||||||
'social_core.pipeline.social_auth.load_extra_data',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
'weblate.accounts.pipeline.user_full_name',
|
|
||||||
'weblate.accounts.pipeline.store_email',
|
|
||||||
'weblate.accounts.pipeline.notify_connect',
|
|
||||||
'weblate.accounts.pipeline.password_reset',
|
|
||||||
)
|
|
||||||
SOCIAL_AUTH_DISCONNECT_PIPELINE = (
|
|
||||||
'social_core.pipeline.disconnect.allowed_to_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.get_entries',
|
|
||||||
'social_core.pipeline.disconnect.revoke_tokens',
|
|
||||||
'weblate.accounts.pipeline.cycle_session',
|
|
||||||
'weblate.accounts.pipeline.adjust_primary_mail',
|
|
||||||
'weblate.accounts.pipeline.notify_disconnect',
|
|
||||||
'social_core.pipeline.disconnect.disconnect',
|
|
||||||
'weblate.accounts.pipeline.cleanup_next',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom authentication strategy
|
|
||||||
SOCIAL_AUTH_STRATEGY = 'weblate.accounts.strategy.WeblateStrategy'
|
|
||||||
|
|
||||||
# Raise exceptions so that we can handle them later
|
|
||||||
SOCIAL_AUTH_RAISE_EXCEPTIONS = True
|
|
||||||
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_FUNCTION = \
|
|
||||||
'weblate.accounts.pipeline.send_validation'
|
|
||||||
SOCIAL_AUTH_EMAIL_VALIDATION_URL = \
|
|
||||||
'{0}/accounts/email-sent/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_LOGIN_ERROR_URL = \
|
|
||||||
'{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_EMAIL_FORM_URL = \
|
|
||||||
'{0}/accounts/email/'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL = \
|
|
||||||
'{0}/accounts/profile/#account'.format(URL_PREFIX)
|
|
||||||
SOCIAL_AUTH_PROTECTED_USER_FIELDS = ('email',)
|
|
||||||
SOCIAL_AUTH_SLUGIFY_USERNAMES = True
|
|
||||||
SOCIAL_AUTH_SLUGIFY_FUNCTION = 'weblate.accounts.pipeline.slugify_username'
|
|
||||||
|
|
||||||
# Password validation configuration
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', # noqa: E501, pylint: disable=line-too-long
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
||||||
'OPTIONS': {
|
|
||||||
'min_length': 6,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.CharsPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'weblate.accounts.password_validation.PastPasswordsValidator',
|
|
||||||
},
|
|
||||||
# Optional password strength validation by django-zxcvbn-password
|
|
||||||
# {
|
|
||||||
# 'NAME': 'zxcvbn_password.ZXCVBNValidator',
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'min_score': 3,
|
|
||||||
# 'user_attributes': ('username', 'email', 'full_name')
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
]
|
|
||||||
|
|
||||||
# Allow new user registrations
|
|
||||||
REGISTRATION_OPEN = True
|
|
||||||
|
|
||||||
# Middleware
|
|
||||||
MIDDLEWARE = [
|
|
||||||
'weblate.middleware.ProxyMiddleware',
|
|
||||||
'django.middleware.security.SecurityMiddleware',
|
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
||||||
'django.middleware.common.CommonMiddleware',
|
|
||||||
'django.middleware.locale.LocaleMiddleware',
|
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
|
||||||
'weblate.accounts.middleware.AuthenticationMiddleware',
|
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
||||||
'social_django.middleware.SocialAuthExceptionMiddleware',
|
|
||||||
'weblate.accounts.middleware.RequireLoginMiddleware',
|
|
||||||
'weblate.middleware.SecurityMiddleware',
|
|
||||||
]
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'weblate.urls'
|
|
||||||
|
|
||||||
# Django and Weblate apps
|
|
||||||
INSTALLED_APPS = (
|
|
||||||
'django.contrib.auth',
|
|
||||||
'django.contrib.contenttypes',
|
|
||||||
'django.contrib.sessions',
|
|
||||||
'django.contrib.sites',
|
|
||||||
'django.contrib.messages',
|
|
||||||
'django.contrib.staticfiles',
|
|
||||||
'django.contrib.admin.apps.SimpleAdminConfig',
|
|
||||||
'django.contrib.admindocs',
|
|
||||||
'django.contrib.sitemaps',
|
|
||||||
'social_django',
|
|
||||||
'crispy_forms',
|
|
||||||
'compressor',
|
|
||||||
'rest_framework',
|
|
||||||
'rest_framework.authtoken',
|
|
||||||
'weblate.addons',
|
|
||||||
'weblate.auth',
|
|
||||||
'weblate.checks',
|
|
||||||
'weblate.formats',
|
|
||||||
'weblate.machinery',
|
|
||||||
'weblate.trans',
|
|
||||||
'weblate.lang',
|
|
||||||
'weblate.langdata',
|
|
||||||
'weblate.memory',
|
|
||||||
'weblate.screenshots',
|
|
||||||
'weblate.fonts',
|
|
||||||
'weblate.accounts',
|
|
||||||
'weblate.utils',
|
|
||||||
'weblate.vcs',
|
|
||||||
'weblate.wladmin',
|
|
||||||
'weblate',
|
|
||||||
|
|
||||||
# Optional: Git exporter
|
|
||||||
# 'weblate.gitexport',
|
|
||||||
)
|
|
||||||
|
|
||||||
# Path to locales
|
|
||||||
LOCALE_PATHS = (os.path.join(BASE_DIR, 'weblate', 'locale'), )
|
|
||||||
|
|
||||||
# Custom exception reporter to include some details
|
|
||||||
DEFAULT_EXCEPTION_REPORTER_FILTER = \
|
|
||||||
'weblate.trans.debug.WeblateExceptionReporterFilter'
|
|
||||||
|
|
||||||
# Default logging of Weblate messages
|
|
||||||
# - to syslog in production (if available)
|
|
||||||
# - otherwise to console
|
|
||||||
# - you can also choose 'logfile' to log into separate file
|
|
||||||
# after configuring it below
|
|
||||||
|
|
||||||
# Detect if we can connect to syslog
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
if platform.system() != 'Windows':
|
|
||||||
try:
|
|
||||||
handler = SysLogHandler(
|
|
||||||
address='/dev/log', facility=SysLogHandler.LOG_LOCAL2
|
|
||||||
)
|
|
||||||
handler.close()
|
|
||||||
HAVE_SYSLOG = True
|
|
||||||
except IOError:
|
|
||||||
HAVE_SYSLOG = False
|
|
||||||
|
|
||||||
if DEBUG or not HAVE_SYSLOG:
|
|
||||||
DEFAULT_LOG = 'console'
|
|
||||||
else:
|
|
||||||
DEFAULT_LOG = 'syslog'
|
|
||||||
|
|
||||||
# A sample logging configuration. The only tangible logging
|
|
||||||
# performed by this configuration is to send an email to
|
|
||||||
# the site admins on every HTTP 500 error when DEBUG=False.
|
|
||||||
# See http://docs.djangoproject.com/en/stable/topics/logging for
|
|
||||||
# more details on how to customize your logging configuration.
|
|
||||||
LOGGING = {
|
|
||||||
'version': 1,
|
|
||||||
'disable_existing_loggers': True,
|
|
||||||
'filters': {
|
|
||||||
'require_debug_false': {
|
|
||||||
'()': 'django.utils.log.RequireDebugFalse'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'formatters': {
|
|
||||||
'syslog': {
|
|
||||||
'format': 'weblate[%(process)d]: %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'simple': {
|
|
||||||
'format': '%(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'logfile': {
|
|
||||||
'format': '%(asctime)s %(levelname)s %(message)s'
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'()': 'django.utils.log.ServerFormatter',
|
|
||||||
'format': '[%(server_time)s] %(message)s',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'handlers': {
|
|
||||||
'mail_admins': {
|
|
||||||
'level': 'ERROR',
|
|
||||||
'filters': ['require_debug_false'],
|
|
||||||
'class': 'django.utils.log.AdminEmailHandler',
|
|
||||||
'include_html': True,
|
|
||||||
},
|
|
||||||
'console': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'simple'
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'level': 'INFO',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'django.server',
|
|
||||||
},
|
|
||||||
'syslog': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.handlers.SysLogHandler',
|
|
||||||
'formatter': 'syslog',
|
|
||||||
'address': '/dev/log',
|
|
||||||
'facility': SysLogHandler.LOG_LOCAL2,
|
|
||||||
},
|
|
||||||
# Logging to a file
|
|
||||||
# 'logfile': {
|
|
||||||
# 'level':'DEBUG',
|
|
||||||
# 'class':'logging.handlers.RotatingFileHandler',
|
|
||||||
# 'filename': "/var/log/weblate/weblate.log",
|
|
||||||
# 'maxBytes': 100000,
|
|
||||||
# 'backupCount': 3,
|
|
||||||
# 'formatter': 'logfile',
|
|
||||||
# },
|
|
||||||
},
|
|
||||||
'loggers': {
|
|
||||||
'django.request': {
|
|
||||||
'handlers': ['mail_admins', DEFAULT_LOG],
|
|
||||||
'level': 'ERROR',
|
|
||||||
'propagate': True,
|
|
||||||
},
|
|
||||||
'django.server': {
|
|
||||||
'handlers': ['django.server'],
|
|
||||||
'level': 'INFO',
|
|
||||||
'propagate': False,
|
|
||||||
},
|
|
||||||
# Logging database queries
|
|
||||||
# 'django.db.backends': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
'weblate': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'DEBUG',
|
|
||||||
},
|
|
||||||
# Logging search operations
|
|
||||||
'weblate.search': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'INFO',
|
|
||||||
},
|
|
||||||
# Logging VCS operations
|
|
||||||
'weblate.vcs': {
|
|
||||||
'handlers': [DEFAULT_LOG],
|
|
||||||
'level': 'WARNING',
|
|
||||||
},
|
|
||||||
# Python Social Auth logging
|
|
||||||
# 'social': {
|
|
||||||
# 'handlers': [DEFAULT_LOG],
|
|
||||||
# 'level': 'DEBUG',
|
|
||||||
# },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Logging of management commands to console
|
|
||||||
if (os.environ.get('DJANGO_IS_MANAGEMENT_COMMAND', False)
|
|
||||||
and 'console' not in LOGGING['loggers']['weblate']['handlers']):
|
|
||||||
LOGGING['loggers']['weblate']['handlers'].append('console')
|
|
||||||
|
|
||||||
# Remove syslog setup if it's not present
|
|
||||||
if not HAVE_SYSLOG:
|
|
||||||
del LOGGING['handlers']['syslog']
|
|
||||||
|
|
||||||
# List of machine translations
|
|
||||||
# MT_SERVICES = (
|
|
||||||
# 'weblate.machinery.apertium.ApertiumAPYTranslation',
|
|
||||||
# 'weblate.machinery.baidu.BaiduTranslation',
|
|
||||||
# 'weblate.machinery.deepl.DeepLTranslation',
|
|
||||||
# 'weblate.machinery.glosbe.GlosbeTranslation',
|
|
||||||
# 'weblate.machinery.google.GoogleTranslation',
|
|
||||||
# 'weblate.machinery.microsoft.MicrosoftCognitiveTranslation',
|
|
||||||
# 'weblate.machinery.microsoftterminology.MicrosoftTerminologyService',
|
|
||||||
# 'weblate.machinery.mymemory.MyMemoryTranslation',
|
|
||||||
# 'weblate.machinery.netease.NeteaseSightTranslation',
|
|
||||||
# 'weblate.machinery.tmserver.AmagamaTranslation',
|
|
||||||
# 'weblate.machinery.tmserver.TMServerTranslation',
|
|
||||||
# 'weblate.machinery.yandex.YandexTranslation',
|
|
||||||
# 'weblate.machinery.weblatetm.WeblateTranslation',
|
|
||||||
# 'weblate.machinery.saptranslationhub.SAPTranslationHub',
|
|
||||||
# 'weblate.machinery.youdao.YoudaoTranslation',
|
|
||||||
# 'weblate.memory.machine.WeblateMemory',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Machine translation API keys
|
|
||||||
|
|
||||||
# URL of the Apertium APy server
|
|
||||||
MT_APERTIUM_APY = None
|
|
||||||
|
|
||||||
# DeepL API key
|
|
||||||
MT_DEEPL_KEY = None
|
|
||||||
|
|
||||||
# Microsoft Cognitive Services Translator API, register at
|
|
||||||
# https://portal.azure.com/
|
|
||||||
MT_MICROSOFT_COGNITIVE_KEY = None
|
|
||||||
|
|
||||||
# MyMemory identification email, see
|
|
||||||
# https://mymemory.translated.net/doc/spec.php
|
|
||||||
MT_MYMEMORY_EMAIL = None
|
|
||||||
|
|
||||||
# Optional MyMemory credentials to access private translation memory
|
|
||||||
MT_MYMEMORY_USER = None
|
|
||||||
MT_MYMEMORY_KEY = None
|
|
||||||
|
|
||||||
# Google API key for Google Translate API
|
|
||||||
MT_GOOGLE_KEY = None
|
|
||||||
|
|
||||||
# Baidu app key and secret
|
|
||||||
MT_BAIDU_ID = None
|
|
||||||
MT_BAIDU_SECRET = None
|
|
||||||
|
|
||||||
# Youdao Zhiyun app key and secret
|
|
||||||
MT_YOUDAO_ID = None
|
|
||||||
MT_YOUDAO_SECRET = None
|
|
||||||
|
|
||||||
# Netease Sight (Jianwai) app key and secret
|
|
||||||
MT_NETEASE_KEY = None
|
|
||||||
MT_NETEASE_SECRET = None
|
|
||||||
|
|
||||||
# API key for Yandex Translate API
|
|
||||||
MT_YANDEX_KEY = None
|
|
||||||
|
|
||||||
# tmserver URL
|
|
||||||
MT_TMSERVER = None
|
|
||||||
|
|
||||||
# SAP Translation Hub
|
|
||||||
MT_SAP_BASE_URL = None
|
|
||||||
MT_SAP_SANDBOX_APIKEY = None
|
|
||||||
MT_SAP_USERNAME = None
|
|
||||||
MT_SAP_PASSWORD = None
|
|
||||||
MT_SAP_USE_MT = True
|
|
||||||
|
|
||||||
# Title of site to use
|
|
||||||
SITE_TITLE = 'Weblate'
|
|
||||||
|
|
||||||
# Whether site uses https
|
|
||||||
ENABLE_HTTPS = True
|
|
||||||
|
|
||||||
# Use HTTPS when creating redirect URLs for social authentication, see
|
|
||||||
# documentation for more details:
|
|
||||||
# https://python-social-auth-docs.readthedocs.io/en/latest/configuration/settings.html#processing-redirects-and-urlopen
|
|
||||||
SOCIAL_AUTH_REDIRECT_IS_HTTPS = ENABLE_HTTPS
|
|
||||||
|
|
||||||
# Make CSRF cookie HttpOnly, see documentation for more details:
|
|
||||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#csrf-cookie-httponly
|
|
||||||
CSRF_COOKIE_HTTPONLY = True
|
|
||||||
CSRF_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# Store CSRF token in session
|
|
||||||
CSRF_USE_SESSIONS = True
|
|
||||||
# Customize CSRF failure view
|
|
||||||
CSRF_FAILURE_VIEW = 'weblate.trans.views.error.csrf_failure'
|
|
||||||
SESSION_COOKIE_SECURE = ENABLE_HTTPS
|
|
||||||
# SSL redirect
|
|
||||||
SECURE_SSL_REDIRECT = ENABLE_HTTPS
|
|
||||||
# Session cookie age (in seconds)
|
|
||||||
SESSION_COOKIE_AGE = 1209600
|
|
||||||
|
|
||||||
# Some security headers
|
|
||||||
SECURE_BROWSER_XSS_FILTER = True
|
|
||||||
X_FRAME_OPTIONS = 'DENY'
|
|
||||||
SECURE_CONTENT_TYPE_NOSNIFF = True
|
|
||||||
|
|
||||||
# Optionally enable HSTS
|
|
||||||
SECURE_HSTS_SECONDS = 0
|
|
||||||
SECURE_HSTS_PRELOAD = False
|
|
||||||
SECURE_HSTS_INCLUDE_SUBDOMAINS = False
|
|
||||||
|
|
||||||
# URL of login
|
|
||||||
LOGIN_URL = '{0}/accounts/login/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# URL of logout
|
|
||||||
LOGOUT_URL = '{0}/accounts/logout/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Default location for login
|
|
||||||
LOGIN_REDIRECT_URL = '{0}/'.format(URL_PREFIX)
|
|
||||||
|
|
||||||
# Anonymous user name
|
|
||||||
ANONYMOUS_USER_NAME = 'anonymous'
|
|
||||||
|
|
||||||
# Reverse proxy settings
|
|
||||||
IP_PROXY_HEADER = 'HTTP_X_FORWARDED_FOR'
|
|
||||||
IP_BEHIND_REVERSE_PROXY = False
|
|
||||||
IP_PROXY_OFFSET = 0
|
|
||||||
|
|
||||||
# Sending HTML in mails
|
|
||||||
EMAIL_SEND_HTML = True
|
|
||||||
|
|
||||||
# Subject of emails includes site title
|
|
||||||
EMAIL_SUBJECT_PREFIX = '[{0}] '.format(SITE_TITLE)
|
|
||||||
|
|
||||||
EMAIL_BACKEND = 'django_sendmail_backend.backends.EmailBackend'
|
|
||||||
|
|
||||||
# Enable remote hooks
|
|
||||||
ENABLE_HOOKS = True
|
|
||||||
|
|
||||||
# Number of nearby messages to show in each direction
|
|
||||||
NEARBY_MESSAGES = 5
|
|
||||||
|
|
||||||
# By default the length of a given translation is limited to the length of
|
|
||||||
# the source string * 10 characters. Set this option to False to allow longer
|
|
||||||
# translations (up to 10.000 characters)
|
|
||||||
LIMIT_TRANSLATION_LENGTH_BY_SOURCE_LENGTH = True
|
|
||||||
|
|
||||||
# Use simple language codes for default language/country combinations
|
|
||||||
SIMPLIFY_LANGUAGES = True
|
|
||||||
|
|
||||||
# Render forms using bootstrap
|
|
||||||
CRISPY_TEMPLATE_PACK = 'bootstrap3'
|
|
||||||
|
|
||||||
# List of quality checks
|
|
||||||
# CHECK_LIST = (
|
|
||||||
# 'weblate.checks.same.SameCheck',
|
|
||||||
# 'weblate.checks.chars.BeginNewlineCheck',
|
|
||||||
# 'weblate.checks.chars.EndNewlineCheck',
|
|
||||||
# 'weblate.checks.chars.BeginSpaceCheck',
|
|
||||||
# 'weblate.checks.chars.EndSpaceCheck',
|
|
||||||
# 'weblate.checks.chars.EndStopCheck',
|
|
||||||
# 'weblate.checks.chars.EndColonCheck',
|
|
||||||
# 'weblate.checks.chars.EndQuestionCheck',
|
|
||||||
# 'weblate.checks.chars.EndExclamationCheck',
|
|
||||||
# 'weblate.checks.chars.EndEllipsisCheck',
|
|
||||||
# 'weblate.checks.chars.EndSemicolonCheck',
|
|
||||||
# 'weblate.checks.chars.MaxLengthCheck',
|
|
||||||
# 'weblate.checks.chars.KashidaCheck',
|
|
||||||
# 'weblate.checks.format.PythonFormatCheck',
|
|
||||||
# 'weblate.checks.format.PythonBraceFormatCheck',
|
|
||||||
# 'weblate.checks.format.PHPFormatCheck',
|
|
||||||
# 'weblate.checks.format.CFormatCheck',
|
|
||||||
# 'weblate.checks.format.PerlFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavaScriptFormatCheck',
|
|
||||||
# 'weblate.checks.format.CSharpFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavaFormatCheck',
|
|
||||||
# 'weblate.checks.format.JavaMessageFormatCheck',
|
|
||||||
# 'weblate.checks.angularjs.AngularJSInterpolationCheck',
|
|
||||||
# 'weblate.checks.consistency.PluralsCheck',
|
|
||||||
# 'weblate.checks.consistency.SamePluralsCheck',
|
|
||||||
# 'weblate.checks.consistency.ConsistencyCheck',
|
|
||||||
# 'weblate.checks.consistency.TranslatedCheck',
|
|
||||||
# 'weblate.checks.chars.NewlineCountingCheck',
|
|
||||||
# 'weblate.checks.markup.BBCodeCheck',
|
|
||||||
# 'weblate.checks.chars.ZeroWidthSpaceCheck',
|
|
||||||
# 'weblate.checks.render.MaxSizeCheck',
|
|
||||||
# 'weblate.checks.markup.XMLValidityCheck',
|
|
||||||
# 'weblate.checks.markup.XMLTagsCheck',
|
|
||||||
# 'weblate.checks.markup.MarkdownRefLinkCheck',
|
|
||||||
# 'weblate.checks.markup.MarkdownLinkCheck',
|
|
||||||
# 'weblate.checks.markup.MarkdownSyntaxCheck',
|
|
||||||
# 'weblate.checks.markup.URLCheck',
|
|
||||||
# 'weblate.checks.source.OptionalPluralCheck',
|
|
||||||
# 'weblate.checks.source.EllipsisCheck',
|
|
||||||
# 'weblate.checks.source.MultipleFailingCheck',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of automatic fixups
|
|
||||||
# AUTOFIX_LIST = (
|
|
||||||
# 'weblate.trans.autofixes.whitespace.SameBookendingWhitespace',
|
|
||||||
# 'weblate.trans.autofixes.chars.ReplaceTrailingDotsWithEllipsis',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveZeroSpace',
|
|
||||||
# 'weblate.trans.autofixes.chars.RemoveControlChars',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# List of enabled addons
|
|
||||||
# WEBLATE_ADDONS = (
|
|
||||||
# 'weblate.addons.gettext.GenerateMoAddon',
|
|
||||||
# 'weblate.addons.gettext.UpdateLinguasAddon',
|
|
||||||
# 'weblate.addons.gettext.UpdateConfigureAddon',
|
|
||||||
# 'weblate.addons.gettext.MsgmergeAddon',
|
|
||||||
# 'weblate.addons.gettext.GettextCustomizeAddon',
|
|
||||||
# 'weblate.addons.gettext.GettextAuthorComments',
|
|
||||||
# 'weblate.addons.cleanup.CleanupAddon',
|
|
||||||
# 'weblate.addons.consistency.LangaugeConsistencyAddon',
|
|
||||||
# 'weblate.addons.discovery.DiscoveryAddon',
|
|
||||||
# 'weblate.addons.flags.SourceEditAddon',
|
|
||||||
# 'weblate.addons.flags.TargetEditAddon',
|
|
||||||
# 'weblate.addons.flags.SameEditAddon',
|
|
||||||
# 'weblate.addons.generate.GenerateFileAddon',
|
|
||||||
# 'weblate.addons.json.JSONCustomizeAddon',
|
|
||||||
# 'weblate.addons.properties.PropertiesSortAddon',
|
|
||||||
# 'weblate.addons.git.GitSquashAddon',
|
|
||||||
# 'weblate.addons.removal.RemoveComments',
|
|
||||||
# 'weblate.addons.removal.RemoveSuggestions',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# E-mail address that error messages come from.
|
|
||||||
SERVER_EMAIL = 'noreply@__DOMAIN__'
|
|
||||||
|
|
||||||
# Default email address to use for various automated correspondence from
|
|
||||||
# the site managers. Used for registration emails.
|
|
||||||
DEFAULT_FROM_EMAIL = '__ADMINMAIL__'
|
|
||||||
|
|
||||||
# List of URLs your site is supposed to serve
|
|
||||||
ALLOWED_HOSTS = ['__DOMAIN__']
|
|
||||||
|
|
||||||
CACHES = {
|
|
||||||
'default': {
|
|
||||||
'BACKEND': 'django_redis.cache.RedisCache',
|
|
||||||
'LOCATION': 'redis://127.0.0.1:6379/__REDIS_DB__',
|
|
||||||
'OPTIONS': {
|
|
||||||
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
|
||||||
'PARSER_CLASS': 'redis.connection.HiredisParser',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'avatar': {
|
|
||||||
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
|
||||||
'LOCATION': os.path.join(BASE_DIR, 'avatar-cache'),
|
|
||||||
'TIMEOUT': 3600,
|
|
||||||
'OPTIONS': {
|
|
||||||
'MAX_ENTRIES': 1000,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example configuration for caching
|
|
||||||
# CACHES = {
|
|
||||||
# 'default': {
|
|
||||||
# 'BACKEND': 'django_redis.cache.RedisCache',
|
|
||||||
# 'LOCATION': 'redis://127.0.0.1:6379/0',
|
|
||||||
# # If redis is running on same host as Weblate, you might
|
|
||||||
# # want to use unix sockets instead:
|
|
||||||
# # 'LOCATION': 'unix:///var/run/redis/redis.sock?db=0',
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
|
||||||
# 'PARSER_CLASS': 'redis.connection.HiredisParser',
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
# 'avatar': {
|
|
||||||
# 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
|
||||||
# 'LOCATION': os.path.join(DATA_DIR, 'avatar-cache'),
|
|
||||||
# 'TIMEOUT': 3600,
|
|
||||||
# 'OPTIONS': {
|
|
||||||
# 'MAX_ENTRIES': 1000,
|
|
||||||
# },
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
|
|
||||||
# REST framework settings for API
|
|
||||||
REST_FRAMEWORK = {
|
|
||||||
# Use Django's standard `django.contrib.auth` permissions,
|
|
||||||
# or allow read-only access for unauthenticated users.
|
|
||||||
'DEFAULT_PERMISSION_CLASSES': [
|
|
||||||
'rest_framework.permissions.IsAuthenticatedOrReadOnly'
|
|
||||||
],
|
|
||||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
|
||||||
'rest_framework.authentication.TokenAuthentication',
|
|
||||||
'weblate.api.authentication.BearerAuthentication',
|
|
||||||
'rest_framework.authentication.SessionAuthentication',
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_CLASSES': (
|
|
||||||
'rest_framework.throttling.AnonRateThrottle',
|
|
||||||
'rest_framework.throttling.UserRateThrottle'
|
|
||||||
),
|
|
||||||
'DEFAULT_THROTTLE_RATES': {
|
|
||||||
'anon': '100/day',
|
|
||||||
'user': '1000/day'
|
|
||||||
},
|
|
||||||
'DEFAULT_PAGINATION_CLASS': (
|
|
||||||
'rest_framework.pagination.PageNumberPagination'
|
|
||||||
),
|
|
||||||
'PAGE_SIZE': 20,
|
|
||||||
'VIEW_DESCRIPTION_FUNCTION': 'weblate.api.views.get_view_description',
|
|
||||||
'UNAUTHENTICATED_USER': 'weblate.auth.models.get_anonymous',
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example for restricting access to logged in users
|
|
||||||
# LOGIN_REQUIRED_URLS = (
|
|
||||||
# r'/(.*)$',
|
|
||||||
# )
|
|
||||||
|
|
||||||
# In such case you will want to include some of the exceptions
|
|
||||||
# LOGIN_REQUIRED_URLS_EXCEPTIONS = (
|
|
||||||
# r'/accounts/(.*)$', # Required for login
|
|
||||||
# r'/admin/login/(.*)$', # Required for admin login
|
|
||||||
# r'/static/(.*)$', # Required for development mode
|
|
||||||
# r'/widgets/(.*)$', # Allowing public access to widgets
|
|
||||||
# r'/data/(.*)$', # Allowing public access to data exports
|
|
||||||
# r'/hooks/(.*)$', # Allowing public access to notification hooks
|
|
||||||
# r'/healthz/$', # Allowing public access to health check
|
|
||||||
# r'/api/(.*)$', # Allowing access to API
|
|
||||||
# r'/js/i18n/$', # JavaScript localization
|
|
||||||
# r'/contact/$', # Optional for contact form
|
|
||||||
# r'/legal/(.*)$', # Optional for legal app
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Silence some of the Django system checks
|
|
||||||
SILENCED_SYSTEM_CHECKS = [
|
|
||||||
# We have modified django.contrib.auth.middleware.AuthenticationMiddleware
|
|
||||||
# as weblate.accounts.middleware.AuthenticationMiddleware
|
|
||||||
'admin.E408',
|
|
||||||
]
|
|
||||||
|
|
||||||
# Celery worker configuration for testing
|
|
||||||
# CELERY_TASK_ALWAYS_EAGER = True
|
|
||||||
# CELERY_BROKER_URL = 'memory://'
|
|
||||||
# CELERY_TASK_EAGER_PROPAGATES = True
|
|
||||||
# Celery worker configuration for production
|
|
||||||
CELERY_TASK_ALWAYS_EAGER = False
|
|
||||||
CELERY_BROKER_URL = 'redis://127.0.0.1:6379/__REDIS_DB__'
|
|
||||||
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
|
|
||||||
|
|
||||||
# Celery settings, it is not recommended to change these
|
|
||||||
CELERY_WORKER_PREFETCH_MULTIPLIER = 0
|
|
||||||
CELERY_WORKER_MAX_MEMORY_PER_CHILD = 200000
|
|
||||||
CELERY_BEAT_SCHEDULE_FILENAME = os.path.join(
|
|
||||||
DATA_DIR, 'celery', 'beat-schedule'
|
|
||||||
)
|
|
||||||
CELERY_TASK_ROUTES = {
|
|
||||||
'weblate.trans.search.*': {'queue': 'search'},
|
|
||||||
'weblate.trans.tasks.optimize_fulltext': {'queue': 'search'},
|
|
||||||
'weblate.trans.tasks.cleanup_fulltext': {'queue': 'search'},
|
|
||||||
'weblate.memory.tasks.*': {'queue': 'memory'},
|
|
||||||
'weblate.accounts.tasks.notify_change': {'queue': 'notify'},
|
|
||||||
}
|
|
||||||
|
|
|
@ -3,22 +3,48 @@ plugins = python3
|
||||||
master = true
|
master = true
|
||||||
protocol = uwsgi
|
protocol = uwsgi
|
||||||
socket = /var/run/__APP__/socket
|
socket = /var/run/__APP__/socket
|
||||||
virtualenv = __FINALPATH__/venv
|
|
||||||
|
|
||||||
# http://uwsgi-docs.readthedocs.io/en/latest/Nginx.html#hosting-multiple-apps-in-the-same-process-aka-managing-script-name-and-path-info
|
# http://uwsgi-docs.readthedocs.io/en/latest/Nginx.html#hosting-multiple-apps-in-the-same-process-aka-managing-script-name-and-path-info
|
||||||
mount = __PATH__=__FINALPATH__/venv/lib/__PYTHONPATH__/site-packages/weblate/wsgi.py
|
mount = __PATH__=__FINALPATH__/venv/lib/__PYTHONPATH__/site-packages/weblate/wsgi.py
|
||||||
|
|
||||||
|
# Add path to Weblate checkout if you did not install
|
||||||
|
# Weblate by pip
|
||||||
|
# python-path = /path/to/weblate
|
||||||
|
|
||||||
|
# In case you're using virtualenv uncomment this:
|
||||||
|
virtualenv = __FINALPATH__/venv
|
||||||
|
|
||||||
# Needed for OAuth/OpenID
|
# Needed for OAuth/OpenID
|
||||||
buffer-size = 8192
|
buffer-size = 8192
|
||||||
|
|
||||||
|
# Reload when consuming too much of memory
|
||||||
|
reload-on-rss = 250
|
||||||
|
|
||||||
# Increase number of workers for heavily loaded sites
|
# Increase number of workers for heavily loaded sites
|
||||||
# Needed for background processing
|
workers = 8
|
||||||
|
|
||||||
|
# Enable threads for Sentry error submission
|
||||||
enable-threads = true
|
enable-threads = true
|
||||||
|
|
||||||
# Child processes do not need file descriptors
|
# Child processes do not need file descriptors
|
||||||
close-on-exec = true
|
close-on-exec = true
|
||||||
|
|
||||||
|
# Avoid default 0000 umask
|
||||||
|
umask = 0022
|
||||||
|
|
||||||
# Run as weblate user
|
# Run as weblate user
|
||||||
#uid = __APP__
|
uid = __APP__
|
||||||
#gid = www-data
|
gid = __APP__
|
||||||
|
|
||||||
|
chmod-socket = 666
|
||||||
|
|
||||||
|
# Enable harakiri mode (kill requests after some time)
|
||||||
|
# harakiri = 3600
|
||||||
|
# harakiri-verbose = true
|
||||||
|
|
||||||
|
# Enable uWSGI stats server
|
||||||
|
# stats = :1717
|
||||||
|
# stats-http = true
|
||||||
|
|
||||||
# Do not log some errors caused by client disconnects
|
# Do not log some errors caused by client disconnects
|
||||||
ignore-sigpipe = true
|
ignore-sigpipe = true
|
||||||
|
|
|
@ -5,7 +5,7 @@ After=syslog.target
|
||||||
[Service]
|
[Service]
|
||||||
Type=forking
|
Type=forking
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Group=www-data
|
Group=__APP__
|
||||||
PermissionsStartOnly=true
|
PermissionsStartOnly=true
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,10 +16,7 @@ ExecStartPre=/bin/chown -R __APP__ /var/log/__APP__
|
||||||
|
|
||||||
ExecStart=/usr/bin/uwsgi \
|
ExecStart=/usr/bin/uwsgi \
|
||||||
--ini /etc/uwsgi/apps-available/__APP__.ini \
|
--ini /etc/uwsgi/apps-available/__APP__.ini \
|
||||||
--socket /var/run/__APP__/socket \
|
--logto /var/log/__APP__/weblate.log
|
||||||
--chmod-socket=775 \
|
|
||||||
--logto /var/log/__APP__/weblate.log \
|
|
||||||
--processes 4
|
|
||||||
|
|
||||||
|
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"en": "A translation platform using Git and Python",
|
"en": "A translation platform using Git and Python",
|
||||||
"fr": "Une plateforme de traduction utilisant Git et Python"
|
"fr": "Une plateforme de traduction utilisant Git et Python"
|
||||||
},
|
},
|
||||||
"version": "3.8.0~ynh3",
|
"version": "3.11.3~ynh1",
|
||||||
"url": "https://weblate.org",
|
"url": "https://weblate.org",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
"email": "jean-baptiste@holcroft.fr"
|
"email": "jean-baptiste@holcroft.fr"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 3.5.0"
|
"yunohost": ">= 4.0.0"
|
||||||
},
|
},
|
||||||
"multi_instance": true,
|
"multi_instance": true,
|
||||||
"services": [
|
"services": [
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
"en": "Any YunoHost user and anonymous people from the web will be able to access the application",
|
"en": "Any YunoHost user and anonymous people from the web will be able to access the application",
|
||||||
"fr": "Tout utilisateur YunoHost et les personnes anonymes pourront accéder à l'application"
|
"fr": "Tout utilisateur YunoHost et les personnes anonymes pourront accéder à l'application"
|
||||||
},
|
},
|
||||||
"default": "0"
|
"default": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "admin",
|
"name": "admin",
|
||||||
|
@ -61,7 +61,7 @@
|
||||||
"en": "Choose an admin user for Weblate",
|
"en": "Choose an admin user for Weblate",
|
||||||
"fr": "Choisissez l'administrateur pour Weblate"
|
"fr": "Choisissez l'administrateur pour Weblate"
|
||||||
},
|
},
|
||||||
"example": "simon"
|
"example": "johndoe"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "github_account",
|
"name": "github_account",
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
"en": "GitHub's username",
|
"en": "GitHub's username",
|
||||||
"fr": "Nom d'utilisateur de GitHub"
|
"fr": "Nom d'utilisateur de GitHub"
|
||||||
},
|
},
|
||||||
"example": "simon"
|
"example": "Github account"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "github_token",
|
"name": "github_token",
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
"en": "GitHub's token (OAuth)",
|
"en": "GitHub's token (OAuth)",
|
||||||
"fr": "Jeton GitHub (OAuth)"
|
"fr": "Jeton GitHub (OAuth)"
|
||||||
},
|
},
|
||||||
"example": "simon"
|
"example": "A secret token"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,15 +5,14 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# dependencies used by the app
|
# dependencies used by the app
|
||||||
pkg_dependencies="libxml2-dev libxslt-dev libfreetype6-dev \
|
pkg_dependencies="libxml2-dev libxslt-dev libfreetype6-dev libjpeg-dev libz-dev libyaml-dev \
|
||||||
libjpeg-dev libz-dev libyaml-dev python3-dev python3-pip python3-virtualenv \
|
libcairo-dev gir1.2-pango-1.0 libgirepository1.0-dev libacl1-dev libssl-dev \
|
||||||
python3-enchant \
|
build-essential python3-gdbm python3-enchant python3-dev python3-pip python3-virtualenv virtualenv git \
|
||||||
postgresql libpq-dev uwsgi uwsgi-plugin-python3 \
|
uwsgi uwsgi-plugin-python3 redis-server postgresql postgresql-contrib \
|
||||||
libpango1.0-dev libcairo2-dev libglib2.0-dev libgirepository1.0-dev \
|
libpq-dev libglib2.0-dev mailutils python-celery-common hub"
|
||||||
mailutils python-celery-common virtualenv redis-server"
|
|
||||||
|
|
||||||
# Weblate's version for PIP and settings file
|
# Weblate's version for PIP and settings file
|
||||||
current_version="3.8"
|
current_version="3.11.3"
|
||||||
|
|
||||||
|
|
||||||
debian_maj_version=$(sed 's/\..*//' /etc/debian_version)
|
debian_maj_version=$(sed 's/\..*//' /etc/debian_version)
|
||||||
|
@ -25,46 +24,9 @@ elif [ "$debian_maj_version" -eq 10 ] ; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# EXPERIMENTAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
weblate_fill_settings() {
|
|
||||||
local settings="$1"
|
|
||||||
|
|
||||||
ynh_replace_string "__NAME__" "$app" "$settings"
|
|
||||||
ynh_replace_string "__DB_PWD__" "$db_pwd" "$settings"
|
|
||||||
ynh_replace_string "__ADMIN__" "$admin" "$settings"
|
|
||||||
ynh_replace_string "__ADMINMAIL__" "$admin_mail" "$settings"
|
|
||||||
ynh_replace_string "__DOMAIN__" "$domain" "$settings"
|
|
||||||
ynh_replace_string "__KEY__" "$key" "$settings"
|
|
||||||
ynh_replace_string "__FINALPATH__" "$final_path" "$settings"
|
|
||||||
ynh_replace_string "__GITHUBUSER__" "$github_account" "$settings"
|
|
||||||
ynh_replace_string "__REDIS_DB__" "$redis_db" "$settings"
|
|
||||||
ynh_replace_string "__PYTHONPATH__" "$weblate_pypath" "$settings"
|
|
||||||
|
|
||||||
# root install as an empty PATHURL to prevent '//static'
|
|
||||||
if [ "$path_url" == "/" ]
|
|
||||||
then
|
|
||||||
ynh_replace_string "__PATHURL__" "" "$settings"
|
|
||||||
else
|
|
||||||
ynh_replace_string "__PATHURL__" "$path_url" "$settings"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
ynh_check_if_checksum_is_different() {
|
|
||||||
local file=$1
|
|
||||||
local checksum_setting_name=checksum_${file//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
|
||||||
local checksum_value=$(ynh_app_setting_get $app $checksum_setting_name)
|
|
||||||
local check=0
|
|
||||||
|
|
||||||
if ! echo "$checksum_value $file" | md5sum -c --status
|
|
||||||
then # If the checksum is now different
|
|
||||||
check=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "$check"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Send an email to inform the administrator
|
# Send an email to inform the administrator
|
||||||
#
|
#
|
||||||
# usage: ynh_send_readme_to_admin app_message [recipients]
|
# usage: ynh_send_readme_to_admin app_message [recipients]
|
||||||
|
|
|
@ -14,98 +14,70 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Loading installation settings..."
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||||
db_name=$(ynh_app_setting_get "$app" db_name)
|
db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD BACKUP STEPS
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICE
|
# STOP SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Stopping systemd services..."
|
||||||
ynh_script_progression --message="Stopping systemd services..."
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app" --action="stop"
|
ynh_systemd_action --service_name="$app" --action="stop"
|
||||||
ynh_systemd_action --service_name="$app-celery" --action="stop"
|
ynh_systemd_action --service_name="$app-celery" --action="stop"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info --message="Declaring files to be backed up..."
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Backing up the main app directory..."
|
ynh_backup --src_path="$final_path"
|
||||||
|
|
||||||
ynh_backup "$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE NGINX CONFIGURATION
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Backing up nginx web server configuration..."
|
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE PostgreSQL DATABASE
|
# BACKUP THE PostgreSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Backing up the PostgreSQL database..."
|
ynh_psql_dump_db --database="$db_name" > db.sql
|
||||||
|
|
||||||
ynh_psql_dump_db "$db_name" > db.sql
|
|
||||||
ynh_backup "db.sql"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC BACKUP
|
# SPECIFIC BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP LOGROTATE
|
# BACKUP LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up logrotate configuration..."
|
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE CRON FILE
|
# BACKUP THE UWSGI files
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Backing up systemd configuration..."
|
ynh_backup --src_path="/etc/uwsgi/apps-available/$app.ini"
|
||||||
|
|
||||||
ynh_backup "/etc/cron.d/$app"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE uwsgi files
|
# BACKUP SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Backing up uwsgi configuration..."
|
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||||
|
ynh_backup --src_path="/etc/systemd/system/$app-celery.service"
|
||||||
ynh_backup "/etc/uwsgi/apps-available/$app.ini"
|
|
||||||
ynh_backup "/etc/systemd/system/$app.service"
|
|
||||||
ynh_backup "/etc/systemd/system/$app-celery.service"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP THE celery files
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# nothing to do because it is inside $finalpath
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP THE hub binary file
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_script_progression --message="Backing up uwsgi configuration..."
|
|
||||||
|
|
||||||
ynh_backup /usr/bin/hub
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Starting systemd services..."
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app" --action="start"
|
ynh_systemd_action --service_name="$app" --action="start"
|
||||||
ynh_systemd_action --service_name="$app-celery" --action="start"
|
ynh_systemd_action --service_name="$app-celery" --action="start"
|
||||||
|
|
||||||
|
@ -113,4 +85,4 @@ ynh_systemd_action --service_name="$app-celery" --action="start"
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last
|
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||||
|
|
|
@ -24,10 +24,27 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||||
is_public=$(ynh_app_setting_get "$app" is_public)
|
is_public=$(ynh_app_setting_get --app="$app" --key=is_public)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --time --weight=1
|
||||||
|
|
||||||
|
# Backup the current version of the app
|
||||||
|
ynh_backup_before_upgrade
|
||||||
|
ynh_clean_setup () {
|
||||||
|
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
||||||
|
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
|
|
||||||
|
# restore it if the upgrade fails
|
||||||
|
ynh_restore_upgradebackup
|
||||||
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||||
|
@ -50,8 +67,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICE
|
# STOP SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Stopping systemd services..." --time --weight=1
|
||||||
ynh_script_progression --message="Stopping systemd services..."
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app" --action="stop"
|
ynh_systemd_action --service_name="$app" --action="stop"
|
||||||
ynh_systemd_action --service_name="$app-celery" --action="stop"
|
ynh_systemd_action --service_name="$app-celery" --action="stop"
|
||||||
|
@ -61,88 +77,62 @@ ynh_systemd_action --service_name="$app-celery" --action="stop"
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN NGINX CONF
|
# MODIFY URL IN NGINX CONF
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1
|
||||||
|
|
||||||
ynh_script_progression --message="Updating nginx web server configuration..."
|
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||||
|
|
||||||
nginx_conf_path="/etc/nginx/conf.d/$old_domain.d/$app.conf"
|
|
||||||
finalnginxconf=$nginx_conf_path
|
|
||||||
|
|
||||||
# Change the path in the nginx config file
|
# Change the path in the nginx config file
|
||||||
if [ $change_path -eq 1 ]
|
if [ $change_path -eq 1 ]
|
||||||
then
|
then
|
||||||
ynh_replace_string "location $old_path" "location $new_path" "$nginx_conf_path"
|
# Make a backup of the original nginx config file if modified
|
||||||
ynh_replace_string "SCRIPT_NAME $old_path" "SCRIPT_NAME $new_path" "$nginx_conf_path"
|
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||||
|
# Set global variables for nginx helper
|
||||||
|
domain="$old_domain"
|
||||||
|
path_url="$new_path"
|
||||||
|
# Create a dedicated nginx config
|
||||||
|
ynh_add_nginx_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change the domain for nginx
|
# Change the domain for nginx
|
||||||
if [ $change_domain -eq 1 ]
|
if [ $change_domain -eq 1 ]
|
||||||
then
|
then
|
||||||
|
# Delete file checksum for the old conf file location
|
||||||
finalnginxconf="/etc/nginx/conf.d/${new_domain}.d/${app}.conf"
|
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||||
mv "$nginx_conf_path" "$finalnginxconf"
|
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||||
|
# Store file checksum for the new config file location
|
||||||
|
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# Edit specific content from nginx configuration
|
# SPECIFIC MODIFICATIONS
|
||||||
#=================================================
|
|
||||||
settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py"
|
|
||||||
|
|
||||||
if [ "$old_path" == "/" ] && [ "$new_path" != "/" ]
|
|
||||||
then
|
|
||||||
if [ "$is_public" -eq 0 ]
|
|
||||||
then
|
|
||||||
# ynh panel is only comptable with non-root installation
|
|
||||||
# ynh panel is useless for public websites
|
|
||||||
ynh_replace_string " #include conf.d/" " include conf.d/" "$finalnginxconf"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$old_path" != "/" ] && [ "$new_path" == "/" ]
|
|
||||||
then
|
|
||||||
|
|
||||||
# ynh panel is only comptable with non-root installation
|
|
||||||
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ynh_store_file_checksum "$finalnginxconf"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY settings.py
|
# MODIFY settings.py
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Modify weblate's config file..."
|
ynh_script_progression --message="Modify weblate's config file..." --time --weight=1
|
||||||
|
|
||||||
|
settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py"
|
||||||
|
|
||||||
# Change the path in the nginx config file
|
# Change the path in the nginx config file
|
||||||
if [ $change_path -eq 1 ]
|
if [ $change_path -eq 1 ]
|
||||||
then
|
then
|
||||||
ynh_replace_string "URL_PREFIX = '$old_path" "URL_PREFIX = '$new_path" "$settings"
|
ynh_replace_string --match_string="URL_PREFIX = '${old_path%/}'" --replace_string="URL_PREFIX = '${new_path%/}'" --target_file="$settings"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change the domain for nginx
|
# Change the domain for nginx
|
||||||
if [ $change_domain -eq 1 ]
|
if [ $change_domain -eq 1 ]
|
||||||
then
|
then
|
||||||
# replace SERVER_EMAIL
|
# replace SERVER_EMAIL
|
||||||
ynh_replace_string "noreply@$old_domain" "noreply@$new_domain" "$settings"
|
ynh_replace_string --match_string="noreply@$old_domain" --replace_string="noreply@$new_domain" --target_file="$settings"
|
||||||
# replace ALLOWED_HOSTS
|
# replace ALLOWED_HOSTS
|
||||||
ynh_replace_string "['$old_domain']" "['$new_domain']" "$settings"
|
ynh_replace_string --match_string="['$old_domain']" --replace_string="['$new_domain']" --target_file="$settings"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$old_path" == "/" ] && [ "$new_path" != "/" ]
|
ynh_store_file_checksum --file="$settings"
|
||||||
then
|
|
||||||
ynh_replace_string "URL_PREFIX = ''" "URL_PREFIX = '$new_path'" "$settings"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$old_path" != "/" ] && [ "$new_path" == "/" ]
|
|
||||||
then
|
|
||||||
# root install as an empty PATHURL to prevent '//static'
|
|
||||||
ynh_replace_string "URL_PREFIX = '$old_path'" "URL_PREFIX = ''" "$settings"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ynh_store_file_checksum "$settings"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ChangeSite inside weblate
|
# ChangeSite inside weblate
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Run weblate's command changesite..."
|
ynh_script_progression --message="Run weblate's command changesite..." --time --weight=1
|
||||||
(
|
(
|
||||||
set +eu
|
set +eu
|
||||||
source "${final_path}/venv/bin/activate"
|
source "${final_path}/venv/bin/activate"
|
||||||
|
@ -155,7 +145,7 @@ ynh_script_progression --message="Run weblate's command changesite..."
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting systemd services..."
|
ynh_script_progression --message="Starting systemd services..." --time --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app" --action="start"
|
ynh_systemd_action --service_name="$app" --action="start"
|
||||||
ynh_systemd_action --service_name="$app-celery" --action="start"
|
ynh_systemd_action --service_name="$app-celery" --action="start"
|
||||||
|
@ -163,7 +153,7 @@ ynh_systemd_action --service_name="$app-celery" --action="start"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading nginx web server..."
|
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
@ -171,4 +161,4 @@ ynh_systemd_action --service_name=nginx --action=reload
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
ynh_script_progression --message="Change of URL completed for $app" --time --last
|
||||||
|
|
262
scripts/install
262
scripts/install
|
@ -27,148 +27,85 @@ is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
github_account=$YNH_APP_ARG_GITHUB_ACCOUNT
|
github_account=$YNH_APP_ARG_GITHUB_ACCOUNT
|
||||||
github_token=$YNH_APP_ARG_GITHUB_TOKEN
|
github_token=$YNH_APP_ARG_GITHUB_TOKEN
|
||||||
|
|
||||||
# This is a multi-instance app, meaning it can be installed several times independently
|
|
||||||
# The id of the app as stated in the manifest is available as $YNH_APP_ID
|
|
||||||
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
|
||||||
# The app instance name is available as $YNH_APP_INSTANCE_NAME
|
|
||||||
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
|
||||||
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
|
||||||
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
|
||||||
# The app instance name is probably what you are interested the most, since this is
|
|
||||||
# guaranteed to be unique. This is a good unique identifier to define installation path,
|
|
||||||
# db names, ...
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Validating installation parameters..."
|
ynh_script_progression --message="Validating installation parameters..." --time --weight=1
|
||||||
|
|
||||||
# Register (book) web path
|
|
||||||
ynh_webpath_register "$app" "$domain" "$path_url"
|
|
||||||
|
|
||||||
final_path=/var/www/$app
|
final_path=/var/www/$app
|
||||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||||
|
|
||||||
|
# Register (book) web path
|
||||||
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||||
|
|
||||||
mkdir -p "$final_path"
|
mkdir -p "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Storing installation settings..." --time --weight=1
|
||||||
|
|
||||||
ynh_script_progression --message="Storing installation settings..."
|
ynh_app_setting_set --app="$app" --key=domain --value="$domain"
|
||||||
|
ynh_app_setting_set --app="$app" --key=path --value="$path_url"
|
||||||
ynh_app_setting_set "$app" domain "$domain"
|
ynh_app_setting_set --app="$app" --key=admin --value="$admin"
|
||||||
ynh_app_setting_set "$app" path "$path_url"
|
ynh_app_setting_set --app="$app" --key=is_public --value="$is_public"
|
||||||
ynh_app_setting_set "$app" admin "$admin"
|
ynh_app_setting_set --app="$app" --key=final_path --value="$final_path"
|
||||||
ynh_app_setting_set "$app" is_public "$is_public"
|
ynh_app_setting_set --app="$app" --key=github_account --value="$github_account"
|
||||||
ynh_app_setting_set "$app" final_path "$final_path"
|
ynh_app_setting_set --app="$app" --key=github_token --value="$github_token"
|
||||||
ynh_app_setting_set "$app" github_account "$github_account"
|
|
||||||
ynh_app_setting_set "$app" github_token "$github_token"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Installing dependencies..." --time --weight=1
|
||||||
ynh_script_progression --message="Installing dependencies..."
|
|
||||||
|
|
||||||
ynh_install_app_dependencies "$pkg_dependencies"
|
ynh_install_app_dependencies "$pkg_dependencies"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE A PostgreSQL DATABASE
|
# CREATE A PostgreSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Creating a PostgreSQL database..."
|
ynh_script_progression --message="Creating a PostgreSQL database..." --time --weight=1
|
||||||
|
|
||||||
db_name=$(ynh_sanitize_dbid "$app")
|
db_name=$(ynh_sanitize_dbid --db_name="$app")
|
||||||
ynh_app_setting_set "$app" db_name "$db_name"
|
db_user=$db_name
|
||||||
|
ynh_app_setting_set --app="$app" --key=db_name --value="$db_name"
|
||||||
|
|
||||||
ynh_psql_test_if_first_run
|
ynh_psql_test_if_first_run
|
||||||
|
|
||||||
# Initialize database and store postgres password for upgrade
|
# Initialize database and store postgres password for upgrade
|
||||||
ynh_psql_setup_db "$db_name" "$app"
|
ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name"
|
||||||
|
|
||||||
ynh_systemd_action --service_name=postgresql --action=reload
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring nginx web server..." --time --weight=1
|
||||||
ynh_script_progression --message="Configuring nginx web server..."
|
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
if [ "$path_url" == "/" ]
|
|
||||||
then
|
|
||||||
# $finalnginxconf comes from ynh_add_nginx_config
|
|
||||||
ynh_replace_string "location //" "location /" "$finalnginxconf"
|
|
||||||
|
|
||||||
# ynh panel is only comptable with non-root installation
|
|
||||||
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"
|
|
||||||
|
|
||||||
ynh_store_file_checksum "$finalnginxconf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring system user..." --time --weight=1
|
||||||
ynh_script_progression --message="Configuring system user..."
|
|
||||||
|
|
||||||
# Hub needs a home directory with a config file
|
# Hub needs a home directory with a config file
|
||||||
ynh_system_user_create "$app" "$final_path"
|
ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell
|
||||||
# Allow bash for our user, so he can use Hub
|
|
||||||
chsh --shell /bin/bash "$app"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# Download and install hub
|
# CONFIGURE HUB
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configure hub..." --time --weight=1
|
||||||
ynh_script_progression --message="Download and install hub..."
|
|
||||||
|
|
||||||
arch=$(dpkg --print-architecture)
|
|
||||||
# Rasberry Pi: Debian armhf (ARM hard float) refers to the ARMv7
|
|
||||||
[[ $arch = "armhf" ]] && arch="arm"
|
|
||||||
[[ $arch = "i386" ]] && arch="386"
|
|
||||||
|
|
||||||
version="hub-linux-${arch}-2.3.0-pre10"
|
|
||||||
file_bin="hub-linux-${arch}-2.3.0-pre10.tgz"
|
|
||||||
wget --quiet "https://github.com/github/hub/releases/download/v2.3.0-pre10/${file_bin}"
|
|
||||||
|
|
||||||
case "$arch" in
|
|
||||||
"386")
|
|
||||||
sha256sum="08e29a118577b57f962c7c6e4c2e4bfc72b23df1469f2339631c55454893e24f"
|
|
||||||
;;
|
|
||||||
"amd64")
|
|
||||||
sha256sum="015297eb81e8fe11f3989d8f65c213111e508cecf0e9de8af1b7741de2077320"
|
|
||||||
;;
|
|
||||||
"arm")
|
|
||||||
sha256sum="a05cd6a42c973177c2a0b457451e9eef0035be67c666e4beebe3b9ed6d526f3d"
|
|
||||||
;;
|
|
||||||
"arm64")
|
|
||||||
sha256sum="6d845601196ef26342b8bafa9ab6e98c88270fb6dad60e0915396ba5486d0c76"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
sha256sum="-1"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
[[ $(sha256sum "$file_bin" | cut -d' ' -f1) = "$sha256sum" ]] || ynh_die "Hub's sha256sum failed (arch: ${arch})"
|
|
||||||
|
|
||||||
tar --extract --file "$file_bin" "$version/bin/hub"
|
|
||||||
mv "$version/bin/hub" /usr/bin/
|
|
||||||
|
|
||||||
mkdir "$final_path/.config/"
|
mkdir "$final_path/.config/"
|
||||||
cp ../conf/hub_config "$final_path/.config/hub"
|
cp ../conf/hub_config "$final_path/.config/hub"
|
||||||
ynh_replace_string "__GITHUBUSER__" "$github_account" "$final_path/.config/hub"
|
ynh_replace_string --match_string="__GITHUBUSER__" --replace_string="$github_account" --target_file="$final_path/.config/hub"
|
||||||
ynh_replace_string "__GITHUBTOKEN__" "$github_token" "$final_path/.config/hub"
|
ynh_replace_string --match_string="__GITHUBTOKEN__" --replace_string="$github_token" --target_file="$final_path/.config/hub"
|
||||||
|
|
||||||
cat <<EOF > "$final_path/.bashrc"
|
cat <<EOF > "$final_path/.bashrc"
|
||||||
alias git=hub
|
eval "$(hub alias -s /bin/bash)"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -176,8 +113,7 @@ EOF
|
||||||
#=================================================
|
#=================================================
|
||||||
# PIP INSTALLATION
|
# PIP INSTALLATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Install weblate using PIP..." --time --weight=1
|
||||||
ynh_script_progression --message="Install weblate using PIP..." --weight=10
|
|
||||||
|
|
||||||
virtualenv --python=python3 "${final_path}/venv"
|
virtualenv --python=python3 "${final_path}/venv"
|
||||||
#run source in a 'sub shell'
|
#run source in a 'sub shell'
|
||||||
|
@ -185,12 +121,12 @@ virtualenv --python=python3 "${final_path}/venv"
|
||||||
set +o nounset
|
set +o nounset
|
||||||
source "${final_path}/venv/bin/activate"
|
source "${final_path}/venv/bin/activate"
|
||||||
set -o nounset
|
set -o nounset
|
||||||
pip install --upgrade pip
|
pip install --upgrade pip setuptools wheel
|
||||||
# prevent error: "command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers"
|
# Still needed with latest version of weblate?
|
||||||
pip install --upgrade setuptools
|
pip install Django==2.* celery==4.*
|
||||||
pip install Django==2.2.*
|
|
||||||
pip install Weblate=="$current_version"
|
pip install Weblate=="$current_version"
|
||||||
pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2-binary phply django-redis hiredis aeidon ruamel.yaml
|
pip install psycopg2-binary ruamel.yaml aeidon phply
|
||||||
|
#pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2-binary phply django-redis hiredis aeidon ruamel.yaml
|
||||||
# specific to YunoHost package:
|
# specific to YunoHost package:
|
||||||
pip install django_sendmail_backend
|
pip install django_sendmail_backend
|
||||||
)
|
)
|
||||||
|
@ -200,25 +136,38 @@ virtualenv --python=python3 "${final_path}/venv"
|
||||||
# https://docs.weblate.org/en/latest/admin/install.html#installation
|
# https://docs.weblate.org/en/latest/admin/install.html#installation
|
||||||
# TODO: use --extra-search-dir=/path/to/dists
|
# TODO: use --extra-search-dir=/path/to/dists
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Create weblate configuration file..." --time --weight=1
|
||||||
|
|
||||||
ynh_script_progression --message="Create weblate configuration file..."
|
db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd)
|
||||||
|
admin_mail=$(ynh_user_get_info --username="$admin" --key=mail)
|
||||||
db_pwd=$(ynh_app_setting_get "$app" psqlpwd)
|
key=$(ynh_string_random --length=50)
|
||||||
admin_mail=$(ynh_user_get_info "$admin" mail)
|
|
||||||
key=$(ynh_string_random 24)$(ynh_string_random 24)$(ynh_string_random 2)
|
|
||||||
redis_db=$(ynh_redis_get_free_db)
|
redis_db=$(ynh_redis_get_free_db)
|
||||||
|
|
||||||
settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py"
|
settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py"
|
||||||
cp "../conf/settings_history/settings.$current_version.py" "$settings"
|
cp "../conf/settings.py" "$settings"
|
||||||
|
|
||||||
weblate_fill_settings "$settings"
|
ynh_replace_string --match_string="__NAME__" --replace_string="$app" --target_file="$settings"
|
||||||
ynh_app_setting_set "$app" redis_db "$redis_db"
|
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$settings"
|
||||||
|
ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$settings"
|
||||||
|
ynh_replace_string --match_string="__ADMINMAIL__" --replace_string="$admin_mail" --target_file="$settings"
|
||||||
|
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$settings"
|
||||||
|
ynh_replace_string --match_string="__KEY__" --replace_string="$key" --target_file="$settings"
|
||||||
|
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$settings"
|
||||||
|
ynh_replace_string --match_string="__GITHUBUSER__" --replace_string="$github_account" --target_file="$settings"
|
||||||
|
ynh_replace_string --match_string="__REDIS_DB__" --replace_string="$redis_db" --target_file="$settings"
|
||||||
|
ynh_replace_string --match_string="__PYTHONPATH__" --replace_string="$weblate_pypath" --target_file="$settings"
|
||||||
|
|
||||||
|
# remove last "/" of $path_url
|
||||||
|
ynh_replace_string --match_string="__PATHURL__" --replace_string="${path_url%/}" --target_file="$settings"
|
||||||
|
|
||||||
|
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP Filling up the database
|
# SPECIFIC SETUP Filling up the database
|
||||||
# https://docs.weblate.org/en/latest/admin/install.html#filling-up-the-database
|
# https://docs.weblate.org/en/latest/admin/install.html#filling-up-the-database
|
||||||
#==========================================
|
#==========================================
|
||||||
ynh_script_progression --message="Filling up the database..."
|
ynh_script_progression --message="Filling up the database..." --time --weight=1
|
||||||
|
|
||||||
(
|
(
|
||||||
set +o nounset
|
set +o nounset
|
||||||
source "${final_path}/venv/bin/activate"
|
source "${final_path}/venv/bin/activate"
|
||||||
|
@ -235,61 +184,48 @@ ynh_script_progression --message="Filling up the database..."
|
||||||
--email "$admin_mail"
|
--email "$admin_mail"
|
||||||
)
|
)
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP CRON
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_script_progression --message="Configure cron file..."
|
|
||||||
|
|
||||||
cp ../conf/cron "/etc/cron.d/$app"
|
|
||||||
ynh_replace_string "__APP__" "$app" "/etc/cron.d/$app"
|
|
||||||
ynh_replace_string "__FINALPATH__" "$final_path/" "/etc/cron.d/$app"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE THE CHECKSUM OF THE CONFIG FILE
|
# STORE THE CHECKSUM OF THE CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Calculate and store the config file checksum into the app settings
|
# Calculate and store the config file checksum into the app settings
|
||||||
ynh_store_file_checksum "$settings"
|
ynh_store_file_checksum --file="$settings"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP uwsgi
|
# SPECIFIC SETUP UWSGI
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configure uwsgi..."
|
ynh_script_progression --message="Configure uwsgi..." --time --weight=1
|
||||||
|
|
||||||
|
|
||||||
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
||||||
cp ../conf/uwsgi.ini "$finaluwsgiini"
|
cp ../conf/uwsgi.ini "$finaluwsgiini"
|
||||||
|
|
||||||
ynh_replace_string "__FINALPATH__" "$final_path" "$finaluwsgiini"
|
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$finaluwsgiini"
|
||||||
ynh_replace_string "__PATH__" "$path_url" "$finaluwsgiini"
|
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$finaluwsgiini"
|
||||||
ynh_replace_string "__APP__" "$app" "$finaluwsgiini"
|
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$finaluwsgiini"
|
||||||
ynh_replace_string "__PYTHONPATH__" "$weblate_pypath" "$finaluwsgiini"
|
ynh_replace_string --match_string="__PYTHONPATH__" --replace_string="$weblate_pypath" --target_file="$finaluwsgiini"
|
||||||
|
|
||||||
|
ynh_store_file_checksum --file="$finaluwsgiini"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP SYSTEMD
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring a systemd service..." --time --weight=1
|
||||||
|
|
||||||
# root install doesn't require uwsgi to handle script names
|
ynh_add_systemd_config --service="$app" --template="weblate.service"
|
||||||
if [ "$path_url" == "/" ]
|
|
||||||
then
|
|
||||||
ynh_replace_string "manage-script-name = true" "manage-script-name = false" "$finaluwsgiini"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ynh_add_systemd_config "$app" "weblate.service"
|
|
||||||
|
|
||||||
ynh_store_file_checksum "$finaluwsgiini"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ACTIVATE CELERY
|
# ACTIVATE CELERY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configure celery..." --time --weight=1
|
||||||
ynh_script_progression --message="Configure celery..."
|
|
||||||
|
|
||||||
celeryconf="$final_path/celery-weblate"
|
celeryconf="$final_path/celery-weblate"
|
||||||
cp ../conf/celery-weblate "$celeryconf"
|
cp ../conf/celery-weblate "$celeryconf"
|
||||||
|
|
||||||
ynh_replace_string "__APP__" "$app" "$celeryconf"
|
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$celeryconf"
|
||||||
ynh_replace_string "__FINALPATH__" "$final_path" "$celeryconf"
|
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$celeryconf"
|
||||||
|
|
||||||
ynh_add_systemd_config "$app-celery" "celery-weblate.service"
|
ynh_add_systemd_config --service="$app-celery" --template="celery-weblate.service"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
@ -298,52 +234,47 @@ ynh_add_systemd_config "$app-celery" "celery-weblate.service"
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Set permissions to app files
|
# Set permissions to app files
|
||||||
|
chown -R root:root "$final_path"
|
||||||
chown -R "$app": "$final_path/data"
|
chown -R "$app": "$final_path/data"
|
||||||
|
|
||||||
mkdir -p "$final_path/avatar-cache"
|
mkdir -p "$final_path/avatar-cache"
|
||||||
chown -R "$app": "$final_path/avatar-cache"
|
chown -R "$app": "$final_path/avatar-cache"
|
||||||
|
|
||||||
|
mkdir -p "/var/run/$app"
|
||||||
|
chown -R "$app": "/var/run/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# SETUP LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring log rotation..."
|
ynh_script_progression --message="Configuring log rotation..." --time --weight=1
|
||||||
|
|
||||||
# Use logrotate to manage application logfile(s)
|
# Use logrotate to manage application logfile(s)
|
||||||
ynh_use_logrotate
|
ynh_use_logrotate --non-append
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_script_progression --message="Configuring SSOwat..."
|
|
||||||
|
|
||||||
if [ "$is_public" -eq 0 ]
|
|
||||||
then # Remove the public access
|
|
||||||
ynh_app_setting_delete "$app" skipped_uris
|
|
||||||
fi
|
|
||||||
# Make app public if necessary
|
|
||||||
if [ "$is_public" -eq 1 ]
|
|
||||||
then
|
|
||||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
|
||||||
|
|
||||||
# ynh panel is not needed
|
|
||||||
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"
|
|
||||||
|
|
||||||
ynh_store_file_checksum "$finalnginxconf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# ADVERTISE SERVICES IN ADMIN PANEL
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1
|
||||||
|
|
||||||
yunohost service add "$app" --log "/var/log/$app/weblate.log"
|
yunohost service add "$app" --log "/var/log/$app/weblate.log"
|
||||||
yunohost service add "$app-celery" --log "/var/log/$app/weblate-celery-w1.log"
|
yunohost service add "$app-celery" --log "/var/log/$app/weblate-celery-w1.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP SSOWAT
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring SSOwat..." --time --weight=1
|
||||||
|
|
||||||
|
# Make app public if necessary
|
||||||
|
if [ "$is_public" -eq 1 ]
|
||||||
|
then
|
||||||
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||||
|
ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# Start weblate
|
# Start weblate
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting weblate's services..."
|
ynh_script_progression --message="Starting weblate's services..." --time --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app" --action="start"
|
ynh_systemd_action --service_name="$app" --action="start"
|
||||||
ynh_systemd_action --service_name="$app-celery" --action="start"
|
ynh_systemd_action --service_name="$app-celery" --action="start"
|
||||||
|
@ -351,8 +282,7 @@ ynh_systemd_action --service_name="$app-celery" --action="start"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
|
||||||
ynh_script_progression --message="Reloading nginx web server..."
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name="nginx" --action="reload"
|
ynh_systemd_action --service_name="nginx" --action="reload"
|
||||||
|
|
||||||
|
@ -367,4 +297,4 @@ If you facing an issue or want to improve this app, please open a new issue in t
|
||||||
|
|
||||||
ynh_send_readme_to_admin "$message" "$admin"
|
ynh_send_readme_to_admin "$message" "$admin"
|
||||||
|
|
||||||
ynh_script_progression --message="Installation of $app completed" --last
|
ynh_script_progression --message="Installation of $app completed" --time --last
|
||||||
|
|
|
@ -12,12 +12,13 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||||
db_name=$(ynh_app_setting_get "$app" db_name)
|
db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
|
||||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
db_user=$db_name
|
||||||
|
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
|
@ -28,53 +29,61 @@ final_path=$(ynh_app_setting_get "$app" final_path)
|
||||||
# Remove a service from the admin panel, added by `yunohost service add`
|
# Remove a service from the admin panel, added by `yunohost service add`
|
||||||
if yunohost service status "$app" >/dev/null 2>&1
|
if yunohost service status "$app" >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Removing $app service..."
|
ynh_script_progression --message="Removing $app service integration..." --time --weight=1
|
||||||
yunohost service remove "$app"
|
yunohost service remove "$app"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove a service from the admin panel, added by `yunohost service add`
|
# Remove a service from the admin panel, added by `yunohost service add`
|
||||||
if yunohost service status "$app-celery" >/dev/null 2>&1
|
if yunohost service status "$app-celery" >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Removing $app-celery service..."
|
ynh_script_progression --message="Removing $app-celery service integration..." --time --weight=1
|
||||||
yunohost service remove "$app-celery"
|
yunohost service remove "$app-celery"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP WEBLATE'S SERVICES
|
# STOP WEBLATE'S SERVICES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping and removing systemd services..."
|
ynh_script_progression --message="Stopping and removing systemd services..." --time --weight=1
|
||||||
|
|
||||||
ynh_remove_systemd_config "$app"
|
ynh_remove_systemd_config --service="$app"
|
||||||
ynh_remove_systemd_config "$app-celery"
|
ynh_remove_systemd_config --service="$app-celery"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE PostgreSQL DATABASE
|
# REMOVE THE PostgreSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing the PostgreSQL database..."
|
ynh_script_progression --message="Removing the PostgreSQL database..." --time --weight=1
|
||||||
|
|
||||||
# Remove a database if it exists, along with the associated user
|
# Remove a database if it exists, along with the associated user
|
||||||
ynh_psql_remove_db "$db_name" "$app"
|
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE REDIS DB
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_redis_remove_db
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEPENDENCIES
|
# REMOVE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing dependencies..."
|
ynh_script_progression --message="Removing dependencies..." --time --weight=1
|
||||||
|
|
||||||
# Remove metapackage and its dependencies
|
# Remove metapackage and its dependencies
|
||||||
|
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
||||||
|
ynh_secure_remove --file="$finaluwsgiini"
|
||||||
ynh_remove_app_dependencies
|
ynh_remove_app_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE APP MAIN DIR
|
# REMOVE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing app main directory..."
|
ynh_script_progression --message="Removing app main directory..." --time --weight=1
|
||||||
|
|
||||||
# Remove the app directory securely
|
# Remove the app directory securely
|
||||||
ynh_secure_remove "$final_path"
|
ynh_secure_remove --file="$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE NGINX CONFIGURATION
|
# REMOVE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing nginx web server configuration..."
|
ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1
|
||||||
|
|
||||||
# Remove the dedicated nginx config
|
# Remove the dedicated nginx config
|
||||||
ynh_remove_nginx_config
|
ynh_remove_nginx_config
|
||||||
|
@ -82,37 +91,30 @@ ynh_remove_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE LOGROTATE CONFIGURATION
|
# REMOVE LOGROTATE CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing logrotate configuration..."
|
ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1
|
||||||
|
|
||||||
# Remove the app-specific logrotate config
|
# Remove the app-specific logrotate config
|
||||||
ynh_remove_logrotate
|
ynh_remove_logrotate
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC REMOVE
|
# SPECIFIC REMOVE
|
||||||
#=================================================
|
|
||||||
# REMOVE CRON FILE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Remove a cron file
|
|
||||||
ynh_secure_remove "/etc/cron.d/$app"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE CELERY FILES
|
# REMOVE CELERY FILES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_secure_remove "/var/run/$app-celery"
|
ynh_secure_remove --file="/var/run/$app-celery"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEDICATED USER
|
# REMOVE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing the dedicated system user..."
|
ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1
|
||||||
|
|
||||||
# Delete a system user
|
# Delete a system user
|
||||||
ynh_system_user_delete "$app"
|
ynh_system_user_delete --username="$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removal of $app completed" --last
|
ynh_script_progression --message="Removal of $app completed" --time --last
|
||||||
|
|
|
@ -18,25 +18,26 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading settings..."
|
ynh_script_progression --message="Loading settings..." --time --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||||
path_url=$(ynh_app_setting_get "$app" path)
|
path_url=$(ynh_app_setting_get --app="$app" --key=path)
|
||||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||||
db_name=$(ynh_app_setting_get "$app" db_name)
|
db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
|
||||||
db_pwd=$(ynh_app_setting_get "$app" psqlpwd)
|
db_user=$db_name
|
||||||
|
db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Validating restoration parameters..."
|
ynh_script_progression --message="Validating restoration parameters..." --time --weight=1
|
||||||
|
|
||||||
# Check web path availability
|
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
||||||
ynh_webpath_available "$domain" "$path_url" || ynh_die "Path not available: ${domain}${path_url}"
|
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||||
|
test ! -d $final_path \
|
||||||
test ! -e "$final_path" || ynh_die "There is already a directory: $final_path"
|
|| ynh_die --message="There is already a directory: $final_path "
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD RESTORATION STEPS
|
# STANDARD RESTORATION STEPS
|
||||||
|
@ -44,98 +45,93 @@ test ! -e "$final_path" || ynh_die "There is already a directory: $final_path"
|
||||||
# RESTORE THE NGINX CONFIGURATION
|
# RESTORE THE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the app main directory..."
|
ynh_script_progression --message="Restoring the app main directory..." --time --weight=1
|
||||||
|
|
||||||
ynh_restore_file "$final_path"
|
ynh_restore_file --origin_path="$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RECREATE THE DEDICATED USER
|
# RECREATE THE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Recreating the dedicated system user..."
|
ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
# Create the dedicated user (if not existing)
|
||||||
ynh_system_user_create "$app" "$final_path"
|
ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell
|
||||||
# Allow bash for our user, so he can use hub
|
|
||||||
chsh --shell /bin/bash "$app"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE USER RIGHTS
|
# RESTORE USER RIGHTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Restore permissions on app files
|
# Restore permissions on app files
|
||||||
chown -R "$app": "$final_path"
|
chown -R root:root "$final_path"
|
||||||
|
chown -R "$app": "$final_path/data"
|
||||||
|
|
||||||
|
mkdir -p "$final_path/avatar-cache"
|
||||||
|
chown -R "$app": "$final_path/avatar-cache"
|
||||||
|
|
||||||
|
mkdir -p "/var/run/$app"
|
||||||
|
chown -R "$app": "/var/run/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORATION
|
# SPECIFIC RESTORATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# REINSTALL DEPENDENCIES
|
# REINSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reinstalling dependencies..."
|
ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1
|
||||||
|
|
||||||
ynh_install_app_dependencies "$pkg_dependencies"
|
ynh_install_app_dependencies "$pkg_dependencies"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE PostgreSQL DATABASE
|
# RESTORE THE PostgreSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the PostgreSQL database..."
|
ynh_script_progression --message="Restoring the PostgreSQL database..." --time --weight=1
|
||||||
|
|
||||||
ynh_psql_test_if_first_run
|
ynh_psql_test_if_first_run
|
||||||
ynh_psql_setup_db "$db_name" "$db_name" "$db_pwd"
|
ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd"
|
||||||
ynh_psql_execute_file_as_root ./db.sql "$db_name"
|
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE Weblate service
|
# RESTORE SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring systemd configurations..."
|
ynh_script_progression --message="Restoring the systemd configuration..." --time --weight=1
|
||||||
|
|
||||||
usermod --append --groups www-data "$app"
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||||
|
systemctl enable $app.service
|
||||||
ynh_restore_file "/etc/uwsgi/apps-available/$app.ini"
|
ynh_restore_file --origin_path="/etc/systemd/system/$app-celery.service"
|
||||||
ynh_restore_file "/etc/systemd/system/$app.service"
|
|
||||||
|
|
||||||
systemctl enable "$app"
|
|
||||||
|
|
||||||
ynh_restore_file "/etc/systemd/system/$app-celery.service"
|
|
||||||
systemctl enable "$app-celery"
|
systemctl enable "$app-celery"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
# RESTORE UWSGI
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring uwsgi configurations..." --time --weight=1
|
||||||
|
|
||||||
|
ynh_restore_file --origin_path="/etc/uwsgi/apps-available/$app.ini"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1
|
||||||
|
|
||||||
# Add as a service
|
|
||||||
yunohost service add "$app" --log "/var/log/$app/weblate.log"
|
yunohost service add "$app" --log "/var/log/$app/weblate.log"
|
||||||
yunohost service add "$app-celery" --log "/var/log/$app/weblate-celery-w1.log"
|
yunohost service add "$app-celery" --log "/var/log/$app/weblate-celery-w1.log"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTORE THE CRON FILE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_restore_file "/etc/cron.d/$app"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTORE THE HUB BINARY FILE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Restore hub's binary file..."
|
|
||||||
ynh_restore_file "/usr/bin/hub"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE LOGROTATE CONFIGURATION
|
# RESTORE THE LOGROTATE CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
|
||||||
mkdir -p "/var/log/$app"
|
mkdir -p "/var/log/$app"
|
||||||
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# Start weblate
|
# START WEBLATE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..."
|
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app" --action="start"
|
ynh_systemd_action --service_name="$app" --action="start"
|
||||||
ynh_systemd_action --service_name="$app-celery" --action="start"
|
ynh_systemd_action --service_name="$app-celery" --action="start"
|
||||||
|
@ -143,7 +139,7 @@ ynh_systemd_action --service_name="$app-celery" --action="start"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading nginx web server and php-fpm..."
|
ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name="nginx" --action="reload"
|
ynh_systemd_action --service_name="nginx" --action="reload"
|
||||||
|
|
||||||
|
|
283
scripts/upgrade
283
scripts/upgrade
|
@ -11,47 +11,27 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
path_url=$(ynh_app_setting_get "$app" path)
|
path_url=$(ynh_app_setting_get --app="$app" --key=path)
|
||||||
is_public=$(ynh_app_setting_get "$app" is_public)
|
is_public=$(ynh_app_setting_get --app="$app" --key=is_public)
|
||||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||||
db_name=$(ynh_app_setting_get "$app" db_name)
|
db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
db_user=$db_name
|
||||||
db_pwd=$(ynh_app_setting_get "$app" psqlpwd)
|
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||||
admin=$(ynh_app_setting_get "$app" admin)
|
db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd)
|
||||||
|
admin=$(ynh_app_setting_get --app="$app" --key=admin)
|
||||||
admin_mail=$(ynh_user_get_info "$admin" mail)
|
admin_mail=$(ynh_user_get_info "$admin" mail)
|
||||||
memc_port=$(ynh_app_setting_get "$app" memc_port)
|
github_account=$(ynh_app_setting_get --app="$app" --key=github_account)
|
||||||
github_account=$(ynh_app_setting_get "$app" github_account)
|
key=$(ynh_string_random 50)
|
||||||
migration311=$(ynh_app_setting_get "$app" migration311)
|
redis_db=$(ynh_app_setting_get --app="$app" --key=redis_db)
|
||||||
key=$(ynh_string_random 24)$(ynh_string_random 24)$(ynh_string_random 2)
|
|
||||||
redis_db=$(ynh_app_setting_get "$app" redis_db)
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# Get previous version number
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Get previous version number..."
|
|
||||||
|
|
||||||
(
|
|
||||||
set +o nounset
|
|
||||||
source "${final_path}/venv/bin/activate"
|
|
||||||
set -o nounset
|
|
||||||
pip install --upgrade pip
|
|
||||||
pip freeze --local > freeze.pip
|
|
||||||
)
|
|
||||||
previous_version=$(cat freeze.pip | grep "Weblate==" | sed "s|Weblate==||")
|
|
||||||
|
|
||||||
ynh_secure_remove freeze.pip
|
|
||||||
|
|
||||||
previous_version_template="../conf/settings_history/settings.$previous_version.py"
|
|
||||||
test -e "$previous_version_template" || ynh_die "Previous version unknown: $previous_version"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1
|
||||||
|
|
||||||
# Backup the current version of the app
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
ynh_backup_before_upgrade
|
||||||
|
@ -65,19 +45,20 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
|
||||||
|
|
||||||
|
# Fix is_public as a boolean value
|
||||||
if [ "$is_public" = "Yes" ]; then
|
if [ "$is_public" = "Yes" ]; then
|
||||||
ynh_app_setting_set "$app" is_public 1 # Fix is_public as a boolean value
|
ynh_app_setting_set --app=$app --key=is_public --value=1
|
||||||
is_public=1
|
is_public=1
|
||||||
elif [ "$is_public" = "No" ]; then
|
elif [ "$is_public" = "No" ]; then
|
||||||
ynh_app_setting_set "$app" is_public 0
|
ynh_app_setting_set --app=$app --key=is_public --value=0
|
||||||
is_public=0
|
is_public=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -d "$final_path/bin/" ]]
|
if [[ -d "$final_path/bin/" ]]
|
||||||
then
|
then
|
||||||
ynh_secure_remove "$final_path/bin/"
|
ynh_secure_remove --file="$final_path/bin/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# (<3.8) log cleanups
|
# (<3.8) log cleanups
|
||||||
|
@ -85,8 +66,8 @@ if [[ -e "/var/log/uwsgi/app/$app" ]]
|
||||||
then
|
then
|
||||||
ynh_systemd_action --service_name="$app" --action="stop"
|
ynh_systemd_action --service_name="$app" --action="stop"
|
||||||
ynh_systemd_action --service_name="$app-celery" --action="stop"
|
ynh_systemd_action --service_name="$app-celery" --action="stop"
|
||||||
ynh_secure_remove "/var/log/uwsgi/app/$app"
|
ynh_secure_remove --file="/var/log/uwsgi/app/$app"
|
||||||
ynh_secure_remove "/var/log/$app-celery"
|
ynh_secure_remove --file="/var/log/$app-celery"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -94,15 +75,14 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Normalize the URL path syntax
|
# Normalize the URL path syntax
|
||||||
path_url=$(ynh_normalize_url_path "$path_url")
|
path_url=$(ynh_normalize_url_path --path_url=$path_url)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# STANDARD UPGRADE STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICE
|
# STOP SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Stopping systemd services..." --time --weight=1
|
||||||
ynh_script_progression --message="Stopping systemd services..."
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app" --action="stop"
|
ynh_systemd_action --service_name="$app" --action="stop"
|
||||||
ynh_systemd_action --service_name="$app-celery" --action="stop"
|
ynh_systemd_action --service_name="$app-celery" --action="stop"
|
||||||
|
@ -110,27 +90,17 @@ ynh_systemd_action --service_name="$app-celery" --action="stop"
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading nginx web server configuration..."
|
ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
if [ "$path_url" == "/" ]
|
|
||||||
then
|
|
||||||
# $finalnginxconf comes from ynh_add_nginx_config
|
|
||||||
ynh_replace_string "location //" "location /" "$finalnginxconf"
|
|
||||||
|
|
||||||
# ynh panel is only comptable with non-root installation
|
|
||||||
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"
|
|
||||||
|
|
||||||
ynh_store_file_checksum "$finalnginxconf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# SPECIFIC UPGRADE
|
||||||
#=================================================
|
#=================================================
|
||||||
# Update dependencies
|
# Update dependencies
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
|
||||||
|
|
||||||
ynh_install_app_dependencies "$pkg_dependencies"
|
ynh_install_app_dependencies "$pkg_dependencies"
|
||||||
|
|
||||||
|
@ -140,127 +110,101 @@ ynh_install_app_dependencies "$pkg_dependencies"
|
||||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||||
|
|
||||||
# Create a system user
|
# Create a system user
|
||||||
ynh_system_user_create "$app" "$final_path"
|
ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell
|
||||||
chsh --shell /bin/bash "$app"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP uwsgi
|
# SPECIFIC SETUP UWSGI
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configure uwsgi..."
|
ynh_script_progression --message="Configure uwsgi..." --time --weight=1
|
||||||
|
|
||||||
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
||||||
|
ynh_backup_if_checksum_is_different --file="$finaluwsgiini"
|
||||||
cp ../conf/uwsgi.ini "$finaluwsgiini"
|
cp ../conf/uwsgi.ini "$finaluwsgiini"
|
||||||
|
|
||||||
ynh_replace_string "__FINALPATH__" "$final_path" "$finaluwsgiini"
|
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$finaluwsgiini"
|
||||||
ynh_replace_string "__PATH__" "$path_url" "$finaluwsgiini"
|
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$finaluwsgiini"
|
||||||
ynh_replace_string "__APP__" "$app" "$finaluwsgiini"
|
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$finaluwsgiini"
|
||||||
ynh_replace_string "__PYTHONPATH__" "$weblate_pypath" "$finaluwsgiini"
|
ynh_replace_string --match_string="__PYTHONPATH__" --replace_string="$weblate_pypath" --target_file="$finaluwsgiini"
|
||||||
|
|
||||||
|
ynh_store_file_checksum --file="$finaluwsgiini"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP SYSTEMD
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring a systemd service..." --time --weight=1
|
||||||
|
|
||||||
# root install doesn't require uwsgi to handle script names
|
ynh_add_systemd_config --service="$app" --template="weblate.service"
|
||||||
if [ "$path_url" == "/" ]
|
|
||||||
then
|
|
||||||
ynh_replace_string "manage-script-name = true" "manage-script-name = false" "$finaluwsgiini"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ynh_add_systemd_config "$app" "weblate.service"
|
#=================================================
|
||||||
|
# ACTIVATE CELERY
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configure celery..." --time --weight=1
|
||||||
|
|
||||||
ynh_store_file_checksum "$finaluwsgiini"
|
celeryconf="$final_path/celery-weblate"
|
||||||
|
cp ../conf/celery-weblate "$celeryconf"
|
||||||
|
|
||||||
|
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$celeryconf"
|
||||||
|
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$celeryconf"
|
||||||
|
|
||||||
|
ynh_add_systemd_config --service="$app-celery" --template="celery-weblate.service"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PIP INSTALLATION
|
# PIP INSTALLATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Install weblate using PIP..." --time --weight=1
|
||||||
|
|
||||||
ynh_script_progression --message="Install weblate using PIP..." --weight=10
|
virtualenv --python=python3 "${final_path}/venv"
|
||||||
|
#run source in a 'sub shell'
|
||||||
(
|
(
|
||||||
set +o nounset
|
set +o nounset
|
||||||
source "${final_path}/venv/bin/activate"
|
source "${final_path}/venv/bin/activate"
|
||||||
set -o nounset
|
set -o nounset
|
||||||
pip install --upgrade pip
|
pip install --upgrade pip setuptools wheel
|
||||||
# prevent error: "command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers"
|
# Still needed with latest version of weblate?
|
||||||
pip install --upgrade setuptools
|
pip install Django==2.* celery==4.*
|
||||||
pip install Django==2.2.*
|
|
||||||
pip install Weblate=="$current_version"
|
pip install Weblate=="$current_version"
|
||||||
pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2-binary phply django-redis hiredis aeidon ruamel.yaml
|
pip install psycopg2-binary ruamel.yaml aeidon phply
|
||||||
|
#pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2-binary phply django-redis hiredis aeidon ruamel.yaml
|
||||||
# specific to YunoHost package:
|
# specific to YunoHost package:
|
||||||
pip install django_sendmail_backend
|
pip install django_sendmail_backend
|
||||||
)
|
)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIG FILE UPGRADE
|
# MODIFY A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Create weblate configuration file..."
|
ynh_script_progression --message="Create weblate configuration file..."
|
||||||
# save old settings file
|
# save old settings file
|
||||||
settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py"
|
settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py"
|
||||||
|
|
||||||
old_settings="$final_path/settings.$previous_version.old.py"
|
ynh_backup_if_checksum_is_different --file="$settings"
|
||||||
|
cp "../conf/settings.py" "$settings"
|
||||||
|
|
||||||
cp "$settings" "$old_settings"
|
ynh_replace_string --match_string="__NAME__" --replace_string="$app" --target_file="$settings"
|
||||||
|
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$settings"
|
||||||
|
ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$settings"
|
||||||
|
ynh_replace_string --match_string="__ADMINMAIL__" --replace_string="$admin_mail" --target_file="$settings"
|
||||||
|
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$settings"
|
||||||
|
ynh_replace_string --match_string="__KEY__" --replace_string="$key" --target_file="$settings"
|
||||||
|
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$settings"
|
||||||
|
ynh_replace_string --match_string="__GITHUBUSER__" --replace_string="$github_account" --target_file="$settings"
|
||||||
|
ynh_replace_string --match_string="__REDIS_DB__" --replace_string="$redis_db" --target_file="$settings"
|
||||||
|
ynh_replace_string --match_string="__PYTHONPATH__" --replace_string="$weblate_pypath" --target_file="$settings"
|
||||||
|
|
||||||
check=$(ynh_check_if_checksum_is_different "$settings")
|
# remove last "/" of $path_url
|
||||||
|
ynh_replace_string --match_string="__PATHURL__" --replace_string="${path_url%/}" --target_file="$settings"
|
||||||
|
|
||||||
if [[ "$check" -eq 1 ]]
|
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
|
||||||
then
|
|
||||||
echo "Settings.py was modified localy, running diff before using the new default file for $current_version."
|
|
||||||
# generate previous defaults settings
|
|
||||||
cp "$previous_version_template" "$old_settings"
|
|
||||||
weblate_fill_settings "$old_settings"
|
|
||||||
|
|
||||||
# store diff between defaults and local settings
|
# Recalculate and store the config file checksum into the app settings
|
||||||
set +eu
|
ynh_store_file_checksum --file="$settings"
|
||||||
diff --unified "$old_settings" "$settings" > "$final_path/settings.${previous_version}_${current_version}.diff"
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
# send diff to the server administrator
|
|
||||||
mail_message="
|
|
||||||
Weblate was updated from version $previous_version to $current_version
|
|
||||||
Please read:
|
|
||||||
https://docs.weblate.org/en/latest/admin/upgrade.html
|
|
||||||
|
|
||||||
A new settings.py has been created:
|
|
||||||
$settings
|
|
||||||
|
|
||||||
You may have changed your defaults settings.
|
|
||||||
To help you, here is a diff file with every changes you did.
|
|
||||||
|
|
||||||
Diff has been created in:
|
|
||||||
$final_path/settings.${previous_version}_${current_version}.diff
|
|
||||||
|
|
||||||
Please note secret key is updated, this is normal.
|
|
||||||
|
|
||||||
For any issue, please file a bug in: https://github.com/YunoHost-Apps/weblate_ynh
|
|
||||||
"
|
|
||||||
|
|
||||||
ynh_send_readme_to_admin "$mail_message" root "$admin_mail"
|
|
||||||
else
|
|
||||||
echo "Settings.py was not modified, using the new default file for $current_version."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# generate new defaults settings
|
|
||||||
cp "../conf/settings_history/settings.$current_version.py" "$settings"
|
|
||||||
weblate_fill_settings "$settings"
|
|
||||||
|
|
||||||
ynh_secure_remove "$old_settings"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ACTIVATE CELERY
|
# MIGRATE WEBLATE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configure celery..."
|
ynh_script_progression --message="Run migration scripts..." --time --weight=1
|
||||||
|
|
||||||
celeryconf="$final_path/celery-weblate"
|
ynh_systemd_action --service_name="$app-celery" --action="start"
|
||||||
cp ../conf/celery-weblate "$celeryconf"
|
|
||||||
|
|
||||||
ynh_replace_string "__APP__" "$app" "$celeryconf"
|
|
||||||
ynh_replace_string "__FINALPATH__" "$final_path" "$celeryconf"
|
|
||||||
|
|
||||||
ynh_add_systemd_config "$app-celery" "celery-weblate.service"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# Run migration scripts
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Run migration scripts..."
|
|
||||||
(
|
(
|
||||||
set +o nounset
|
set +o nounset
|
||||||
source "${final_path}/venv/bin/activate"
|
source "${final_path}/venv/bin/activate"
|
||||||
|
@ -272,27 +216,25 @@ ynh_script_progression --message="Run migration scripts..."
|
||||||
weblate collectstatic --noinput
|
weblate collectstatic --noinput
|
||||||
weblate setuplang
|
weblate setuplang
|
||||||
weblate setupgroups
|
weblate setupgroups
|
||||||
|
weblate compilemessages
|
||||||
|
sudo -u $app $final_path/venv/bin/weblate check --deploy
|
||||||
)
|
)
|
||||||
|
|
||||||
# Recalculate and store the config file checksum into the app settings
|
|
||||||
ynh_store_file_checksum "$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP CRON
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Configure cron file..."
|
|
||||||
|
|
||||||
cp ../conf/cron "/etc/cron.d/$app"
|
|
||||||
ynh_replace_string "__APP__" "$app" "/etc/cron.d/$app"
|
|
||||||
ynh_replace_string "__FINALPATH__" "$final_path/" "/etc/cron.d/$app"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# SETUP LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading logrotate configuration..."
|
ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1
|
||||||
|
|
||||||
# Use logrotate to manage app-specific logfile(s)
|
# Use logrotate to manage app-specific logfile(s)
|
||||||
ynh_use_logrotate
|
ynh_use_logrotate --non-append
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1
|
||||||
|
|
||||||
|
yunohost service add "$app" --log "/var/log/$app/weblate.log"
|
||||||
|
yunohost service add "$app-celery" --log "/var/log/$app/weblate-celery-w1.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
@ -307,45 +249,38 @@ chown -R "$app": "$final_path/data"
|
||||||
mkdir -p "$final_path/avatar-cache"
|
mkdir -p "$final_path/avatar-cache"
|
||||||
chown -R "$app": "$final_path/avatar-cache"
|
chown -R "$app": "$final_path/avatar-cache"
|
||||||
|
|
||||||
#=================================================
|
mkdir -p "/var/run/$app"
|
||||||
# SETUP SSOWAT
|
chown -R "$app": "/var/run/$app"
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Configuring SSOwat..."
|
|
||||||
|
|
||||||
if [ $is_public -eq 0 ]
|
|
||||||
then # Remove the public access
|
|
||||||
ynh_app_setting_delete "$app" skipped_uris
|
|
||||||
fi
|
|
||||||
# Make app public if necessary
|
|
||||||
if [ $is_public -eq 1 ]
|
|
||||||
then
|
|
||||||
# unprotected_uris allows SSO credentials to be passed anyway
|
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
|
||||||
|
|
||||||
# ynh panel is not needed
|
|
||||||
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"
|
|
||||||
|
|
||||||
ynh_store_file_checksum "$finalnginxconf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# Restart weblate
|
# START SYSTEMD SERVICES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting weblate's services..."
|
ynh_script_progression --message="Starting systemd services..." --time --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app" --action="start"
|
ynh_systemd_action --service_name="$app" --action="start"
|
||||||
ynh_systemd_action --service_name="$app-celery" --action="start"
|
ynh_systemd_action --service_name="$app-celery" --action="start"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP SSOWAT
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1
|
||||||
|
|
||||||
|
# Make app public if necessary
|
||||||
|
if [ "$is_public" -eq 1 ]
|
||||||
|
then
|
||||||
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||||
|
ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
|
||||||
|
|
||||||
ynh_script_progression --message="Reloading nginx web server..."
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
ynh_systemd_action --service_name="nginx" --action="reload"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
ynh_script_progression --message="Upgrade of $app completed" --time --last
|
Loading…
Reference in a new issue