From 2f7cb17c56199f4707c4e3391bc321172154ef1c Mon Sep 17 00:00:00 2001 From: Tudor Amariei Date: Thu, 4 Apr 2024 14:21:38 +0300 Subject: [PATCH] Add version+revision in the admin --- backend/seismic_site/settings.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/backend/seismic_site/settings.py b/backend/seismic_site/settings.py index 9ac152f6..97118f9c 100644 --- a/backend/seismic_site/settings.py +++ b/backend/seismic_site/settings.py @@ -33,6 +33,7 @@ HERE_MAPS_API_KEY=(str, ""), DATA_UPLOAD_MAX_NUMBER_FIELDS=(int, 1000), BACKGROUND_WORKERS_COUNT=(int, 1), + IS_CONTAINERIZED=(bool, True), DJANGO_ADMIN_EMAIL=(str, ""), DJANGO_ADMIN_PASSWORD=(str, ""), # email settings @@ -112,6 +113,23 @@ # Logging DJANGO_LOG_LEVEL = env.str("LOG_LEVEL").upper() +# some settings will be different if it's not running in a container (e.g., locally, on a PC) +IS_CONTAINERIZED = BASE_DIR.startswith(os.path.join("/", "var", "www")) # noqa + +VERSION = env.str("VERSION", "edge") +REVISION = env.str("REVISION", "develop") + +if IS_CONTAINERIZED and VERSION == "edge" and REVISION == "develop": + version_file = os.path.join(BASE_DIR, ".version") # noqa + if os.path.exists(version_file): + with open(version_file) as f: + VERSION, REVISION = f.read().strip().split("+") + +REVISION = REVISION[:7] + +VERSION_SUFFIX = f"seismic@{VERSION}+{REVISION}" + + LOGGING = { "version": 1, "disable_existing_loggers": False, @@ -502,7 +520,7 @@ # Welcome text on the login screen "welcome_sign": "", # Copyright on the footer - "copyright": "Commit Global", + "copyright": f"Commit Global | {VERSION_SUFFIX}", # The model admin to search from the search bar, search bar omitted if excluded # "search_model": "donors.Donor", # The field name on the user model that contains avatar image