diff --git a/README.md b/README.md index 8e9fc8c9..e13abd6e 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ See `.tool-versions` file for used django and node version You have to set up at least the following environment variables: ```bash -export IT_APP_ENVIRONMENT=development +export IT_APP_ENVIRONMENT=local ``` See `.env_secrets/local_daniel.env` for more possible environment variables. diff --git a/caprover_create_app.py b/caprover_create_app.py index 549b5b23..2b615955 100644 --- a/caprover_create_app.py +++ b/caprover_create_app.py @@ -73,7 +73,8 @@ def main(app_name, image_name, environment_file): container_http_port=7555, environment_variables={ # 'DJANGO_SETTINGS_MODULE': 'config.settings.base', - "IT_APP_ENVIRONMENT": env.str("IT_APP_ENVIRONMENT", "caprover_feature"), + "IT_APP_ENVIRONMENT": env.str("IT_APP_ENVIRONMENT", "dev-feature"), + "IT_DEFAULT_ADMIN_PASSWORD": env.str("fWwoQzreIS5uztLOyF8jJpS9M"), "POSTGRES_HOST": f"srv-captain--{app_name}-postgres", "POSTGRES_PORT": 5432, "POSTGRES_DB": db_name, @@ -88,6 +89,7 @@ def main(app_name, image_name, environment_file): "IT_DJANGO_DEBUG": "false", "IT_SERVE_VUE": "false", "IT_ALLOW_LOCAL_LOGIN": "true", + "IT_DJANGO_LOGGING_CONF": "IT_DJANGO_LOGGING_CONF_JSON_FILE", }, ) diff --git a/env/bitbucket/prepare_for_deployment.sh b/env/bitbucket/prepare_for_deployment.sh index c2f7435c..27d16ca5 100755 --- a/env/bitbucket/prepare_for_deployment.sh +++ b/env/bitbucket/prepare_for_deployment.sh @@ -13,7 +13,7 @@ export PATH="$PWD/vbvvenv/bin:$PATH" docker login --username=iterativ --password=$DOCKER_PASSWORD_TOKEN # only used for `python manage.py collectstatic` so value doesn't matter -export IT_APP_ENVIRONMENT=development +export IT_APP_ENVIRONMENT=dev pip install -r $BITBUCKET_CLONE_DIR/server/requirements/requirements-dev.txt diff --git a/env/docker_local.env b/env/docker_local.env deleted file mode 100644 index 409e30f8..00000000 --- a/env/docker_local.env +++ /dev/null @@ -1,13 +0,0 @@ -# PostgreSQL -# ------------------------------------------------------------------------------ -POSTGRES_HOST=postgres -POSTGRES_PORT=5432 -POSTGRES_DB=vbv_lernwelt -POSTGRES_USER=postgres -POSTGRES_PASSWORD=hNqfCdG6bwCLcnfboDtNM1L2Hiwp8GuKp1DJ6t2rcKl15Vls2QbByoIZ6IQlciKM - -# General -# ------------------------------------------------------------------------------ -IT_DJANGO_LOCAL_DOCKER=True -IPYTHONDIR=/app/.ipython -IT_APP_ENVIRONMENT=local diff --git a/env_secrets/caprover_dev.env b/env_secrets/caprover_dev.env index 4551800d..ce116288 100644 Binary files a/env_secrets/caprover_dev.env and b/env_secrets/caprover_dev.env differ diff --git a/env_secrets/caprover_prod.env b/env_secrets/caprover_prod.env index 32320d96..8c8aca70 100644 Binary files a/env_secrets/caprover_prod.env and b/env_secrets/caprover_prod.env differ diff --git a/env_secrets/caprover_stage.env b/env_secrets/caprover_stage.env index d0b38980..9d4e3c92 100644 Binary files a/env_secrets/caprover_stage.env and b/env_secrets/caprover_stage.env differ diff --git a/env_secrets/local_chrigu.env b/env_secrets/local_chrigu.env index 324ec6b9..b012626b 100644 Binary files a/env_secrets/local_chrigu.env and b/env_secrets/local_chrigu.env differ diff --git a/env_secrets/local_daniel.env b/env_secrets/local_daniel.env index 1664c3b5..9b641f2e 100644 Binary files a/env_secrets/local_daniel.env and b/env_secrets/local_daniel.env differ diff --git a/env_secrets/local_elia.env b/env_secrets/local_elia.env index 16a4c5a0..920f089e 100644 Binary files a/env_secrets/local_elia.env and b/env_secrets/local_elia.env differ diff --git a/env_secrets/local_lorenz.env b/env_secrets/local_lorenz.env index 764a8653..22665c98 100644 Binary files a/env_secrets/local_lorenz.env and b/env_secrets/local_lorenz.env differ diff --git a/env_secrets/pg_backup_local.env b/env_secrets/pg_backup_local.env deleted file mode 100644 index ca8e7f15..00000000 Binary files a/env_secrets/pg_backup_local.env and /dev/null differ diff --git a/env_secrets/production_azure.json b/env_secrets/production_azure.json index 1314d1dd..64f9b95c 100644 Binary files a/env_secrets/production_azure.json and b/env_secrets/production_azure.json differ diff --git a/example.env b/example.env index 06329196..cebd3ce6 100644 --- a/example.env +++ b/example.env @@ -1 +1 @@ -export IT_APP_ENVIRONMENT='development' +export IT_APP_ENVIRONMENT=local diff --git a/prepare_server_cypress.sh b/prepare_server_cypress.sh index b08106f5..0bc71716 100755 --- a/prepare_server_cypress.sh +++ b/prepare_server_cypress.sh @@ -3,7 +3,7 @@ # set location to script directory cd "${0%/*}" -export IT_APP_ENVIRONMENT=development +export IT_APP_ENVIRONMENT=local export DJANGO_SETTINGS_MODULE=config.settings.test_cypress export DJANGO_PORT=8001 export PGDATABASE=vbv_lernwelt_cypress diff --git a/scripts/count_queries.py b/scripts/count_queries.py index 48167c3b..905f001e 100644 --- a/scripts/count_queries.py +++ b/scripts/count_queries.py @@ -7,7 +7,7 @@ import django sys.path.append("../server") -os.environ.setdefault("IT_APP_ENVIRONMENT", "development") +os.environ.setdefault("IT_APP_ENVIRONMENT", "local") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.base") django.setup() @@ -16,12 +16,16 @@ from wagtail.models import Page def main(): from django.conf import settings + settings.DEBUG = True from django.db import connection from django.db import reset_queries + reset_queries() - page = Page.objects.get(slug='versicherungsvermittlerin', locale__language_code='de-CH') + page = Page.objects.get( + slug="versicherungsvermittlerin", locale__language_code="de-CH" + ) serializer = page.specific.get_serializer_class()(page.specific) print(serializer.data) @@ -29,5 +33,5 @@ def main(): print(len(connection.queries)) -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/server/config/settings/base.py b/server/config/settings/base.py index 06b57573..fb31f49a 100644 --- a/server/config/settings/base.py +++ b/server/config/settings/base.py @@ -14,13 +14,18 @@ APPS_DIR = SERVER_ROOT_DIR / "vbv_lernwelt" env = Env() env.read_env() -# set to "development" for local development +# set to "local" for local development APP_ENVIRONMENT = env("IT_APP_ENVIRONMENT") # GENERAL # ------------------------------------------------------------------------------ # https://docs.djangoproject.com/en/dev/ref/settings/#debug -DEBUG = env.bool("IT_DJANGO_DEBUG", True if APP_ENVIRONMENT == "development" else False) +DEBUG = env.bool("IT_DJANGO_DEBUG", True if APP_ENVIRONMENT == "local" else False) + +# check that IT_DEFAULT_ADMIN_PASSWORD is set +if not DEBUG: + # fails if not set + env.str("IT_DEFAULT_ADMIN_PASSWORD") # Local time zone. Choices are # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name @@ -614,7 +619,7 @@ if FILE_UPLOAD_STORAGE == "s3": AWS_PRESIGNED_EXPIRY = env.int("AWS_PRESIGNED_EXPIRY", default=300) # seconds -if APP_ENVIRONMENT == "development": +if APP_ENVIRONMENT.startswith("dev"): # http://whitenoise.evans.io/en/latest/django.html#using-whitenoise-in-development INSTALLED_APPS = ["whitenoise.runserver_nostatic"] + INSTALLED_APPS # noqa F405 @@ -697,11 +702,6 @@ if APP_ENVIRONMENT in ["production", "caprover"] or APP_ENVIRONMENT.startswith( default="[VBV Lernwelt]", ) - # ADMIN - # ------------------------------------------------------------------------------ - # Django Admin URL regex. - ADMIN_URL = env("IT_DJANGO_ADMIN_URL", "admin/") - # Anymail # ------------------------------------------------------------------------------ # https://anymail.readthedocs.io/en/stable/installation/#installing-anymail diff --git a/server/config/settings/test.py b/server/config/settings/test.py index 0485c979..5878c8c8 100644 --- a/server/config/settings/test.py +++ b/server/config/settings/test.py @@ -1,7 +1,7 @@ # pylint: disable=unused-wildcard-import,wildcard-import,wrong-import-position import os -os.environ["IT_APP_ENVIRONMENT"] = "development" +os.environ["IT_APP_ENVIRONMENT"] = "local" from .base import * # noqa diff --git a/server/config/settings/test_cypress.py b/server/config/settings/test_cypress.py index 91d808b0..a82cbe93 100644 --- a/server/config/settings/test_cypress.py +++ b/server/config/settings/test_cypress.py @@ -1,7 +1,7 @@ # pylint: disable=unused-wildcard-import,wildcard-import,wrong-import-position import os -os.environ["IT_APP_ENVIRONMENT"] = "development" +os.environ["IT_APP_ENVIRONMENT"] = "local" from .base import * # noqa