From 005a764dc272265539c9e5ebbf5646d5711e2e8d Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Sun, 7 Jul 2024 14:15:09 +0200 Subject: [PATCH] Fixed wrong access to settings properties --- modoboa/core/commands/templates/settings.py.tpl | 10 +++++----- modoboa/core/management/commands/load_initial_data.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modoboa/core/commands/templates/settings.py.tpl b/modoboa/core/commands/templates/settings.py.tpl index dbcf80a5e..9513eceb5 100644 --- a/modoboa/core/commands/templates/settings.py.tpl +++ b/modoboa/core/commands/templates/settings.py.tpl @@ -2,7 +2,7 @@ Django settings for {{ name }} project. For more information on this file, see -https://docs.djangoproject.com/en/2.2/topics/settings/ +https://docs.djangoproject.com/en/4.2/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/2.2/ref/settings/ @@ -22,7 +22,7 @@ BASE_DIR = os.path.realpath(os.path.dirname(os.path.dirname(__file__))) environ.Env.read_env(os.path.join(BASE_DIR, '.env')) # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '{{ secret_key }}' @@ -164,14 +164,14 @@ WSGI_APPLICATION = '{{ name }}.wsgi.application' # Database -# https://docs.djangoproject.com/en/2.2/ref/settings/#databases +# https://docs.djangoproject.com/en/4.2/ref/settings/#databases DATABASES = { {% for conn in db_connections.values %}{{ conn|safe }}{% endfor %} } # Internationalization -# https://docs.djangoproject.com/en/2.2/topics/i18n/ +# https://docs.djangoproject.com/en/4.2/topics/i18n/ LANGUAGE_CODE = '{{ lang }}' @@ -308,7 +308,7 @@ CACHES = { # Password validation -# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators +# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { diff --git a/modoboa/core/management/commands/load_initial_data.py b/modoboa/core/management/commands/load_initial_data.py index 290b819a1..67e36ba84 100644 --- a/modoboa/core/management/commands/load_initial_data.py +++ b/modoboa/core/management/commands/load_initial_data.py @@ -98,14 +98,14 @@ class Command(BaseCommand): shutil.copytree(base_frontend_dir, frontend_target_dir) app_model = get_application_model() - allowed_host = settings.get("ALLOWED_HOSTS") + allowed_host = getattr(settings, "ALLOWED_HOSTS", None) if allowed_host is not None: allowed_host = allowed_host[0] else: allowed_host = input("What will be the hostname used to access Modoboa? ") if not allowed_host: allowed_host = "localhost" - frontend_path = settings.get("NEW_ADMIN_URL", "new-admin") + frontend_path = getattr(settings, "NEW_ADMIN_URL", "new-admin") redirect_uri = f"https://{allowed_host}/{frontend_path}/login/logged" client_id = str(uuid.uuid4()) frontend_application = app_model.objects.filter(name="frontend")