diff --git a/src/backend/core/api/viewsets.py b/src/backend/core/api/viewsets.py index 5fbd4ce43..d45ecb94c 100644 --- a/src/backend/core/api/viewsets.py +++ b/src/backend/core/api/viewsets.py @@ -504,7 +504,7 @@ def get(self, request): GET /api/v1.0/config/ Return a dictionary of public settings. """ - array_settings = ["LANGUAGES", "FEATURES", "RELEASE"] + array_settings = ["LANGUAGES", "FEATURES", "RELEASE", "COMMIT"] dict_settings = {} for setting in array_settings: dict_settings[setting] = getattr(settings, setting) diff --git a/src/backend/core/tests/test_api_config.py b/src/backend/core/tests/test_api_config.py index d2132917a..efe1e533f 100644 --- a/src/backend/core/tests/test_api_config.py +++ b/src/backend/core/tests/test_api_config.py @@ -20,6 +20,7 @@ def test_api_config_anonymous(): assert response.status_code == HTTP_200_OK assert response.json() == { "LANGUAGES": [["en-us", "English"], ["fr-fr", "French"]], + "COMMIT":"NA", "FEATURES": { "CONTACTS_DISPLAY": True, "CONTACTS_CREATE": True, @@ -42,6 +43,7 @@ def test_api_config_authenticated(): assert response.status_code == HTTP_200_OK assert response.json() == { "LANGUAGES": [["en-us", "English"], ["fr-fr", "French"]], + "COMMIT":"NA", "FEATURES": { "CONTACTS_DISPLAY": True, "CONTACTS_CREATE": True, diff --git a/src/backend/people/settings.py b/src/backend/people/settings.py index 8c99afa6b..50bc0f6fa 100755 --- a/src/backend/people/settings.py +++ b/src/backend/people/settings.py @@ -44,6 +44,17 @@ def get_release(): return "NA" # Default: not available +def get_commit(): + """ + Get the current commit of the application + """ + try: + with open(os.path.join(BASE_DIR, "version.json"), encoding="utf8") as version: + return json.load(version)["commit"] + except FileNotFoundError: + return "NA" # Default: not available + + class Base(Configuration): """ This is the base configuration every configuration (aka environment) should inherit from. It @@ -488,6 +499,14 @@ def RELEASE(self): """ return get_release() + # pylint: disable=invalid-name + @property + def COMMIT(self): + """ + Return the commit information. + """ + return get_release() + # pylint: disable=invalid-name @property def PARLER_LANGUAGES(self): diff --git a/src/frontend/apps/desk/src/core/config/types.ts b/src/frontend/apps/desk/src/core/config/types.ts index ca2316646..20044b21a 100644 --- a/src/frontend/apps/desk/src/core/config/types.ts +++ b/src/frontend/apps/desk/src/core/config/types.ts @@ -1,6 +1,7 @@ export interface Config { LANGUAGES: [string, string][]; RELEASE: string; + COMMIT: string; FEATURES: { TEAMS_DISPLAY: boolean; }; diff --git a/src/frontend/apps/desk/src/features/footer/Footer.tsx b/src/frontend/apps/desk/src/features/footer/Footer.tsx index 95808c5a7..b171b5c2f 100644 --- a/src/frontend/apps/desk/src/features/footer/Footer.tsx +++ b/src/frontend/apps/desk/src/features/footer/Footer.tsx @@ -5,6 +5,8 @@ import styled from 'styled-components'; import { Box, LogoGouv, StyledLink, Text } from '@/components'; import { useConfigStore } from '@/core'; +import frontVersion from '../../../version.json'; + import IconLink from './assets/external-link.svg'; const BlueStripe = styled.div` @@ -141,6 +143,17 @@ export const Footer = () => { ))} + + You have found the hidden app version information ! Well done ! back + commit is: {config?.COMMIT}; front commit is: {frontVersion?.commit} + +