From 76c28760dcfff4973d78a91192992fde40cfd0b9 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 7 May 2025 12:06:16 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5(back)=20remove=20footer=20endpoint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With the configuration file, the footer endpoint can be removed and will not be used anymore by the front application. --- CHANGELOG.md | 4 + docs/env.md | 3 - env.d/development/common.dist | 2 - env.d/development/common.e2e.dist | 1 + src/backend/core/api/viewsets.py | 2 - src/backend/core/services/config_services.py | 25 ---- src/backend/core/tests/test_api_config.py | 2 - src/backend/core/tests/test_api_footer.py | 81 ----------- src/backend/core/urls.py | 1 - src/backend/impress/settings.py | 13 -- .../apps/e2e/__tests__/app-impress/common.ts | 2 +- .../impress/public/contents/footer-demo.json | 121 ---------------- .../impress/public/contents/footer-dsfr.json | 135 ------------------ 13 files changed, 6 insertions(+), 386 deletions(-) delete mode 100644 src/backend/core/services/config_services.py delete mode 100644 src/backend/core/tests/test_api_footer.py delete mode 100644 src/frontend/apps/impress/public/contents/footer-demo.json delete mode 100644 src/frontend/apps/impress/public/contents/footer-dsfr.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 33139d2b..a9474480 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,10 @@ and this project adheres to - 📝(frontend) Update documentation - ✅(frontend) Improve tests coverage +### Removed + +- 🔥(back) remove footer endpoint + ## [3.2.1] - 2025-05-06 ## Fixed diff --git a/docs/env.md b/docs/env.md index 28c2ffe0..2b66aa21 100644 --- a/docs/env.md +++ b/docs/env.md @@ -49,9 +49,6 @@ These are the environmental variables you can set for the impress-backend contai | COLLABORATION_WS_URL | collaboration websocket url | | | FRONTEND_CSS_URL | To add a external css file to the app | | | FRONTEND_HOMEPAGE_FEATURE_ENABLED | frontend feature flag to display the homepage | false | -| FRONTEND_FOOTER_FEATURE_ENABLED | frontend feature flag to display the footer | false | -| FRONTEND_FOOTER_VIEW_CACHE_TIMEOUT | Cache duration of the json footer | 86400 | -| FRONTEND_URL_JSON_FOOTER | Url with a json to configure the footer | | | FRONTEND_THEME | frontend theme to use | | | POSTHOG_KEY | posthog key for analytics | | | CRISP_WEBSITE_ID | crisp website id for support | | diff --git a/env.d/development/common.dist b/env.d/development/common.dist index 451a40a7..4b1389bf 100644 --- a/env.d/development/common.dist +++ b/env.d/development/common.dist @@ -64,5 +64,3 @@ COLLABORATION_WS_URL=ws://localhost:4444/collaboration/ws/ # Frontend FRONTEND_THEME=default -FRONTEND_FOOTER_FEATURE_ENABLED=True -FRONTEND_URL_JSON_FOOTER=http://frontend:3000/contents/footer-demo.json diff --git a/env.d/development/common.e2e.dist b/env.d/development/common.e2e.dist index 747b9a9d..94322d0f 100644 --- a/env.d/development/common.e2e.dist +++ b/env.d/development/common.e2e.dist @@ -4,3 +4,4 @@ BURST_THROTTLE_RATES="200/minute" DJANGO_SERVER_TO_SERVER_API_TOKENS=test-e2e Y_PROVIDER_API_KEY=yprovider-api-key Y_PROVIDER_API_BASE_URL=http://y-provider:4444/api/ +THEME_CUSTOMIZATION_FILE_PATH="" #force theme_customization to be empty \ No newline at end of file diff --git a/src/backend/core/api/viewsets.py b/src/backend/core/api/viewsets.py index 9b4115d0..45bc9bc8 100644 --- a/src/backend/core/api/viewsets.py +++ b/src/backend/core/api/viewsets.py @@ -33,7 +33,6 @@ from rest_framework.throttling import UserRateThrottle from core import authentication, enums, models from core.services.ai_services import AIService from core.services.collaboration_services import CollaborationService -from core.services.config_services import get_footer_json from core.utils import extract_attachments, filter_descendants from . import permissions, serializers, utils @@ -1734,7 +1733,6 @@ class ConfigView(drf.views.APIView): "ENVIRONMENT", "FRONTEND_CSS_URL", "FRONTEND_HOMEPAGE_FEATURE_ENABLED", - "FRONTEND_FOOTER_FEATURE_ENABLED", "FRONTEND_THEME", "MEDIA_BASE_URL", "POSTHOG_KEY", diff --git a/src/backend/core/services/config_services.py b/src/backend/core/services/config_services.py deleted file mode 100644 index f4efa946..00000000 --- a/src/backend/core/services/config_services.py +++ /dev/null @@ -1,25 +0,0 @@ -"""Config services.""" - -import logging - -import requests - -logger = logging.getLogger(__name__) - - -def get_footer_json(footer_json_url: str) -> dict: - """ - Fetches the footer JSON from the given URL." - """ - try: - response = requests.get( - footer_json_url, timeout=5, headers={"User-Agent": "Docs-Application"} - ) - response.raise_for_status() - - footer_json = response.json() - - return footer_json - except (requests.RequestException, ValueError) as e: - logger.error("Failed to fetch footer JSON: %s", e) - return {} diff --git a/src/backend/core/tests/test_api_config.py b/src/backend/core/tests/test_api_config.py index e67b70c3..b91b48f4 100644 --- a/src/backend/core/tests/test_api_config.py +++ b/src/backend/core/tests/test_api_config.py @@ -21,7 +21,6 @@ pytestmark = pytest.mark.django_db COLLABORATION_WS_URL="http://testcollab/", CRISP_WEBSITE_ID="123", FRONTEND_CSS_URL="http://testcss/", - FRONTEND_FOOTER_FEATURE_ENABLED=True, FRONTEND_THEME="test-theme", MEDIA_BASE_URL="http://testserver/", POSTHOG_KEY={"id": "132456", "host": "https://eu.i.posthog-test.com"}, @@ -45,7 +44,6 @@ def test_api_config(is_authenticated): "ENVIRONMENT": "test", "FRONTEND_CSS_URL": "http://testcss/", "FRONTEND_HOMEPAGE_FEATURE_ENABLED": True, - "FRONTEND_FOOTER_FEATURE_ENABLED": True, "FRONTEND_THEME": "test-theme", "LANGUAGES": [ ["en-us", "English"], diff --git a/src/backend/core/tests/test_api_footer.py b/src/backend/core/tests/test_api_footer.py deleted file mode 100644 index 8dd892cd..00000000 --- a/src/backend/core/tests/test_api_footer.py +++ /dev/null @@ -1,81 +0,0 @@ -"""Test the footer API.""" - -import responses -from rest_framework.test import APIClient - - -def test_api_footer_without_settings_configured(settings): - """Test the footer API without settings configured.""" - settings.FRONTEND_URL_JSON_FOOTER = None - client = APIClient() - response = client.get("/api/v1.0/footer/") - assert response.status_code == 200 - assert response.json() == {} - - -@responses.activate -def test_api_footer_with_invalid_request(settings): - """Test the footer API with an invalid request.""" - settings.FRONTEND_URL_JSON_FOOTER = "https://invalid-request.com" - - footer_response = responses.get(settings.FRONTEND_URL_JSON_FOOTER, status=404) - - client = APIClient() - response = client.get("/api/v1.0/footer/") - assert response.status_code == 200 - assert response.json() == {} - assert footer_response.call_count == 1 - - -@responses.activate -def test_api_footer_with_invalid_json(settings): - """Test the footer API with an invalid JSON response.""" - settings.FRONTEND_URL_JSON_FOOTER = "https://valid-request.com" - - footer_response = responses.get( - settings.FRONTEND_URL_JSON_FOOTER, status=200, body="invalid json" - ) - - client = APIClient() - response = client.get("/api/v1.0/footer/") - assert response.status_code == 200 - assert response.json() == {} - assert footer_response.call_count == 1 - - -@responses.activate -def test_api_footer_with_valid_json(settings): - """Test the footer API with an invalid JSON response.""" - settings.FRONTEND_URL_JSON_FOOTER = "https://valid-request.com" - - footer_response = responses.get( - settings.FRONTEND_URL_JSON_FOOTER, status=200, json={"foo": "bar"} - ) - - client = APIClient() - response = client.get("/api/v1.0/footer/") - assert response.status_code == 200 - assert response.json() == {"foo": "bar"} - assert footer_response.call_count == 1 - - -@responses.activate -def test_api_footer_with_valid_json_and_cache(settings): - """Test the footer API with an invalid JSON response.""" - settings.FRONTEND_URL_JSON_FOOTER = "https://valid-request.com" - - footer_response = responses.get( - settings.FRONTEND_URL_JSON_FOOTER, status=200, json={"foo": "bar"} - ) - - client = APIClient() - response = client.get("/api/v1.0/footer/") - assert response.status_code == 200 - assert response.json() == {"foo": "bar"} - assert footer_response.call_count == 1 - - response = client.get("/api/v1.0/footer/") - assert response.status_code == 200 - assert response.json() == {"foo": "bar"} - # The cache should have been used - assert footer_response.call_count == 1 diff --git a/src/backend/core/urls.py b/src/backend/core/urls.py index 9f568dec..05441895 100644 --- a/src/backend/core/urls.py +++ b/src/backend/core/urls.py @@ -56,5 +56,4 @@ urlpatterns = [ ), ), path(f"api/{settings.API_VERSION}/config/", viewsets.ConfigView.as_view()), - path(f"api/{settings.API_VERSION}/footer/", viewsets.FooterView.as_view()), ] diff --git a/src/backend/impress/settings.py b/src/backend/impress/settings.py index 120f0445..7ab73250 100755 --- a/src/backend/impress/settings.py +++ b/src/backend/impress/settings.py @@ -423,19 +423,6 @@ class Base(Configuration): environ_name="FRONTEND_HOMEPAGE_FEATURE_ENABLED", environ_prefix=None, ) - FRONTEND_URL_JSON_FOOTER = values.Value( - None, environ_name="FRONTEND_URL_JSON_FOOTER", environ_prefix=None - ) - FRONTEND_FOOTER_FEATURE_ENABLED = values.BooleanValue( - default=False, - environ_name="FRONTEND_FOOTER_FEATURE_ENABLED", - environ_prefix=None, - ) - FRONTEND_FOOTER_VIEW_CACHE_TIMEOUT = values.Value( - 60 * 60 * 24, - environ_name="FRONTEND_FOOTER_VIEW_CACHE_TIMEOUT", - environ_prefix=None, - ) FRONTEND_CSS_URL = values.Value( None, environ_name="FRONTEND_CSS_URL", environ_prefix=None ) diff --git a/src/frontend/apps/e2e/__tests__/app-impress/common.ts b/src/frontend/apps/e2e/__tests__/app-impress/common.ts index 9a638fa9..8217dc1b 100644 --- a/src/frontend/apps/e2e/__tests__/app-impress/common.ts +++ b/src/frontend/apps/e2e/__tests__/app-impress/common.ts @@ -7,7 +7,6 @@ export const CONFIG = { ENVIRONMENT: 'development', FRONTEND_CSS_URL: null, FRONTEND_HOMEPAGE_FEATURE_ENABLED: true, - FRONTEND_FOOTER_FEATURE_ENABLED: true, FRONTEND_THEME: 'default', MEDIA_BASE_URL: 'http://localhost:8083', LANGUAGES: [ @@ -20,6 +19,7 @@ export const CONFIG = { LANGUAGE_CODE: 'en-us', POSTHOG_KEY: {}, SENTRY_DSN: null, + theme_customization: {}, }; export const keyCloakSignIn = async ( diff --git a/src/frontend/apps/impress/public/contents/footer-demo.json b/src/frontend/apps/impress/public/contents/footer-demo.json deleted file mode 100644 index 77d9ed9f..00000000 --- a/src/frontend/apps/impress/public/contents/footer-demo.json +++ /dev/null @@ -1,121 +0,0 @@ -{ - "default": { - "externalLinks": [ - { - "label": "Github", - "href": "https://github.com/suitenumerique/docs/" - }, - { - "label": "DINUM", - "href": "https://www.numerique.gouv.fr/dinum/" - }, - { - "label": "ZenDiS", - "href": "https://zendis.de/" - }, - { - "label": "BlockNote.js", - "href": "https://www.blocknotejs.org/" - } - ], - "bottomInformation": { - "label": "Unless otherwise stated, all content on this site is under", - "link": { - "label": "licence etalab-2.0", - "href": "https://github.com/etalab/licence-ouverte/blob/master/LO.md" - } - } - }, - "en": { - "legalLinks": [ - { - "label": "Legal Notice", - "href": "#" - }, - { - "label": "Personal data and cookies", - "href": "#" - }, - { - "label": "Accessibility", - "href": "#" - } - ], - "bottomInformation": { - "label": "Unless otherwise stated, all content on this site is under", - "link": { - "label": "licence MIT", - "href": "https://github.com/suitenumerique/docs/blob/main/LICENSE" - } - } - }, - "fr": { - "legalLinks": [ - { - "label": "Mentions légales", - "href": "#" - }, - { - "label": "Données personnelles et cookies", - "href": "#" - }, - { - "label": "Accessibilité", - "href": "#" - } - ], - "bottomInformation": { - "label": "Sauf mention contraire, tout le contenu de ce site est sous", - "link": { - "label": "licence MIT", - "href": "https://github.com/suitenumerique/docs/blob/main/LICENSE" - } - } - }, - "de": { - "legalLinks": [ - { - "label": "Impressum", - "href": "#" - }, - { - "label": "Personenbezogene Daten und Cookies", - "href": "#" - }, - { - "label": "Barrierefreiheit", - "href": "#" - } - ], - "bottomInformation": { - "label": "Sofern nicht anders angegeben, steht der gesamte Inhalt dieser Website unter", - "link": { - "label": "licence MIT", - "href": "https://github.com/suitenumerique/docs/blob/main/LICENSE" - } - } - }, - "nl": { - "legalLinks": [ - { - "label": "Wettelijke bepalingen", - "href": "#" - }, - { - "label": "Persoonlijke gegevens en cookies", - "href": "#" - }, - { - "label": "Toegankelijkheid", - "href": "#" - } - ], - "bottomInformation": { - "label": "Tenzij anders vermeld, is alle inhoud van deze site ondergebracht onder", - "link": { - "label": "licence MIT", - "href": "https://github.com/suitenumerique/docs/blob/main/LICENSE" - } - } - } -} diff --git a/src/frontend/apps/impress/public/contents/footer-dsfr.json b/src/frontend/apps/impress/public/contents/footer-dsfr.json deleted file mode 100644 index fd6d8a8a..00000000 --- a/src/frontend/apps/impress/public/contents/footer-dsfr.json +++ /dev/null @@ -1,135 +0,0 @@ -{ - "default": { - "externalLinks": [ - { - "label": "legifrance.gouv.fr", - "href": "https://legifrance.gouv.fr/" - }, - { - "label": "info.gouv.fr", - "href": "https://info.gouv.fr/" - }, - { - "label": "service-public.fr", - "href": "https://service-public.fr/" - }, - { - "label": "data.gouv.fr", - "href": "https://data.gouv.fr/" - } - ], - "legalLinks": [ - { - "label": "Legal Notice", - "href": "https://docs.numerique.gouv.fr/docs/4db744e3-5b47-4ed9-b9e7-d4312318bbce/" - }, - { - "label": "Personal data and cookies", - "href": "https://docs.numerique.gouv.fr/docs/eb863389-a5e5-4d18-879d-149a1122380e/" - }, - { - "label": "Accessibility", - "href": "https://docs.numerique.gouv.fr/docs/9694e570-1427-4ef7-b0a0-c3e894360e1b/" - } - ], - "bottomInformation": { - "label": "Unless otherwise stated, all content on this site is under", - "link": { - "label": "licence etalab-2.0", - "href": "https://github.com/etalab/licence-ouverte/blob/master/LO.md" - } - } - }, - "en": { - "legalLinks": [ - { - "label": "Legal Notice", - "href": "https://docs.numerique.gouv.fr/docs/4db744e3-5b47-4ed9-b9e7-d4312318bbce/" - }, - { - "label": "Personal data and cookies", - "href": "https://docs.numerique.gouv.fr/docs/eb863389-a5e5-4d18-879d-149a1122380e/" - }, - { - "label": "Accessibility", - "href": "https://docs.numerique.gouv.fr/docs/9694e570-1427-4ef7-b0a0-c3e894360e1b/" - } - ], - "bottomInformation": { - "label": "Unless otherwise stated, all content on this site is under", - "link": { - "label": "licence etalab-2.0", - "href": "https://github.com/etalab/licence-ouverte/blob/master/LO.md" - } - } - }, - "fr": { - "legalLinks": [ - { - "label": "Mentions légales", - "href": "https://docs.numerique.gouv.fr/docs/4db744e3-5b47-4ed9-b9e7-d4312318bbce/" - }, - { - "label": "Données personnelles et cookies", - "href": "https://docs.numerique.gouv.fr/docs/eb863389-a5e5-4d18-879d-149a1122380e/" - }, - { - "label": "Accessibilité", - "href": "https://docs.numerique.gouv.fr/docs/9694e570-1427-4ef7-b0a0-c3e894360e1b/" - } - ], - "bottomInformation": { - "label": "Sauf mention contraire, tout le contenu de ce site est sous", - "link": { - "label": "licence etalab-2.0", - "href": "https://github.com/etalab/licence-ouverte/blob/master/LO.md" - } - } - }, - "de": { - "legalLinks": [ - { - "label": "Impressum", - "href": "https://docs.numerique.gouv.fr/docs/4db744e3-5b47-4ed9-b9e7-d4312318bbce/" - }, - { - "label": "Personenbezogene Daten und Cookies", - "href": "https://docs.numerique.gouv.fr/docs/eb863389-a5e5-4d18-879d-149a1122380e/" - }, - { - "label": "Barrierefreiheit", - "href": "https://docs.numerique.gouv.fr/docs/9694e570-1427-4ef7-b0a0-c3e894360e1b/" - } - ], - "bottomInformation": { - "label": "Sofern nicht anders angegeben, steht der gesamte Inhalt dieser Website unter", - "link": { - "label": "licence etalab-2.0", - "href": "https://github.com/etalab/licence-ouverte/blob/master/LO.md" - } - } - }, - "nl": { - "legalLinks": [ - { - "label": "Wettelijke bepalingen", - "href": "https://docs.numerique.gouv.fr/docs/4db744e3-5b47-4ed9-b9e7-d4312318bbce/" - }, - { - "label": "Persoonlijke gegevens en cookies", - "href": "https://docs.numerique.gouv.fr/docs/eb863389-a5e5-4d18-879d-149a1122380e/" - }, - { - "label": "Toegankelijkheid", - "href": "https://docs.numerique.gouv.fr/docs/9694e570-1427-4ef7-b0a0-c3e894360e1b/" - } - ], - "bottomInformation": { - "label": "Tenzij anders vermeld, is alle inhoud van deze site ondergebracht onder", - "link": { - "label": "licence etalab-2.0", - "href": "https://github.com/etalab/licence-ouverte/blob/master/LO.md" - } - } - } -}