diff --git a/README.md b/README.md index 5e95f42..b2c1e44 100644 --- a/README.md +++ b/README.md @@ -1,76 +1,59 @@ -[![Install Weblate with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=weblate) -![](https://dash.yunohost.org/integration/weblate.svg) -# Weblate translation platform for YunoHost +# Weblate for YunoHost -The YunoHost team uses [Weblate](https://weblate.org) for translations: https://translate.yunohost.org +[![Integration level](https://dash.yunohost.org/integration/weblate.svg)](https://dash.yunohost.org/appci/app/weblate) ![](https://ci-apps.yunohost.org/ci/badges/weblate.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/weblate.maintain.svg) +[![Install Weblate with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=weblate) + +> *This package allows you to install Weblate quickly and simply on a YunoHost server. +If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* + +## Overview + +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:** 4.3.1 + +## Screenshots + +![](https://weblate.org/static/img/BigScreenshot.png) + +## Demo + +* [YunoHost project uses Weblate for translations](https://translate.yunohost.org) ## Admin account An admin user is created at installation, the login is what you provided at installation, the password is **weblate**. -## Weblate 3.0 upgrade +## GitHub -This upgrade is a major one, remember to read this page before upgrading: https://docs.weblate.org/en/latest/admin/upgrade.html#upgrade-3 - -After upgrading: - - * All existing users and groups have been migrated to new model. - * Any per user permissions are removed, please assign users to appropriate groups and roles to grant them permissions. - * Any custom groups will not have any permissions after upgrade, please grant the permissions again. - -## Github - -You'll need to give weblate a github user and a token. Please read [github's documentation about token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/). +You'll need to give Weblate a GitHub user and a token. Please read [GitHub's documentation about token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/). This user will only be used to open the pull-request, each translation keep his author. -**Careful**, I still have to understand why, but you'll have to **manually** move your hub binary frile from /var/www/$app/bin/ to /usr/bin to enable pull request on github. I'm close to fix this. - -**SSH keys**, you'll have to go in administration, and generate a public key for weblate and add github.com so weblate knows the fingerprint. Please note if your account already have a public key (ssh-rsa), you'll have to manually add the weblate's one to your github account. +**SSH keys**, you will have to go in administration, and generate a public key for Weblate and add github.com so Weblate knows the fingerprint. Please note if your account already have a public key (ssh-rsa), you will have to manually add the Weblate's one to your GitHub account. ## Settings and upgrades Almost everything related to Weblate's configuration is handled in a `settings.py` file. -You'll probably edit it to enable or disable diverse features, it is stored in `$final_path/venv/lib/python2.7/site-packages/weblate/settings.py`. - -Unfortunatly, this settings file also gets upgrades for each release. - -This package will : - -* generate a default settings file for your current installation, -* send you a diff with your actual settings (the content will be sent to *root*, and only basic information for weblate's admin), -* generate a default settings file the new weblate's version, that will **replace** your actual `settings.py`. - -You'll have to **manually** add your previous changes to this new `settings.py`. +You can edit the file `$final_path/local_settings.py` to enable or disable features. # Miscellaneous -## Weblate and databases - -Weblate [recommands PostgreSQL](https://docs.weblate.org/en/latest/admin/install.html#database-setup-for-weblate), but YunoHost uses Mysql. - -Carefull, this application install PostgreSQL and change the default configuration to ask for every connexion and every user a password (*local all all password*). - ## LDAP connexion It doesn't work yet, but while [it looks doable](https://docs.weblate.org/en/latest/admin/auth.html?highlight=LDAP#ldap-authentication), I'm unsure it is a good idea to connect this kind of tools to your LDAP. -## State of this package +#### Supported architectures -* works fine: -[x] install/remove/backup/remove/upgrade with x86_64 +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/weblate%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/weblate/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/weblate%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/weblate/) -* to be confirmed: -[ ] ARM support +## Limitations -* to be added: -[ ] use jq instead of grep/sed -[ ] change URL script -[ ] use debian package for lxml (may unlock ARM support) -[ ] Add configuration options using the YunoHost interface (https://forum.yunohost.org/t/yunohost-3-1-minor-stable-release-version-stable-mineure/5445) -[ ] Add fail2ban script -[ ] Enable CHECK_LIST? -[ ] Enable AUTOFIX_LIST? -[ ] Enable Translation Memory? +* Any known limitations. + +## Additional information + +* Other info you would like to add about this app. ## Links @@ -79,3 +62,17 @@ It doesn't work yet, but while [it looks doable](https://docs.weblate.org/en/lat * Documentation: https://docs.weblate.org/ * Weblate website: https://weblate.org/ * YunoHost website: https://yunohost.org/ + +--- + +Developer info +---------------- + +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/weblate_ynh/tree/testing). + +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/weblate_ynh/tree/testing --debug +or +sudo yunohost app upgrade weblate -u https://github.com/YunoHost-Apps/weblate_ynh/tree/testing --debug +``` diff --git a/check_process b/check_process index 9cde86a..4259df3 100644 --- a/check_process +++ b/check_process @@ -19,26 +19,18 @@ setup_private=1 setup_public=1 upgrade=1 - upgrade=1 from_commit=565bfc66719f55b9c6a03cba8ac9991111992c9b - upgrade=1 from_commit=73a808f7a93e063e652533244fa1657fbc41c4f3 - upgrade=1 from_commit=31b82950959699478f2372259116b6d117a85d69 + upgrade=1 from_commit=cef22ac5634565cecd2d8545229efe3fe79d85bc backup_restore=1 multi_instance=1 port_already_use=0 - change_url=0 + change_url=1 ;;; Levels # If the level 5 (Package linter) is forced to 1. Please add justifications here. Level 5=auto ;;; Options -Email=jean-baptiste@holcroft.fr +Email= Notification=all ;;; Upgrade options - ; commit=565bfc66719f55b9c6a03cba8ac9991111992c9b - name=Upgrade from 3.5.1 -manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1&github_account=fake&github_token=fake - ; commit=73a808f7a93e063e652533244fa1657fbc41c4f3 - name=Upgrade from 3.6.1 -manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1&github_account=fake&github_token=fake - ; commit=31b82950959699478f2372259116b6d117a85d69 - name=Upgrade from 3.7.0 + ; commit=cef22ac5634565cecd2d8545229efe3fe79d85bc + name=Upgrade from 3.11.3 manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1&github_account=fake&github_token=fake diff --git a/conf/celery-weblate b/conf/celery-weblate index 1005d7c..4624a9b 100644 --- a/conf/celery-weblate +++ b/conf/celery-weblate @@ -1,19 +1,22 @@ # Name of nodes to start -CELERYD_NODES="celery notify search memory" +CELERYD_NODES="celery notify memory backup translate" # Absolute or relative path to the 'celery' command: CELERY_BIN="__FINALPATH__/venv/bin/celery" # App instance to use # 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 -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:search=1 --queues:search=search --prefetch-multiplier:search=2000 \ ---concurrency:memory=1 --queues:memory=memory --prefetch-multiplier:memory=2000" +# Extra command-line arguments to the worker, +# increase concurency if you get weblate.E019 +CELERYD_OPTS="--beat:celery --queues:celery=celery --prefetch-multiplier:celery=4 \ + --queues:notify=notify --prefetch-multiplier:notify=10 \ + --queues:memory=memory --prefetch-multiplier:memory=10 \ + --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. # - %I will be replaced with the current child process index # and is important when using the prefork pool to avoid race conditions. @@ -22,4 +25,4 @@ CELERYD_LOG_FILE="/var/log/__APP__/weblate-celery-%n%I.log" CELERYD_LOG_LEVEL="INFO" # Internal Weblate variable to indicate we're running inside Celery -CELERY_WORKER_RUNNING="1" +CELERY_WORKER_RUNNING="1" \ No newline at end of file diff --git a/conf/celery-weblate.service b/conf/celery-weblate.service index a033ad6..867f85f 100644 --- a/conf/celery-weblate.service +++ b/conf/celery-weblate.service @@ -1,19 +1,16 @@ [Unit] -Description=Celery Service for Weblate (__APP__) +Description=Celery Service (__APP__) After=network.target [Service] Type=forking User=__APP__ -Group=www-data -PermissionsStartOnly=true +Group=__APP__ EnvironmentFile=__FINALPATH__/celery-weblate WorkingDirectory=__FINALPATH__/ -# https://www.freedesktop.org/software/systemd/man/systemd.exec.html#RuntimeDirectory= RuntimeDirectory=__APP__ - -ExecStartPre=/bin/chown -R __APP__ /var/log/__APP__ - +RuntimeDirectoryPreserve=restart +LogsDirectory=celery ExecStart=/bin/sh -c '${CELERY_BIN} multi start ${CELERYD_NODES} \ -A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \ --logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}' @@ -24,4 +21,4 @@ ExecReload=/bin/sh -c '${CELERY_BIN} multi restart ${CELERYD_NODES} \ --logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}' [Install] -WantedBy=multi-user.target +WantedBy=multi-user.target \ No newline at end of file diff --git a/conf/cron b/conf/cron deleted file mode 100644 index d4520d5..0000000 --- a/conf/cron +++ /dev/null @@ -1,2 +0,0 @@ -# https://docs.weblate.org/en/latest/admin/install.html#production-cron -# now automatically done with celery diff --git a/conf/nginx.conf b/conf/nginx.conf index 61637a1..83e71d4 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,5 +1,5 @@ #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 { # DATA_DIR/static/favicon.ico alias __FINALPATH__/data/static/favicon.ico; diff --git a/conf/settings.4.1.1.py b/conf/settings.4.1.1.py new file mode 100644 index 0000000..52fe16b --- /dev/null +++ b/conf/settings.4.1.1.py @@ -0,0 +1,877 @@ +# +# Copyright © 2012 - 2020 Michal Čihař +# +# This file is part of Weblate +# +# 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 . +# + + +import os +import platform +from logging.handlers import SysLogHandler + +# +# Django settings for Weblate project. +# + +DEBUG = False + +ADMINS = ( + ('__ADMIN__', '__ADMINMAIL__'), +) + +MANAGERS = ADMINS + +DATABASES = { + "default": { + # Use "postgresql" or "mysql". + "ENGINE": "django.db.backends.postgresql", + # Database name. + "NAME": "__NAME__", + # Database user. + "USER": "__NAME__", + # Database password. + "PASSWORD": "__DB_PWD__", + # Set to empty string for localhost. + "HOST": "127.0.0.1", + # Set to empty string for default. + "PORT": "", + # 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", + # Change connection timeout in case you get MySQL gone away error: + # "connect_timeout": 28800, + }, + } +} + +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"), + ("el", "Ελληνικά"), + ("en-gb", "English (United Kingdom)"), + ("es", "Español"), + ("fi", "Suomi"), + ("fr", "Français"), + ("gl", "Galego"), + ("he", "עברית"), + ("hu", "Magyar"), + ("hr", "Hrvatski"), + ("id", "Indonesia"), + ("it", "Italiano"), + ("ja", "日本語"), + ("kab", "Taqbaylit"), + ("kk", "Қазақ тілі"), + ("ko", "한국어"), + ("nb", "Norsk bokmål"), + ("nl", "Nederlands"), + ("pl", "Polski"), + ("pt", "Português"), + ("pt-br", "Português brasileiro"), + ("ru", "Русский"), + ("sk", "Slovenčina"), + ("sl", "Slovenščina"), + ("sq", "Shqip"), + ("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. +MEDIA_ROOT = os.path.join(DATA_DIR, "media") + +# URL that handles the media served from MEDIA_ROOT. Make sure to use a +# trailing slash. +MEDIA_URL = f"{URL_PREFIX}/media/" + +# 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. +STATIC_ROOT = os.path.join(DATA_DIR, "static") + +# URL prefix for static files. +STATIC_URL = f"{URL_PREFIX}/static/" + +# 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 + +_TEMPLATE_LOADERS = [ + "django.template.loaders.filesystem.Loader", + "django.template.loaders.app_directories.Loader", +] +if not DEBUG: + _TEMPLATE_LOADERS = [("django.template.loaders.cached.Loader", _TEMPLATE_LOADERS)] +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": _TEMPLATE_LOADERS, + }, + } +] + + +# GitHub username for sending pull requests. +# Please see the documentation for more details. +GITHUB_USERNAME = None + +# GitLab username for sending merge requests. +# Please see the documentation for more details. +GITLAB_USERNAME = None + +# 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": 10}, + }, + {"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 + +# Shortcut for login required setting +REQUIRE_LOGIN = False + +# Middleware +MIDDLEWARE = [ + "weblate.middleware.ProxyMiddleware", + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "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.api.middleware.ThrottlingMiddleware", + "weblate.middleware.SecurityMiddleware", +] + +ROOT_URLCONF = "weblate.urls" + +# Django and Weblate apps +INSTALLED_APPS = [ + # Weblate apps on top to override Django locales and templates + "weblate.addons", + "weblate.auth", + "weblate.checks", + "weblate.formats", + "weblate.glossary", + "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", + # Standard Django modules + "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", + "django.contrib.humanize", + # Third party Django modules + "social_django", + "crispy_forms", + "compressor", + "rest_framework", + "rest_framework.authtoken", + "django_filters", +] + +# 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 + "social": {"handlers": [DEFAULT_LOG], "level": "DEBUG" if DEBUG else "WARNING"}, + # Django Authentication Using LDAP + "django_auth_ldap": { + "level": "DEBUG" if DEBUG else "WARNING", + "handlers": [DEFAULT_LOG], + }, + }, +} + +# 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.googlev3.GoogleV3Translation", +# "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.saptranslationhub.SAPTranslationHub", +# "weblate.machinery.youdao.YoudaoTranslation", +# "weblate.machinery.weblatetm.WeblateTranslation", +# "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 +MT_MICROSOFT_REGION = 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 v2 +MT_GOOGLE_KEY = None + +# Google Translate API3 credentials and project id +MT_GOOGLE_CREDENTIALS = None +MT_GOOGLE_PROJECT = 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 = False + +# 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 +SESSION_COOKIE_HTTPONLY = True +# SSL redirect +SECURE_SSL_REDIRECT = ENABLE_HTTPS +# Sent referrrer only for same origin links +SECURE_REFERRER_POLICY = "same-origin" +# SSL redirect URL exemption list +SECURE_REDIRECT_EXEMPT = (r"healthz/$",) # Allowing HTTP access to health check +# Session cookie age (in seconds) +SESSION_COOKIE_AGE = 1209600 +# Increase allowed upload size +DATA_UPLOAD_MAX_MEMORY_SIZE = 50000000 + +# Apply session coookie settings to language cookie as ewll +LANGUAGE_COOKIE_SECURE = SESSION_COOKIE_SECURE +LANGUAGE_COOKIE_HTTPONLY = SESSION_COOKIE_HTTPONLY +LANGUAGE_COOKIE_AGE = SESSION_COOKIE_AGE * 10 + +# Some security headers +SECURE_BROWSER_XSS_FILTER = True +X_FRAME_OPTIONS = "DENY" +SECURE_CONTENT_TYPE_NOSNIFF = True + +# Optionally enable HSTS +SECURE_HSTS_SECONDS = 31536000 if ENABLE_HTTPS else 0 +SECURE_HSTS_PRELOAD = ENABLE_HTTPS +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) + +# 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.DoubleSpaceCheck", +# "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.chars.PuctuationSpacingCheck", +# "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.format.PercentPlaceholdersCheck", +# "weblate.checks.format.I18NextInterpolationCheck", +# "weblate.checks.angularjs.AngularJSInterpolationCheck", +# "weblate.checks.qt.QtFormatCheck", +# "weblate.checks.qt.QtPluralCheck", +# "weblate.checks.ruby.RubyFormatCheck", +# "weblate.checks.consistency.PluralsCheck", +# "weblate.checks.consistency.SamePluralsCheck", +# "weblate.checks.consistency.ConsistencyCheck", +# "weblate.checks.consistency.TranslatedCheck", +# "weblate.checks.chars.EscapedNewlineCountingCheck", +# "weblate.checks.chars.NewLineCountCheck", +# "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.markup.SafeHTMLCheck", +# "weblate.checks.placeholders.PlaceholderCheck", +# "weblate.checks.placeholders.RegexCheck", +# "weblate.checks.duplicate.DuplicateCheck", +# "weblate.checks.source.OptionalPluralCheck", +# "weblate.checks.source.EllipsisCheck", +# "weblate.checks.source.MultipleFailingCheck", +# "weblate.checks.source.LongUntranslatedCheck", +# "weblate.checks.format.MultipleUnnamedFormatsCheck", +# ) + +# 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.flags.BulkEditAddon", +# "weblate.addons.generate.GenerateFileAddon", +# "weblate.addons.json.JSONCustomizeAddon", +# "weblate.addons.properties.PropertiesSortAddon", +# "weblate.addons.git.GitSquashAddon", +# "weblate.addons.removal.RemoveComments", +# "weblate.addons.removal.RemoveSuggestions", +# "weblate.addons.resx.ResxUpdateAddon", +# "weblate.addons.yaml.YAMLCustomizeAddon", +# "weblate.addons.autotranslate.AutoTranslateAddon", +# ) + +# 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 = "noreply@__ADMINMAIL__" + +# List of URLs your site is supposed to serve +ALLOWED_HOSTS = ["__DOMAIN__"] + +# Configuration for caching +CACHES = { + "default": { + "BACKEND": "django_redis.cache.RedisCache", + "LOCATION": "redis://127.0.0.1:6379/__REDIS_DB__", + # 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=1", + "OPTIONS": { + "CLIENT_CLASS": "django_redis.client.DefaultClient", + "PARSER_CLASS": "redis.connection.HiredisParser", + "PASSWORD": None, + "CONNECTION_POOL_KWARGS": {}, + }, + "KEY_PREFIX": "weblate", + }, + "avatar": { + "BACKEND": "django.core.cache.backends.filebased.FileBasedCache", + "LOCATION": os.path.join(DATA_DIR, "avatar-cache"), + "TIMEOUT": 86400, + "OPTIONS": {"MAX_ENTRIES": 1000}, + }, +} + +# Store sessions in cache +SESSION_ENGINE = "django.contrib.sessions.backends.cache" +# Store messages in session +MESSAGE_STORAGE = "django.contrib.messages.storage.session.SessionStorage" + +# 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": [ + # Require authentication for login required sites + "rest_framework.permissions.IsAuthenticated" + if REQUIRE_LOGIN + else "rest_framework.permissions.IsAuthenticatedOrReadOnly" + ], + "DEFAULT_AUTHENTICATION_CLASSES": ( + "rest_framework.authentication.TokenAuthentication", + "weblate.api.authentication.BearerAuthentication", + "rest_framework.authentication.SessionAuthentication", + ), + "DEFAULT_THROTTLE_CLASSES": ( + "weblate.api.throttling.UserRateThrottle", + "weblate.api.throttling.AnonRateThrottle", + ), + "DEFAULT_THROTTLE_RATES": {"anon": "100/day", "user": "5000/hour"}, + "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", +} + +# Require login for all URLs +if REQUIRE_LOGIN: + LOGIN_REQUIRED_URLS = (r"/(.*)$",) + +# In such case you will want to include some of the exceptions +# LOGIN_REQUIRED_URLS_EXCEPTIONS = ( +# rf"{URL_PREFIX}/accounts/(.*)$", # Required for login +# rf"{URL_PREFIX}/admin/login/(.*)$", # Required for admin login +# rf"{URL_PREFIX}/static/(.*)$", # Required for development mode +# rf"{URL_PREFIX}/widgets/(.*)$", # Allowing public access to widgets +# rf"{URL_PREFIX}/data/(.*)$", # Allowing public access to data exports +# rf"{URL_PREFIX}/hooks/(.*)$", # Allowing public access to notification hooks +# rf"{URL_PREFIX}/healthz/$", # Allowing public access to health check +# rf"{URL_PREFIX}/api/(.*)$", # Allowing access to API +# rf"{URL_PREFIX}/js/i18n/$", # JavaScript localization +# rf"{URL_PREFIX}/contact/$", # Optional for contact form +# rf"{URL_PREFIX}/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" +CELERY_RESULT_BACKEND = CELERY_BROKER_URL + +# Celery settings, it is not recommended to change these +CELERY_WORKER_MAX_MEMORY_PER_CHILD = 200000 +CELERY_BEAT_SCHEDULE_FILENAME = os.path.join(DATA_DIR, "celery", "beat-schedule") +CELERY_TASK_ROUTES = { + "weblate.trans.tasks.auto_translate": {"queue": "translate"}, + "weblate.memory.tasks.*": {"queue": "memory"}, + "weblate.accounts.tasks.notify_*": {"queue": "notify"}, + "weblate.accounts.tasks.send_mails": {"queue": "notify"}, + "weblate.utils.tasks.settings_backup": {"queue": "backup"}, + "weblate.utils.tasks.database_backup": {"queue": "backup"}, + "weblate.wladmin.tasks.backup": {"queue": "backup"}, + "weblate.wladmin.tasks.backup_service": {"queue": "backup"}, +} + +# Enable plain database backups +DATABASE_BACKUP = "plain" + +# Enable auto updating +AUTO_UPDATE = False + +# PGP commits signing +WEBLATE_GPG_IDENTITY = None + +# Third party services integration +MATOMO_SITE_ID = None +MATOMO_URL = None +GOOGLE_ANALYTICS_ID = None +SENTRY_DSN = None +AKISMET_API_KEY = None \ No newline at end of file diff --git a/conf/settings.py b/conf/settings.py new file mode 100644 index 0000000..7991e05 --- /dev/null +++ b/conf/settings.py @@ -0,0 +1,917 @@ +################################################################################ +################################################################################ +## FOR YUNOHOST USERS ## +################################################################################ +################################################################################ + +# Please do not modify this file, it will be reset at the next update. +# You can edit the file __FINALPATH__/local_settings.py and add/modify the settings you need. +# The parameters you add in local_settings.py will overwrite these, +# but you can use the options and documentation in this file to find out what can be done. + +################################################################################ +################################################################################ +# +# Copyright © 2012 - 2020 Michal Čihař +# +# This file is part of Weblate +# +# 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 . +# + + +import os +import platform +from logging.handlers import SysLogHandler + +# +# Django settings for Weblate project. +# + +DEBUG = False + +ADMINS = ( + ('__ADMIN__', '__ADMINMAIL__'), +) + +MANAGERS = ADMINS + +DATABASES = { + "default": { + # Use "postgresql" or "mysql". + "ENGINE": "django.db.backends.postgresql", + # Database name. + "NAME": "__NAME__", + # Database user. + "USER": "__NAME__", + # Name of role to alter to set parameters in PostgreSQL, + # use in case role name is different than user used for authentication. + # "ALTER_ROLE": "weblate", + # Database password. + "PASSWORD": "__DB_PWD__", + # Set to empty string for localhost. + "HOST": "127.0.0.1", + # Set to empty string for default. + "PORT": "", + # 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", + # Change connection timeout in case you get MySQL gone away error: + # "connect_timeout": 28800, + }, + } +} + +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"), + ("el", "Ελληνικά"), + ("en-gb", "English (United Kingdom)"), + ("es", "Español"), + ("fi", "Suomi"), + ("fr", "Français"), + ("gl", "Galego"), + ("he", "עברית"), + ("hu", "Magyar"), + ("hr", "Hrvatski"), + ("id", "Indonesia"), + ("is", "Íslenska"), + ("it", "Italiano"), + ("ja", "日本語"), + ("kab", "Taqbaylit"), + ("kk", "Қазақ тілі"), + ("ko", "한국어"), + ("nb", "Norsk bokmål"), + ("nl", "Nederlands"), + ("pl", "Polski"), + ("pt", "Português"), + ("pt-br", "Português brasileiro"), + ("ru", "Русский"), + ("sk", "Slovenčina"), + ("sl", "Slovenščina"), + ("sq", "Shqip"), + ("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. +MEDIA_ROOT = os.path.join(DATA_DIR, "media") + +# URL that handles the media served from MEDIA_ROOT. Make sure to use a +# trailing slash. +MEDIA_URL = f"{URL_PREFIX}/media/" + +# 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. +STATIC_ROOT = os.path.join(DATA_DIR, "static") + +# URL prefix for static files. +STATIC_URL = f"{URL_PREFIX}/static/" + +# 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__" + +_TEMPLATE_LOADERS = [ + "django.template.loaders.filesystem.Loader", + "django.template.loaders.app_directories.Loader", +] +if not DEBUG: + _TEMPLATE_LOADERS = [("django.template.loaders.cached.Loader", _TEMPLATE_LOADERS)] +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": _TEMPLATE_LOADERS, + }, + } +] + + +# GitHub username for sending pull requests. +# Please see the documentation for more details. +GITHUB_USERNAME = "__GITHUBUSER__" +GITHUB_TOKEN = "__GITHUBTOKEN__" + +# GitLab username for sending merge requests. +# Please see the documentation for more details. +GITLAB_USERNAME = None +GITLAB_TOKEN = None + +# 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_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": 10}, + }, + {"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 + +# Shortcut for login required setting +REQUIRE_LOGIN = False + +# Middleware +MIDDLEWARE = [ + "weblate.middleware.RedirectMiddleware", + "weblate.middleware.ProxyMiddleware", + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "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.api.middleware.ThrottlingMiddleware", + "weblate.middleware.SecurityMiddleware", +] + +ROOT_URLCONF = "weblate.urls" + +# Django and Weblate apps +INSTALLED_APPS = [ + # Weblate apps on top to override Django locales and templates + "weblate.addons", + "weblate.auth", + "weblate.checks", + "weblate.formats", + "weblate.glossary", + "weblate.machinery", + "weblate.trans", + "weblate.lang", + "weblate_language_data", + "weblate.memory", + "weblate.screenshots", + "weblate.fonts", + "weblate.accounts", + "weblate.utils", + "weblate.vcs", + "weblate.wladmin", + "weblate", + # Optional: Git exporter + "weblate.gitexport", + # Standard Django modules + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", + "django.contrib.admin.apps.SimpleAdminConfig", + "django.contrib.admindocs", + "django.contrib.sitemaps", + "django.contrib.humanize", + # Third party Django modules + "social_django", + "crispy_forms", + "compressor", + "rest_framework", + "rest_framework.authtoken", + "django_filters", +] + +# 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" +DEFAULT_LOGLEVEL = "DEBUG" if DEBUG else "INFO" + +# 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": DEFAULT_LOGLEVEL}, + # Logging VCS operations + "weblate.vcs": {"handlers": [DEFAULT_LOG], "level": DEFAULT_LOGLEVEL}, + # Python Social Auth + "social": {"handlers": [DEFAULT_LOG], "level": DEFAULT_LOGLEVEL}, + # Django Authentication Using LDAP + "django_auth_ldap": {"handlers": [DEFAULT_LOG], "level": DEFAULT_LOGLEVEL}, + }, +} + +# 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.googlev3.GoogleV3Translation", + # "weblate.machinery.microsoft.MicrosoftCognitiveTranslation", + # "weblate.machinery.microsoftterminology.MicrosoftTerminologyService", + # "weblate.machinery.modernmt.ModernMTTranslation", + # "weblate.machinery.mymemory.MyMemoryTranslation", + # "weblate.machinery.netease.NeteaseSightTranslation", + # "weblate.machinery.tmserver.AmagamaTranslation", + # "weblate.machinery.tmserver.TMServerTranslation", + # "weblate.machinery.yandex.YandexTranslation", + # "weblate.machinery.saptranslationhub.SAPTranslationHub", + # "weblate.machinery.youdao.YoudaoTranslation", + "weblate.machinery.weblatetm.WeblateTranslation", + "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 +MT_MICROSOFT_REGION = None + +# ModernMT +MT_MODERNMT_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 v2 +MT_GOOGLE_KEY = None + +# Google Translate API3 credentials and project id +MT_GOOGLE_CREDENTIALS = None +MT_GOOGLE_PROJECT = 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" + +# Site domain +SITE_DOMAIN = "__DOMAIN__" + +# 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 +SESSION_COOKIE_HTTPONLY = True +# SSL redirect +SECURE_SSL_REDIRECT = ENABLE_HTTPS +# Sent referrrer only for same origin links +SECURE_REFERRER_POLICY = "same-origin" +# SSL redirect URL exemption list +SECURE_REDIRECT_EXEMPT = (r"healthz/$",) # Allowing HTTP access to health check +# Session cookie age (in seconds) +SESSION_COOKIE_AGE = 1000 +SESSION_COOKIE_AGE_AUTHENTICATED = 1209600 +# Increase allowed upload size +DATA_UPLOAD_MAX_MEMORY_SIZE = 50000000 + +# Apply session coookie settings to language cookie as ewll +LANGUAGE_COOKIE_SECURE = SESSION_COOKIE_SECURE +LANGUAGE_COOKIE_HTTPONLY = SESSION_COOKIE_HTTPONLY +LANGUAGE_COOKIE_AGE = SESSION_COOKIE_AGE_AUTHENTICATED * 10 + +# Some security headers +SECURE_BROWSER_XSS_FILTER = True +X_FRAME_OPTIONS = "DENY" +SECURE_CONTENT_TYPE_NOSNIFF = True + +# Optionally enable HSTS +SECURE_HSTS_SECONDS = 31536000 if ENABLE_HTTPS else 0 +SECURE_HSTS_PRELOAD = ENABLE_HTTPS +SECURE_HSTS_INCLUDE_SUBDOMAINS = ENABLE_HTTPS + +# HTTPS detection behind reverse proxy +SECURE_PROXY_SSL_HEADER = None + +# 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) + +# Enable remote hooks +ENABLE_HOOKS = True + +# 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.DoubleSpaceCheck", +# "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.chars.PunctuationSpacingCheck", +# "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.format.PercentPlaceholdersCheck", +# "weblate.checks.format.VueFormattingCheck", +# "weblate.checks.format.I18NextInterpolationCheck", +# "weblate.checks.format.ESTemplateLiteralsCheck", +# "weblate.checks.angularjs.AngularJSInterpolationCheck", +# "weblate.checks.qt.QtFormatCheck", +# "weblate.checks.qt.QtPluralCheck", +# "weblate.checks.ruby.RubyFormatCheck", +# "weblate.checks.consistency.PluralsCheck", +# "weblate.checks.consistency.SamePluralsCheck", +# "weblate.checks.consistency.ConsistencyCheck", +# "weblate.checks.consistency.TranslatedCheck", +# "weblate.checks.chars.EscapedNewlineCountingCheck", +# "weblate.checks.chars.NewLineCountCheck", +# "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.markup.SafeHTMLCheck", +# "weblate.checks.placeholders.PlaceholderCheck", +# "weblate.checks.placeholders.RegexCheck", +# "weblate.checks.duplicate.DuplicateCheck", +# "weblate.checks.source.OptionalPluralCheck", +# "weblate.checks.source.EllipsisCheck", +# "weblate.checks.source.MultipleFailingCheck", +# "weblate.checks.source.LongUntranslatedCheck", +# "weblate.checks.format.MultipleUnnamedFormatsCheck", +# ) + +# 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.flags.BulkEditAddon", +# "weblate.addons.generate.GenerateFileAddon", +# "weblate.addons.json.JSONCustomizeAddon", +# "weblate.addons.properties.PropertiesSortAddon", +# "weblate.addons.git.GitSquashAddon", +# "weblate.addons.removal.RemoveComments", +# "weblate.addons.removal.RemoveSuggestions", +# "weblate.addons.resx.ResxUpdateAddon", +# "weblate.addons.yaml.YAMLCustomizeAddon", +# "weblate.addons.cdn.CDNJSAddon", +# "weblate.addons.autotranslate.AutoTranslateAddon", +# ) + +# 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__"] + +# Configuration for caching +CACHES = { + "default": { + "BACKEND": "django_redis.cache.RedisCache", + "LOCATION": "redis://127.0.0.1:6379/__REDIS_DB__", + # 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=1", + "OPTIONS": { + "CLIENT_CLASS": "django_redis.client.DefaultClient", + "PARSER_CLASS": "redis.connection.HiredisParser", + "PASSWORD": None, + "CONNECTION_POOL_KWARGS": {}, + }, + "KEY_PREFIX": "weblate", + }, + "avatar": { + "BACKEND": "django.core.cache.backends.filebased.FileBasedCache", + "LOCATION": os.path.join(DATA_DIR, "avatar-cache"), + "TIMEOUT": 86400, + "OPTIONS": {"MAX_ENTRIES": 1000}, + }, +} + +# Store sessions in cache +SESSION_ENGINE = "django.contrib.sessions.backends.cache" +# Store messages in session +MESSAGE_STORAGE = "django.contrib.messages.storage.session.SessionStorage" + +# 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": [ + # Require authentication for login required sites + "rest_framework.permissions.IsAuthenticated" + if REQUIRE_LOGIN + else "rest_framework.permissions.IsAuthenticatedOrReadOnly" + ], + "DEFAULT_AUTHENTICATION_CLASSES": ( + "rest_framework.authentication.TokenAuthentication", + "weblate.api.authentication.BearerAuthentication", + "rest_framework.authentication.SessionAuthentication", + ), + "DEFAULT_THROTTLE_CLASSES": ( + "weblate.api.throttling.UserRateThrottle", + "weblate.api.throttling.AnonRateThrottle", + ), + "DEFAULT_THROTTLE_RATES": {"anon": "100/day", "user": "5000/hour"}, + "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", +} + +# Fonts CDN URL +FONTS_CDN_URL = None + +# Django compressor offline mode +COMPRESS_OFFLINE = False +COMPRESS_OFFLINE_CONTEXT = [ + {"fonts_cdn_url": FONTS_CDN_URL, "STATIC_URL": STATIC_URL, "LANGUAGE_BIDI": True}, + {"fonts_cdn_url": FONTS_CDN_URL, "STATIC_URL": STATIC_URL, "LANGUAGE_BIDI": False}, +] + +# Require login for all URLs +if REQUIRE_LOGIN: + LOGIN_REQUIRED_URLS = (r"/(.*)$",) + +# In such case you will want to include some of the exceptions +# LOGIN_REQUIRED_URLS_EXCEPTIONS = ( +# rf"{URL_PREFIX}/accounts/(.*)$", # Required for login +# rf"{URL_PREFIX}/admin/login/(.*)$", # Required for admin login +# rf"{URL_PREFIX}/static/(.*)$", # Required for development mode +# rf"{URL_PREFIX}/widgets/(.*)$", # Allowing public access to widgets +# rf"{URL_PREFIX}/data/(.*)$", # Allowing public access to data exports +# rf"{URL_PREFIX}/hooks/(.*)$", # Allowing public access to notification hooks +# rf"{URL_PREFIX}/healthz/$", # Allowing public access to health check +# rf"{URL_PREFIX}/api/(.*)$", # Allowing access to API +# rf"{URL_PREFIX}/js/i18n/$", # JavaScript localization +# rf"{URL_PREFIX}/contact/$", # Optional for contact form +# rf"{URL_PREFIX}/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" +CELERY_RESULT_BACKEND = CELERY_BROKER_URL + +# Celery settings, it is not recommended to change these +CELERY_WORKER_MAX_MEMORY_PER_CHILD = 200000 +CELERY_BEAT_SCHEDULE_FILENAME = os.path.join(DATA_DIR, "celery", "beat-schedule") +CELERY_TASK_ROUTES = { + "weblate.trans.tasks.auto_translate": {"queue": "translate"}, + "weblate.accounts.tasks.notify_*": {"queue": "notify"}, + "weblate.accounts.tasks.send_mails": {"queue": "notify"}, + "weblate.utils.tasks.settings_backup": {"queue": "backup"}, + "weblate.utils.tasks.database_backup": {"queue": "backup"}, + "weblate.wladmin.tasks.backup": {"queue": "backup"}, + "weblate.wladmin.tasks.backup_service": {"queue": "backup"}, + "weblate.memory.tasks.*": {"queue": "memory"}, +} + +# Enable plain database backups +DATABASE_BACKUP = "plain" + +# Enable auto updating +AUTO_UPDATE = False + +# PGP commits signing +WEBLATE_GPG_IDENTITY = None + +# Third party services integration +MATOMO_SITE_ID = None +MATOMO_URL = None +GOOGLE_ANALYTICS_ID = None +SENTRY_DSN = None +AKISMET_API_KEY = None + +try: + from .local_settings import * +except ImportError: + pass diff --git a/conf/settings_history/settings.2.16.py b/conf/settings_history/settings.2.16.py deleted file mode 100644 index d053616..0000000 --- a/conf/settings_history/settings.2.16.py +++ /dev/null @@ -1,699 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright © 2012 - 2017 Michal Čihař -# -# This file is part of Weblate -# -# 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 . -# - -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' diff --git a/conf/settings_history/settings.2.17.1.py b/conf/settings_history/settings.2.17.1.py deleted file mode 100644 index aabf755..0000000 --- a/conf/settings_history/settings.2.17.1.py +++ /dev/null @@ -1,708 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright © 2012 - 2017 Michal Čihař -# -# This file is part of Weblate -# -# 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 . -# - -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' diff --git a/conf/settings_history/settings.2.18.py b/conf/settings_history/settings.2.18.py deleted file mode 100644 index 80f7de6..0000000 --- a/conf/settings_history/settings.2.18.py +++ /dev/null @@ -1,708 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright © 2012 - 2017 Michal Čihař -# -# This file is part of Weblate -# -# 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 . -# - -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' diff --git a/conf/settings_history/settings.2.20.py b/conf/settings_history/settings.2.20.py deleted file mode 100644 index fd84cfc..0000000 --- a/conf/settings_history/settings.2.20.py +++ /dev/null @@ -1,754 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright © 2012 - 2018 Michal Čihař -# -# This file is part of Weblate -# -# 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 . -# - -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' - diff --git a/conf/settings_history/settings.3.0.1.py b/conf/settings_history/settings.3.0.1.py deleted file mode 100644 index a142e66..0000000 --- a/conf/settings_history/settings.3.0.1.py +++ /dev/null @@ -1,757 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright © 2012 - 2018 Michal Čihař -# -# This file is part of Weblate -# -# 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 . -# - -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' diff --git a/conf/settings_history/settings.3.0.py b/conf/settings_history/settings.3.0.py deleted file mode 100644 index a142e66..0000000 --- a/conf/settings_history/settings.3.0.py +++ /dev/null @@ -1,757 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright © 2012 - 2018 Michal Čihař -# -# This file is part of Weblate -# -# 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 . -# - -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' diff --git a/conf/settings_history/settings.3.1.1.py b/conf/settings_history/settings.3.1.1.py deleted file mode 100644 index 37193f5..0000000 --- a/conf/settings_history/settings.3.1.1.py +++ /dev/null @@ -1,770 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright © 2012 - 2018 Michal Čihař -# -# This file is part of Weblate -# -# 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 . -# - -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' diff --git a/conf/settings_history/settings.3.2.2.py b/conf/settings_history/settings.3.2.2.py deleted file mode 100644 index 67dd6bc..0000000 --- a/conf/settings_history/settings.3.2.2.py +++ /dev/null @@ -1,824 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright © 2012 - 2018 Michal Čihař -# -# This file is part of Weblate -# -# 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 . -# - -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' -) - diff --git a/conf/settings_history/settings.3.3.py b/conf/settings_history/settings.3.3.py deleted file mode 100644 index 4683a5b..0000000 --- a/conf/settings_history/settings.3.3.py +++ /dev/null @@ -1,834 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright © 2012 - 2018 Michal Čihař -# -# This file is part of Weblate -# -# 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 . -# - -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' -) diff --git a/conf/settings_history/settings.3.4.py b/conf/settings_history/settings.3.4.py deleted file mode 100644 index 30e4d44..0000000 --- a/conf/settings_history/settings.3.4.py +++ /dev/null @@ -1,855 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright © 2012 - 2019 Michal Čihař -# -# This file is part of Weblate -# -# 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 . -# - -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'}, -} - diff --git a/conf/settings_history/settings.3.5.1.py b/conf/settings_history/settings.3.5.1.py deleted file mode 100644 index ca6f682..0000000 --- a/conf/settings_history/settings.3.5.1.py +++ /dev/null @@ -1,867 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright © 2012 - 2019 Michal Čihař -# -# This file is part of Weblate -# -# 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 . -# - -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'}, -} diff --git a/conf/settings_history/settings.3.5.py b/conf/settings_history/settings.3.5.py deleted file mode 100644 index ca6f682..0000000 --- a/conf/settings_history/settings.3.5.py +++ /dev/null @@ -1,867 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright © 2012 - 2019 Michal Čihař -# -# This file is part of Weblate -# -# 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 . -# - -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'}, -} diff --git a/conf/settings_history/settings.3.6.1.py b/conf/settings_history/settings.3.6.1.py deleted file mode 100644 index b231714..0000000 --- a/conf/settings_history/settings.3.6.1.py +++ /dev/null @@ -1,870 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright © 2012 - 2019 Michal Čihař -# -# This file is part of Weblate -# -# 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 . -# - -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'}, -} - diff --git a/conf/settings_history/settings.3.7.py b/conf/settings_history/settings.3.7.py deleted file mode 100644 index cfe7067..0000000 --- a/conf/settings_history/settings.3.7.py +++ /dev/null @@ -1,879 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright © 2012 - 2019 Michal Čihař -# -# This file is part of Weblate -# -# 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 . -# - -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'}, -} - diff --git a/conf/settings_history/settings.3.8.py b/conf/settings_history/settings.3.8.py deleted file mode 100644 index cf43ac2..0000000 --- a/conf/settings_history/settings.3.8.py +++ /dev/null @@ -1,887 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright © 2012 - 2019 Michal Čihař -# -# This file is part of Weblate -# -# 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 . -# - -from __future__ import unicode_literals - -import os -import platform -from logging.handlers import SysLogHandler - -# -# Django settings for Weblate project. -# - -DEBUG = False - -ADMINS = ( - ('__ADMIN__', '__ADMINMAIL__'), -) - -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'), - ('el', 'Ελληνικά'), - ('en-gb', 'English (United Kingdom)'), - ('es', 'Español'), - ('fi', 'Suomi'), - ('fr', 'Français'), - ('gl', 'Galego'), - ('he', 'עברית'), - ('hu', 'Magyar'), - ('id', 'Indonesia'), - ('it', 'Italiano'), - ('ja', '日本語'), - ('kk', 'Қазақ тілі'), - ('ko', '한국어'), - ('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', - 'django.contrib.humanize', - '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 -# SSL redirect URL exemption list -SECURE_REDIRECT_EXEMPT = ( - r'healthz/$', # Allowing HTTP access to health check -) -# 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 = 63072000 # as in Strict-Transport-Security : max-age=yunohost/data/templates/nginx/yunohost_admin.conf -SECURE_HSTS_PRELOAD = False # already done by YunoHost -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.qt.QtFormatCheck', -# 'weblate.checks.qt.QtPluralCheck', -# 'weblate.checks.ruby.RubyFormatCheck', -# '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'}, - 'weblate.accounts.tasks.send_mails': {'queue': 'notify'}, -} - diff --git a/conf/uwsgi.ini b/conf/uwsgi.ini index ca9a11f..31a67b9 100644 --- a/conf/uwsgi.ini +++ b/conf/uwsgi.ini @@ -3,24 +3,50 @@ plugins = python3 master = true protocol = uwsgi 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 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 buffer-size = 8192 + +# Reload when consuming too much of memory +reload-on-rss = 250 + # Increase number of workers for heavily loaded sites -# Needed for background processing +workers = 8 + +# Enable threads for Sentry error submission enable-threads = true + # Child processes do not need file descriptors close-on-exec = true +# Avoid default 0000 umask +umask = 0022 + # Run as weblate user -#uid = __APP__ -#gid = www-data +uid = __APP__ +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 ignore-sigpipe = true ignore-write-errors = true -disable-write-exception = true +disable-write-exception = true \ No newline at end of file diff --git a/conf/weblate.service b/conf/weblate.service index 16e6b43..6ffe8df 100644 --- a/conf/weblate.service +++ b/conf/weblate.service @@ -5,7 +5,7 @@ After=syslog.target [Service] Type=forking User=__APP__ -Group=www-data +Group=__APP__ PermissionsStartOnly=true @@ -16,10 +16,7 @@ ExecStartPre=/bin/chown -R __APP__ /var/log/__APP__ ExecStart=/usr/bin/uwsgi \ --ini /etc/uwsgi/apps-available/__APP__.ini \ - --socket /var/run/__APP__/socket \ - --chmod-socket=775 \ - --logto /var/log/__APP__/weblate.log \ - --processes 4 + --logto /var/log/__APP__/weblate.log Restart=on-failure diff --git a/manifest.json b/manifest.json index b237c41..a22d327 100644 --- a/manifest.json +++ b/manifest.json @@ -2,18 +2,23 @@ "name": "Weblate", "id": "weblate", "packaging_format": 1, - "requirements": { - "yunohost": ">= 3.5.0" - }, "description": { - "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" }, - "version": "3.8.0~ynh3", + "version": "4.3.1~ynh1", "url": "https://weblate.org", "license": "AGPL-3.0", "maintainer": { + "name": "", + "email": "" + }, + "previous_maintainers": [{ "name": "Jean-Baptiste Holcroft", "email": "jean-baptiste@holcroft.fr" + }], + "requirements": { + "yunohost": ">= 4.0.0" }, "multi_instance": true, "services": [ @@ -25,7 +30,8 @@ "name": "domain", "type": "domain", "ask": { - "en": "Choose a domain for Weblate:" + "en": "Choose a domain for Weblate", + "fr": "Choisissez un domaine pour Weblate" }, "example": "domain.org" }, @@ -33,7 +39,8 @@ "name": "path", "type": "path", "ask": { - "en": "Choose a path for Weblate:" + "en": "Choose a path for Weblate", + "fr": "Choisissez un chemin pour Weblate" }, "example": "/weblate", "default": "/weblate" @@ -42,36 +49,41 @@ "name": "is_public", "type": "boolean", "ask": { - "en": "Should Weblate be public accessible?" + "en": "Should Weblate be public accessible?", + "fr": "Weblate doit-il être accessible au public ?" }, "help": { - "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" }, - "default": "0" + "default": false }, { "name": "admin", "type": "user", "ask": { - "en": "Choose an admin user for Weblate" + "en": "Choose an admin user for Weblate", + "fr": "Choisissez l'administrateur pour Weblate" }, - "example": "simon" + "example": "johndoe" }, { "name": "github_account", "type": "string", "ask": { - "en": "Github's username" + "en": "GitHub's username", + "fr": "Nom d'utilisateur de GitHub" }, - "example": "simon" + "example": "Github account" }, { "name": "github_token", "type": "string", "ask": { - "en": "Github's token (oauth)" + "en": "GitHub's token (OAuth)", + "fr": "Jeton GitHub (OAuth)" }, - "example": "simon" + "example": "A secret token" } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index 74bff58..4df9ede 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,15 +5,14 @@ #================================================= # dependencies used by the app -pkg_dependencies="libxml2-dev libxslt-dev libfreetype6-dev \ - libjpeg-dev libz-dev libyaml-dev python3-dev python3-pip python3-virtualenv \ - python3-enchant \ - postgresql libpq-dev uwsgi uwsgi-plugin-python3 \ - libpango1.0-dev libcairo2-dev libglib2.0-dev libgirepository1.0-dev \ - mailutils python-celery-common virtualenv redis-server" +pkg_dependencies="libxml2-dev libxslt-dev libfreetype6-dev libjpeg-dev libz-dev libyaml-dev \ + libcairo-dev gir1.2-pango-1.0 libgirepository1.0-dev libacl1-dev libssl-dev \ + build-essential python3-gdbm python3-enchant python3-dev python3-pip python3-virtualenv virtualenv git \ + uwsgi uwsgi-plugin-python3 redis-server postgresql postgresql-contrib \ + libpq-dev libglib2.0-dev mailutils python-celery-common hub" # Weblate's version for PIP and settings file -current_version="3.8" +weblate_version="4.3.1" debian_maj_version=$(sed 's/\..*//' /etc/debian_version) @@ -25,46 +24,9 @@ elif [ "$debian_maj_version" -eq 10 ] ; then 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 # # usage: ynh_send_readme_to_admin app_message [recipients] diff --git a/scripts/backup b/scripts/backup index 11bb4d9..df73ca3 100755 --- a/scripts/backup +++ b/scripts/backup @@ -14,98 +14,70 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= - -ynh_script_progression --message="Loading installation settings..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get "$app" final_path) -domain=$(ynh_app_setting_get "$app" domain) -db_name=$(ynh_app_setting_get "$app" db_name) +final_path=$(ynh_app_setting_get --app="$app" --key=final_path) +domain=$(ynh_app_setting_get --app="$app" --key=domain) +db_name=$(ynh_app_setting_get --app="$app" --key=db_name) -#================================================= -# STANDARD BACKUP STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= - -ynh_script_progression --message="Stopping systemd services..." +ynh_print_info --message="Stopping systemd services..." ynh_systemd_action --service_name="$app" --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 #================================================= -ynh_script_progression --message="Backing up the main app directory..." - -ynh_backup "$final_path" +ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Backing up nginx web server configuration..." - -ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE PostgreSQL DATABASE #================================================= -ynh_script_progression --message="Backing up the PostgreSQL database..." - -ynh_psql_dump_db "$db_name" > db.sql -ynh_backup "db.sql" +ynh_psql_dump_db --database="$db_name" > db.sql #================================================= # SPECIFIC BACKUP #================================================= # BACKUP LOGROTATE #================================================= -ynh_script_progression --message="Backing up logrotate configuration..." 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 "/etc/cron.d/$app" +ynh_backup --src_path="/etc/uwsgi/apps-available/$app.ini" #================================================= -# BACKUP THE uwsgi files +# BACKUP SYSTEMD #================================================= -ynh_script_progression --message="Backing up uwsgi configuration..." - -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 +ynh_backup --src_path="/etc/systemd/system/$app.service" +ynh_backup --src_path="/etc/systemd/system/$app-celery.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-celery" --action="start" @@ -113,4 +85,4 @@ ynh_systemd_action --service_name="$app-celery" --action="start" # 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)." diff --git a/scripts/change_url b/scripts/change_url index 0edad8c..47a73ca 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -26,8 +26,25 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_script_progression --message="Loading installation settings..." -final_path=$(ynh_app_setting_get "$app" final_path) -is_public=$(ynh_app_setting_get "$app" is_public) +final_path=$(ynh_app_setting_get --app="$app" --key=final_path) +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)..." --weight=40 + +# 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 @@ -50,7 +67,6 @@ fi #================================================= # STOP SYSTEMD SERVICE #================================================= - ynh_script_progression --message="Stopping systemd services..." ynh_systemd_action --service_name="$app" --action="stop" @@ -61,101 +77,82 @@ ynh_systemd_action --service_name="$app-celery" --action="stop" #================================================= # MODIFY URL IN NGINX CONF #================================================= - ynh_script_progression --message="Updating nginx web server configuration..." -nginx_conf_path="/etc/nginx/conf.d/$old_domain.d/$app.conf" -finalnginxconf=$nginx_conf_path +nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf # Change the path in the nginx config file if [ $change_path -eq 1 ] then - ynh_replace_string "location $old_path" "location $new_path" "$nginx_conf_path" - ynh_replace_string "SCRIPT_NAME $old_path" "SCRIPT_NAME $new_path" "$nginx_conf_path" + # Make a backup of the original nginx config file if modified + 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 # Change the domain for nginx if [ $change_domain -eq 1 ] then - - finalnginxconf="/etc/nginx/conf.d/${new_domain}.d/${app}.conf" - mv "$nginx_conf_path" "$finalnginxconf" + # Delete file checksum for the old conf file location + ynh_delete_file_checksum --file="$nginx_conf_path" + 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 #================================================= -# 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 #================================================= ynh_script_progression --message="Modify weblate's config file..." +settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" +ynh_backup_if_checksum_is_different --file="$settings" + # Change the path in the nginx config file if [ $change_path -eq 1 ] 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 # Change the domain for nginx if [ $change_domain -eq 1 ] then # 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 SITE_DOMAIN + ynh_replace_string --match_string="SITE_DOMAIN = \"$old_domain\"" --replace_string="SITE_DOMAIN = \"$new_domain\"" --target_file="$settings" # replace ALLOWED_HOSTS - ynh_replace_string "['$old_domain']" "['$new_domain']" "$settings" + ynh_replace_string --match_string="ALLOWED_HOSTS = \[\"$old_domain\"\]" --replace_string="ALLOWED_HOSTS = \[\"$new_domain\"\]" --target_file="$settings" fi -if [ "$old_path" == "/" ] && [ "$new_path" != "/" ] -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" +ynh_store_file_checksum --file="$settings" #================================================= -# ChangeSite inside weblate +# MODIFY UWSGI #================================================= -ynh_script_progression --message="Run weblate's command changesite..." -( - set +eu - source "${final_path}/venv/bin/activate" - export DJANGO_SETTINGS_MODULE="weblate.settings" - weblate changesite --set-name "$new_domain" -) + +finaluwsgiini="/etc/uwsgi/apps-available/$app.ini" +ynh_backup_if_checksum_is_different --file="$finaluwsgiini" + +# Change the path in the nginx config file +if [ $change_path -eq 1 ] +then + ynh_replace_string --match_string="mount = $old_path=" --replace_string="mount = $new_path=" --target_file="$finaluwsgiini" +fi + +ynh_store_file_checksum --file="$finaluwsgiini" #================================================= # GENERIC FINALISATION #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting systemd services..." +ynh_script_progression --message="Starting systemd services..." --weight=5 ynh_systemd_action --service_name="$app" --action="start" ynh_systemd_action --service_name="$app-celery" --action="start" diff --git a/scripts/install b/scripts/install index 5a34320..e79568b 100755 --- a/scripts/install +++ b/scripts/install @@ -27,16 +27,6 @@ is_public=$YNH_APP_ARG_IS_PUBLIC github_account=$YNH_APP_ARG_GITHUB_ACCOUNT 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 #================================================= @@ -44,131 +34,78 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_script_progression --message="Validating installation parameters..." -# Register (book) web path -ynh_webpath_register "$app" "$domain" "$path_url" - 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" #================================================= # STORE SETTINGS FROM MANIFEST #================================================= - ynh_script_progression --message="Storing installation settings..." -ynh_app_setting_set "$app" domain "$domain" -ynh_app_setting_set "$app" path "$path_url" -ynh_app_setting_set "$app" admin "$admin" -ynh_app_setting_set "$app" is_public "$is_public" -ynh_app_setting_set "$app" final_path "$final_path" -ynh_app_setting_set "$app" github_account "$github_account" -ynh_app_setting_set "$app" github_token "$github_token" +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="$app" --key=admin --value="$admin" +ynh_app_setting_set --app="$app" --key=is_public --value="$is_public" +ynh_app_setting_set --app="$app" --key=final_path --value="$final_path" +ynh_app_setting_set --app="$app" --key=github_account --value="$github_account" +ynh_app_setting_set --app="$app" --key=github_token --value="$github_token" #================================================= # STANDARD MODIFICATIONS -#================================================= - #================================================= # INSTALL DEPENDENCIES #================================================= +ynh_script_progression --message="Installing dependencies..." --weight=40 -ynh_script_progression --message="Installing dependencies..." - -ynh_install_app_dependencies "$pkg_dependencies" +ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" #================================================= # CREATE A PostgreSQL DATABASE #================================================= ynh_script_progression --message="Creating a PostgreSQL database..." -db_name=$(ynh_sanitize_dbid "$app") -ynh_app_setting_set "$app" db_name "$db_name" +db_name=$(ynh_sanitize_dbid --db_name="$app") +db_user=$db_name +ynh_app_setting_set --app="$app" --key=db_name --value="$db_name" ynh_psql_test_if_first_run # Initialize database and store postgres password for upgrade -ynh_psql_setup_db "$db_name" "$app" - -ynh_systemd_action --service_name=postgresql --action=reload +ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" #================================================= # NGINX CONFIGURATION #================================================= - ynh_script_progression --message="Configuring nginx web server..." # Create a dedicated 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 #================================================= - ynh_script_progression --message="Configuring system user..." # Hub needs a home directory with a config file -ynh_system_user_create "$app" "$final_path" -# Allow bash for our user, so he can use Hub -chsh --shell /bin/bash "$app" +ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell #================================================= -# Download and install hub +# CONFIGURE HUB #================================================= - -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/ +ynh_script_progression --message="Configure hub..." mkdir "$final_path/.config/" cp ../conf/hub_config "$final_path/.config/hub" -ynh_replace_string "__GITHUBUSER__" "$github_account" "$final_path/.config/hub" -ynh_replace_string "__GITHUBTOKEN__" "$github_token" "$final_path/.config/hub" +ynh_replace_string --match_string="__GITHUBUSER__" --replace_string="$github_account" --target_file="$final_path/.config/hub" +ynh_replace_string --match_string="__GITHUBTOKEN__" --replace_string="$github_token" --target_file="$final_path/.config/hub" cat < "$final_path/.bashrc" -alias git=hub +eval "$(hub alias -s /bin/bash)" EOF #================================================= @@ -176,23 +113,25 @@ EOF #================================================= # PIP INSTALLATION #================================================= +ynh_script_progression --message="Install weblate using PIP..." --weight=80 -ynh_script_progression --message="Install weblate using PIP..." --weight=10 +ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name virtualenv --python=python3 "${final_path}/venv" +chown -R "$app": "$final_path" + #run source in a 'sub shell' ( set +o nounset source "${final_path}/venv/bin/activate" set -o nounset - pip install --upgrade pip - # prevent error: "command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers" - pip install --upgrade setuptools - pip install Django==2.2.* - pip install Weblate=="$current_version" - pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2-binary phply django-redis hiredis aeidon ruamel.yaml + sudo -u $app $final_path/venv/bin/pip install --upgrade pip setuptools wheel + # Still needed with latest version of weblate? + sudo -u $app $final_path/venv/bin/pip install Weblate=="$weblate_version" + sudo -u $app $final_path/venv/bin/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: - pip install django_sendmail_backend + sudo -u $app $final_path/venv/bin/pip install django_sendmail_backend ) #================================================= @@ -200,96 +139,103 @@ virtualenv --python=python3 "${final_path}/venv" # https://docs.weblate.org/en/latest/admin/install.html#installation # TODO: use --extra-search-dir=/path/to/dists #================================================= - ynh_script_progression --message="Create weblate configuration file..." -db_pwd=$(ynh_app_setting_get "$app" psqlpwd) -admin_mail=$(ynh_user_get_info "$admin" mail) -key=$(ynh_string_random 24)$(ynh_string_random 24)$(ynh_string_random 2) +db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd) +admin_mail=$(ynh_user_get_info --username="$admin" --key=mail) +key=$(ynh_string_random --length=50) redis_db=$(ynh_redis_get_free_db) 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_app_setting_set "$app" redis_db "$redis_db" +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="__GITHUBTOKEN__" --replace_string="$github_token" --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" + +touch "$final_path/local_settings.py" +ln -sf "$final_path/local_settings.py" "$final_path/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py" #================================================= # SPECIFIC SETUP 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..." --weight=10 + ( set +o nounset source "${final_path}/venv/bin/activate" set -o nounset export DJANGO_SETTINGS_MODULE="weblate.settings" # the user needs to be weblate for postgresql - weblate migrate --noinput + sudo -u $app $final_path/venv/bin/weblate migrate --noinput # generate static files - weblate collectstatic --noinput - weblate changesite --set-name "$domain" - weblate createadmin --no-color \ + sudo -u $app $final_path/venv/bin/weblate collectstatic --noinput + sudo -u $app $final_path/venv/bin/weblate createadmin --no-color \ --password "weblate" \ --username "$admin" \ --email "$admin_mail" + + # Check the configuration + # This may fail in some cases with errors, etc., but the app works and the user can fix issues later. + sudo -u $app $final_path/venv/bin/weblate check --deploy || true ) -#================================================= -# 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 #================================================= # 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..." + finaluwsgiini="/etc/uwsgi/apps-available/$app.ini" cp ../conf/uwsgi.ini "$finaluwsgiini" -ynh_replace_string "__FINALPATH__" "$final_path" "$finaluwsgiini" -ynh_replace_string "__PATH__" "$path_url" "$finaluwsgiini" -ynh_replace_string "__APP__" "$app" "$finaluwsgiini" -ynh_replace_string "__PYTHONPATH__" "$weblate_pypath" "$finaluwsgiini" +ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$finaluwsgiini" +ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$finaluwsgiini" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$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..." -# root install doesn't require uwsgi to handle script names -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" +ynh_add_systemd_config --service="$app" --template="weblate.service" #================================================= # ACTIVATE CELERY #================================================= - ynh_script_progression --message="Configure celery..." celeryconf="$final_path/celery-weblate" cp ../conf/celery-weblate "$celeryconf" -ynh_replace_string "__APP__" "$app" "$celeryconf" -ynh_replace_string "__FINALPATH__" "$final_path" "$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 "$app-celery" "celery-weblate.service" +ynh_add_systemd_config --service="$app-celery" --template="celery-weblate.service" #================================================= # GENERIC FINALIZATION @@ -298,7 +244,7 @@ ynh_add_systemd_config "$app-celery" "celery-weblate.service" #================================================= # Set permissions to app files -chown -R "$app": "$final_path/data" +chown -R "$app": "$final_path" mkdir -p "$final_path/avatar-cache" chown -R "$app": "$final_path/avatar-cache" @@ -309,41 +255,32 @@ chown -R "$app": "$final_path/avatar-cache" ynh_script_progression --message="Configuring log rotation..." # Use logrotate to manage application logfile(s) -ynh_use_logrotate +ynh_use_logrotate --non-append #================================================= -# SETUP SSOWAT -#================================================= - -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 +# INTEGRATE SERVICE IN YUNOHOST #================================================= +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add "$app" --log "/var/log/$app/weblate.log" yunohost service add "$app-celery" --log "/var/log/$app/weblate-celery-w1.log" +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Configuring SSOwat..." + +# 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 #================================================= -ynh_script_progression --message="Starting weblate's services..." +ynh_script_progression --message="Starting weblate's services..." --weight=5 ynh_systemd_action --service_name="$app" --action="start" ynh_systemd_action --service_name="$app-celery" --action="start" @@ -351,7 +288,6 @@ ynh_systemd_action --service_name="$app-celery" --action="start" #================================================= # RELOAD NGINX #================================================= - ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name="nginx" --action="reload" diff --git a/scripts/remove b/scripts/remove index 269941f..a490614 100755 --- a/scripts/remove +++ b/scripts/remove @@ -15,9 +15,10 @@ source /usr/share/yunohost/helpers ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get "$app" domain) -db_name=$(ynh_app_setting_get "$app" db_name) -final_path=$(ynh_app_setting_get "$app" final_path) +domain=$(ynh_app_setting_get --app="$app" --key=domain) +db_name=$(ynh_app_setting_get --app="$app" --key=db_name) +db_user=$db_name +final_path=$(ynh_app_setting_get --app="$app" --key=final_path) #================================================= # STANDARD REMOVE @@ -28,24 +29,24 @@ final_path=$(ynh_app_setting_get "$app" final_path) # Remove a service from the admin panel, added by `yunohost service add` if yunohost service status "$app" >/dev/null 2>&1 then - ynh_script_progression --message="Removing $app service..." + ynh_script_progression --message="Removing $app service integration..." yunohost service remove "$app" fi # Remove a service from the admin panel, added by `yunohost service add` if yunohost service status "$app-celery" >/dev/null 2>&1 then - ynh_script_progression --message="Removing $app-celery service..." + ynh_script_progression --message="Removing $app-celery service integration..." yunohost service remove "$app-celery" fi #================================================= # STOP WEBLATE'S SERVICES #================================================= -ynh_script_progression --message="Stopping and removing systemd services..." +ynh_script_progression --message="Stopping and removing systemd services..." --weight=5 -ynh_remove_systemd_config "$app" -ynh_remove_systemd_config "$app-celery" +ynh_remove_systemd_config --service="$app" +ynh_remove_systemd_config --service="$app-celery" #================================================= # REMOVE THE PostgreSQL DATABASE @@ -53,15 +54,23 @@ ynh_remove_systemd_config "$app-celery" ynh_script_progression --message="Removing the PostgreSQL database..." # 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 #================================================= -ynh_script_progression --message="Removing dependencies..." +ynh_script_progression --message="Removing dependencies..." --weight=10 # Remove metapackage and its dependencies -ynh_remove_app_dependencies +finaluwsgiini="/etc/uwsgi/apps-available/$app.ini" +ynh_secure_remove --file="$finaluwsgiini" +ynh_exec_warn_less ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR @@ -69,7 +78,7 @@ ynh_remove_app_dependencies ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely -ynh_secure_remove "$final_path" +ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION @@ -89,18 +98,11 @@ ynh_remove_logrotate #================================================= # SPECIFIC REMOVE -#================================================= -# REMOVE CRON FILE -#================================================= - -# Remove a cron file -ynh_secure_remove "/etc/cron.d/$app" - #================================================= # REMOVE CELERY FILES #================================================= -ynh_secure_remove "/var/run/$app-celery" +ynh_secure_remove --file="/var/run/$app-celery" #================================================= # GENERIC FINALIZATION @@ -110,7 +112,7 @@ ynh_secure_remove "/var/run/$app-celery" ynh_script_progression --message="Removing the dedicated system user..." # Delete a system user -ynh_system_user_delete "$app" +ynh_system_user_delete --username="$app" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index d624d1a..9404ed6 100755 --- a/scripts/restore +++ b/scripts/restore @@ -22,21 +22,22 @@ ynh_script_progression --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get "$app" domain) -path_url=$(ynh_app_setting_get "$app" path) -final_path=$(ynh_app_setting_get "$app" final_path) -db_name=$(ynh_app_setting_get "$app" db_name) -db_pwd=$(ynh_app_setting_get "$app" psqlpwd) +domain=$(ynh_app_setting_get --app="$app" --key=domain) +path_url=$(ynh_app_setting_get --app="$app" --key=path) +final_path=$(ynh_app_setting_get --app="$app" --key=final_path) +db_name=$(ynh_app_setting_get --app="$app" --key=db_name) +db_user=$db_name +db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= ynh_script_progression --message="Validating restoration parameters..." -# Check web path availability -ynh_webpath_available "$domain" "$path_url" || ynh_die "Path not available: ${domain}${path_url}" - -test ! -e "$final_path" || ynh_die "There is already a directory: $final_path" +ynh_webpath_available --domain=$domain --path_url=$path_url \ + || ynh_die --message="Path not available: ${domain}${path_url}" +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS @@ -44,14 +45,17 @@ test ! -e "$final_path" || ynh_die "There is already a directory: $final_path" # 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 #================================================= ynh_script_progression --message="Restoring the app main directory..." -ynh_restore_file "$final_path" +ynh_restore_file --origin_path="$final_path" + +touch "$final_path/local_settings.py" +ln -sf "$final_path/local_settings.py" "$final_path/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py" #================================================= # RECREATE THE DEDICATED USER @@ -59,9 +63,7 @@ ynh_restore_file "$final_path" ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) -ynh_system_user_create "$app" "$final_path" -# Allow bash for our user, so he can use hub -chsh --shell /bin/bash "$app" +ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell #================================================= # RESTORE USER RIGHTS @@ -70,72 +72,66 @@ chsh --shell /bin/bash "$app" # Restore permissions on app files chown -R "$app": "$final_path" +mkdir -p "$final_path/avatar-cache" +chown -R "$app": "$final_path/avatar-cache" + #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." +ynh_script_progression --message="Reinstalling dependencies..." --weight=40 -ynh_install_app_dependencies "$pkg_dependencies" +ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" #================================================= # RESTORE THE PostgreSQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." +ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=5 ynh_psql_test_if_first_run -ynh_psql_setup_db "$db_name" "$db_name" "$db_pwd" -ynh_psql_execute_file_as_root ./db.sql "$db_name" +ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd" +ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$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..." -usermod --append --groups www-data "$app" - -ynh_restore_file "/etc/uwsgi/apps-available/$app.ini" -ynh_restore_file "/etc/systemd/system/$app.service" - -systemctl enable "$app" - -ynh_restore_file "/etc/systemd/system/$app-celery.service" +ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +systemctl enable $app.service +ynh_restore_file --origin_path="/etc/systemd/system/$app-celery.service" systemctl enable "$app-celery" #================================================= -# ADVERTISE SERVICE IN ADMIN PANEL +# RESTORE UWSGI #================================================= +ynh_script_progression --message="Restoring uwsgi configurations..." + +ynh_restore_file --origin_path="/etc/uwsgi/apps-available/$app.ini" + +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." -# Add as a service yunohost service add "$app" --log "/var/log/$app/weblate.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 #================================================= -ynh_restore_file --origin_path="/etc/logrotate.d/$app" mkdir -p "/var/log/$app" +ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # GENERIC FINALIZATION #================================================= -# Start weblate +# START WEBLATE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." --weight=5 ynh_systemd_action --service_name="$app" --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 #================================================= -ynh_script_progression --message="Reloading nginx web server and php-fpm..." +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name="nginx" --action="reload" diff --git a/scripts/upgrade b/scripts/upgrade index 72b96b7..56e6312 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -15,43 +15,24 @@ ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -path_url=$(ynh_app_setting_get "$app" path) -is_public=$(ynh_app_setting_get "$app" is_public) -final_path=$(ynh_app_setting_get "$app" final_path) -db_name=$(ynh_app_setting_get "$app" db_name) -domain=$(ynh_app_setting_get "$app" domain) -db_pwd=$(ynh_app_setting_get "$app" psqlpwd) -admin=$(ynh_app_setting_get "$app" admin) +path_url=$(ynh_app_setting_get --app="$app" --key=path) +is_public=$(ynh_app_setting_get --app="$app" --key=is_public) +final_path=$(ynh_app_setting_get --app="$app" --key=final_path) +db_name=$(ynh_app_setting_get --app="$app" --key=db_name) +db_user=$db_name +domain=$(ynh_app_setting_get --app="$app" --key=domain) +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) -memc_port=$(ynh_app_setting_get "$app" memc_port) -github_account=$(ynh_app_setting_get "$app" github_account) -migration311=$(ynh_app_setting_get "$app" migration311) -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" +github_account=$(ynh_app_setting_get --app="$app" --key=github_account) +github_token=$(ynh_app_setting_get --app="$app" --key=github_token) +key=$(ynh_string_random 50) +redis_db=$(ynh_app_setting_get --app="$app" --key=redis_db) #================================================= # 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)..." --weight=40 # Backup the current version of the app ynh_backup_before_upgrade @@ -67,17 +48,18 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Ensuring downward compatibility..." +# Fix is_public as a boolean value 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 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 fi if [[ -d "$final_path/bin/" ]] then - ynh_secure_remove "$final_path/bin/" + ynh_secure_remove --file="$final_path/bin/" fi # (<3.8) log cleanups @@ -85,8 +67,8 @@ if [[ -e "/var/log/uwsgi/app/$app" ]] then ynh_systemd_action --service_name="$app" --action="stop" ynh_systemd_action --service_name="$app-celery" --action="stop" - ynh_secure_remove "/var/log/uwsgi/app/$app" - ynh_secure_remove "/var/log/$app-celery" + ynh_secure_remove --file="/var/log/uwsgi/app/$app" + ynh_secure_remove --file="/var/log/$app-celery" fi #================================================= @@ -94,15 +76,14 @@ fi #================================================= # 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 #================================================= # STOP SYSTEMD SERVICE #================================================= - -ynh_script_progression --message="Stopping systemd services..." +ynh_script_progression --message="Stopping systemd services..." --weight=5 ynh_systemd_action --service_name="$app" --action="stop" ynh_systemd_action --service_name="$app-celery" --action="stop" @@ -115,24 +96,14 @@ ynh_script_progression --message="Upgrading nginx web server configuration..." # Create a dedicated 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 #================================================= # Update dependencies #================================================= +ynh_script_progression --message="Upgrading dependencies..." -ynh_install_app_dependencies "$pkg_dependencies" +ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" #================================================= # CREATE DEDICATED USER @@ -140,109 +111,44 @@ ynh_install_app_dependencies "$pkg_dependencies" ynh_script_progression --message="Making sure dedicated system user exists..." # Create a system user -ynh_system_user_create "$app" "$final_path" -chsh --shell /bin/bash "$app" +ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell #================================================= -# SPECIFIC SETUP uwsgi +# CONFIGURE HUB +#================================================= +ynh_script_progression --message="Configure hub..." + +mkdir -p "$final_path/.config/" +cp ../conf/hub_config "$final_path/.config/hub" +ynh_replace_string --match_string="__GITHUBUSER__" --replace_string="$github_account" --target_file="$final_path/.config/hub" +ynh_replace_string --match_string="__GITHUBTOKEN__" --replace_string="$github_token" --target_file="$final_path/.config/hub" + +cat < "$final_path/.bashrc" +eval "$(hub alias -s /bin/bash)" +EOF + +#================================================= +# SPECIFIC SETUP UWSGI #================================================= ynh_script_progression --message="Configure uwsgi..." finaluwsgiini="/etc/uwsgi/apps-available/$app.ini" +ynh_backup_if_checksum_is_different --file="$finaluwsgiini" cp ../conf/uwsgi.ini "$finaluwsgiini" -ynh_replace_string "__FINALPATH__" "$final_path" "$finaluwsgiini" -ynh_replace_string "__PATH__" "$path_url" "$finaluwsgiini" -ynh_replace_string "__APP__" "$app" "$finaluwsgiini" -ynh_replace_string "__PYTHONPATH__" "$weblate_pypath" "$finaluwsgiini" +ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$finaluwsgiini" +ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$finaluwsgiini" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$finaluwsgiini" +ynh_replace_string --match_string="__PYTHONPATH__" --replace_string="$weblate_pypath" --target_file="$finaluwsgiini" - - -# root install doesn't require uwsgi to handle script names -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" +ynh_store_file_checksum --file="$finaluwsgiini" #================================================= -# PIP INSTALLATION +# SETUP SYSTEMD #================================================= +ynh_script_progression --message="Configuring a systemd service..." -ynh_script_progression --message="Install weblate using PIP..." --weight=10 - -( - set +o nounset - source "${final_path}/venv/bin/activate" - set -o nounset - pip install --upgrade pip - # prevent error: "command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers" - pip install --upgrade setuptools - pip install Django==2.2.* - pip install Weblate=="$current_version" - pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2-binary phply django-redis hiredis aeidon ruamel.yaml - # specific to YunoHost package: - pip install django_sendmail_backend -) - -#================================================= -# CONFIG FILE UPGRADE -#================================================= -ynh_script_progression --message="Create weblate configuration file..." -# save old settings file -settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" - -old_settings="$final_path/settings.$previous_version.old.py" - -cp "$settings" "$old_settings" - -check=$(ynh_check_if_checksum_is_different "$settings") - -if [[ "$check" -eq 1 ]] -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 - set +eu - 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" +ynh_add_systemd_config --service="$app" --template="weblate.service" #================================================= # ACTIVATE CELERY @@ -252,39 +158,119 @@ ynh_script_progression --message="Configure celery..." celeryconf="$final_path/celery-weblate" cp ../conf/celery-weblate "$celeryconf" -ynh_replace_string "__APP__" "$app" "$celeryconf" -ynh_replace_string "__FINALPATH__" "$final_path" "$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 "$app-celery" "celery-weblate.service" +ynh_add_systemd_config --service="$app-celery" --template="celery-weblate.service" #================================================= -# Run migration scripts +# UPGRADE WEBLATE #================================================= -ynh_script_progression --message="Run migration scripts..." -( - set +o nounset - source "${final_path}/venv/bin/activate" - set -o nounset - export DJANGO_SETTINGS_MODULE="weblate.settings" - cd "${final_path}" - weblate migrate --noinput - weblate collectstatic --noinput - weblate setuplang - weblate setupgroups -) +upgrade() { + new_version=$1 + settings_template=$2 + #================================================= + # PIP INSTALLATION + #================================================= + ynh_script_progression --message="Install weblate using PIP..." --weight=15 -# 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" + ynh_systemd_action --service_name="$app-celery" --action="stop" -#================================================= -# SETUP CRON -#================================================= -ynh_script_progression --message="Configure cron file..." + virtualenv --python=python3 "${final_path}/venv" + chown -R "$app": "$final_path/venv" -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" + #run source in a 'sub shell' + ( + set +o nounset + source "${final_path}/venv/bin/activate" + set -o nounset + sudo -u $app $final_path/venv/bin/pip install --upgrade pip setuptools wheel + # Still needed with latest version of weblate? + sudo -u $app $final_path/venv/bin/pip install --upgrade Weblate=="$new_version" + sudo -u $app $final_path/venv/bin/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: + sudo -u $app $final_path/venv/bin/pip install django_sendmail_backend + ) + + #================================================= + # MODIFY A CONFIG FILE + #================================================= + ynh_script_progression --message="Create weblate configuration file..." + # save old settings file + settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" + + ynh_backup_if_checksum_is_different --file="$settings" + cp "$settings_template" "$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="__GITHUBTOKEN__" --replace_string="$github_token" --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" + + # Recalculate and store the config file checksum into the app settings + ynh_store_file_checksum --file="$settings" + + touch "$final_path/local_settings.py" + ln -sf "$final_path/local_settings.py" "$final_path/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py" + + #================================================= + # MIGRATE WEBLATE + #================================================= + ynh_script_progression --message="Run migration scripts..." --weight=10 + + ynh_systemd_action --service_name="$app-celery" --action="start" + + ( + set +o nounset + source "${final_path}/venv/bin/activate" + set -o nounset + export DJANGO_SETTINGS_MODULE="weblate.settings" + cd "${final_path}" + + sudo -u $app $final_path/venv/bin/weblate migrate --noinput + sudo -u $app $final_path/venv/bin/weblate collectstatic --noinput + sudo -u $app $final_path/venv/bin/weblate setuplang + sudo -u $app $final_path/venv/bin/weblate setupgroups + sudo -u $app $final_path/venv/bin/weblate compilemessages + + # Check the configuration + # This may fail in some cases with errors, etc., but the app works and the user can fix issues later. + if [ "$new_version" == "$weblate_version" ]; then + sudo -u $app $final_path/venv/bin/weblate check --deploy || true + fi + ) +} + +file_version="${final_path}/venv/lib/$weblate_pypath/site-packages/weblate/__init__.py" +if [ -e $file_version ] +then + current_version=$(cat $file_version | grep "^VERSION = " | grep -o "[0-9].[0-9]" | head -n1 | cut -d"." -f1) +else + current_version=3 +fi + +ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name + +if [ "$current_version" -lt "4" ] +then + upgrade "4.1.1" "../conf/settings.4.1.1.py" +fi + +upgrade $weblate_version "../conf/settings.py" #================================================= # SETUP LOGROTATE @@ -292,7 +278,15 @@ ynh_replace_string "__FINALPATH__" "$final_path/" "/etc/cron.d/$app" ynh_script_progression --message="Upgrading logrotate configuration..." # 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..." + +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 @@ -301,51 +295,40 @@ ynh_use_logrotate #================================================= # Set right permissions for curl installation -chown -R root:root "$final_path" -chown -R "$app": "$final_path/data" +chown -R "$app": "$final_path" mkdir -p "$final_path/avatar-cache" chown -R "$app": "$final_path/avatar-cache" #================================================= -# SETUP SSOWAT +# START SYSTEMD SERVICES #================================================= -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 -#================================================= -ynh_script_progression --message="Starting weblate's services..." +ynh_script_progression --message="Starting systemd services..." --weight=5 ynh_systemd_action --service_name="$app" --action="start" ynh_systemd_action --service_name="$app-celery" --action="start" +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Upgrading SSOwat configuration..." + +# 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 #================================================= - 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 #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression --message="Upgrade of $app completed" --last \ No newline at end of file