From 2307b59c2dd1c2d7eeb5cf936feda2135dd4b852 Mon Sep 17 00:00:00 2001 From: SebastienReuiller Date: Tue, 16 Jan 2024 09:36:46 +0100 Subject: [PATCH] [Wagtail] Correction du chargement des pages statiques (#1035) * fix server error on wagtail static page edition * fix failing old test --- lemarche/cms/models.py | 8 +++++--- lemarche/tenders/tests.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lemarche/cms/models.py b/lemarche/cms/models.py index 2b3c074fc..a90fc6244 100644 --- a/lemarche/cms/models.py +++ b/lemarche/cms/models.py @@ -36,10 +36,12 @@ class ArticlePage(Page): blank=True, verbose_name="Contenu de l'article", features=settings.WAGTAIL_RICHTEXT_FIELD_FEATURES ) - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) + # Override template file for static pages + def get_template(self, request, *args, **kwargs): if self.is_static_page: - self.template = f"cms/static/{self.template_name}" + return f"cms/static/{self.template_name}" + else: + return super().get_template(request, *args, **kwargs) base_form_class = ArticlePageForm diff --git a/lemarche/tenders/tests.py b/lemarche/tenders/tests.py index 54eecf1bc..7b05b6d89 100644 --- a/lemarche/tenders/tests.py +++ b/lemarche/tenders/tests.py @@ -352,7 +352,7 @@ def test_with_siae_stats(self): self.assertEqual(tender_with_siae_1.siae_email_send_count_annotated, 5) self.assertEqual(tender_with_siae_1.siae_email_link_click_count_annotated, 4) self.assertEqual(tender_with_siae_1.siae_detail_display_count_annotated, 2) - self.assertEqual(tender_with_siae_1.siae_email_link_click_or_detail_display_count_annotated, 2) + self.assertEqual(tender_with_siae_1.siae_email_link_click_or_detail_display_count_annotated, 4) self.assertEqual(tender_with_siae_1.siae_detail_contact_click_count_annotated, 1) self.assertEqual(tender_with_siae_1.siae_detail_cocontracting_click_count_annotated, 1) self.assertEqual(tender_with_siae_1.siae_detail_contact_click_since_last_seen_date_count_annotated, 1)