From 4d6decf9fcd5ad06a1f984577b681c355389ebee Mon Sep 17 00:00:00 2001 From: Mudiwa Matanda Date: Mon, 29 Jan 2024 07:58:15 +0200 Subject: [PATCH 1/3] fixed web preview --- home/templates/home/content_page.html | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/home/templates/home/content_page.html b/home/templates/home/content_page.html index e69de29b..1b908f95 100644 --- a/home/templates/home/content_page.html +++ b/home/templates/home/content_page.html @@ -0,0 +1,16 @@ +{% extends "base.html" %} +{% load wagtailcore_tags %} + +{% block body_class %}template-contentpage{% endblock %} + + +{% block content %} +

{{ page.title }}

+

{{ page.date }}

+ +
{{ page.intro }}
+ + + {% include_block page.body %} + +{% endblock %} \ No newline at end of file From 1134257c1c10b598abd481a79c9affaf96a4cbf1 Mon Sep 17 00:00:00 2001 From: Mudiwa Matanda Date: Mon, 29 Jan 2024 09:24:33 +0200 Subject: [PATCH 2/3] format fix --- home/import_content_pages.py | 6 +++--- home/wagtail_hooks.py | 8 +++++--- requirements-dev.txt | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/home/import_content_pages.py b/home/import_content_pages.py index 658be256..2f241fac 100644 --- a/home/import_content_pages.py +++ b/home/import_content_pages.py @@ -64,9 +64,9 @@ def __init__( self.locale = locale self.locale_map: dict[str, Locale] = {} self.shadow_pages: dict[PageId, ShadowContentPage] = {} - self.go_to_page_buttons: dict[ - PageId, dict[int, list[dict[str, Any]]] - ] = defaultdict(lambda: defaultdict(list)) + self.go_to_page_buttons: dict[PageId, dict[int, list[dict[str, Any]]]] = ( + defaultdict(lambda: defaultdict(list)) + ) def locale_from_display_name(self, langname: str) -> Locale: if langname not in self.locale_map: diff --git a/home/wagtail_hooks.py b/home/wagtail_hooks.py index a0319d66..1725ea14 100644 --- a/home/wagtail_hooks.py +++ b/home/wagtail_hooks.py @@ -189,9 +189,11 @@ def profile_field(self, obj): def page(self, obj): if obj.pages: return [ - p.value["contentpage"].slug - if p.value and "contentpage" in p.value - else "" + ( + p.value["contentpage"].slug + if p.value and "contentpage" in p.value + else "" + ) for p in obj.pages ] return ["-"] diff --git a/requirements-dev.txt b/requirements-dev.txt index 2e69ff69..aa631277 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,7 +1,7 @@ -black -ruff +black==24.1.1 +ruff==0.1.14 responses -pytest +pytest==8.0.0 pytest-django pytest-cov pytest-xdist From 8a5b0b710bfc207db416705dd0924f64748aa672 Mon Sep 17 00:00:00 2001 From: Mudiwa Matanda Date: Tue, 30 Jan 2024 08:52:11 +0200 Subject: [PATCH 3/3] web preview field fix + variable mismatch update --- home/models.py | 20 ++++++++++++++++++++ home/templates/home/content_page.html | 6 +----- home/tests/test_models.py | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/home/models.py b/home/models.py index b71c9513..23691989 100644 --- a/home/models.py +++ b/home/models.py @@ -865,6 +865,26 @@ def clean(self): # The variable check is only for templates if self.is_whatsapp_template and len(self.whatsapp_body.raw_data) > 0: whatsapp_message = self.whatsapp_body.raw_data[0]["value"]["message"] + + right_mismatch = re.findall(r"(?{{ page.title }} -

{{ page.date }}

- -
{{ page.intro }}
- - +

{{ page.subtitle }}

{% include_block page.body %} {% endblock %} \ No newline at end of file diff --git a/home/tests/test_models.py b/home/tests/test_models.py index dce1405d..bafab958 100644 --- a/home/tests/test_models.py +++ b/home/tests/test_models.py @@ -277,7 +277,7 @@ def test_clean_text_valid_variables(self): "WA Title", [ WABlk( - "{{2}}{{1}} {{foo}}", + "{{2}}{{1}} {{foo}} {{mismatch1} {mismatch2}}", ) ], )