From 85d0041429a33d72fde7df6a877c1a79bff4de13 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 28 Jun 2020 23:01:11 +0200 Subject: [PATCH 01/16] Update README.md --- README.md | 79 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 5e95f42..27874a1 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,42 @@ -[![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:** 3.8.0 + +## 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 - -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. +**Careful**, You will have to **manually** move your hub binary file from `/var/www/$app/bin/` to `/usr/bin` to enable pull request on Github. -**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`. +You will 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. @@ -54,23 +60,18 @@ Carefull, this application install PostgreSQL and change the default configurati 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 +80,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 +``` From 6da5dd0aa2b4f7cccbfac6b895c6b1fd04d00c09 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 15 Jul 2020 18:51:36 +0200 Subject: [PATCH 02/16] Update manifest.json --- manifest.json | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/manifest.json b/manifest.json index b237c41..7210cf5 100644 --- a/manifest.json +++ b/manifest.json @@ -2,11 +2,9 @@ "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", "url": "https://weblate.org", @@ -14,6 +12,9 @@ "maintainer": { "name": "Jean-Baptiste Holcroft", "email": "jean-baptiste@holcroft.fr" + }, + "requirements": { + "yunohost": ">= 3.5.0" }, "multi_instance": true, "services": [ @@ -25,7 +26,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 +35,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,10 +45,12 @@ "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" }, @@ -53,7 +58,8 @@ "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" }, @@ -61,7 +67,8 @@ "name": "github_account", "type": "string", "ask": { - "en": "Github's username" + "en": "GitHub's username", + "fr": "Nom d'utilisateur de GitHub" }, "example": "simon" }, @@ -69,7 +76,8 @@ "name": "github_token", "type": "string", "ask": { - "en": "Github's token (oauth)" + "en": "GitHub's token (OAuth)", + "fr": "Jeton GitHub (OAuth)" }, "example": "simon" } From cc199df5fb73b0f278ef49a20b82192371a81f5a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 23 Jul 2020 22:23:09 +0200 Subject: [PATCH 03/16] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 27874a1..af49cd8 100644 --- a/README.md +++ b/README.md @@ -24,14 +24,14 @@ Weblate is a libre web-based translation tool with tight version control integra An admin user is created at installation, the login is what you provided at installation, the password is **weblate**. -## Github +## 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**, You will have to **manually** move your hub binary file from `/var/www/$app/bin/` to `/usr/bin` to enable pull request on Github. +**Careful**, You will have to **manually** move your hub binary file from `/var/www/$app/bin/` to `/usr/bin` to enable pull request on GitHub. -**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. +**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 @@ -40,7 +40,7 @@ You will probably edit it to enable or disable diverse features, it is stored in Unfortunatly, this settings file also gets upgrades for each release. -This package will : +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), From 7435990215a92a3025c466b5e8857fdd01619bef Mon Sep 17 00:00:00 2001 From: Kay0u Date: Wed, 28 Oct 2020 12:02:15 +0100 Subject: [PATCH 04/16] Global upgrade --- README.md | 2 +- check_process | 2 +- conf/celery-weblate | 18 +- conf/celery-weblate.service | 13 +- conf/cron | 2 - conf/nginx.conf | 2 +- .../settings.3.8.py => settings.py} | 744 +++++++-------- conf/settings_history/settings.2.16.py | 699 -------------- conf/settings_history/settings.2.17.1.py | 708 -------------- conf/settings_history/settings.2.18.py | 708 -------------- conf/settings_history/settings.2.20.py | 754 --------------- conf/settings_history/settings.3.0.1.py | 757 --------------- conf/settings_history/settings.3.0.py | 757 --------------- conf/settings_history/settings.3.1.1.py | 770 --------------- conf/settings_history/settings.3.2.2.py | 824 ---------------- conf/settings_history/settings.3.3.py | 834 ----------------- conf/settings_history/settings.3.4.py | 855 ----------------- conf/settings_history/settings.3.5.1.py | 867 ----------------- conf/settings_history/settings.3.5.py | 867 ----------------- conf/settings_history/settings.3.6.1.py | 870 ----------------- conf/settings_history/settings.3.7.py | 879 ------------------ conf/uwsgi.ini | 36 +- conf/weblate.service | 7 +- manifest.json | 12 +- scripts/_common.sh | 52 +- scripts/backup | 66 +- scripts/change_url | 104 +-- scripts/install | 262 ++---- scripts/remove | 56 +- scripts/restore | 98 +- scripts/upgrade | 283 +++--- 31 files changed, 770 insertions(+), 12138 deletions(-) delete mode 100644 conf/cron rename conf/{settings_history/settings.3.8.py => settings.py} (51%) delete mode 100644 conf/settings_history/settings.2.16.py delete mode 100644 conf/settings_history/settings.2.17.1.py delete mode 100644 conf/settings_history/settings.2.18.py delete mode 100644 conf/settings_history/settings.2.20.py delete mode 100644 conf/settings_history/settings.3.0.1.py delete mode 100644 conf/settings_history/settings.3.0.py delete mode 100644 conf/settings_history/settings.3.1.1.py delete mode 100644 conf/settings_history/settings.3.2.2.py delete mode 100644 conf/settings_history/settings.3.3.py delete mode 100644 conf/settings_history/settings.3.4.py delete mode 100644 conf/settings_history/settings.3.5.1.py delete mode 100644 conf/settings_history/settings.3.5.py delete mode 100644 conf/settings_history/settings.3.6.1.py delete mode 100644 conf/settings_history/settings.3.7.py diff --git a/README.md b/README.md index af49cd8..d6c2620 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Weblate is a libre web-based translation tool with tight version control integration. It provides two user interfaces, propagation of translations across components, quality checks and automatic linking to source files. -**Shipped version:** 3.8.0 +**Shipped version:** 3.11.3 ## Screenshots diff --git a/check_process b/check_process index 9cde86a..1024265 100644 --- a/check_process +++ b/check_process @@ -25,7 +25,7 @@ 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 diff --git a/conf/celery-weblate b/conf/celery-weblate index 1005d7c..cc9014c 100644 --- a/conf/celery-weblate +++ b/conf/celery-weblate @@ -1,19 +1,23 @@ # Name of nodes to start -CELERYD_NODES="celery notify search memory" +CELERYD_NODES="celery notify search memory backup translate" # Absolute or relative path to the 'celery' command: 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 +# Extra command-line arguments to the worker, +# increase concurency if you get weblate.E019 CELERYD_OPTS="--beat:celery --concurrency:celery=4 --queues:celery=celery --prefetch-multiplier:celery=4 \ ---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" + --concurrency:notify=4 --queues:notify=notify --prefetch-multiplier:notify=10 \ + --concurrency:search=1 --queues:search=search --prefetch-multiplier:search=2000 \ + --concurrency:memory=1 --queues:memory=memory --prefetch-multiplier:memory=2000 \ + --concurrency:translate=4 --queues:translate=translate --prefetch-multiplier:translate=4 \ + --concurrency:backup=1 --queues:backup=backup --prefetch-multiplier:backup=2" +# Logging configuration # - %n will be replaced with the first part of the nodename. # - %I will be replaced with the current child process index # and is important when using the prefork pool to avoid race conditions. @@ -22,4 +26,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_history/settings.3.8.py b/conf/settings.py similarity index 51% rename from conf/settings_history/settings.3.8.py rename to conf/settings.py index cf43ac2..1d768eb 100644 --- a/conf/settings_history/settings.3.8.py +++ b/conf/settings.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright © 2012 - 2019 Michal Čihař +# Copyright © 2012 - 2020 Michal Čihař # # This file is part of Weblate # @@ -37,21 +37,21 @@ ADMINS = ( MANAGERS = ADMINS DATABASES = { - 'default': { + "default": { # Use 'postgresql', 'mysql', 'sqlite3' or 'oracle'. - 'ENGINE': 'django.db.backends.postgresql_psycopg2', + "ENGINE": "django.db.backends.postgresql", # Database name or path to database file if using sqlite3. - 'NAME': '__NAME__', + "NAME": "__NAME__", # Database user, not used with sqlite3. - 'USER': '__NAME__', + "USER": "__NAME__", # Database password, not used with sqlite3. - 'PASSWORD': '__DB_PWD__', + "PASSWORD": "__DB_PWD__", # Set to empty string for localhost. Not used with sqlite3. - 'HOST': 'localhost', + "HOST": "127.0.0.1", # Set to empty string for default. Not used with sqlite3. - 'PORT': '5432', + "PORT": "", # Customizations for databases - 'OPTIONS': { + "OPTIONS": { # In case of using an older MySQL server, # which has MyISAM as a default storage # 'init_command': 'SET storage_engine=INNODB', @@ -59,66 +59,68 @@ DATABASES = { # 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", # Set emoji capable charset for MySQL: # 'charset': 'utf8mb4', - 'sslmode': 'disable' + # Change connection timeout in case you get MySQL gone away error: + # 'connect_timeout': 28800, }, } } -BASE_DIR = '__FINALPATH__' +BASE_DIR = "__FINALPATH__" # Data directory -DATA_DIR = os.path.join(BASE_DIR, 'data') -TTF_PATH = '__FINALPATH__/venv/lib/__PYTHONPATH__/site-packages/weblate/ttf/' +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' +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' +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', '正體字'), + ("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", "日本語"), + ("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 @@ -135,26 +137,22 @@ USE_L10N = True USE_TZ = True # URL prefix to use, please see documentation for more details -URL_PREFIX = '__PATHURL__' +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') +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) +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') +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) +STATIC_URL = "{0}/static/".format(URL_PREFIX) # Additional locations of static files STATICFILES_DIRS = ( @@ -166,39 +164,38 @@ STATICFILES_DIRS = ( # 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', + "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 +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', - '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', - ]), + "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": _TEMPLATE_LOADERS, }, - }, + } ] @@ -206,120 +203,111 @@ TEMPLATES = [ # Please see the documentation for more details. GITHUB_USERNAME = "__GITHUBUSER__" +# 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.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.suse.OpenSUSEOpenId', + # 'social_core.backends.ubuntu.UbuntuOpenId', + # 'social_core.backends.fedora.FedoraOpenId', # 'social_core.backends.facebook.FacebookOAuth2', - 'weblate.accounts.auth.WeblateUserBackend', + "weblate.accounts.auth.WeblateUserBackend", ) # Custom user model -AUTH_USER_MODEL = 'weblate_auth.User' +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_GITHUB_KEY = "" +SOCIAL_AUTH_GITHUB_SECRET = "" +SOCIAL_AUTH_GITHUB_SCOPE = ["user:email"] -SOCIAL_AUTH_BITBUCKET_KEY = '' -SOCIAL_AUTH_BITBUCKET_SECRET = '' +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_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_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_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', + "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' +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_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' +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.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', + "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', @@ -335,66 +323,64 @@ 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', + "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' +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', - +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', -) + "weblate.gitexport", +] # Path to locales -LOCALE_PATHS = (os.path.join(BASE_DIR, 'weblate', 'locale'), ) +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_EXCEPTION_REPORTER_FILTER = "weblate.trans.debug.WeblateExceptionReporterFilter" # Default logging of Weblate messages # - to syslog in production (if available) @@ -404,20 +390,18 @@ DEFAULT_EXCEPTION_REPORTER_FILTER = \ # Detect if we can connect to syslog HAVE_SYSLOG = False -if platform.system() != 'Windows': +if platform.system() != "Windows": try: - handler = SysLogHandler( - address='/dev/log', facility=SysLogHandler.LOG_LOCAL2 - ) + 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' + DEFAULT_LOG = "console" else: - DEFAULT_LOG = 'syslog' + DEFAULT_LOG = "syslog" # A sample logging configuration. The only tangible logging # performed by this configuration is to send an email to @@ -425,51 +409,41 @@ else: # 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' - } + "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", + }, }, - 'formatters': { - 'syslog': { - 'format': 'weblate[%(process)d]: %(levelname)s %(message)s' + "handlers": { + "mail_admins": { + "level": "ERROR", + "filters": ["require_debug_false"], + "class": "django.utils.log.AdminEmailHandler", + "include_html": True, }, - 'simple': { - 'format': '%(levelname)s %(message)s' + "console": { + "level": "DEBUG", + "class": "logging.StreamHandler", + "formatter": "simple", }, - 'logfile': { - 'format': '%(asctime)s %(levelname)s %(message)s' + "django.server": { + "level": "INFO", + "class": "logging.StreamHandler", + "formatter": "django.server", }, - '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, + "syslog": { + "level": "DEBUG", + "class": "logging.handlers.SysLogHandler", + "formatter": "syslog", + "address": "/dev/log", + "facility": SysLogHandler.LOG_LOCAL2, }, # Logging to a file # 'logfile': { @@ -481,52 +455,40 @@ LOGGING = { # 'formatter': 'logfile', # }, }, - 'loggers': { - 'django.request': { - 'handlers': ['mail_admins', DEFAULT_LOG], - 'level': 'ERROR', - 'propagate': True, + "loggers": { + "django.request": { + "handlers": ["mail_admins", DEFAULT_LOG], + "level": "ERROR", + "propagate": True, }, - 'django.server': { - 'handlers': ['django.server'], - 'level': 'INFO', - 'propagate': False, + "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', - }, + "weblate": {"handlers": [DEFAULT_LOG], "level": "DEBUG"}, # Logging search operations - 'weblate.search': { - 'handlers': [DEFAULT_LOG], - 'level': 'INFO', - }, + "weblate.search": {"handlers": [DEFAULT_LOG], "level": "INFO"}, # Logging VCS operations - 'weblate.vcs': { - 'handlers': [DEFAULT_LOG], - 'level': 'WARNING', + "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], }, - # 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'] + del LOGGING["handlers"]["syslog"] # List of machine translations # MT_SERVICES = ( @@ -597,7 +559,7 @@ MT_SAP_PASSWORD = None MT_SAP_USE_MT = True # Title of site to use -SITE_TITLE = 'Weblate' +SITE_TITLE = "Weblate" # Whether site uses https ENABLE_HTTPS = True @@ -614,41 +576,43 @@ 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' +CSRF_FAILURE_VIEW = "weblate.trans.views.error.csrf_failure" SESSION_COOKIE_SECURE = ENABLE_HTTPS # 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 -) +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 # Some security headers SECURE_BROWSER_XSS_FILTER = True -X_FRAME_OPTIONS = 'DENY' +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_SECONDS = 0 +SECURE_HSTS_PRELOAD = False SECURE_HSTS_INCLUDE_SUBDOMAINS = False # URL of login -LOGIN_URL = '{0}/accounts/login/'.format(URL_PREFIX) +LOGIN_URL = "{0}/accounts/login/".format(URL_PREFIX) # URL of logout -LOGOUT_URL = '{0}/accounts/logout/'.format(URL_PREFIX) +LOGOUT_URL = "{0}/accounts/logout/".format(URL_PREFIX) # Default location for login -LOGIN_REDIRECT_URL = '{0}/'.format(URL_PREFIX) +LOGIN_REDIRECT_URL = "{0}/".format(URL_PREFIX) # Anonymous user name -ANONYMOUS_USER_NAME = 'anonymous' +ANONYMOUS_USER_NAME = "anonymous" # Reverse proxy settings -IP_PROXY_HEADER = 'HTTP_X_FORWARDED_FOR' +IP_PROXY_HEADER = "HTTP_X_FORWARDED_FOR" IP_BEHIND_REVERSE_PROXY = False IP_PROXY_OFFSET = 0 @@ -656,9 +620,7 @@ IP_PROXY_OFFSET = 0 EMAIL_SEND_HTML = True # Subject of emails includes site title -EMAIL_SUBJECT_PREFIX = '[{0}] '.format(SITE_TITLE) - -EMAIL_BACKEND = 'django_sendmail_backend.backends.EmailBackend' +EMAIL_SUBJECT_PREFIX = "[{0}] ".format(SITE_TITLE) # Enable remote hooks ENABLE_HOOKS = True @@ -675,7 +637,7 @@ LIMIT_TRANSLATION_LENGTH_BY_SOURCE_LENGTH = True SIMPLIFY_LANGUAGES = True # Render forms using bootstrap -CRISPY_TEMPLATE_PACK = 'bootstrap3' +CRISPY_TEMPLATE_PACK = "bootstrap3" # List of quality checks # CHECK_LIST = ( @@ -684,6 +646,7 @@ CRISPY_TEMPLATE_PACK = 'bootstrap3' # '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', @@ -692,6 +655,7 @@ CRISPY_TEMPLATE_PACK = 'bootstrap3' # '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', @@ -709,7 +673,8 @@ CRISPY_TEMPLATE_PACK = 'bootstrap3' # 'weblate.checks.consistency.SamePluralsCheck', # 'weblate.checks.consistency.ConsistencyCheck', # 'weblate.checks.consistency.TranslatedCheck', -# 'weblate.checks.chars.NewlineCountingCheck', +# 'weblate.checks.chars.EscapedNewlineCountingCheck', +# 'weblate.checks.chars.NewLineCountCheck', # 'weblate.checks.markup.BBCodeCheck', # 'weblate.checks.chars.ZeroWidthSpaceCheck', # 'weblate.checks.render.MaxSizeCheck', @@ -719,6 +684,9 @@ CRISPY_TEMPLATE_PACK = 'bootstrap3' # '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.source.OptionalPluralCheck', # 'weblate.checks.source.EllipsisCheck', # 'weblate.checks.source.MultipleFailingCheck', @@ -746,92 +714,78 @@ CRISPY_TEMPLATE_PACK = 'bootstrap3' # '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__' +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__' +DEFAULT_FROM_EMAIL = "__ADMINMAIL__" # List of URLs your site is supposed to serve -ALLOWED_HOSTS = ['__DOMAIN__'] +ALLOWED_HOSTS = ["__DOMAIN__"] +# Configuration for caching 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, - }, - } - } + "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}, + }, +} -# 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, -# }, -# } -# } +# Store sessions in cache +SESSION_ENGINE = "django.contrib.sessions.backends.cache" # 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_PERMISSION_CLASSES": [ + "rest_framework.permissions.IsAuthenticatedOrReadOnly" + # Use following with LOGIN_REQUIRED_URLS + # "rest_framework.permissions.IsAuthenticated" ], - 'DEFAULT_AUTHENTICATION_CLASSES': ( - 'rest_framework.authentication.TokenAuthentication', - 'weblate.api.authentication.BearerAuthentication', - 'rest_framework.authentication.SessionAuthentication', + "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_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', + "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", } # Example for restricting access to logged in users @@ -858,7 +812,7 @@ REST_FRAMEWORK = { SILENCED_SYSTEM_CHECKS = [ # We have modified django.contrib.auth.middleware.AuthenticationMiddleware # as weblate.accounts.middleware.AuthenticationMiddleware - 'admin.E408', + "admin.E408" ] # Celery worker configuration for testing @@ -867,21 +821,39 @@ SILENCED_SYSTEM_CHECKS = [ # 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_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_PREFETCH_MULTIPLIER = 0 CELERY_WORKER_MAX_MEMORY_PER_CHILD = 200000 -CELERY_BEAT_SCHEDULE_FILENAME = os.path.join( - DATA_DIR, 'celery', 'beat-schedule' -) +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'}, + "weblate.trans.search.*": {"queue": "search"}, + "weblate.trans.tasks.optimize_fulltext": {"queue": "search"}, + "weblate.trans.tasks.cleanup_fulltext": {"queue": "search"}, + "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.memory.tasks.memory_backup": {"queue": "backup"}, + "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 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/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 7210cf5..b6672a4 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "A translation platform using Git and Python", "fr": "Une plateforme de traduction utilisant Git et Python" }, - "version": "3.8.0~ynh3", + "version": "3.11.3~ynh1", "url": "https://weblate.org", "license": "AGPL-3.0", "maintainer": { @@ -14,7 +14,7 @@ "email": "jean-baptiste@holcroft.fr" }, "requirements": { - "yunohost": ">= 3.5.0" + "yunohost": ">= 4.0.0" }, "multi_instance": true, "services": [ @@ -52,7 +52,7 @@ "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", @@ -61,7 +61,7 @@ "en": "Choose an admin user for Weblate", "fr": "Choisissez l'administrateur pour Weblate" }, - "example": "simon" + "example": "johndoe" }, { "name": "github_account", @@ -70,7 +70,7 @@ "en": "GitHub's username", "fr": "Nom d'utilisateur de GitHub" }, - "example": "simon" + "example": "Github account" }, { "name": "github_token", @@ -79,7 +79,7 @@ "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..ffbd489 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" +current_version="3.11.3" 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..bab7546 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,10 +24,27 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --time --weight=1 -final_path=$(ynh_app_setting_get "$app" final_path) -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)..." --time --weight=1 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED @@ -50,8 +67,7 @@ fi #================================================= # STOP SYSTEMD SERVICE #================================================= - -ynh_script_progression --message="Stopping systemd services..." +ynh_script_progression --message="Stopping systemd services..." --time --weight=1 ynh_systemd_action --service_name="$app" --action="stop" ynh_systemd_action --service_name="$app-celery" --action="stop" @@ -61,88 +77,62 @@ ynh_systemd_action --service_name="$app-celery" --action="stop" #================================================= # MODIFY URL IN NGINX CONF #================================================= +ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1 -ynh_script_progression --message="Updating nginx web server configuration..." - -nginx_conf_path="/etc/nginx/conf.d/$old_domain.d/$app.conf" -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 -#================================================= -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" - +# SPECIFIC MODIFICATIONS #================================================= # MODIFY settings.py #================================================= -ynh_script_progression --message="Modify weblate's config file..." +ynh_script_progression --message="Modify weblate's config file..." --time --weight=1 + +settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" # Change the path in the nginx config file 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 ALLOWED_HOSTS - ynh_replace_string "['$old_domain']" "['$new_domain']" "$settings" + ynh_replace_string --match_string="['$old_domain']" --replace_string="['$new_domain']" --target_file="$settings" fi -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 #================================================= -ynh_script_progression --message="Run weblate's command changesite..." +ynh_script_progression --message="Run weblate's command changesite..." --time --weight=1 ( set +eu source "${final_path}/venv/bin/activate" @@ -155,7 +145,7 @@ ynh_script_progression --message="Run weblate's command changesite..." #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting systemd services..." +ynh_script_progression --message="Starting systemd services..." --time --weight=1 ynh_systemd_action --service_name="$app" --action="start" ynh_systemd_action --service_name="$app-celery" --action="start" @@ -163,7 +153,7 @@ ynh_systemd_action --service_name="$app-celery" --action="start" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 ynh_systemd_action --service_name=nginx --action=reload @@ -171,4 +161,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression --message="Change of URL completed for $app" --time --last diff --git a/scripts/install b/scripts/install index 5a34320..cac902e 100755 --- a/scripts/install +++ b/scripts/install @@ -27,148 +27,85 @@ 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 #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." - -# Register (book) web path -ynh_webpath_register "$app" "$domain" "$path_url" +ynh_script_progression --message="Validating installation parameters..." --time --weight=1 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..." --time --weight=1 -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..." +ynh_script_progression --message="Installing dependencies..." --time --weight=1 ynh_install_app_dependencies "$pkg_dependencies" #================================================= # CREATE A PostgreSQL DATABASE #================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." +ynh_script_progression --message="Creating a PostgreSQL database..." --time --weight=1 -db_name=$(ynh_sanitize_dbid "$app") -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..." +ynh_script_progression --message="Configuring nginx web server..." --time --weight=1 # 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..." +ynh_script_progression --message="Configuring system user..." --time --weight=1 # 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..." --time --weight=1 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,8 +113,7 @@ EOF #================================================= # PIP INSTALLATION #================================================= - -ynh_script_progression --message="Install weblate using PIP..." --weight=10 +ynh_script_progression --message="Install weblate using PIP..." --time --weight=1 virtualenv --python=python3 "${final_path}/venv" #run source in a 'sub shell' @@ -185,12 +121,12 @@ virtualenv --python=python3 "${final_path}/venv" 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 --upgrade pip setuptools wheel + # Still needed with latest version of weblate? + pip install Django==2.* celery==4.* pip install Weblate=="$current_version" - pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2-binary phply django-redis hiredis aeidon ruamel.yaml + pip install psycopg2-binary ruamel.yaml aeidon phply + #pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2-binary phply django-redis hiredis aeidon ruamel.yaml # specific to YunoHost package: pip install django_sendmail_backend ) @@ -200,25 +136,38 @@ virtualenv --python=python3 "${final_path}/venv" # https://docs.weblate.org/en/latest/admin/install.html#installation # TODO: use --extra-search-dir=/path/to/dists #================================================= +ynh_script_progression --message="Create weblate configuration file..." --time --weight=1 -ynh_script_progression --message="Create weblate configuration file..." - -db_pwd=$(ynh_app_setting_get "$app" 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="__REDIS_DB__" --replace_string="$redis_db" --target_file="$settings" +ynh_replace_string --match_string="__PYTHONPATH__" --replace_string="$weblate_pypath" --target_file="$settings" + +# remove last "/" of $path_url +ynh_replace_string --match_string="__PATHURL__" --replace_string="${path_url%/}" --target_file="$settings" + +ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db" #================================================= # SPECIFIC SETUP Filling up the database # https://docs.weblate.org/en/latest/admin/install.html#filling-up-the-database #========================================== -ynh_script_progression --message="Filling up the database..." +ynh_script_progression --message="Filling up the database..." --time --weight=1 + ( set +o nounset source "${final_path}/venv/bin/activate" @@ -235,61 +184,48 @@ ynh_script_progression --message="Filling up the database..." --email "$admin_mail" ) -#================================================= -# SETUP CRON -#================================================= - -ynh_script_progression --message="Configure cron file..." - -cp ../conf/cron "/etc/cron.d/$app" -ynh_replace_string "__APP__" "$app" "/etc/cron.d/$app" -ynh_replace_string "__FINALPATH__" "$final_path/" "/etc/cron.d/$app" - #================================================= # STORE THE CHECKSUM OF THE CONFIG FILE #================================================= # Calculate and store the config file checksum into the app settings -ynh_store_file_checksum "$settings" +ynh_store_file_checksum --file="$settings" #================================================= -# SPECIFIC SETUP uwsgi +# SPECIFIC SETUP UWSGI #================================================= -ynh_script_progression --message="Configure uwsgi..." +ynh_script_progression --message="Configure uwsgi..." --time --weight=1 + finaluwsgiini="/etc/uwsgi/apps-available/$app.ini" 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..." --time --weight=1 -# 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..." +ynh_script_progression --message="Configure celery..." --time --weight=1 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,52 +234,47 @@ ynh_add_systemd_config "$app-celery" "celery-weblate.service" #================================================= # Set permissions to app files +chown -R root:root "$final_path" chown -R "$app": "$final_path/data" mkdir -p "$final_path/avatar-cache" chown -R "$app": "$final_path/avatar-cache" +mkdir -p "/var/run/$app" +chown -R "$app": "/var/run/$app" + #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Configuring log rotation..." +ynh_script_progression --message="Configuring log rotation..." --time --weight=1 # Use logrotate to manage application logfile(s) -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..." --time --weight=1 yunohost service add "$app" --log "/var/log/$app/weblate.log" yunohost service add "$app-celery" --log "/var/log/$app/weblate-celery-w1.log" +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Configuring SSOwat..." --time --weight=1 + +# Make app public if necessary +if [ "$is_public" -eq 1 ] +then + # unprotected_uris allows SSO credentials to be passed anyway. + ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/" +fi + #================================================= # Start weblate #================================================= -ynh_script_progression --message="Starting weblate's services..." +ynh_script_progression --message="Starting weblate's services..." --time --weight=1 ynh_systemd_action --service_name="$app" --action="start" ynh_systemd_action --service_name="$app-celery" --action="start" @@ -351,8 +282,7 @@ ynh_systemd_action --service_name="$app-celery" --action="start" #================================================= # RELOAD NGINX #================================================= - -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 ynh_systemd_action --service_name="nginx" --action="reload" @@ -367,4 +297,4 @@ If you facing an issue or want to improve this app, please open a new issue in t ynh_send_readme_to_admin "$message" "$admin" -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression --message="Installation of $app completed" --time --last diff --git a/scripts/remove b/scripts/remove index 269941f..b356f87 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,12 +12,13 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --time --weight=1 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,53 +29,61 @@ 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..." --time --weight=1 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..." --time --weight=1 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..." --time --weight=1 -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 #================================================= -ynh_script_progression --message="Removing the PostgreSQL database..." +ynh_script_progression --message="Removing the PostgreSQL database..." --time --weight=1 # Remove a database if it exists, along with the associated user -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..." --time --weight=1 # Remove metapackage and its dependencies +finaluwsgiini="/etc/uwsgi/apps-available/$app.ini" +ynh_secure_remove --file="$finaluwsgiini" ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." +ynh_script_progression --message="Removing app main directory..." --time --weight=1 # Remove the app directory securely -ynh_secure_remove "$final_path" +ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration..." +ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1 # Remove the dedicated nginx config ynh_remove_nginx_config @@ -82,37 +91,30 @@ ynh_remove_nginx_config #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Removing logrotate configuration..." +ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1 # Remove the app-specific logrotate config 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 #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." +ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1 # Delete a system user -ynh_system_user_delete "$app" +ynh_system_user_delete --username="$app" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression --message="Removal of $app completed" --time --last diff --git a/scripts/restore b/scripts/restore index d624d1a..2d3c957 100755 --- a/scripts/restore +++ b/scripts/restore @@ -18,25 +18,26 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." +ynh_script_progression --message="Loading settings..." --time --weight=1 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..." +ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 -# 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,98 +45,93 @@ 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_script_progression --message="Restoring the app main directory..." --time --weight=1 -ynh_restore_file "$final_path" +ynh_restore_file --origin_path="$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." +ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 # Create the dedicated user (if not existing) -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 #================================================= # Restore permissions on app files -chown -R "$app": "$final_path" +chown -R root:root "$final_path" +chown -R "$app": "$final_path/data" + +mkdir -p "$final_path/avatar-cache" +chown -R "$app": "$final_path/avatar-cache" + +mkdir -p "/var/run/$app" +chown -R "$app": "/var/run/$app" #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." +ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 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..." --time --weight=1 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_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= -# RESTORE Weblate service +# RESTORE SYSTEMD #================================================= -ynh_script_progression --message="Restoring systemd configurations..." +ynh_script_progression --message="Restoring the systemd configuration..." --time --weight=1 -usermod --append --groups www-data "$app" - -ynh_restore_file "/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..." --time --weight=1 + +ynh_restore_file --origin_path="/etc/uwsgi/apps-available/$app.ini" + +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 -# Add as a service yunohost service add "$app" --log "/var/log/$app/weblate.log" yunohost service add "$app-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..." --time --weight=1 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 and php-fpm..." --time --weight=1 ynh_systemd_action --service_name="nginx" --action="reload" diff --git a/scripts/upgrade b/scripts/upgrade index 72b96b7..639b4d7 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -11,47 +11,27 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --time --weight=1 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) +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)..." --time --weight=1 # Backup the current version of the app ynh_backup_before_upgrade @@ -65,19 +45,20 @@ ynh_abort_if_errors #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." +ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 +# Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then - 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 +66,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 +75,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..." --time --weight=1 ynh_systemd_action --service_name="$app" --action="stop" ynh_systemd_action --service_name="$app-celery" --action="stop" @@ -110,27 +90,17 @@ ynh_systemd_action --service_name="$app-celery" --action="stop" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." +ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1 # Create a dedicated nginx config 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..." --time --weight=1 ynh_install_app_dependencies "$pkg_dependencies" @@ -140,127 +110,101 @@ ynh_install_app_dependencies "$pkg_dependencies" ynh_script_progression --message="Making sure dedicated system user exists..." # 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 +# SPECIFIC SETUP UWSGI #================================================= -ynh_script_progression --message="Configure uwsgi..." +ynh_script_progression --message="Configure uwsgi..." --time --weight=1 finaluwsgiini="/etc/uwsgi/apps-available/$app.ini" +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" +ynh_store_file_checksum --file="$finaluwsgiini" +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Configuring a systemd service..." --time --weight=1 -# root install doesn't require uwsgi to handle script names -if [ "$path_url" == "/" ] -then - ynh_replace_string "manage-script-name = true" "manage-script-name = false" "$finaluwsgiini" -fi +ynh_add_systemd_config --service="$app" --template="weblate.service" -ynh_add_systemd_config "$app" "weblate.service" +#================================================= +# ACTIVATE CELERY +#================================================= +ynh_script_progression --message="Configure celery..." --time --weight=1 -ynh_store_file_checksum "$finaluwsgiini" +celeryconf="$final_path/celery-weblate" +cp ../conf/celery-weblate "$celeryconf" + +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$celeryconf" +ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$celeryconf" + +ynh_add_systemd_config --service="$app-celery" --template="celery-weblate.service" #================================================= # PIP INSTALLATION #================================================= +ynh_script_progression --message="Install weblate using PIP..." --time --weight=1 -ynh_script_progression --message="Install weblate using PIP..." --weight=10 - +virtualenv --python=python3 "${final_path}/venv" +#run source in a 'sub shell' ( set +o nounset 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 --upgrade pip setuptools wheel + # Still needed with latest version of weblate? + pip install Django==2.* celery==4.* pip install Weblate=="$current_version" - pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2-binary phply django-redis hiredis aeidon ruamel.yaml + pip install psycopg2-binary ruamel.yaml aeidon phply + #pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2-binary phply django-redis hiredis aeidon ruamel.yaml # specific to YunoHost package: pip install django_sendmail_backend ) #================================================= -# CONFIG FILE UPGRADE +# 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" -old_settings="$final_path/settings.$previous_version.old.py" +ynh_backup_if_checksum_is_different --file="$settings" +cp "../conf/settings.py" "$settings" -cp "$settings" "$old_settings" +ynh_replace_string --match_string="__NAME__" --replace_string="$app" --target_file="$settings" +ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$settings" +ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$settings" +ynh_replace_string --match_string="__ADMINMAIL__" --replace_string="$admin_mail" --target_file="$settings" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$settings" +ynh_replace_string --match_string="__KEY__" --replace_string="$key" --target_file="$settings" +ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$settings" +ynh_replace_string --match_string="__GITHUBUSER__" --replace_string="$github_account" --target_file="$settings" +ynh_replace_string --match_string="__REDIS_DB__" --replace_string="$redis_db" --target_file="$settings" +ynh_replace_string --match_string="__PYTHONPATH__" --replace_string="$weblate_pypath" --target_file="$settings" -check=$(ynh_check_if_checksum_is_different "$settings") +# remove last "/" of $path_url +ynh_replace_string --match_string="__PATHURL__" --replace_string="${path_url%/}" --target_file="$settings" -if [[ "$check" -eq 1 ]] -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" +ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db" - # 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" +# Recalculate and store the config file checksum into the app settings +ynh_store_file_checksum --file="$settings" #================================================= -# ACTIVATE CELERY +# MIGRATE WEBLATE #================================================= -ynh_script_progression --message="Configure celery..." +ynh_script_progression --message="Run migration scripts..." --time --weight=1 -celeryconf="$final_path/celery-weblate" -cp ../conf/celery-weblate "$celeryconf" +ynh_systemd_action --service_name="$app-celery" --action="start" -ynh_replace_string "__APP__" "$app" "$celeryconf" -ynh_replace_string "__FINALPATH__" "$final_path" "$celeryconf" - -ynh_add_systemd_config "$app-celery" "celery-weblate.service" - -#================================================= -# Run migration scripts -#================================================= -ynh_script_progression --message="Run migration scripts..." ( set +o nounset source "${final_path}/venv/bin/activate" @@ -272,27 +216,25 @@ ynh_script_progression --message="Run migration scripts..." weblate collectstatic --noinput weblate setuplang weblate setupgroups + weblate compilemessages + sudo -u $app $final_path/venv/bin/weblate check --deploy ) -# Recalculate and store the config file checksum into the app settings -ynh_store_file_checksum "$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" - -#================================================= -# SETUP CRON -#================================================= -ynh_script_progression --message="Configure cron file..." - -cp ../conf/cron "/etc/cron.d/$app" -ynh_replace_string "__APP__" "$app" "/etc/cron.d/$app" -ynh_replace_string "__FINALPATH__" "$final_path/" "/etc/cron.d/$app" - #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." +ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1 # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate +ynh_use_logrotate --non-append + +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 + +yunohost service add "$app" --log "/var/log/$app/weblate.log" +yunohost service add "$app-celery" --log "/var/log/$app/weblate-celery-w1.log" #================================================= # GENERIC FINALIZATION @@ -307,45 +249,38 @@ chown -R "$app": "$final_path/data" mkdir -p "$final_path/avatar-cache" chown -R "$app": "$final_path/avatar-cache" -#================================================= -# 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 +mkdir -p "/var/run/$app" +chown -R "$app": "/var/run/$app" #================================================= -# Restart weblate +# START SYSTEMD SERVICES #================================================= -ynh_script_progression --message="Starting weblate's services..." +ynh_script_progression --message="Starting systemd services..." --time --weight=1 ynh_systemd_action --service_name="$app" --action="start" ynh_systemd_action --service_name="$app-celery" --action="start" +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1 + +# Make app public if necessary +if [ "$is_public" -eq 1 ] +then + # unprotected_uris allows SSO credentials to be passed anyway. + ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/" +fi + #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 -ynh_script_progression --message="Reloading nginx web server..." - -ynh_systemd_action --service_name="nginx" --action="reload" +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression --message="Upgrade of $app completed" --time --last \ No newline at end of file From d43693f8e876461b9f7a7f7692682b8401fcf799 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Wed, 28 Oct 2020 14:33:45 +0100 Subject: [PATCH 05/16] update pip package needed during the install/upgrade --- scripts/install | 2 +- scripts/upgrade | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index cac902e..7e44ebc 100755 --- a/scripts/install +++ b/scripts/install @@ -123,7 +123,7 @@ virtualenv --python=python3 "${final_path}/venv" set -o nounset pip install --upgrade pip setuptools wheel # Still needed with latest version of weblate? - pip install Django==2.* celery==4.* + pip install celery==4.* pip install Weblate=="$current_version" 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 diff --git a/scripts/upgrade b/scripts/upgrade index 639b4d7..68584ec 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -161,8 +161,8 @@ virtualenv --python=python3 "${final_path}/venv" set -o nounset pip install --upgrade pip setuptools wheel # Still needed with latest version of weblate? - pip install Django==2.* celery==4.* - pip install Weblate=="$current_version" + pip install celery==4.* + pip install --upgrade Weblate=="$current_version" 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: From 33182706ed6732deefdfaad0e630b375759ec64f Mon Sep 17 00:00:00 2001 From: Kay0u Date: Wed, 28 Oct 2020 16:10:55 +0100 Subject: [PATCH 06/16] fix scripts --- scripts/change_url | 24 ++++++++++++++++++++---- scripts/install | 24 ++++++++++-------------- scripts/restore | 6 +----- scripts/upgrade | 26 +++++++++++--------------- 4 files changed, 42 insertions(+), 38 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index bab7546..d6e90dd 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -106,16 +106,17 @@ fi #================================================= # SPECIFIC MODIFICATIONS #================================================= -# MODIFY settings.py +# MODIFY SETTINGS #================================================= ynh_script_progression --message="Modify weblate's config file..." --time --weight=1 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 --match_string="URL_PREFIX = '${old_path%/}'" --replace_string="URL_PREFIX = '${new_path%/}'" --target_file="$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 @@ -124,11 +125,26 @@ then # replace SERVER_EMAIL ynh_replace_string --match_string="noreply@$old_domain" --replace_string="noreply@$new_domain" --target_file="$settings" # replace ALLOWED_HOSTS - ynh_replace_string --match_string="['$old_domain']" --replace_string="['$new_domain']" --target_file="$settings" + ynh_replace_string --match_string="ALLOWED_HOSTS = \[\"$old_domain\"\]" --replace_string="ALLOWED_HOSTS = \[\"$new_domain\"\]" --target_file="$settings" fi ynh_store_file_checksum --file="$settings" +#================================================= +# MODIFY UWSGI +#================================================= + +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" + #================================================= # ChangeSite inside weblate #================================================= @@ -137,7 +153,7 @@ ynh_script_progression --message="Run weblate's command changesite..." --time -- set +eu source "${final_path}/venv/bin/activate" export DJANGO_SETTINGS_MODULE="weblate.settings" - weblate changesite --set-name "$new_domain" + sudo -u $app $final_path/venv/bin/weblate changesite --set-name "$new_domain" ) #================================================= diff --git a/scripts/install b/scripts/install index 7e44ebc..5d75178 100755 --- a/scripts/install +++ b/scripts/install @@ -121,14 +121,14 @@ virtualenv --python=python3 "${final_path}/venv" set +o nounset source "${final_path}/venv/bin/activate" set -o nounset - pip install --upgrade pip setuptools wheel + sudo -u $app $final_path/venv/bin/pip install --upgrade pip setuptools wheel # Still needed with latest version of weblate? - pip install celery==4.* - pip install Weblate=="$current_version" - pip install psycopg2-binary ruamel.yaml aeidon phply + sudo -u $app $final_path/venv/bin/pip install celery==4.* + sudo -u $app $final_path/venv/bin/pip install Weblate=="$current_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 ) #================================================= @@ -174,11 +174,11 @@ ynh_script_progression --message="Filling up the database..." --time --weight=1 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 changesite --set-name "$domain" + sudo -u $app $final_path/venv/bin/weblate createadmin --no-color \ --password "weblate" \ --username "$admin" \ --email "$admin_mail" @@ -234,15 +234,11 @@ ynh_add_systemd_config --service="$app-celery" --template="celery-weblate.servic #================================================= # Set permissions to app files -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" -mkdir -p "/var/run/$app" -chown -R "$app": "/var/run/$app" - #================================================= # SETUP LOGROTATE #================================================= diff --git a/scripts/restore b/scripts/restore index 2d3c957..fa8079b 100755 --- a/scripts/restore +++ b/scripts/restore @@ -67,15 +67,11 @@ ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell #================================================= # Restore permissions on app files -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" -mkdir -p "/var/run/$app" -chown -R "$app": "/var/run/$app" - #================================================= # SPECIFIC RESTORATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 68584ec..b969ac4 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -159,14 +159,14 @@ virtualenv --python=python3 "${final_path}/venv" set +o nounset source "${final_path}/venv/bin/activate" set -o nounset - pip install --upgrade pip setuptools wheel + sudo -u $app $final_path/venv/bin/pip install --upgrade pip setuptools wheel # Still needed with latest version of weblate? - pip install celery==4.* - pip install --upgrade Weblate=="$current_version" - pip install psycopg2-binary ruamel.yaml aeidon phply + sudo -u $app $final_path/venv/bin/pip install celery==4.* + sudo -u $app $final_path/venv/bin/pip install --upgrade Weblate=="$current_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 ) #================================================= @@ -212,11 +212,11 @@ ynh_systemd_action --service_name="$app-celery" --action="start" export DJANGO_SETTINGS_MODULE="weblate.settings" cd "${final_path}" - weblate migrate --noinput - weblate collectstatic --noinput - weblate setuplang - weblate setupgroups - weblate compilemessages + 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 sudo -u $app $final_path/venv/bin/weblate check --deploy ) @@ -243,15 +243,11 @@ yunohost service add "$app-celery" --log "/var/log/$app/weblate-celery-w1.log" #================================================= # 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" -mkdir -p "/var/run/$app" -chown -R "$app": "/var/run/$app" - #================================================= # START SYSTEMD SERVICES #================================================= From cef22ac5634565cecd2d8545229efe3fe79d85bc Mon Sep 17 00:00:00 2001 From: Kay0u Date: Wed, 28 Oct 2020 17:21:00 +0100 Subject: [PATCH 07/16] Add local_settings.py cf #24 --- README.md | 20 +------------------- conf/settings.py | 19 +++++++++++++++++++ scripts/install | 5 +++++ scripts/restore | 3 +++ scripts/upgrade | 3 +++ 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index d6c2620..543651f 100644 --- a/README.md +++ b/README.md @@ -29,33 +29,15 @@ An admin user is created at installation, the login is what you provided at inst 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**, You will have to **manually** move your hub binary file from `/var/www/$app/bin/` to `/usr/bin` to enable pull request on GitHub. - **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 will 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. diff --git a/conf/settings.py b/conf/settings.py index 1d768eb..8f0465a 100644 --- a/conf/settings.py +++ b/conf/settings.py @@ -1,4 +1,18 @@ # -*- coding: utf-8 -*- +################################################################################ +################################################################################ +## FOR YUNOHOST USERS ## +################################################################################ +################################################################################ + +# Please do not modify this file, it will be reset at the next update. +# You can edit the file /var/www/weblate/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ř # @@ -857,3 +871,8 @@ 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/scripts/install b/scripts/install index 5d75178..1f99ff8 100755 --- a/scripts/install +++ b/scripts/install @@ -116,6 +116,8 @@ EOF ynh_script_progression --message="Install weblate using PIP..." --time --weight=1 virtualenv --python=python3 "${final_path}/venv" +chown -R "$app": "$final_path" + #run source in a 'sub shell' ( set +o nounset @@ -162,6 +164,9 @@ ynh_replace_string --match_string="__PATHURL__" --replace_string="${path_url%/}" 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 diff --git a/scripts/restore b/scripts/restore index fa8079b..c890e2e 100755 --- a/scripts/restore +++ b/scripts/restore @@ -54,6 +54,9 @@ ynh_script_progression --message="Restoring the app main directory..." --time -- 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 #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b969ac4..9c4f2cb 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -198,6 +198,9 @@ 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 #================================================= From 9c57acbb89acb0c65a2fa556e573ec05ce66dd3d Mon Sep 17 00:00:00 2001 From: Kay0u Date: Wed, 28 Oct 2020 19:20:46 +0100 Subject: [PATCH 08/16] 4.3.1 --- README.md | 2 +- check_process | 14 +- conf/celery-weblate | 11 +- conf/settings.4.1.1.py | 877 +++++++++++++++++++++++++++++++++++++++++ conf/settings.py | 435 ++++++++++---------- manifest.json | 2 +- scripts/_common.sh | 2 +- scripts/install | 3 +- scripts/upgrade | 145 ++++--- 9 files changed, 1211 insertions(+), 280 deletions(-) create mode 100644 conf/settings.4.1.1.py diff --git a/README.md b/README.md index 543651f..b2c1e44 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Weblate is a libre web-based translation tool with tight version control integration. It provides two user interfaces, propagation of translations across components, quality checks and automatic linking to source files. -**Shipped version:** 3.11.3 +**Shipped version:** 4.3.1 ## Screenshots diff --git a/check_process b/check_process index 1024265..84b8ca1 100644 --- a/check_process +++ b/check_process @@ -19,9 +19,7 @@ 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 @@ -33,12 +31,6 @@ Email=jean-baptiste@holcroft.fr 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 cc9014c..4624a9b 100644 --- a/conf/celery-weblate +++ b/conf/celery-weblate @@ -1,5 +1,5 @@ # Name of nodes to start -CELERYD_NODES="celery notify search memory backup translate" +CELERYD_NODES="celery notify memory backup translate" # Absolute or relative path to the 'celery' command: CELERY_BIN="__FINALPATH__/venv/bin/celery" @@ -10,11 +10,10 @@ CELERY_APP="weblate.utils" # Extra command-line arguments to the worker, # increase concurency if you get weblate.E019 -CELERYD_OPTS="--beat:celery --concurrency:celery=4 --queues:celery=celery --prefetch-multiplier:celery=4 \ - --concurrency:notify=4 --queues:notify=notify --prefetch-multiplier:notify=10 \ - --concurrency:search=1 --queues:search=search --prefetch-multiplier:search=2000 \ - --concurrency:memory=1 --queues:memory=memory --prefetch-multiplier:memory=2000 \ - --concurrency:translate=4 --queues:translate=translate --prefetch-multiplier:translate=4 \ +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 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 index 8f0465a..bac3b5f 100644 --- a/conf/settings.py +++ b/conf/settings.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- ################################################################################ ################################################################################ ## FOR YUNOHOST USERS ## @@ -12,7 +11,6 @@ ################################################################################ ################################################################################ - # # Copyright © 2012 - 2020 Michal Čihař # @@ -32,7 +30,6 @@ # along with this program. If not, see . # -from __future__ import unicode_literals import os import platform @@ -52,29 +49,32 @@ MANAGERS = ADMINS DATABASES = { "default": { - # Use 'postgresql', 'mysql', 'sqlite3' or 'oracle'. + # Use "postgresql" or "mysql". "ENGINE": "django.db.backends.postgresql", - # Database name or path to database file if using sqlite3. + # Database name. "NAME": "__NAME__", - # Database user, not used with sqlite3. + # Database user. "USER": "__NAME__", - # Database password, not used with sqlite3. + # 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. Not used with sqlite3. + # Set to empty string for localhost. "HOST": "127.0.0.1", - # Set to empty string for default. Not used with sqlite3. + # Set to empty string for default. "PORT": "", - # Customizations for databases + # 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', + # "init_command": "SET storage_engine=INNODB", # Uncomment for MySQL older than 5.7: - # 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", + # "init_command": "SET sql_mode='STRICT_TRANS_TABLES'", # Set emoji capable charset for MySQL: - # 'charset': 'utf8mb4', + # "charset": "utf8mb4", # Change connection timeout in case you get MySQL gone away error: - # 'connect_timeout': 28800, + # "connect_timeout": 28800, }, } } @@ -116,8 +116,10 @@ LANGUAGES = ( ("hu", "Magyar"), ("hr", "Hrvatski"), ("id", "Indonesia"), + ("is", "Íslenska"), ("it", "Italiano"), ("ja", "日本語"), + ("kab", "Taqbaylit"), ("kk", "Қазақ тілі"), ("ko", "한국어"), ("nb", "Norsk bokmål"), @@ -158,7 +160,7 @@ 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 = "{0}/media/".format(URL_PREFIX) +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 @@ -166,7 +168,7 @@ MEDIA_URL = "{0}/media/".format(URL_PREFIX) STATIC_ROOT = os.path.join(DATA_DIR, "static") # URL prefix for static files. -STATIC_URL = "{0}/static/".format(URL_PREFIX) +STATIC_URL = f"{URL_PREFIX}/static/" # Additional locations of static files STATICFILES_DIRS = ( @@ -185,7 +187,7 @@ STATICFILES_FINDERS = ( # Make this unique, and don't share it with anybody. # You can generate it using weblate/examples/generate-secret-key -SECRET_KEY = "__KEY__" # noqa +SECRET_KEY = "__KEY__" _TEMPLATE_LOADERS = [ "django.template.loaders.filesystem.Loader", @@ -196,7 +198,6 @@ if not DEBUG: TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", - "DIRS": [os.path.join(BASE_DIR, "weblate", "templates")], "OPTIONS": { "context_processors": [ "django.contrib.auth.context_processors.auth", @@ -216,21 +217,23 @@ TEMPLATES = [ # 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', + # "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", ) @@ -250,7 +253,6 @@ 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 = "" @@ -316,7 +318,7 @@ AUTH_PASSWORD_VALIDATORS = [ }, { "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", - "OPTIONS": {"min_length": 6}, + "OPTIONS": {"min_length": 10}, }, {"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator"}, {"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"}, @@ -324,10 +326,10 @@ AUTH_PASSWORD_VALIDATORS = [ {"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') + # "NAME": "zxcvbn_password.ZXCVBNValidator", + # "OPTIONS": { + # "min_score": 3, + # "user_attributes": ("username", "email", "full_name") # } # }, ] @@ -335,19 +337,23 @@ AUTH_PASSWORD_VALIDATORS = [ # 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.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.api.middleware.ThrottlingMiddleware", "weblate.middleware.SecurityMiddleware", ] @@ -355,29 +361,16 @@ 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 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_language_data", "weblate.memory", "weblate.screenshots", "weblate.fonts", @@ -388,18 +381,32 @@ INSTALLED_APPS = [ "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", ] -# 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 +# - you can also choose "logfile" to log into separate file # after configuring it below # Detect if we can connect to syslog @@ -416,6 +423,7 @@ 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 @@ -460,13 +468,13 @@ LOGGING = { "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', + # "logfile": { + # "level":"DEBUG", + # "class":"logging.handlers.RotatingFileHandler", + # "filename": "/var/log/weblate/weblate.log", + # "maxBytes": 100000, + # "backupCount": 3, + # "formatter": "logfile", # }, }, "loggers": { @@ -481,22 +489,17 @@ LOGGING = { "propagate": False, }, # Logging database queries - # 'django.db.backends': { - # 'handlers': [DEFAULT_LOG], - # 'level': 'DEBUG', + # "django.db.backends": { + # "handlers": [DEFAULT_LOG], + # "level": "DEBUG", # }, - "weblate": {"handlers": [DEFAULT_LOG], "level": "DEBUG"}, - # Logging search operations - "weblate.search": {"handlers": [DEFAULT_LOG], "level": "INFO"}, + "weblate": {"handlers": [DEFAULT_LOG], "level": DEFAULT_LOGLEVEL}, # Logging VCS operations - "weblate.vcs": {"handlers": [DEFAULT_LOG], "level": "WARNING"}, + "weblate.vcs": {"handlers": [DEFAULT_LOG], "level": DEFAULT_LOGLEVEL}, # Python Social Auth - "social": {"handlers": [DEFAULT_LOG], "level": "DEBUG" if DEBUG else "WARNING"}, + "social": {"handlers": [DEFAULT_LOG], "level": DEFAULT_LOGLEVEL}, # Django Authentication Using LDAP - "django_auth_ldap": { - "level": "DEBUG" if DEBUG else "WARNING", - "handlers": [DEFAULT_LOG], - }, + "django_auth_ldap": {"handlers": [DEFAULT_LOG], "level": DEFAULT_LOGLEVEL}, }, } @@ -505,24 +508,26 @@ 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', -# ) +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 @@ -535,6 +540,10 @@ 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 @@ -544,9 +553,13 @@ MT_MYMEMORY_EMAIL = None MT_MYMEMORY_USER = None MT_MYMEMORY_KEY = None -# Google API key for Google Translate API +# 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 @@ -575,6 +588,9 @@ 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 @@ -592,6 +608,7 @@ 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 @@ -599,19 +616,28 @@ 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 +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 = 0 -SECURE_HSTS_PRELOAD = False -SECURE_HSTS_INCLUDE_SUBDOMAINS = False +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) @@ -639,9 +665,6 @@ 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) @@ -655,89 +678,97 @@ 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.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.source.OptionalPluralCheck', -# 'weblate.checks.source.EllipsisCheck', -# 'weblate.checks.source.MultipleFailingCheck', +# "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', +# "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.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', +# "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. @@ -757,7 +788,7 @@ CACHES = { "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', + # "LOCATION": "unix:///var/run/redis/redis.sock?db=1", "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", "PARSER_CLASS": "redis.connection.HiredisParser", @@ -776,15 +807,18 @@ CACHES = { # 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": [ - "rest_framework.permissions.IsAuthenticatedOrReadOnly" - # Use following with LOGIN_REQUIRED_URLS - # "rest_framework.permissions.IsAuthenticated" + # 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", @@ -792,8 +826,8 @@ REST_FRAMEWORK = { "rest_framework.authentication.SessionAuthentication", ), "DEFAULT_THROTTLE_CLASSES": ( - "rest_framework.throttling.AnonRateThrottle", - "rest_framework.throttling.UserRateThrottle", + "weblate.api.throttling.UserRateThrottle", + "weblate.api.throttling.AnonRateThrottle", ), "DEFAULT_THROTTLE_RATES": {"anon": "100/day", "user": "5000/hour"}, "DEFAULT_PAGINATION_CLASS": ("rest_framework.pagination.PageNumberPagination"), @@ -802,24 +836,33 @@ REST_FRAMEWORK = { "UNAUTHENTICATED_USER": "weblate.auth.models.get_anonymous", } -# Example for restricting access to logged in users -# LOGIN_REQUIRED_URLS = ( -# r'/(.*)$', -# ) +# 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 = ( -# 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 +# 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 @@ -831,7 +874,7 @@ SILENCED_SYSTEM_CHECKS = [ # Celery worker configuration for testing # CELERY_TASK_ALWAYS_EAGER = True -# CELERY_BROKER_URL = 'memory://' +# CELERY_BROKER_URL = "memory://" # CELERY_TASK_EAGER_PROPAGATES = True # Celery worker configuration for production CELERY_TASK_ALWAYS_EAGER = False @@ -842,18 +885,14 @@ CELERY_RESULT_BACKEND = CELERY_BROKER_URL 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.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.memory.tasks.memory_backup": {"queue": "backup"}, "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 diff --git a/manifest.json b/manifest.json index b6672a4..0048042 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "A translation platform using Git and Python", "fr": "Une plateforme de traduction utilisant Git et Python" }, - "version": "3.11.3~ynh1", + "version": "4.3.1~ynh1", "url": "https://weblate.org", "license": "AGPL-3.0", "maintainer": { diff --git a/scripts/_common.sh b/scripts/_common.sh index ffbd489..4df9ede 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -12,7 +12,7 @@ pkg_dependencies="libxml2-dev libxslt-dev libfreetype6-dev libjpeg-dev libz-dev libpq-dev libglib2.0-dev mailutils python-celery-common hub" # Weblate's version for PIP and settings file -current_version="3.11.3" +weblate_version="4.3.1" debian_maj_version=$(sed 's/\..*//' /etc/debian_version) diff --git a/scripts/install b/scripts/install index 1f99ff8..04f2153 100755 --- a/scripts/install +++ b/scripts/install @@ -125,8 +125,7 @@ chown -R "$app": "$final_path" 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 celery==4.* - sudo -u $app $final_path/venv/bin/pip install Weblate=="$current_version" + 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: diff --git a/scripts/upgrade b/scripts/upgrade index 9c4f2cb..5f40aea 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -149,79 +149,104 @@ ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" ynh_add_systemd_config --service="$app-celery" --template="celery-weblate.service" #================================================= -# PIP INSTALLATION +# UPGRADE WEBLATE #================================================= -ynh_script_progression --message="Install weblate using PIP..." --time --weight=1 -virtualenv --python=python3 "${final_path}/venv" -#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 celery==4.* - sudo -u $app $final_path/venv/bin/pip install --upgrade Weblate=="$current_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 -) +upgrade() { + new_version=$1 + settings_template=$2 + #================================================= + # PIP INSTALLATION + #================================================= + ynh_script_progression --message="Install weblate using PIP..." --time --weight=1 -#================================================= -# 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_systemd_action --service_name="$app-celery" --action="stop" -ynh_backup_if_checksum_is_different --file="$settings" -cp "../conf/settings.py" "$settings" + virtualenv --python=python3 "${final_path}/venv" + #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 + ) -ynh_replace_string --match_string="__NAME__" --replace_string="$app" --target_file="$settings" -ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$settings" -ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$settings" -ynh_replace_string --match_string="__ADMINMAIL__" --replace_string="$admin_mail" --target_file="$settings" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$settings" -ynh_replace_string --match_string="__KEY__" --replace_string="$key" --target_file="$settings" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$settings" -ynh_replace_string --match_string="__GITHUBUSER__" --replace_string="$github_account" --target_file="$settings" -ynh_replace_string --match_string="__REDIS_DB__" --replace_string="$redis_db" --target_file="$settings" -ynh_replace_string --match_string="__PYTHONPATH__" --replace_string="$weblate_pypath" --target_file="$settings" + #================================================= + # 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" -# remove last "/" of $path_url -ynh_replace_string --match_string="__PATHURL__" --replace_string="${path_url%/}" --target_file="$settings" + ynh_backup_if_checksum_is_different --file="$settings" + cp "$settings_template" "$settings" -ynh_app_setting_set --app="$app" --key=redis_db --value="$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="__REDIS_DB__" --replace_string="$redis_db" --target_file="$settings" + ynh_replace_string --match_string="__PYTHONPATH__" --replace_string="$weblate_pypath" --target_file="$settings" -# Recalculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$settings" + # remove last "/" of $path_url + ynh_replace_string --match_string="__PATHURL__" --replace_string="${path_url%/}" --target_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" + ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db" -#================================================= -# MIGRATE WEBLATE -#================================================= -ynh_script_progression --message="Run migration scripts..." --time --weight=1 + # Recalculate and store the config file checksum into the app settings + ynh_store_file_checksum --file="$settings" -ynh_systemd_action --service_name="$app-celery" --action="start" + 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" -( - set +o nounset - source "${final_path}/venv/bin/activate" - set -o nounset - export DJANGO_SETTINGS_MODULE="weblate.settings" - cd "${final_path}" + #================================================= + # MIGRATE WEBLATE + #================================================= + ynh_script_progression --message="Run migration scripts..." --time --weight=1 - 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 - sudo -u $app $final_path/venv/bin/weblate check --deploy -) + 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 + sudo -u $app $final_path/venv/bin/weblate check --deploy + ) +} + +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 + +if [ "$current_version" -lt "4" ]; +then + ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name + upgrade "4.1.1" "../conf/settings.4.1.1.py" +fi + +upgrade $weblate_version "../conf/settings.py" #================================================= # SETUP LOGROTATE From ed63e5ab5d1c225759d8ac130837812048ce6bb0 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Wed, 28 Oct 2020 20:22:25 +0100 Subject: [PATCH 09/16] Fix install/upgrade --- scripts/install | 2 ++ scripts/upgrade | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 04f2153..53a683d 100755 --- a/scripts/install +++ b/scripts/install @@ -115,6 +115,8 @@ EOF #================================================= ynh_script_progression --message="Install weblate using PIP..." --time --weight=1 +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" diff --git a/scripts/upgrade b/scripts/upgrade index 5f40aea..1afc53d 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -240,9 +240,10 @@ 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 - ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name upgrade "4.1.1" "../conf/settings.4.1.1.py" fi From 09c091b53b0144f6a758b882aca1357f64e81091 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Wed, 28 Oct 2020 20:39:35 +0100 Subject: [PATCH 10/16] no more changesite option --- scripts/change_url | 13 ++----------- scripts/install | 1 - 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index d6e90dd..314b3aa 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -124,6 +124,8 @@ if [ $change_domain -eq 1 ] then # replace SERVER_EMAIL 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 --match_string="ALLOWED_HOSTS = \[\"$old_domain\"\]" --replace_string="ALLOWED_HOSTS = \[\"$new_domain\"\]" --target_file="$settings" fi @@ -145,17 +147,6 @@ fi ynh_store_file_checksum --file="$finaluwsgiini" -#================================================= -# ChangeSite inside weblate -#================================================= -ynh_script_progression --message="Run weblate's command changesite..." --time --weight=1 -( - set +eu - source "${final_path}/venv/bin/activate" - export DJANGO_SETTINGS_MODULE="weblate.settings" - sudo -u $app $final_path/venv/bin/weblate changesite --set-name "$new_domain" -) - #================================================= # GENERIC FINALISATION #================================================= diff --git a/scripts/install b/scripts/install index 53a683d..7ce510a 100755 --- a/scripts/install +++ b/scripts/install @@ -183,7 +183,6 @@ ynh_script_progression --message="Filling up the database..." --time --weight=1 sudo -u $app $final_path/venv/bin/weblate migrate --noinput # generate static files sudo -u $app $final_path/venv/bin/weblate collectstatic --noinput - sudo -u $app $final_path/venv/bin/weblate changesite --set-name "$domain" sudo -u $app $final_path/venv/bin/weblate createadmin --no-color \ --password "weblate" \ --username "$admin" \ From eaf0954273fb389d45bc0672279a0f3007d9c156 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Date: Wed, 28 Oct 2020 23:10:54 +0100 Subject: [PATCH 11/16] less emails --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index 84b8ca1..4259df3 100644 --- a/check_process +++ b/check_process @@ -28,7 +28,7 @@ # 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=cef22ac5634565cecd2d8545229efe3fe79d85bc From c38d7976af5af38fa6fa2718f76861d9f89c0695 Mon Sep 17 00:00:00 2001 From: Kayou Date: Thu, 29 Oct 2020 10:07:07 +0100 Subject: [PATCH 12/16] Update manifest.json --- manifest.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 0048042..a22d327 100644 --- a/manifest.json +++ b/manifest.json @@ -10,10 +10,14 @@ "url": "https://weblate.org", "license": "AGPL-3.0", "maintainer": { + "name": "", + "email": "" + }, + "previous_maintainers": [{ "name": "Jean-Baptiste Holcroft", "email": "jean-baptiste@holcroft.fr" - }, - "requirements": { + }], + "requirements": { "yunohost": ">= 4.0.0" }, "multi_instance": true, From 2950375f65c6af760429c251c10ad3ccaaf3454d Mon Sep 17 00:00:00 2001 From: Kay0u Date: Tue, 3 Nov 2020 10:19:34 +0100 Subject: [PATCH 13/16] Fix upgrade --- scripts/install | 1 + scripts/upgrade | 26 +++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 7ce510a..a727e30 100755 --- a/scripts/install +++ b/scripts/install @@ -157,6 +157,7 @@ ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --targ 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" diff --git a/scripts/upgrade b/scripts/upgrade index 1afc53d..c8254ed 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,6 +25,7 @@ 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) 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) @@ -112,6 +113,20 @@ ynh_script_progression --message="Making sure dedicated system user exists..." # Create a system user ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell +#================================================= +# CONFIGURE HUB +#================================================= +ynh_script_progression --message="Configure hub..." --time --weight=1 + +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 #================================================= @@ -163,6 +178,8 @@ upgrade() { ynh_systemd_action --service_name="$app-celery" --action="stop" virtualenv --python=python3 "${final_path}/venv" + chown -R "$app": "$final_path/venv" + #run source in a 'sub shell' ( set +o nounset @@ -195,6 +212,7 @@ upgrade() { 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" @@ -228,12 +246,14 @@ upgrade() { 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 - sudo -u $app $final_path/venv/bin/weblate check --deploy + if [ "$new_version" -eq "$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 ]; +if [ -e $file_version ] then current_version=$(cat $file_version | grep "^VERSION = " | grep -o "[0-9].[0-9]" | head -n1 | cut -d"." -f1) else @@ -242,7 +262,7 @@ fi ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name -if [ "$current_version" -lt "4" ]; +if [ "$current_version" -lt "4" ] then upgrade "4.1.1" "../conf/settings.4.1.1.py" fi From 7e1c41253676076828c898931658f53b05c9ce97 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Tue, 3 Nov 2020 16:26:23 +0100 Subject: [PATCH 14/16] Remove some warnings --- scripts/install | 6 +++++- scripts/restore | 3 ++- scripts/upgrade | 5 ++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index a727e30..12c96d4 100755 --- a/scripts/install +++ b/scripts/install @@ -62,7 +62,7 @@ ynh_app_setting_set --app="$app" --key=github_token --value="$github_token" #================================================= ynh_script_progression --message="Installing dependencies..." --time --weight=1 -ynh_install_app_dependencies "$pkg_dependencies" +ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" #================================================= # CREATE A PostgreSQL DATABASE @@ -188,6 +188,10 @@ ynh_script_progression --message="Filling up the database..." --time --weight=1 --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 ) #================================================= diff --git a/scripts/restore b/scripts/restore index c890e2e..c1f53fb 100755 --- a/scripts/restore +++ b/scripts/restore @@ -82,7 +82,7 @@ chown -R "$app": "$final_path/avatar-cache" #================================================= ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 -ynh_install_app_dependencies "$pkg_dependencies" +ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" #================================================= # RESTORE THE PostgreSQL DATABASE @@ -91,6 +91,7 @@ ynh_script_progression --message="Restoring the PostgreSQL database..." --time - ynh_psql_test_if_first_run 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 #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index c8254ed..826e785 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -103,7 +103,7 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 -ynh_install_app_dependencies "$pkg_dependencies" +ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" #================================================= # CREATE DEDICATED USER @@ -246,6 +246,9 @@ upgrade() { 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" -eq "$weblate_version" ]; then sudo -u $app $final_path/venv/bin/weblate check --deploy || true fi From df68a48f42139946338bccf621c16832f3f97fd7 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Tue, 3 Nov 2020 16:51:25 +0100 Subject: [PATCH 15/16] fix comparison --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 826e785..dfed482 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -249,7 +249,7 @@ upgrade() { # 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" -eq "$weblate_version" ]; then + if [ "$new_version" == "$weblate_version" ]; then sudo -u $app $final_path/venv/bin/weblate check --deploy || true fi ) From cedddd92df237a941bb8d85ec1bf90f0efbeb894 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Tue, 3 Nov 2020 17:19:19 +0100 Subject: [PATCH 16/16] set weight --- conf/settings.py | 2 +- scripts/change_url | 16 ++++++++-------- scripts/install | 38 +++++++++++++++++++------------------- scripts/remove | 24 ++++++++++++------------ scripts/restore | 22 +++++++++++----------- scripts/upgrade | 36 ++++++++++++++++++------------------ 6 files changed, 69 insertions(+), 69 deletions(-) diff --git a/conf/settings.py b/conf/settings.py index bac3b5f..7991e05 100644 --- a/conf/settings.py +++ b/conf/settings.py @@ -5,7 +5,7 @@ ################################################################################ # Please do not modify this file, it will be reset at the next update. -# You can edit the file /var/www/weblate/local_settings.py and add/modify the settings you need. +# 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. diff --git a/scripts/change_url b/scripts/change_url index 314b3aa..47a73ca 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." final_path=$(ynh_app_setting_get --app="$app" --key=final_path) is_public=$(ynh_app_setting_get --app="$app" --key=is_public) @@ -32,7 +32,7 @@ is_public=$(ynh_app_setting_get --app="$app" --key=is_public) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --time --weight=1 +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 @@ -67,7 +67,7 @@ fi #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping systemd services..." --time --weight=1 +ynh_script_progression --message="Stopping systemd services..." ynh_systemd_action --service_name="$app" --action="stop" ynh_systemd_action --service_name="$app-celery" --action="stop" @@ -77,7 +77,7 @@ ynh_systemd_action --service_name="$app-celery" --action="stop" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1 +ynh_script_progression --message="Updating nginx web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -108,7 +108,7 @@ fi #================================================= # MODIFY SETTINGS #================================================= -ynh_script_progression --message="Modify weblate's config file..." --time --weight=1 +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" @@ -152,7 +152,7 @@ ynh_store_file_checksum --file="$finaluwsgiini" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting systemd services..." --time --weight=1 +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" @@ -160,7 +160,7 @@ ynh_systemd_action --service_name="$app-celery" --action="start" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -168,4 +168,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --time --last +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index 12c96d4..e79568b 100755 --- a/scripts/install +++ b/scripts/install @@ -32,7 +32,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." --time --weight=1 +ynh_script_progression --message="Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" @@ -45,7 +45,7 @@ mkdir -p "$final_path" #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --time --weight=1 +ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app="$app" --key=domain --value="$domain" ynh_app_setting_set --app="$app" --key=path --value="$path_url" @@ -60,14 +60,14 @@ ynh_app_setting_set --app="$app" --key=github_token --value="$github_token" #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --time --weight=1 +ynh_script_progression --message="Installing dependencies..." --weight=40 ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" #================================================= # CREATE A PostgreSQL DATABASE #================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." --time --weight=1 +ynh_script_progression --message="Creating a PostgreSQL database..." db_name=$(ynh_sanitize_dbid --db_name="$app") db_user=$db_name @@ -81,7 +81,7 @@ ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." --time --weight=1 +ynh_script_progression --message="Configuring nginx web server..." # Create a dedicated nginx config ynh_add_nginx_config @@ -89,7 +89,7 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." --time --weight=1 +ynh_script_progression --message="Configuring system user..." # Hub needs a home directory with a config file ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell @@ -97,7 +97,7 @@ ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell #================================================= # CONFIGURE HUB #================================================= -ynh_script_progression --message="Configure hub..." --time --weight=1 +ynh_script_progression --message="Configure hub..." mkdir "$final_path/.config/" cp ../conf/hub_config "$final_path/.config/hub" @@ -113,7 +113,7 @@ EOF #================================================= # PIP INSTALLATION #================================================= -ynh_script_progression --message="Install weblate using PIP..." --time --weight=1 +ynh_script_progression --message="Install weblate using PIP..." --weight=80 ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name @@ -139,7 +139,7 @@ chown -R "$app": "$final_path" # 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..." --time --weight=1 +ynh_script_progression --message="Create weblate configuration file..." db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd) admin_mail=$(ynh_user_get_info --username="$admin" --key=mail) @@ -173,7 +173,7 @@ ln -sf "$final_path/local_settings.py" "$final_path/venv/lib/$weblate_pypath/sit # 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..." --time --weight=1 +ynh_script_progression --message="Filling up the database..." --weight=10 ( set +o nounset @@ -204,7 +204,7 @@ ynh_store_file_checksum --file="$settings" #================================================= # SPECIFIC SETUP UWSGI #================================================= -ynh_script_progression --message="Configure uwsgi..." --time --weight=1 +ynh_script_progression --message="Configure uwsgi..." finaluwsgiini="/etc/uwsgi/apps-available/$app.ini" @@ -220,14 +220,14 @@ ynh_store_file_checksum --file="$finaluwsgiini" #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." --time --weight=1 +ynh_script_progression --message="Configuring a systemd service..." ynh_add_systemd_config --service="$app" --template="weblate.service" #================================================= # ACTIVATE CELERY #================================================= -ynh_script_progression --message="Configure celery..." --time --weight=1 +ynh_script_progression --message="Configure celery..." celeryconf="$final_path/celery-weblate" cp ../conf/celery-weblate "$celeryconf" @@ -252,7 +252,7 @@ chown -R "$app": "$final_path/avatar-cache" #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Configuring log rotation..." --time --weight=1 +ynh_script_progression --message="Configuring log rotation..." # Use logrotate to manage application logfile(s) ynh_use_logrotate --non-append @@ -260,7 +260,7 @@ ynh_use_logrotate --non-append #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 +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" @@ -268,7 +268,7 @@ yunohost service add "$app-celery" --log "/var/log/$app/weblate-celery-w1.log" #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --time --weight=1 +ynh_script_progression --message="Configuring SSOwat..." # Make app public if necessary if [ "$is_public" -eq 1 ] @@ -280,7 +280,7 @@ fi #================================================= # Start weblate #================================================= -ynh_script_progression --message="Starting weblate's services..." --time --weight=1 +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" @@ -288,7 +288,7 @@ ynh_systemd_action --service_name="$app-celery" --action="start" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name="nginx" --action="reload" @@ -303,4 +303,4 @@ If you facing an issue or want to improve this app, please open a new issue in t ynh_send_readme_to_admin "$message" "$admin" -ynh_script_progression --message="Installation of $app completed" --time --last +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index b356f87..a490614 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app="$app" --key=domain) @@ -29,21 +29,21 @@ final_path=$(ynh_app_setting_get --app="$app" --key=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 integration..." --time --weight=1 + 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 integration..." --time --weight=1 + 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..." --time --weight=1 +ynh_script_progression --message="Stopping and removing systemd services..." --weight=5 ynh_remove_systemd_config --service="$app" ynh_remove_systemd_config --service="$app-celery" @@ -51,7 +51,7 @@ ynh_remove_systemd_config --service="$app-celery" #================================================= # REMOVE THE PostgreSQL DATABASE #================================================= -ynh_script_progression --message="Removing the PostgreSQL database..." --time --weight=1 +ynh_script_progression --message="Removing the PostgreSQL database..." # Remove a database if it exists, along with the associated user ynh_psql_remove_db --db_user=$db_user --db_name=$db_name @@ -65,17 +65,17 @@ ynh_redis_remove_db #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --time --weight=1 +ynh_script_progression --message="Removing dependencies..." --weight=10 # Remove metapackage and its dependencies finaluwsgiini="/etc/uwsgi/apps-available/$app.ini" ynh_secure_remove --file="$finaluwsgiini" -ynh_remove_app_dependencies +ynh_exec_warn_less ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --time --weight=1 +ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -83,7 +83,7 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1 +ynh_script_progression --message="Removing nginx web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config @@ -91,7 +91,7 @@ ynh_remove_nginx_config #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1 +ynh_script_progression --message="Removing logrotate configuration..." # Remove the app-specific logrotate config ynh_remove_logrotate @@ -109,7 +109,7 @@ ynh_secure_remove --file="/var/run/$app-celery" #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1 +ynh_script_progression --message="Removing the dedicated system user..." # Delete a system user ynh_system_user_delete --username="$app" @@ -117,4 +117,4 @@ ynh_system_user_delete --username="$app" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --time --last +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index c1f53fb..9404ed6 100755 --- a/scripts/restore +++ b/scripts/restore @@ -18,7 +18,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --time --weight=1 +ynh_script_progression --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME @@ -32,7 +32,7 @@ db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 +ynh_script_progression --message="Validating restoration parameters..." ynh_webpath_available --domain=$domain --path_url=$path_url \ || ynh_die --message="Path not available: ${domain}${path_url}" @@ -50,7 +50,7 @@ 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..." --time --weight=1 +ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" @@ -60,7 +60,7 @@ ln -sf "$final_path/local_settings.py" "$final_path/venv/lib/$weblate_pypath/sit #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 +ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell @@ -80,14 +80,14 @@ chown -R "$app": "$final_path/avatar-cache" #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 +ynh_script_progression --message="Reinstalling dependencies..." --weight=40 ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" #================================================= # RESTORE THE PostgreSQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." --time --weight=1 +ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=5 ynh_psql_test_if_first_run ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd" @@ -97,7 +97,7 @@ ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./d #================================================= # RESTORE SYSTEMD #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --time --weight=1 +ynh_script_progression --message="Restoring the systemd configuration..." ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service @@ -107,14 +107,14 @@ systemctl enable "$app-celery" #================================================= # RESTORE UWSGI #================================================= -ynh_script_progression --message="Restoring uwsgi configurations..." --time --weight=1 +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..." --time --weight=1 +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" @@ -131,7 +131,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # START WEBLATE #================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 +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" @@ -139,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..." --time --weight=1 +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 dfed482..56e6312 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -11,7 +11,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -32,7 +32,7 @@ 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)..." --time --weight=1 +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 @@ -46,7 +46,7 @@ ynh_abort_if_errors #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 +ynh_script_progression --message="Ensuring downward compatibility..." # Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then @@ -83,7 +83,7 @@ path_url=$(ynh_normalize_url_path --path_url=$path_url) #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping systemd services..." --time --weight=1 +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" @@ -91,7 +91,7 @@ ynh_systemd_action --service_name="$app-celery" --action="stop" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config @@ -101,7 +101,7 @@ ynh_add_nginx_config #================================================= # Update dependencies #================================================= -ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 +ynh_script_progression --message="Upgrading dependencies..." ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" @@ -116,7 +116,7 @@ ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell #================================================= # CONFIGURE HUB #================================================= -ynh_script_progression --message="Configure hub..." --time --weight=1 +ynh_script_progression --message="Configure hub..." mkdir -p "$final_path/.config/" cp ../conf/hub_config "$final_path/.config/hub" @@ -130,7 +130,7 @@ EOF #================================================= # SPECIFIC SETUP UWSGI #================================================= -ynh_script_progression --message="Configure uwsgi..." --time --weight=1 +ynh_script_progression --message="Configure uwsgi..." finaluwsgiini="/etc/uwsgi/apps-available/$app.ini" ynh_backup_if_checksum_is_different --file="$finaluwsgiini" @@ -146,14 +146,14 @@ ynh_store_file_checksum --file="$finaluwsgiini" #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." --time --weight=1 +ynh_script_progression --message="Configuring a systemd service..." ynh_add_systemd_config --service="$app" --template="weblate.service" #================================================= # ACTIVATE CELERY #================================================= -ynh_script_progression --message="Configure celery..." --time --weight=1 +ynh_script_progression --message="Configure celery..." celeryconf="$final_path/celery-weblate" cp ../conf/celery-weblate "$celeryconf" @@ -173,7 +173,7 @@ upgrade() { #================================================= # PIP INSTALLATION #================================================= - ynh_script_progression --message="Install weblate using PIP..." --time --weight=1 + ynh_script_progression --message="Install weblate using PIP..." --weight=15 ynh_systemd_action --service_name="$app-celery" --action="stop" @@ -230,7 +230,7 @@ upgrade() { #================================================= # MIGRATE WEBLATE #================================================= - ynh_script_progression --message="Run migration scripts..." --time --weight=1 + ynh_script_progression --message="Run migration scripts..." --weight=10 ynh_systemd_action --service_name="$app-celery" --action="start" @@ -275,7 +275,7 @@ upgrade $weblate_version "../conf/settings.py" #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading logrotate configuration..." # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append @@ -283,7 +283,7 @@ ynh_use_logrotate --non-append #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 +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" @@ -303,7 +303,7 @@ chown -R "$app": "$final_path/avatar-cache" #================================================= # START SYSTEMD SERVICES #================================================= -ynh_script_progression --message="Starting systemd services..." --time --weight=1 +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" @@ -311,7 +311,7 @@ ynh_systemd_action --service_name="$app-celery" --action="start" #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading SSOwat configuration..." # Make app public if necessary if [ "$is_public" -eq 1 ] @@ -323,7 +323,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -331,4 +331,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --time --last \ No newline at end of file +ynh_script_progression --message="Upgrade of $app completed" --last \ No newline at end of file