From 3fd38cdae6ccd52305b5783d00bc3f7d9de06ac8 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Wed, 6 Jun 2018 00:23:36 +0200 Subject: [PATCH] Upgrade to 3.0 --- README.md | 10 +++ conf/settings_history/settings.3.0.py | 109 +++++++++++++------------- manifest.json | 2 +- scripts/_common.sh | 2 +- scripts/upgrade | 13 +++ 5 files changed, 81 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index f36b71d..73b3ff3 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,16 @@ The YunoHost team uses [Weblate](https://weblate.org) for translations: https:// 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/). diff --git a/conf/settings_history/settings.3.0.py b/conf/settings_history/settings.3.0.py index fd84cfc..a142e66 100644 --- a/conf/settings_history/settings.3.0.py +++ b/conf/settings_history/settings.3.0.py @@ -207,6 +207,9 @@ AUTHENTICATION_BACKENDS = ( '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 = '' @@ -308,7 +311,7 @@ AUTH_PASSWORD_VALIDATORS = [ # 'NAME': 'zxcvbn_password.ZXCVBNValidator', # 'OPTIONS': { # 'min_score': 3, - # 'user_attributes': ('username', 'email', 'first_name') + # 'user_attributes': ('username', 'email', 'full_name') # } # }, ] @@ -348,6 +351,10 @@ INSTALLED_APPS = ( 'rest_framework', 'rest_framework.authtoken', 'weblate.addons', + 'weblate.auth', + 'weblate.checks', + 'weblate.formats', + 'weblate.machinery', 'weblate.trans', 'weblate.lang', 'weblate.langdata', @@ -356,6 +363,7 @@ INSTALLED_APPS = ( 'weblate.screenshots', 'weblate.accounts', 'weblate.utils', + 'weblate.vcs', 'weblate.wladmin', 'weblate', @@ -498,18 +506,18 @@ 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', +# 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', # ) @@ -615,36 +623,36 @@ 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', +# '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 @@ -662,21 +670,17 @@ CRISPY_TEMPLATE_PACK = 'bootstrap3' # '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.json.JSONCustomizeAddon', # 'weblate.addons.generate.GenerateFileAddon', +# 'weblate.addons.json.JSONCustomizeAddon', # '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__' @@ -728,7 +732,7 @@ REST_FRAMEWORK = { ), 'PAGE_SIZE': 20, 'VIEW_DESCRIPTION_FUNCTION': 'weblate.api.views.get_view_description', - 'UNAUTHENTICATED_USER': 'weblate.accounts.models.get_anonymous', + 'UNAUTHENTICATED_USER': 'weblate.auth.models.get_anonymous', } # Example for restricting access to logged in users @@ -751,4 +755,3 @@ REST_FRAMEWORK = { # Force sane test runner TEST_RUNNER = 'django.test.runner.DiscoverRunner' - diff --git a/manifest.json b/manifest.json index 47fcfbb..41d3fc4 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ "description": { "en": "A translation platform using Git and Python" }, - "version": "2.20-1", + "version": "3.0~ynh1", "url": "https://weblate.org", "license": "AGPL-3.0", "maintainer": { diff --git a/scripts/_common.sh b/scripts/_common.sh index 5a0f3b4..a2d3238 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,6 +1,6 @@ #!/bin/bash -current_version="2.20" +current_version="3.0" ynh_check_global_uwsgi_config () { uwsgi --version || ynh_die "You need to add uwsgi (and appropriate plugin) as a dependency" diff --git a/scripts/upgrade b/scripts/upgrade index 3e265cc..5c87db3 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -203,6 +203,8 @@ then # send diff to the server administrator mail_message=" Weblate was updated from version $previous_version to $current_version + This is a MAJOR upgrade, please read this: + https://docs.weblate.org/en/latest/admin/upgrade.html#upgrade-3 A new settings.py has been created in: $settings @@ -236,6 +238,17 @@ fi set -o nounset export DJANGO_SETTINGS_MODULE="weblate.settings" cd "${final_path}" + + # https://docs.weblate.org/en/latest/admin/upgrade.html#upgrade-3 + # https://github.com/WeblateOrg/docker/blob/386aa8d98bb57dfec3707680827d4e4f4d79e3fd/start#L81-L88 + weblate showmigrations --plan > /tmp/migrations.txt + if grep -Fq '[X] auth.0001_initial' /tmp/migrations.txt && grep -Fq '[ ] weblate_auth.0001_initial' /tmp/migrations.txt ; then + ynh_replace_string "AUTH_USER_MODEL" "#AUTH_USER_MODEL" "$settings" + weblate migrate weblate_auth 0001 + ynh_replace_string "#AUTH_USER_MODEL" "AUTH_USER_MODEL" "$settings" + fi + ynh_secure_remove /tmp/migrations.txt + weblate migrate --noinput weblate collectstatic --noinput weblate setuplang