diff --git a/config/settings/base.py b/config/settings/base.py index dda4a2067f..c9430e24f8 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -524,9 +524,9 @@ ) FILE_UPLOAD_BUCKET_EXTERNAL_ENDPOINT = env( "FILE_UPLOAD_BUCKET_EXTERNAL_ENDPOINT", - default=BUCKET_EXTERNAL_ENDPOINT - if BUCKET_ENDPOINT - else FILE_UPLOAD_BUCKET_ENDPOINT, + default=( + BUCKET_EXTERNAL_ENDPOINT if BUCKET_ENDPOINT else FILE_UPLOAD_BUCKET_ENDPOINT + ), ) ALLOWED_MIME_TYPES = env.list( @@ -578,9 +578,9 @@ ) FACILITY_S3_BUCKET_EXTERNAL_ENDPOINT = env( "FACILITY_S3_BUCKET_EXTERNAL_ENDPOINT", - default=BUCKET_EXTERNAL_ENDPOINT - if BUCKET_ENDPOINT - else FACILITY_S3_BUCKET_ENDPOINT, + default=( + BUCKET_EXTERNAL_ENDPOINT if BUCKET_ENDPOINT else FACILITY_S3_BUCKET_ENDPOINT + ), ) # for setting the shifting mode @@ -604,6 +604,8 @@ json.loads(base64.b64decode(env("JWKS_BASE64", default=generate_encoded_jwks()))) ) +APP_VERSION = env("APP_VERSION", default="unknown") + # ABDM ENABLE_ABDM = env.bool("ENABLE_ABDM", default=False) ABDM_CLIENT_ID = env("ABDM_CLIENT_ID", default="") diff --git a/config/settings/deployment.py b/config/settings/deployment.py index 6667a583ea..d6cb1a3b94 100644 --- a/config/settings/deployment.py +++ b/config/settings/deployment.py @@ -7,13 +7,13 @@ from sentry_sdk.integrations.redis import RedisIntegration from .base import * # noqa -from .base import env +from .base import APP_VERSION, DATABASES, TEMPLATES, env # DATABASES # ------------------------------------------------------------------------------ -DATABASES["default"] = env.db("DATABASE_URL") # noqa F405 -DATABASES["default"]["ATOMIC_REQUESTS"] = True # noqa F405 -DATABASES["default"]["CONN_MAX_AGE"] = env.int("CONN_MAX_AGE", default=60) # noqa F405 +DATABASES["default"] = env.db("DATABASE_URL") +DATABASES["default"]["ATOMIC_REQUESTS"] = True +DATABASES["default"]["CONN_MAX_AGE"] = env.int("CONN_MAX_AGE", default=60) # SECURITY # ------------------------------------------------------------------------------ @@ -45,7 +45,7 @@ # TEMPLATES # ------------------------------------------------------------------------------ # https://docs.djangoproject.com/en/dev/ref/settings/#templates -TEMPLATES[-1]["OPTIONS"]["loaders"] = [ # type: ignore[index] # noqa F405 +TEMPLATES[-1]["OPTIONS"]["loaders"] = [ # type: ignore[index] ( "django.template.loaders.cached.Loader", [ @@ -98,7 +98,7 @@ if SENTRY_DSN := env("SENTRY_DSN", default=""): sentry_sdk.init( dsn=SENTRY_DSN, - release=env("APP_VERSION", default="unknown"), + release=APP_VERSION, environment=env("SENTRY_ENVIRONMENT", default="deployment-unknown"), traces_sample_rate=env.float("SENTRY_TRACES_SAMPLE_RATE", default=0), profiles_sample_rate=env.float("SENTRY_PROFILES_SAMPLE_RATE", default=0), diff --git a/config/urls.py b/config/urls.py index b59954a17d..4d112c686a 100644 --- a/config/urls.py +++ b/config/urls.py @@ -33,11 +33,12 @@ ) from .auth_views import AnnotatedTokenVerifyView, TokenObtainPairView, TokenRefreshView -from .views import home_view, ping +from .views import app_version, home_view, ping urlpatterns = [ path("", home_view, name="home"), path("ping/", ping, name="ping"), + path("app_version/", app_version, name="app_version"), # Django Admin, use {% url 'admin:index' %} path(settings.ADMIN_URL, admin.site.urls), # Rest API diff --git a/config/views.py b/config/views.py index 228ed1fe62..1cd9d3e310 100644 --- a/config/views.py +++ b/config/views.py @@ -1,10 +1,15 @@ +from django.conf import settings from django.http import JsonResponse from django.shortcuts import render +def app_version(_): + return JsonResponse({"version": settings.APP_VERSION}) + + def home_view(request): return render(request, "pages/home.html") -def ping(request): +def ping(_): return JsonResponse({"status": "OK"})