diff --git a/env.d/development/common.dist b/env.d/development/common.dist index 97b8e08a..ec20b2d5 100644 --- a/env.d/development/common.dist +++ b/env.d/development/common.dist @@ -21,6 +21,7 @@ STORAGES_STATICFILES_BACKEND=django.contrib.staticfiles.storage.StaticFilesStora AWS_S3_ENDPOINT_URL=http://minio:9000 AWS_S3_ACCESS_KEY_ID=impress AWS_S3_SECRET_ACCESS_KEY=password +MEDIA_BASE_URL=http://localhost:8083 # OIDC OIDC_OP_JWKS_ENDPOINT=http://nginx:8083/realms/impress/protocol/openid-connect/certs diff --git a/src/backend/core/api/viewsets.py b/src/backend/core/api/viewsets.py index d6bee63e..203c1942 100644 --- a/src/backend/core/api/viewsets.py +++ b/src/backend/core/api/viewsets.py @@ -902,6 +902,7 @@ class ConfigView(views.APIView): """ array_settings = [ "ENVIRONMENT", + "MEDIA_BASE_URL", "LANGUAGES", "LANGUAGE_CODE", "SENTRY_DSN", diff --git a/src/backend/core/tests/test_api_config.py b/src/backend/core/tests/test_api_config.py index ac5d32db..405ff27a 100644 --- a/src/backend/core/tests/test_api_config.py +++ b/src/backend/core/tests/test_api_config.py @@ -15,7 +15,10 @@ from core import factories pytestmark = pytest.mark.django_db -@override_settings(SENTRY_DSN="https://sentry.test/123") +@override_settings( + SENTRY_DSN="https://sentry.test/123", + MEDIA_BASE_URL="http://testserver/", +) def test_api_config_anonymous(): """Anonymous users should be allowed to get the configuration.""" client = APIClient() @@ -26,10 +29,13 @@ def test_api_config_anonymous(): "LANGUAGE_CODE": "en-us", "SENTRY_DSN": "https://sentry.test/123", "ENVIRONMENT": "test", + "MEDIA_BASE_URL": "http://testserver/", } -@override_settings(SENTRY_DSN="https://sentry.test/123") +@override_settings( + SENTRY_DSN="https://sentry.test/123", MEDIA_BASE_URL="http://testserver/" +) def test_api_config_authenticated(): """Authenticated users should be allowed to get the configuration.""" user = factories.UserFactory() @@ -44,4 +50,5 @@ def test_api_config_authenticated(): "LANGUAGE_CODE": "en-us", "SENTRY_DSN": "https://sentry.test/123", "ENVIRONMENT": "test", + "MEDIA_BASE_URL": "http://testserver/", } diff --git a/src/backend/impress/settings.py b/src/backend/impress/settings.py index e1994644..ec62e86d 100755 --- a/src/backend/impress/settings.py +++ b/src/backend/impress/settings.py @@ -104,6 +104,9 @@ class Base(Configuration): STATIC_ROOT = os.path.join(DATA_DIR, "static") MEDIA_URL = "/media/" MEDIA_ROOT = os.path.join(DATA_DIR, "media") + MEDIA_BASE_URL = values.Value( + None, environ_name="MEDIA_BASE_URL", environ_prefix=None + ) SITE_ID = 1