From aa05639d4a8cf7424c02c94bae34cb6c84e88c50 Mon Sep 17 00:00:00 2001 From: Chris Lawton Date: Thu, 13 Jun 2024 16:38:09 +0100 Subject: [PATCH 01/59] first pass at search widget without image --- .../search-widget/search-widget.html | 24 ++++++++++ .../sass/components/_search-widget.scss | 46 +++++++++++++++++++ bc/static_src/sass/main.scss | 1 + 3 files changed, 71 insertions(+) create mode 100644 bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html create mode 100644 bc/static_src/sass/components/_search-widget.scss diff --git a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html new file mode 100644 index 00000000..ed6fe805 --- /dev/null +++ b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html @@ -0,0 +1,24 @@ +{% load wagtailimages_tags %} +
+

{{ title|default:"Find activities and organisations near you" }}

+
+
+
+ + +
+ +
+ + +
+
+ +
+ {% if image %} + {% image image fill-300x300 %} + {% endif %} +
diff --git a/bc/static_src/sass/components/_search-widget.scss b/bc/static_src/sass/components/_search-widget.scss new file mode 100644 index 00000000..22981bb9 --- /dev/null +++ b/bc/static_src/sass/components/_search-widget.scss @@ -0,0 +1,46 @@ +.search-widget { + background-color: $color--river; + color: $color--white; + padding: 30px; + width: 100%; + max-width: 650px; + + &--with-image { + display: grid; + grid-template-columns: 2fr 1fr; + grid-gap: $grid; + max-width: 100%; + } + + &__heading { + margin-top: 0; + } + + &__button { + margin-top: 20px; + + svg { + fill: transparent; + stroke: $color--slate; + width: 20px; + height: 20px; + margin-right: 7px; + } + } + + &__form-layout { + display: grid; + grid-template-columns: 1fr 1fr; + grid-gap: $grid--small; + } + + &__label { + display: block; + margin-bottom: 2px; + } + + &__input { + padding: 5px; + width: 100%; + } +} diff --git a/bc/static_src/sass/main.scss b/bc/static_src/sass/main.scss index 6edc2199..d58526eb 100755 --- a/bc/static_src/sass/main.scss +++ b/bc/static_src/sass/main.scss @@ -69,6 +69,7 @@ @import 'components/search-header'; @import 'components/search-prompt'; @import 'components/search-result'; +@import 'components/search-widget'; @import 'components/section'; @import 'components/split-content'; @import 'components/skip-link'; From 49fc943f70ce73c92e71d301c8f86acd6352dfa4 Mon Sep 17 00:00:00 2001 From: Chris Lawton Date: Thu, 13 Jun 2024 17:01:43 +0100 Subject: [PATCH 02/59] add the image --- .../organisms/search-widget/search-widget.html | 11 +++++++---- .../organisms/search-widget/search-widget.yaml | 8 ++++++++ bc/static_src/sass/components/_search-widget.scss | 5 ++++- 3 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml diff --git a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html index ed6fe805..4ee4d33c 100644 --- a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html +++ b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html @@ -1,11 +1,11 @@ {% load wagtailimages_tags %}
-

{{ title|default:"Find activities and organisations near you" }}

-
+ +

{{ title|default:"Find activities and organisations near you" }}

- +
@@ -19,6 +19,9 @@

{{ title|default:"Find act {% if image %} - {% image image fill-300x300 %} +
+ + {% image image fill-500x500 %} +
{% endif %}

diff --git a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml new file mode 100644 index 00000000..6621fb14 --- /dev/null +++ b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml @@ -0,0 +1,8 @@ +context: + image: true + +tags: + image: + image fill-500x500: + raw: | + diff --git a/bc/static_src/sass/components/_search-widget.scss b/bc/static_src/sass/components/_search-widget.scss index 22981bb9..599d4713 100644 --- a/bc/static_src/sass/components/_search-widget.scss +++ b/bc/static_src/sass/components/_search-widget.scss @@ -1,7 +1,6 @@ .search-widget { background-color: $color--river; color: $color--white; - padding: 30px; width: 100%; max-width: 650px; @@ -12,6 +11,10 @@ max-width: 100%; } + &__form { + padding: 30px; + } + &__heading { margin-top: 0; } From 23c26cb2d15e1281139a4020e9273ac6dc3afe85 Mon Sep 17 00:00:00 2001 From: Chris Lawton Date: Fri, 14 Jun 2024 09:27:47 +0100 Subject: [PATCH 03/59] tidy up desktop layout --- .../organisms/search-widget/search-widget.html | 11 ++++------- .../organisms/search-widget/search-widget.yaml | 4 ++-- bc/static_src/sass/components/_search-widget.scss | 12 +++++++++--- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html index 4ee4d33c..40351bec 100644 --- a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html +++ b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html @@ -5,23 +5,20 @@

{{ title|default:"Find act
- +
- +
{% if image %} -
- - {% image image fill-500x500 %} -
+ {% image image fill-300x270 class="search-widget__image" %} {% endif %}

diff --git a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml index 6621fb14..9fd28513 100644 --- a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml +++ b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml @@ -3,6 +3,6 @@ context: tags: image: - image fill-500x500: + image fill-300x270 class="search-widget__image": raw: | - + diff --git a/bc/static_src/sass/components/_search-widget.scss b/bc/static_src/sass/components/_search-widget.scss index 599d4713..2de53d39 100644 --- a/bc/static_src/sass/components/_search-widget.scss +++ b/bc/static_src/sass/components/_search-widget.scss @@ -3,6 +3,7 @@ color: $color--white; width: 100%; max-width: 650px; + margin-bottom: $grid; &--with-image { display: grid; @@ -16,7 +17,7 @@ } &__heading { - margin-top: 0; + margin: 0 0 $grid--small; } &__button { @@ -25,8 +26,8 @@ svg { fill: transparent; stroke: $color--slate; - width: 20px; - height: 20px; + width: 18px; + height: 18px; margin-right: 7px; } } @@ -43,7 +44,12 @@ } &__input { + @include font-size(s); padding: 5px; width: 100%; } + + &__image { + margin-left: auto; + } } From e55b6dd51c9f74ea60ce86135ff53077ad24bf6d Mon Sep 17 00:00:00 2001 From: Chris Lawton Date: Fri, 14 Jun 2024 09:44:33 +0100 Subject: [PATCH 04/59] mobile layout + hide image at tablet portrait --- .../sass/components/_search-widget.scss | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/bc/static_src/sass/components/_search-widget.scss b/bc/static_src/sass/components/_search-widget.scss index 2de53d39..a3b41b30 100644 --- a/bc/static_src/sass/components/_search-widget.scss +++ b/bc/static_src/sass/components/_search-widget.scss @@ -6,14 +6,21 @@ margin-bottom: $grid; &--with-image { - display: grid; - grid-template-columns: 2fr 1fr; - grid-gap: $grid; max-width: 100%; + + @include media-query(tablet-landscape) { + display: grid; + grid-template-columns: 2fr 1fr; + grid-gap: $grid; + } } &__form { - padding: 30px; + padding: 20px; + + @include media-query(tablet-landscape) { + padding: 30px; + } } &__heading { @@ -29,13 +36,18 @@ width: 18px; height: 18px; margin-right: 7px; + flex-shrink: 0; } } &__form-layout { display: grid; - grid-template-columns: 1fr 1fr; grid-gap: $grid--small; + + @include media-query(tablet-portrait) { + grid-template-columns: 1fr 1fr; + align-items: flex-end; + } } &__label { @@ -47,9 +59,19 @@ @include font-size(s); padding: 5px; width: 100%; + max-width: 320px; + + @include media-query(tablet-portrait) { + max-width: 100%; + } } &__image { - margin-left: auto; + display: none; + + @include media-query(tablet-landscape) { + margin-left: auto; + display: block; + } } } From c8959d13f2951d21f14a0552eb1665378b83896e Mon Sep 17 00:00:00 2001 From: Chris Lawton Date: Fri, 14 Jun 2024 10:25:54 +0100 Subject: [PATCH 05/59] serve a retina image for desktop --- .../templates/patterns/atoms/image/image.html | 2 +- .../organisms/search-widget/search-widget.html | 5 ++++- .../organisms/search-widget/search-widget.yaml | 11 ++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/bc/project_styleguide/templates/patterns/atoms/image/image.html b/bc/project_styleguide/templates/patterns/atoms/image/image.html index 2b1e8928..9e91cb8c 100644 --- a/bc/project_styleguide/templates/patterns/atoms/image/image.html +++ b/bc/project_styleguide/templates/patterns/atoms/image/image.html @@ -1,5 +1,5 @@ - {{ alt }} + {{ alt }} diff --git a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html index 40351bec..682f222e 100644 --- a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html +++ b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html @@ -19,6 +19,9 @@

{{ title|default:"Find act {% if image %} - {% image image fill-300x270 class="search-widget__image" %} + {% image image fill-300x270 as mobile_image %} + {% image image fill-600x540 as retina_mobile_image %} + + {% include "patterns/atoms/image/image.html" with mobile_image=mobile_image retina_mobile_image=retina_mobile_image desktop_image=retina_mobile_image alt="" classes="search-widget__image" %} {% endif %}

diff --git a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml index 9fd28513..7956600d 100644 --- a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml +++ b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml @@ -3,6 +3,11 @@ context: tags: image: - image fill-300x270 class="search-widget__image": - raw: | - + image fill-300x270 as mobile_image: + target_var: mobile_image + raw: + url: https://picsum.photos/300/270.webp + image fill-600x540 as retina_mobile_image: + target_var: retina_mobile_image + raw: + url: https://picsum.photos/600/540.webp From c7a7438b8e5d2fe51abbb32e67482ce016e7f453 Mon Sep 17 00:00:00 2001 From: Chris Lawton Date: Fri, 14 Jun 2024 11:12:22 +0100 Subject: [PATCH 06/59] add the search widget to the fis home page in the pattern library --- .../patterns/pages/home/home_page--fis.html | 5 ++++ .../patterns/pages/home/home_page--fis.yaml | 25 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.html b/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.html index 9325e4e6..74113591 100644 --- a/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.html +++ b/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.html @@ -50,6 +50,11 @@

+ {# TODO: Remove directory-banner.html when search-widget.html is ready for use and remove conditional #} + {% if page.search_widget_image %} + {% include "patterns/organisms/search-widget/search-widget.html" with image=page.search_widget_image %} + {% endif %} + {% include "patterns/molecules/directory-banner/directory-banner.html" with classes="directory-banner--with-space" %} {% include "patterns/molecules/cta/call_to_action.html" with call_to_action=page.call_to_action %} diff --git a/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.yaml b/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.yaml index 55d0bea3..f7d35712 100644 --- a/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.yaml +++ b/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.yaml @@ -1,6 +1,7 @@ context: base_page_template: 'patterns/base_page--fis.html' page: + search_widget_image: true call_to_action: title: Stub content summary: Check out our awesome stub content @@ -26,6 +27,19 @@ context: listing_summary: Get help with finding childcare and early education funding - listing_title: Information, advice and support listing_summary: Parenting support, help for carers and other advice for families + child_pages: + - title: Childcare and early years + listing_summary: Get help with finding childcare and early education funding + - title: Information, advice and support + listing_summary: Parenting support, help for carers and other advice for families + - title: Young people (13 to 25 years old) + listing_summary: Support for young people, including work and education + - title: Family centres and support + listing_summary: Find family centres and contact the Family Support Service + - title: Special education needs and disabilities + listing_summary: Our local offer supports children and young people with SEND + - title: Things to do + listing_summary: Search our directory for activities and events near you tags: image: @@ -45,8 +59,19 @@ tags: target_var: retina_mobile_image raw: url: https://placekitten.com/g/900/700 + image fill-300x270 as mobile_image: + target_var: mobile_image + raw: + url: https://picsum.photos/300/270.webp + image fill-600x540 as retina_mobile_image: + target_var: retina_mobile_image + raw: + url: https://picsum.photos/600/540.webp + pageurl: block.value.page: raw: '#' subpage: raw: '#' + block.value.page: + raw: '#' From 67b2295b1b12fd70bfc09c574c0cca0d80ab1a4c Mon Sep 17 00:00:00 2001 From: Jane Date: Thu, 27 Jun 2024 10:26:31 +0100 Subject: [PATCH 07/59] update styling to match latest designs --- .../search-widget/search-widget.html | 30 ++++++-------- .../search-widget/search-widget.yaml | 15 ++----- bc/static_src/sass/abstracts/_variables.scss | 1 + .../sass/components/_search-widget.scss | 40 ++++++------------- 4 files changed, 30 insertions(+), 56 deletions(-) diff --git a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html index 682f222e..843a752a 100644 --- a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html +++ b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html @@ -1,27 +1,23 @@ {% load wagtailimages_tags %} -
-
-

{{ title|default:"Find activities and organisations near you" }}

+ +
+ +

{{ title|default:"Find activities and organisations near you" }}

- - + +
- - + +
+ +
- - {% if image %} - {% image image fill-300x270 as mobile_image %} - {% image image fill-600x540 as retina_mobile_image %} - - {% include "patterns/atoms/image/image.html" with mobile_image=mobile_image retina_mobile_image=retina_mobile_image desktop_image=retina_mobile_image alt="" classes="search-widget__image" %} - {% endif %}
diff --git a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml index 7956600d..c6ef9317 100644 --- a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml +++ b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml @@ -1,13 +1,4 @@ context: - image: true - -tags: - image: - image fill-300x270 as mobile_image: - target_var: mobile_image - raw: - url: https://picsum.photos/300/270.webp - image fill-600x540 as retina_mobile_image: - target_var: retina_mobile_image - raw: - url: https://picsum.photos/600/540.webp + search_label: Search activities and services + location_label: Enter town/postcode + cta_label: Search directory \ No newline at end of file diff --git a/bc/static_src/sass/abstracts/_variables.scss b/bc/static_src/sass/abstracts/_variables.scss index ead592db..8ddee4d6 100755 --- a/bc/static_src/sass/abstracts/_variables.scss +++ b/bc/static_src/sass/abstracts/_variables.scss @@ -9,6 +9,7 @@ $color--red: #d4351c; $color--border: rgba($color--off-black, 0.2); $color--river: #2c2d84; +$color--river-tint: #dfe0ed; // 15% tint of $color--river $color--lake: #233b8e; $color--sky: #006ab4; $color--grape: #3e2d73; diff --git a/bc/static_src/sass/components/_search-widget.scss b/bc/static_src/sass/components/_search-widget.scss index a3b41b30..88cfce58 100644 --- a/bc/static_src/sass/components/_search-widget.scss +++ b/bc/static_src/sass/components/_search-widget.scss @@ -1,21 +1,12 @@ .search-widget { - background-color: $color--river; - color: $color--white; + background-color: $color--river-tint; + border-left: 5px solid $color--river; + color: $color--default; width: 100%; - max-width: 650px; margin-bottom: $grid; - &--with-image { - max-width: 100%; - - @include media-query(tablet-landscape) { - display: grid; - grid-template-columns: 2fr 1fr; - grid-gap: $grid; - } - } - &__form { + max-width: $site-width; padding: 20px; @include media-query(tablet-landscape) { @@ -28,14 +19,16 @@ } &__button { - margin-top: 20px; + margin-top: 10px; + flex-grow: 0; + max-width: max-content; svg { fill: transparent; - stroke: $color--slate; + stroke: $color--white; width: 18px; height: 18px; - margin-right: 7px; + margin-right: 10px; flex-shrink: 0; } } @@ -44,8 +37,8 @@ display: grid; grid-gap: $grid--small; - @include media-query(tablet-portrait) { - grid-template-columns: 1fr 1fr; + @include media-query(tablet-landscape) { + grid-template-columns: 1fr 1fr 1fr; align-items: flex-end; } } @@ -57,6 +50,8 @@ &__input { @include font-size(s); + border-radius: 0; + border: 1px solid $color--default; padding: 5px; width: 100%; max-width: 320px; @@ -65,13 +60,4 @@ max-width: 100%; } } - - &__image { - display: none; - - @include media-query(tablet-landscape) { - margin-left: auto; - display: block; - } - } } From 445e24d24e669172745b76d7de1db0bb1d04c311 Mon Sep 17 00:00:00 2001 From: Jane Date: Thu, 27 Jun 2024 10:33:18 +0100 Subject: [PATCH 08/59] update fis homepage include for search widget --- .../templates/patterns/pages/home/home_page--fis.html | 4 ++-- .../templates/patterns/pages/home/home_page--fis.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.html b/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.html index 74113591..736bd5c6 100644 --- a/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.html +++ b/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.html @@ -51,8 +51,8 @@

{# TODO: Remove directory-banner.html when search-widget.html is ready for use and remove conditional #} - {% if page.search_widget_image %} - {% include "patterns/organisms/search-widget/search-widget.html" with image=page.search_widget_image %} + {% if page.search_widget %} + {% include "patterns/organisms/search-widget/search-widget.html" %} {% endif %} {% include "patterns/molecules/directory-banner/directory-banner.html" with classes="directory-banner--with-space" %} diff --git a/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.yaml b/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.yaml index f7d35712..132820d5 100644 --- a/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.yaml +++ b/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.yaml @@ -1,7 +1,7 @@ context: base_page_template: 'patterns/base_page--fis.html' page: - search_widget_image: true + search_widget: true call_to_action: title: Stub content summary: Check out our awesome stub content From bfd908f9ead9b1d0fc2a06c8c99d41bb2326a731 Mon Sep 17 00:00:00 2001 From: Jane Date: Thu, 27 Jun 2024 10:44:29 +0100 Subject: [PATCH 09/59] linting --- .../patterns/organisms/search-widget/search-widget.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml index c6ef9317..a7f4a227 100644 --- a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml +++ b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml @@ -1,4 +1,4 @@ context: search_label: Search activities and services location_label: Enter town/postcode - cta_label: Search directory \ No newline at end of file + cta_label: Search directory From ca82467418b41ed7c1262f623e92321abf2fd9d8 Mon Sep 17 00:00:00 2001 From: Shohan Dutta Roy Date: Fri, 28 Jun 2024 00:42:06 +0530 Subject: [PATCH 10/59] feat(directory_widget): Add directory widget block in all streamfields and autocomplete functionality for location service --- .../0018_add_fis_directory_widget.py | 1211 +++++++++++ .../0025_add_fis_directory_widget.py | 629 ++++++ .../0033_add_fis_directory_widget.py | 615 ++++++ .../0011_add_fis_directory_widget.py | 202 ++ bc/family_information/models.py | 25 +- .../0035_add_fis_directory_widget.py | 1211 +++++++++++ .../0016_add_fis_directory_widget.py | 1811 +++++++++++++++++ .../0029_add_fis_directory_widget.py | 1276 ++++++++++++ .../0034_add_fis_directory_widget.py | 615 ++++++ .../location-autocomplete.html | 5 + .../streamfield/blocks/search-widget.html | 1 + .../search-widget/search-widget.html | 21 +- .../search-widget/search-widget.yaml | 4 - .../patterns/pages/home/home_page--fis.html | 5 +- .../standardpages/index_page--fis-cat1.html | 4 + .../standardpages/index_page--fis-cat2.html | 4 + .../0064_add_fis_directory_widget.py | 616 ++++++ .../0041_add_fis_directory_widget.py | 1212 +++++++++++ .../components/location-autocomplete.js | 209 ++ bc/static_src/javascript/main.js | 7 + .../components/_location-autocomplete.scss | 25 + .../sass/components/_search-widget.scss | 5 + bc/static_src/sass/main.scss | 1 + bc/utils/blocks.py | 34 + 24 files changed, 9731 insertions(+), 17 deletions(-) create mode 100644 bc/blogs/migrations/0018_add_fis_directory_widget.py create mode 100644 bc/cases/migrations/0025_add_fis_directory_widget.py create mode 100644 bc/events/migrations/0033_add_fis_directory_widget.py create mode 100644 bc/family_information/migrations/0011_add_fis_directory_widget.py create mode 100644 bc/inlineindex/migrations/0035_add_fis_directory_widget.py create mode 100644 bc/location/migrations/0016_add_fis_directory_widget.py create mode 100644 bc/longform/migrations/0029_add_fis_directory_widget.py create mode 100644 bc/news/migrations/0034_add_fis_directory_widget.py create mode 100644 bc/project_styleguide/templates/patterns/molecules/location-autocomplete/location-autocomplete.html create mode 100644 bc/project_styleguide/templates/patterns/molecules/streamfield/blocks/search-widget.html create mode 100644 bc/recruitment/migrations/0064_add_fis_directory_widget.py create mode 100644 bc/standardpages/migrations/0041_add_fis_directory_widget.py create mode 100644 bc/static_src/javascript/components/location-autocomplete.js create mode 100644 bc/static_src/sass/components/_location-autocomplete.scss diff --git a/bc/blogs/migrations/0018_add_fis_directory_widget.py b/bc/blogs/migrations/0018_add_fis_directory_widget.py new file mode 100644 index 00000000..fcfdf42b --- /dev/null +++ b/bc/blogs/migrations/0018_add_fis_directory_widget.py @@ -0,0 +1,1211 @@ +# Generated by Django 4.2.11 on 2024-06-27 18:39 + +import bc.utils.blocks +from django.db import migrations +import wagtail.blocks +import wagtail.contrib.typed_table_block.blocks +import wagtail.embeds.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ("blogs", "0017_tableblock_help_text"), + ] + + operations = [ + migrations.AlterField( + model_name="blogaboutpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ("send", "send"), + ("familyinfo", "familyinfo"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "send", + "send", + ), + ( + "familyinfo", + "familyinfo", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ] + ), + ), + migrations.AlterField( + model_name="blogpostpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ("send", "send"), + ("familyinfo", "familyinfo"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "send", + "send", + ), + ( + "familyinfo", + "familyinfo", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ] + ), + ), + ] diff --git a/bc/cases/migrations/0025_add_fis_directory_widget.py b/bc/cases/migrations/0025_add_fis_directory_widget.py new file mode 100644 index 00000000..30895bf7 --- /dev/null +++ b/bc/cases/migrations/0025_add_fis_directory_widget.py @@ -0,0 +1,629 @@ +# Generated by Django 4.2.11 on 2024-06-27 18:39 + +import bc.utils.blocks +from django.db import migrations +import wagtail.blocks +import wagtail.contrib.typed_table_block.blocks +import wagtail.embeds.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ("cases", "0024_tableblock_help_text"), + ] + + operations = [ + migrations.AlterField( + model_name="apteanrespondcaseformpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ("send", "send"), + ("familyinfo", "familyinfo"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "send", + "send", + ), + ( + "familyinfo", + "familyinfo", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ( + "form_link_button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title", + help_text="The button label", + ), + ) + ] + ), + ), + ] + ), + ), + ] diff --git a/bc/events/migrations/0033_add_fis_directory_widget.py b/bc/events/migrations/0033_add_fis_directory_widget.py new file mode 100644 index 00000000..7914d24e --- /dev/null +++ b/bc/events/migrations/0033_add_fis_directory_widget.py @@ -0,0 +1,615 @@ +# Generated by Django 4.2.11 on 2024-06-27 18:39 + +import bc.utils.blocks +from django.db import migrations +import wagtail.blocks +import wagtail.contrib.typed_table_block.blocks +import wagtail.embeds.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ("events", "0032_tableblock_help_text"), + ] + + operations = [ + migrations.AlterField( + model_name="eventpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ("send", "send"), + ("familyinfo", "familyinfo"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "send", + "send", + ), + ( + "familyinfo", + "familyinfo", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ] + ), + ), + ] diff --git a/bc/family_information/migrations/0011_add_fis_directory_widget.py b/bc/family_information/migrations/0011_add_fis_directory_widget.py new file mode 100644 index 00000000..b9e9b7e5 --- /dev/null +++ b/bc/family_information/migrations/0011_add_fis_directory_widget.py @@ -0,0 +1,202 @@ +# Generated by Django 4.2.11 on 2024-06-27 18:41 + +from django.db import migrations +import wagtail.blocks +import wagtail.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ("family_information", "0010_subsitehomepage_heading"), + ] + + operations = [ + migrations.AddField( + model_name="categorypage", + name="fis_directory_widget", + field=wagtail.fields.StreamField( + [ + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ("send", "send"), + ("familyinfo", "familyinfo"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ], + template="patterns/organisms/search-widget/search-widget.html", + ), + ) + ], + blank=True, + ), + ), + migrations.AddField( + model_name="categorytypeonepage", + name="fis_directory_widget", + field=wagtail.fields.StreamField( + [ + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ("send", "send"), + ("familyinfo", "familyinfo"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ], + template="patterns/organisms/search-widget/search-widget.html", + ), + ) + ], + blank=True, + ), + ), + migrations.AddField( + model_name="categorytypetwopage", + name="fis_directory_widget", + field=wagtail.fields.StreamField( + [ + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ("send", "send"), + ("familyinfo", "familyinfo"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ], + template="patterns/organisms/search-widget/search-widget.html", + ), + ) + ], + blank=True, + ), + ), + migrations.AddField( + model_name="subsitehomepage", + name="fis_directory_widget", + field=wagtail.fields.StreamField( + [ + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ("send", "send"), + ("familyinfo", "familyinfo"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ) + ], + blank=True, + ), + ), + ] diff --git a/bc/family_information/models.py b/bc/family_information/models.py index 15acdf33..38bb9bc6 100644 --- a/bc/family_information/models.py +++ b/bc/family_information/models.py @@ -15,6 +15,8 @@ from ..standardpages.models import IndexPage from ..utils.models import BasePage, PageTopTask from .blocks import CardsBlock, ThreeCardRowBlock, TwoCardRowBlock +from ..utils.blocks import FISDirectoryWidgetBlock +from ..utils.models import BasePage class FISBannerFields(models.Model): @@ -121,6 +123,10 @@ class SubsiteHomePage(FISBannerFields, BasePage): blank=True, default="Get information, advice and guidance", max_length=255 ) + fis_directory_widget = StreamField( + [("fis_directory_widget", FISDirectoryWidgetBlock())], blank=True, max_num=1 + ) + call_to_action = models.ForeignKey( "utils.CallToActionSnippet", blank=True, @@ -161,6 +167,7 @@ class SubsiteHomePage(FISBannerFields, BasePage): ), FieldPanel("heading"), FieldPanel("highlighted_cards"), + FieldPanel("fis_directory_widget"), ] + FISBannerFields.content_panels + [FieldPanel("search_prompt_text"), FieldPanel("call_to_action")] @@ -240,6 +247,19 @@ class BaseCategoryPage(FISBannerFields, BasePage): # Other child pages other_pages_heading = models.CharField(default="Others", max_length=255) + fis_directory_widget = StreamField( + [ + ( + "fis_directory_widget", + FISDirectoryWidgetBlock( + template="patterns/organisms/search-widget/search-widget.html" + ), + ) + ], + blank=True, + max_num=1, + ) + content_panels = ( BasePage.content_panels + [ @@ -266,9 +286,10 @@ class BaseCategoryPage(FISBannerFields, BasePage): " isn't displayed.)" ), ), - ] - + FISBannerFields.content_panels + FieldPanel("fis_directory_widget"), + ] + FISBannerFields.content_panels ) + search_fields = BasePage.search_fields + FISBannerFields.search_fields class Meta: diff --git a/bc/inlineindex/migrations/0035_add_fis_directory_widget.py b/bc/inlineindex/migrations/0035_add_fis_directory_widget.py new file mode 100644 index 00000000..69759003 --- /dev/null +++ b/bc/inlineindex/migrations/0035_add_fis_directory_widget.py @@ -0,0 +1,1211 @@ +# Generated by Django 4.2.11 on 2024-06-27 18:39 + +import bc.utils.blocks +from django.db import migrations +import wagtail.blocks +import wagtail.contrib.typed_table_block.blocks +import wagtail.embeds.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ("inlineindex", "0034_tableblock_help_text"), + ] + + operations = [ + migrations.AlterField( + model_name="inlineindex", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ("send", "send"), + ("familyinfo", "familyinfo"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "send", + "send", + ), + ( + "familyinfo", + "familyinfo", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ] + ), + ), + migrations.AlterField( + model_name="inlineindexchild", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ("send", "send"), + ("familyinfo", "familyinfo"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "send", + "send", + ), + ( + "familyinfo", + "familyinfo", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ] + ), + ), + ] diff --git a/bc/location/migrations/0016_add_fis_directory_widget.py b/bc/location/migrations/0016_add_fis_directory_widget.py new file mode 100644 index 00000000..f5fb5262 --- /dev/null +++ b/bc/location/migrations/0016_add_fis_directory_widget.py @@ -0,0 +1,1811 @@ +# Generated by Django 4.2.11 on 2024-06-27 18:39 + +import bc.utils.blocks +from django.db import migrations +import wagtail.blocks +import wagtail.contrib.typed_table_block.blocks +import wagtail.embeds.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ("location", "0015_tableblock_help_text"), + ] + + operations = [ + migrations.AlterField( + model_name="locationindexpage", + name="additional_info", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ("send", "send"), + ("familyinfo", "familyinfo"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "send", + "send", + ), + ( + "familyinfo", + "familyinfo", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ], + blank=True, + ), + ), + migrations.AlterField( + model_name="locationpage", + name="additional_info", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ("send", "send"), + ("familyinfo", "familyinfo"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "send", + "send", + ), + ( + "familyinfo", + "familyinfo", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ], + blank=True, + help_text="Additional information about this location like opening times, facilities, etc. This will appear above the map in the template.", + ), + ), + migrations.AlterField( + model_name="locationpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ("send", "send"), + ("familyinfo", "familyinfo"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "send", + "send", + ), + ( + "familyinfo", + "familyinfo", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ], + help_text="Generic body content. This will appear after the map in the template.", + ), + ), + ] diff --git a/bc/longform/migrations/0029_add_fis_directory_widget.py b/bc/longform/migrations/0029_add_fis_directory_widget.py new file mode 100644 index 00000000..2736605a --- /dev/null +++ b/bc/longform/migrations/0029_add_fis_directory_widget.py @@ -0,0 +1,1276 @@ +# Generated by Django 4.2.11 on 2024-06-27 18:39 + +import bc.longform.blocks +import bc.utils.blocks +from django.db import migrations +import wagtail.blocks +import wagtail.contrib.typed_table_block.blocks +import wagtail.embeds.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ("longform", "0028_tableblock_help_text"), + ] + + operations = [ + migrations.AlterField( + model_name="longformchapterpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ("send", "send"), + ("familyinfo", "familyinfo"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ( + "subsubheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subsubheading uses the subsubheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="H4", + template="patterns/molecules/streamfield/blocks/subsubheading_block.html", + ), + ), + ( + "numbered_heading", + bc.longform.blocks.NumberedHeadingBlock( + help_text='Adds a number to the heading if is_numbered is not enabled on the long-form content page (e.g. 1. My heading). The link to this heading will be "section-x" where x is the heading number.' + ), + ), + ( + "numbered_subheading", + bc.longform.blocks.NumberedSubheadingBlock( + help_text='Adds a number to the subheading (e.g. 1.1. My subheading). The link to this subheading will be "section-x.y" where x is the heading or chapter number, and y is the subheading number.' + ), + ), + ( + "numbered_paragraph", + bc.longform.blocks.NumberedParagraphBlock( + help_text='Adds a number before the paragraph (e.g. 1.1.1.). The link to this paragraph will be "section-x.y.z" where x is the heading or chapter number, y is the subheading number, and z is the paragraph number.' + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "send", + "send", + ), + ( + "familyinfo", + "familyinfo", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ("bar_chart", bc.utils.blocks.BarChartBlock()), + ("line_graph", bc.utils.blocks.LineChartBlock()), + ("pie_chart", bc.utils.blocks.PieChartBlock()), + ] + ), + ), + migrations.AlterField( + model_name="longformpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ("send", "send"), + ("familyinfo", "familyinfo"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ( + "subsubheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subsubheading uses the subsubheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="H4", + template="patterns/molecules/streamfield/blocks/subsubheading_block.html", + ), + ), + ( + "numbered_heading", + bc.longform.blocks.NumberedHeadingBlock( + help_text='Adds a number to the heading if is_numbered is not enabled on the long-form content page (e.g. 1. My heading). The link to this heading will be "section-x" where x is the heading number.' + ), + ), + ( + "numbered_subheading", + bc.longform.blocks.NumberedSubheadingBlock( + help_text='Adds a number to the subheading (e.g. 1.1. My subheading). The link to this subheading will be "section-x.y" where x is the heading or chapter number, and y is the subheading number.' + ), + ), + ( + "numbered_paragraph", + bc.longform.blocks.NumberedParagraphBlock( + help_text='Adds a number before the paragraph (e.g. 1.1.1.). The link to this paragraph will be "section-x.y.z" where x is the heading or chapter number, y is the subheading number, and z is the paragraph number.' + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "send", + "send", + ), + ( + "familyinfo", + "familyinfo", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ("bar_chart", bc.utils.blocks.BarChartBlock()), + ("line_graph", bc.utils.blocks.LineChartBlock()), + ("pie_chart", bc.utils.blocks.PieChartBlock()), + ] + ), + ), + ] diff --git a/bc/news/migrations/0034_add_fis_directory_widget.py b/bc/news/migrations/0034_add_fis_directory_widget.py new file mode 100644 index 00000000..159cb4fa --- /dev/null +++ b/bc/news/migrations/0034_add_fis_directory_widget.py @@ -0,0 +1,615 @@ +# Generated by Django 4.2.11 on 2024-06-27 18:39 + +import bc.utils.blocks +from django.db import migrations +import wagtail.blocks +import wagtail.contrib.typed_table_block.blocks +import wagtail.embeds.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ("news", "0033_django_40_upgrade"), + ] + + operations = [ + migrations.AlterField( + model_name="newspage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ("send", "send"), + ("familyinfo", "familyinfo"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "send", + "send", + ), + ( + "familyinfo", + "familyinfo", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ] + ), + ), + ] diff --git a/bc/project_styleguide/templates/patterns/molecules/location-autocomplete/location-autocomplete.html b/bc/project_styleguide/templates/patterns/molecules/location-autocomplete/location-autocomplete.html new file mode 100644 index 00000000..91b4d495 --- /dev/null +++ b/bc/project_styleguide/templates/patterns/molecules/location-autocomplete/location-autocomplete.html @@ -0,0 +1,5 @@ + + + + +
diff --git a/bc/project_styleguide/templates/patterns/molecules/streamfield/blocks/search-widget.html b/bc/project_styleguide/templates/patterns/molecules/streamfield/blocks/search-widget.html new file mode 100644 index 00000000..17098807 --- /dev/null +++ b/bc/project_styleguide/templates/patterns/molecules/streamfield/blocks/search-widget.html @@ -0,0 +1 @@ +{% include 'patterns/organisms/search-widget/search-widget.html' with classes="search-widget--sf" %} diff --git a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html index 843a752a..575788ae 100644 --- a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html +++ b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html @@ -1,23 +1,28 @@ {% load wagtailimages_tags %} -
-
-

{{ title|default:"Find activities and organisations near you" }}

+
+ +

{{ value.title|default:"Find activities and organisations near you" }}

- - + +
- - + + {% include 'patterns/molecules/location-autocomplete/location-autocomplete.html' with location_autocomplete_id="region-search" location_autocomplete_classes="search-widget__input input" location_autocomplete_placeholder="E.g. Buckingham" %}
+ {% for key, value in extra_query_params %} + + {% endfor %} +
+ diff --git a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml index a7f4a227..e69de29b 100644 --- a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml +++ b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.yaml @@ -1,4 +0,0 @@ -context: - search_label: Search activities and services - location_label: Enter town/postcode - cta_label: Search directory diff --git a/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.html b/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.html index 736bd5c6..4ac256b0 100644 --- a/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.html +++ b/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.html @@ -50,9 +50,8 @@

- {# TODO: Remove directory-banner.html when search-widget.html is ready for use and remove conditional #} - {% if page.search_widget %} - {% include "patterns/organisms/search-widget/search-widget.html" %} + {% if page.fis_directory_widget %} + {% include_block page.fis_directory_widget %} {% endif %} {% include "patterns/molecules/directory-banner/directory-banner.html" with classes="directory-banner--with-space" %} diff --git a/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat1.html b/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat1.html index 5abcecc5..dfd6b90e 100644 --- a/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat1.html +++ b/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat1.html @@ -41,6 +41,10 @@

{{ pa + {% if page.fis_directory_widget %} + {% include_block page.fis_directory_widget %} + {% endif %} + {% include "patterns/molecules/directory-banner/directory-banner.html" with classes="directory-banner--with-space" %} {% include "patterns/molecules/search-prompt/search-prompt--fis.html" with search_prompt_text=page.get_parent.specific.search_prompt_text %} diff --git a/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat2.html b/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat2.html index e36ad94d..5406fd2e 100644 --- a/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat2.html +++ b/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat2.html @@ -42,6 +42,10 @@

{{ pa + {% if page.fis_directory_widget %} + {% include_block page.fis_directory_widget %} + {% endif %} + {% include "patterns/molecules/directory-banner/directory-banner.html" with classes="directory-banner--with-space" %} diff --git a/bc/recruitment/migrations/0064_add_fis_directory_widget.py b/bc/recruitment/migrations/0064_add_fis_directory_widget.py new file mode 100644 index 00000000..a9af51e3 --- /dev/null +++ b/bc/recruitment/migrations/0064_add_fis_directory_widget.py @@ -0,0 +1,616 @@ +# Generated by Django 4.2.11 on 2024-06-27 18:39 + +import bc.utils.blocks +from django.db import migrations +import wagtail.blocks +import wagtail.contrib.typed_table_block.blocks +import wagtail.embeds.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ("recruitment", "0063_tableblock_help_text"), + ] + + operations = [ + migrations.AlterField( + model_name="recruitmentindexpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ("send", "send"), + ("familyinfo", "familyinfo"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "send", + "send", + ), + ( + "familyinfo", + "familyinfo", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ], + blank=True, + ), + ), + ] diff --git a/bc/standardpages/migrations/0041_add_fis_directory_widget.py b/bc/standardpages/migrations/0041_add_fis_directory_widget.py new file mode 100644 index 00000000..1efe573c --- /dev/null +++ b/bc/standardpages/migrations/0041_add_fis_directory_widget.py @@ -0,0 +1,1212 @@ +# Generated by Django 4.2.11 on 2024-06-27 18:39 + +import bc.utils.blocks +from django.db import migrations +import wagtail.blocks +import wagtail.contrib.typed_table_block.blocks +import wagtail.embeds.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ("standardpages", "0040_tableblock_help_text"), + ] + + operations = [ + migrations.AlterField( + model_name="informationpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ("send", "send"), + ("familyinfo", "familyinfo"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "send", + "send", + ), + ( + "familyinfo", + "familyinfo", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ] + ), + ), + migrations.AlterField( + model_name="wastewizardpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ("send", "send"), + ("familyinfo", "familyinfo"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "fis_directory_widget", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "send", + "send", + ), + ( + "familyinfo", + "familyinfo", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ("waste_wizard", bc.utils.blocks.WasteWizardSnippetBlock()), + ] + ), + ), + ] diff --git a/bc/static_src/javascript/components/location-autocomplete.js b/bc/static_src/javascript/components/location-autocomplete.js new file mode 100644 index 00000000..c574aa62 --- /dev/null +++ b/bc/static_src/javascript/components/location-autocomplete.js @@ -0,0 +1,209 @@ +/* global google */ + +import accessibleAutocomplete from 'accessible-autocomplete'; + +class LocationAutocomplete { + static selector() { + return '[data-autocomplete-container]'; + } + + constructor(node) { + this.container = node; + this.form = node.closest('form'); + this.labelId = node.dataset.labelId; + + this.latInput = this.form.querySelector('input[name="lat"]'); + this.lngInput = this.form.querySelector('input[name="lng"]'); + this.locationInput = this.form.querySelector('input[name="location"]'); + + this.sessionToken = LocationAutocomplete.getSessionToken(); + + this.autocompleteService = new google.maps.places.AutocompleteService(); + this.geocoder = new google.maps.Geocoder(); + + this.focusOnLocation = false; + this.locationSelected = false; + + this.bindEvents(); + + this.predictions = []; + } + + static getSessionToken() { + return new google.maps.places.AutocompleteSessionToken(); + } + + deduceOption(autocompleteInput) { + let item; + if (autocompleteInput.value.trim() === '') { + item = ''; + } else if (this.predictions.length === 0) { + autocompleteInput.value = ''; + item = ''; + } else if (this.locationSelected) { + const description = this.locationInput.value; + item = this.predictions.find((p) => p.description === description); + if (!item) { + [item] = this.predictions; + } + } else { + [item] = this.predictions; + } + this.selectElement(item); + } + + bindEvents() { + const self = this; + accessibleAutocomplete({ + element: this.container, + id: this.labelId, + source: (query, populateResults) => { + self.getLocations(query, populateResults); + }, + displayMenu: 'overlay', // displays menu as an absolute positioned div + autoSelect: true, + minLength: 3, // minimum number of characters required to trigger autocomplete + showNoOptionsFound: true, // displays a "no options found" message if no options are found + templates: { + suggestion: (item) => + `
${item.description || + item}
`, + noResults: () => + `
No results found
`, + inputValue: (item) => { + if (item) { + const placeId = item.place_id; + if (!placeId) { + return item; + } + return item.description; + } + return item; + }, + }, + onConfirm: (item) => { + if (item) { + this.selectElement(item, () => { + this.focusOnLocation = false; + }); + } + }, + }); + this.autocompleteInput = this.container.querySelector('input'); + this.autocompleteInput.setAttribute( + 'placeholder', + this.form + .querySelector(`#${this.labelId}`) + .getAttribute('placeholder'), + ); + this.autocompleteInput.addEventListener('blur', (e) => { + this.deduceOption(e.target); + }); + this.autocompleteInput.addEventListener('focus', () => { + this.focusOnLocation = true; + }); + this.autocompleteInput.addEventListener('keydown', (e) => { + if (e.keyCode === 13) { + // enter key + e.preventDefault(); + if (this.locationSelected) { + this.form.submit(); + return; + } + this.deduceOption(e.target); + } + }); + + this.form.addEventListener('submit', (e) => { + e.preventDefault(); + this.submitForm(); + }); + } + + submitForm() { + const waitForFocusChange = () => + new Promise((resolve) => { + const interval = setInterval(() => { + if (!this.focusOnLocation) { + clearInterval(interval); + resolve(); + } + }, 10); // Check every 100 milliseconds + }); + + if (this.autocompleteInput.value.length < 3) { + this.locationInput.value = ''; + this.latInput.value = ''; + this.lngInput.value = ''; + this.form.submit(); + } else { + waitForFocusChange().then(() => { + this.form.submit(); + }); + } + } + + selectElement(item, cb) { + if (item) { + const placeId = item.place_id; + this.geocoder.geocode({ placeId }, (results, status) => { + if (status === 'OK') { + const { lat, lng } = results[0].geometry.location; + this.latInput.value = lat(); + this.lngInput.value = lng(); + this.locationInput.value = item.description; + this.autocompleteInput.value = item.description; + } else { + // eslint-disable-next-line no-console + console.log( + `Geocoder failed due to: ${status}`, + results, + placeId, + ); + } + if (cb) cb(); + }); + } else { + this.locationInput.value = ''; + this.latInput.value = ''; + this.lngInput.value = ''; + } + // regenerate a new session token after each selection + // as per https://developers.google.com/maps/documentation/javascript/place-autocomplete#session_tokens + this.sessionToken = LocationAutocomplete.getSessionToken(); + this.focusOnLocation = false; + this.locationSelected = true; + } + + getLocations(query, populateResults) { + if (!this.focusOnLocation) return; + this.locationSelected = false; + + this.autocompleteService.getPlacePredictions( + { + input: query, + sessionToken: this.sessionToken, + componentRestrictions: { + country: 'gb', + }, + types: ['geocode'], + }, + (predictions, status) => { + if (status === google.maps.places.PlacesServiceStatus.OK) { + this.predictions = predictions; + } else { + // eslint-disable-next-line no-console + console.log( + 'Autocomplete service failed: ', + status, + predictions, + ); + this.predictions = []; + } + populateResults(this.predictions); + }, + ); + } +} + +export default LocationAutocomplete; diff --git a/bc/static_src/javascript/main.js b/bc/static_src/javascript/main.js index b1f5546f..65c1d38a 100755 --- a/bc/static_src/javascript/main.js +++ b/bc/static_src/javascript/main.js @@ -21,6 +21,7 @@ import GoogleMap from './components/map'; import Steps from './components/steps'; import ContentsScroller from './components/contents-scroller'; import EHCCOSearch from './components/fis-ehcco-search'; +import LocationAutocomplete from './components/location-autocomplete'; // Add polyfill fix for forEach carousel import foreachPolyfill from './polyfills/foreach-polyfill'; @@ -156,6 +157,12 @@ document.addEventListener('DOMContentLoaded', () => { new EHCCOSearch(search); } + for (const locationAutocomplete of document.querySelectorAll( + LocationAutocomplete.selector(), + )) { + new LocationAutocomplete(locationAutocomplete); + } + // Test react - add a div with a data attribute of `data-test-react` to test for (const element of document.querySelectorAll('[data-test-react]')) { ReactDOM.render(, element); diff --git a/bc/static_src/sass/components/_location-autocomplete.scss b/bc/static_src/sass/components/_location-autocomplete.scss new file mode 100644 index 00000000..d714af59 --- /dev/null +++ b/bc/static_src/sass/components/_location-autocomplete.scss @@ -0,0 +1,25 @@ +.location-autocomplete { + position: relative; + + .autocomplete__menu { + position: absolute; + width: 100%; + border: 1px solid $color--charcoal; + z-index: 10; + + &--hidden { + display: none; + } + } + + .autocomplete__option { + padding: $grid--small; + cursor: pointer; + background-color: $color--white; + + &:hover, + &:focus { + background-color: $color--charcoal-25; + } + } +} diff --git a/bc/static_src/sass/components/_search-widget.scss b/bc/static_src/sass/components/_search-widget.scss index 88cfce58..0a11cd0f 100644 --- a/bc/static_src/sass/components/_search-widget.scss +++ b/bc/static_src/sass/components/_search-widget.scss @@ -1,4 +1,5 @@ .search-widget { + $root: &; background-color: $color--river-tint; border-left: 5px solid $color--river; color: $color--default; @@ -40,6 +41,10 @@ @include media-query(tablet-landscape) { grid-template-columns: 1fr 1fr 1fr; align-items: flex-end; + + #{$root}--sf & { + grid-template-columns: 1fr 1fr; + } } } diff --git a/bc/static_src/sass/main.scss b/bc/static_src/sass/main.scss index d58526eb..87852363 100755 --- a/bc/static_src/sass/main.scss +++ b/bc/static_src/sass/main.scss @@ -94,6 +94,7 @@ @import 'components/fis-ehcco-search'; @import 'components/search-promotions'; @import 'components/top-tasks'; +@import 'components/location-autocomplete'; // Pages @import 'pages/blogglobalhomepage'; diff --git a/bc/utils/blocks.py b/bc/utils/blocks.py index 6c956ebd..4b6f7277 100644 --- a/bc/utils/blocks.py +++ b/bc/utils/blocks.py @@ -1,4 +1,5 @@ import copy +from urllib.parse import parse_qsl from django import forms from django.core.exceptions import ValidationError @@ -578,6 +579,38 @@ def get_context(self, value, parent_context=None): context["get_corresponding_ehc_co_url"] = reverse( "family_information:get_corresponding_ehc_co" ) + + +class FISDirectoryWidgetBlock(blocks.StructBlock): + title = blocks.CharBlock(required=True, help_text="Title of the widget") + search_placeholder = blocks.CharBlock( + required=False, help_text="Placeholder text for the search input" + ) + directory = blocks.ChoiceBlock( + choices=[ + ("send", "send"), + ("familyinfo", "familyinfo"), + ], + required=True, + help_text="Which directory to search", + ) + extra_query_params = blocks.CharBlock( + required=False, help_text="Extra query parameters to add to the search" + ) + + class Meta: + template = "patterns/molecules/streamfield/blocks/search-widget.html" + icon = "link" + label = "FIS Directory Widget" + + def get_context(self, value, parent_context=None): + context = super().get_context(value, parent_context) + if value["extra_query_params"]: + extra_query_params = value["extra_query_params"] + if extra_query_params.startswith("?"): + extra_query_params = extra_query_params[1:] + extra_query_params = parse_qsl(extra_query_params) + context["extra_query_params"] = extra_query_params return context @@ -619,6 +652,7 @@ class BaseStoryBlock(blocks.StreamBlock): highlight = HighlightBlock() inset_text = InsetTextBlock() ehc_co_search = EHCCoSearchBlock(label="EHCCo Search") + fis_directory_widget = FISDirectoryWidgetBlock() class Meta: abstract = True From 430eb715c88483039ba026dd67eba7064195a568 Mon Sep 17 00:00:00 2001 From: Shohan Dutta Roy Date: Tue, 9 Jul 2024 15:55:11 +0530 Subject: [PATCH 11/59] chore(directory_widget): Change block name and add error conditions --- ...ectory_widget.py => 0018_add_directory_widget.py} | 8 ++++---- ...ectory_widget.py => 0025_add_directory_widget.py} | 4 ++-- ...ectory_widget.py => 0033_add_directory_widget.py} | 4 ++-- ...ectory_widget.py => 0011_add_directory_widget.py} | 8 ++++---- bc/family_information/models.py | 6 +++--- ...ectory_widget.py => 0035_add_directory_widget.py} | 8 ++++---- ...ectory_widget.py => 0016_add_directory_widget.py} | 12 ++++++------ ...ectory_widget.py => 0029_add_directory_widget.py} | 8 ++++---- ...ectory_widget.py => 0034_add_directory_widget.py} | 4 ++-- .../location-autocomplete/location-autocomplete.html | 2 ++ .../organisms/search-widget/search-widget.html | 1 - ...ectory_widget.py => 0064_add_directory_widget.py} | 4 ++-- ...ectory_widget.py => 0041_add_directory_widget.py} | 8 ++++---- .../javascript/components/location-autocomplete.js | 10 ++++++++++ bc/utils/blocks.py | 9 ++++++--- 15 files changed, 55 insertions(+), 41 deletions(-) rename bc/blogs/migrations/{0018_add_fis_directory_widget.py => 0018_add_directory_widget.py} (99%) rename bc/cases/migrations/{0025_add_fis_directory_widget.py => 0025_add_directory_widget.py} (99%) rename bc/events/migrations/{0033_add_fis_directory_widget.py => 0033_add_directory_widget.py} (99%) rename bc/family_information/migrations/{0011_add_fis_directory_widget.py => 0011_add_directory_widget.py} (96%) rename bc/inlineindex/migrations/{0035_add_fis_directory_widget.py => 0035_add_directory_widget.py} (99%) rename bc/location/migrations/{0016_add_fis_directory_widget.py => 0016_add_directory_widget.py} (99%) rename bc/longform/migrations/{0029_add_fis_directory_widget.py => 0029_add_directory_widget.py} (99%) rename bc/news/migrations/{0034_add_fis_directory_widget.py => 0034_add_directory_widget.py} (99%) rename bc/recruitment/migrations/{0064_add_fis_directory_widget.py => 0064_add_directory_widget.py} (99%) rename bc/standardpages/migrations/{0041_add_fis_directory_widget.py => 0041_add_directory_widget.py} (99%) diff --git a/bc/blogs/migrations/0018_add_fis_directory_widget.py b/bc/blogs/migrations/0018_add_directory_widget.py similarity index 99% rename from bc/blogs/migrations/0018_add_fis_directory_widget.py rename to bc/blogs/migrations/0018_add_directory_widget.py index fcfdf42b..04e19168 100644 --- a/bc/blogs/migrations/0018_add_fis_directory_widget.py +++ b/bc/blogs/migrations/0018_add_directory_widget.py @@ -254,7 +254,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -561,7 +561,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -850,7 +850,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -1157,7 +1157,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), diff --git a/bc/cases/migrations/0025_add_fis_directory_widget.py b/bc/cases/migrations/0025_add_directory_widget.py similarity index 99% rename from bc/cases/migrations/0025_add_fis_directory_widget.py rename to bc/cases/migrations/0025_add_directory_widget.py index 30895bf7..852b68a3 100644 --- a/bc/cases/migrations/0025_add_fis_directory_widget.py +++ b/bc/cases/migrations/0025_add_directory_widget.py @@ -254,7 +254,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -561,7 +561,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), diff --git a/bc/events/migrations/0033_add_fis_directory_widget.py b/bc/events/migrations/0033_add_directory_widget.py similarity index 99% rename from bc/events/migrations/0033_add_fis_directory_widget.py rename to bc/events/migrations/0033_add_directory_widget.py index 7914d24e..d895f832 100644 --- a/bc/events/migrations/0033_add_fis_directory_widget.py +++ b/bc/events/migrations/0033_add_directory_widget.py @@ -254,7 +254,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -561,7 +561,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), diff --git a/bc/family_information/migrations/0011_add_fis_directory_widget.py b/bc/family_information/migrations/0011_add_directory_widget.py similarity index 96% rename from bc/family_information/migrations/0011_add_fis_directory_widget.py rename to bc/family_information/migrations/0011_add_directory_widget.py index b9e9b7e5..0d34d58a 100644 --- a/bc/family_information/migrations/0011_add_fis_directory_widget.py +++ b/bc/family_information/migrations/0011_add_directory_widget.py @@ -47,7 +47,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -94,7 +94,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -141,7 +141,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -188,7 +188,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), diff --git a/bc/family_information/models.py b/bc/family_information/models.py index 38bb9bc6..37a27203 100644 --- a/bc/family_information/models.py +++ b/bc/family_information/models.py @@ -15,7 +15,7 @@ from ..standardpages.models import IndexPage from ..utils.models import BasePage, PageTopTask from .blocks import CardsBlock, ThreeCardRowBlock, TwoCardRowBlock -from ..utils.blocks import FISDirectoryWidgetBlock +from ..utils.blocks import DirectoryWidgetBlock from ..utils.models import BasePage @@ -124,7 +124,7 @@ class SubsiteHomePage(FISBannerFields, BasePage): ) fis_directory_widget = StreamField( - [("fis_directory_widget", FISDirectoryWidgetBlock())], blank=True, max_num=1 + [("fis_directory_widget", DirectoryWidgetBlock())], blank=True, max_num=1 ) call_to_action = models.ForeignKey( @@ -251,7 +251,7 @@ class BaseCategoryPage(FISBannerFields, BasePage): [ ( "fis_directory_widget", - FISDirectoryWidgetBlock( + DirectoryWidgetBlock( template="patterns/organisms/search-widget/search-widget.html" ), ) diff --git a/bc/inlineindex/migrations/0035_add_fis_directory_widget.py b/bc/inlineindex/migrations/0035_add_directory_widget.py similarity index 99% rename from bc/inlineindex/migrations/0035_add_fis_directory_widget.py rename to bc/inlineindex/migrations/0035_add_directory_widget.py index 69759003..91895eed 100644 --- a/bc/inlineindex/migrations/0035_add_fis_directory_widget.py +++ b/bc/inlineindex/migrations/0035_add_directory_widget.py @@ -254,7 +254,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -561,7 +561,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -850,7 +850,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -1157,7 +1157,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), diff --git a/bc/location/migrations/0016_add_fis_directory_widget.py b/bc/location/migrations/0016_add_directory_widget.py similarity index 99% rename from bc/location/migrations/0016_add_fis_directory_widget.py rename to bc/location/migrations/0016_add_directory_widget.py index f5fb5262..c4f42cba 100644 --- a/bc/location/migrations/0016_add_fis_directory_widget.py +++ b/bc/location/migrations/0016_add_directory_widget.py @@ -254,7 +254,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -561,7 +561,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -851,7 +851,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -1158,7 +1158,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -1449,7 +1449,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -1756,7 +1756,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), diff --git a/bc/longform/migrations/0029_add_fis_directory_widget.py b/bc/longform/migrations/0029_add_directory_widget.py similarity index 99% rename from bc/longform/migrations/0029_add_fis_directory_widget.py rename to bc/longform/migrations/0029_add_directory_widget.py index 2736605a..507a48bf 100644 --- a/bc/longform/migrations/0029_add_fis_directory_widget.py +++ b/bc/longform/migrations/0029_add_directory_widget.py @@ -255,7 +255,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -591,7 +591,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -883,7 +883,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -1219,7 +1219,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), diff --git a/bc/news/migrations/0034_add_fis_directory_widget.py b/bc/news/migrations/0034_add_directory_widget.py similarity index 99% rename from bc/news/migrations/0034_add_fis_directory_widget.py rename to bc/news/migrations/0034_add_directory_widget.py index 159cb4fa..ab06221e 100644 --- a/bc/news/migrations/0034_add_fis_directory_widget.py +++ b/bc/news/migrations/0034_add_directory_widget.py @@ -254,7 +254,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -561,7 +561,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), diff --git a/bc/project_styleguide/templates/patterns/molecules/location-autocomplete/location-autocomplete.html b/bc/project_styleguide/templates/patterns/molecules/location-autocomplete/location-autocomplete.html index 91b4d495..50f9291c 100644 --- a/bc/project_styleguide/templates/patterns/molecules/location-autocomplete/location-autocomplete.html +++ b/bc/project_styleguide/templates/patterns/molecules/location-autocomplete/location-autocomplete.html @@ -3,3 +3,5 @@
+ + diff --git a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html index 575788ae..7c6a5597 100644 --- a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html +++ b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html @@ -25,4 +25,3 @@

{{ value.title|default:"F - diff --git a/bc/recruitment/migrations/0064_add_fis_directory_widget.py b/bc/recruitment/migrations/0064_add_directory_widget.py similarity index 99% rename from bc/recruitment/migrations/0064_add_fis_directory_widget.py rename to bc/recruitment/migrations/0064_add_directory_widget.py index a9af51e3..08951463 100644 --- a/bc/recruitment/migrations/0064_add_fis_directory_widget.py +++ b/bc/recruitment/migrations/0064_add_directory_widget.py @@ -254,7 +254,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -561,7 +561,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), diff --git a/bc/standardpages/migrations/0041_add_fis_directory_widget.py b/bc/standardpages/migrations/0041_add_directory_widget.py similarity index 99% rename from bc/standardpages/migrations/0041_add_fis_directory_widget.py rename to bc/standardpages/migrations/0041_add_directory_widget.py index 1efe573c..4732415a 100644 --- a/bc/standardpages/migrations/0041_add_fis_directory_widget.py +++ b/bc/standardpages/migrations/0041_add_directory_widget.py @@ -254,7 +254,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -561,7 +561,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -850,7 +850,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), @@ -1157,7 +1157,7 @@ class Migration(migrations.Migration): ( "extra_query_params", wagtail.blocks.CharBlock( - help_text="Extra query parameters to add to the search", + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", required=False, ), ), diff --git a/bc/static_src/javascript/components/location-autocomplete.js b/bc/static_src/javascript/components/location-autocomplete.js index c574aa62..74cd7d33 100644 --- a/bc/static_src/javascript/components/location-autocomplete.js +++ b/bc/static_src/javascript/components/location-autocomplete.js @@ -10,7 +10,14 @@ class LocationAutocomplete { constructor(node) { this.container = node; this.form = node.closest('form'); + + if (!this.form) { + throw new Error('No form found for autocomplete container'); + } this.labelId = node.dataset.labelId; + if (!this.labelId) { + throw new Error('No label ID found for autocomplete container'); + } this.latInput = this.form.querySelector('input[name="lat"]'); this.lngInput = this.form.querySelector('input[name="lng"]'); @@ -90,6 +97,9 @@ class LocationAutocomplete { }, }); this.autocompleteInput = this.container.querySelector('input'); + if (!this.autocompleteInput) { + throw new Error('No input element found in autocomplete container'); + } this.autocompleteInput.setAttribute( 'placeholder', this.form diff --git a/bc/utils/blocks.py b/bc/utils/blocks.py index 4b6f7277..dee0bfa6 100644 --- a/bc/utils/blocks.py +++ b/bc/utils/blocks.py @@ -581,7 +581,7 @@ def get_context(self, value, parent_context=None): ) -class FISDirectoryWidgetBlock(blocks.StructBlock): +class DirectoryWidgetBlock(blocks.StructBlock): title = blocks.CharBlock(required=True, help_text="Title of the widget") search_placeholder = blocks.CharBlock( required=False, help_text="Placeholder text for the search input" @@ -595,7 +595,10 @@ class FISDirectoryWidgetBlock(blocks.StructBlock): help_text="Which directory to search", ) extra_query_params = blocks.CharBlock( - required=False, help_text="Extra query parameters to add to the search" + required=False, + help_text=( + "Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism" + ), ) class Meta: @@ -652,7 +655,7 @@ class BaseStoryBlock(blocks.StreamBlock): highlight = HighlightBlock() inset_text = InsetTextBlock() ehc_co_search = EHCCoSearchBlock(label="EHCCo Search") - fis_directory_widget = FISDirectoryWidgetBlock() + fis_directory_widget = DirectoryWidgetBlock() class Meta: abstract = True From 0c680bb275abdfc8fa4157abdb4e8a01e11d58e9 Mon Sep 17 00:00:00 2001 From: Shohan Dutta Roy Date: Tue, 9 Jul 2024 16:08:27 +0530 Subject: [PATCH 12/59] feat(search-widget): Craft directory url in backend instead of in template --- .../patterns/organisms/search-widget/search-widget.html | 2 +- bc/utils/blocks.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html index 7c6a5597..06f834a8 100644 --- a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html +++ b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html @@ -1,7 +1,7 @@ {% load wagtailimages_tags %}
-
+

{{ value.title|default:"Find activities and organisations near you" }}

diff --git a/bc/utils/blocks.py b/bc/utils/blocks.py index dee0bfa6..98b293f9 100644 --- a/bc/utils/blocks.py +++ b/bc/utils/blocks.py @@ -614,6 +614,9 @@ def get_context(self, value, parent_context=None): extra_query_params = extra_query_params[1:] extra_query_params = parse_qsl(extra_query_params) context["extra_query_params"] = extra_query_params + context["directory_url"] = ( + f'https://directory.{value["directory"]}.buckinghamshire.gov.uk/' + ) return context From af98558a26060e717dd3fd5a2849be5c59933c32 Mon Sep 17 00:00:00 2001 From: Tomasz Knapik Date: Thu, 18 Jul 2024 17:30:23 +0100 Subject: [PATCH 13/59] Rename directory widget -> directory search block --- ....py => 0018_add_directory_search_block.py} | 32 ++++++++----- ....py => 0025_add_directory_search_block.py} | 17 ++++--- ....py => 0033_add_directory_search_block.py} | 17 ++++--- ....py => 0011_add_directory_search_block.py} | 46 +++++++++++------- bc/family_information/models.py | 16 +++---- ....py => 0035_add_directory_search_block.py} | 32 ++++++++----- ....py => 0016_add_directory_search_block.py} | 47 +++++++++++-------- ....py => 0029_add_directory_search_block.py} | 32 ++++++++----- ....py => 0034_add_directory_search_block.py} | 17 ++++--- .../patterns/pages/home/home_page--fis.html | 4 +- .../standardpages/index_page--fis-cat1.html | 4 +- .../standardpages/index_page--fis-cat2.html | 4 +- ....py => 0064_add_directory_search_block.py} | 17 ++++--- ....py => 0041_add_directory_search_block.py} | 32 ++++++++----- bc/utils/blocks.py | 34 ++++++++++---- 15 files changed, 211 insertions(+), 140 deletions(-) rename bc/blogs/migrations/{0018_add_directory_widget.py => 0018_add_directory_search_block.py} (98%) rename bc/cases/migrations/{0025_add_directory_widget.py => 0025_add_directory_search_block.py} (98%) rename bc/events/migrations/{0033_add_directory_widget.py => 0033_add_directory_search_block.py} (98%) rename bc/family_information/migrations/{0011_add_directory_widget.py => 0011_add_directory_search_block.py} (83%) rename bc/inlineindex/migrations/{0035_add_directory_widget.py => 0035_add_directory_search_block.py} (98%) rename bc/location/migrations/{0016_add_directory_widget.py => 0016_add_directory_search_block.py} (98%) rename bc/longform/migrations/{0029_add_directory_widget.py => 0029_add_directory_search_block.py} (98%) rename bc/news/migrations/{0034_add_directory_widget.py => 0034_add_directory_search_block.py} (98%) rename bc/recruitment/migrations/{0064_add_directory_widget.py => 0064_add_directory_search_block.py} (98%) rename bc/standardpages/migrations/{0041_add_directory_widget.py => 0041_add_directory_search_block.py} (98%) diff --git a/bc/blogs/migrations/0018_add_directory_widget.py b/bc/blogs/migrations/0018_add_directory_search_block.py similarity index 98% rename from bc/blogs/migrations/0018_add_directory_widget.py rename to bc/blogs/migrations/0018_add_directory_search_block.py index 04e19168..73bb9321 100644 --- a/bc/blogs/migrations/0018_add_directory_widget.py +++ b/bc/blogs/migrations/0018_add_directory_search_block.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.11 on 2024-06-27 18:39 +# Generated by Django 4.2.11 on 2024-07-19 10:04 import bc.utils.blocks from django.db import migrations @@ -225,7 +225,7 @@ class Migration(migrations.Migration): ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -245,8 +245,11 @@ class Migration(migrations.Migration): "directory", wagtail.blocks.ChoiceBlock( choices=[ - ("send", "send"), - ("familyinfo", "familyinfo"), + ("send", "SEND"), + ( + "familyinfo", + "Family Information Service", + ), ], help_text="Which directory to search", ), @@ -525,7 +528,7 @@ class Migration(migrations.Migration): bc.utils.blocks.InsetTextBlock(), ), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -548,11 +551,11 @@ class Migration(migrations.Migration): choices=[ ( "send", - "send", + "SEND", ), ( "familyinfo", - "familyinfo", + "Family Information Service", ), ], help_text="Which directory to search", @@ -821,7 +824,7 @@ class Migration(migrations.Migration): ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -841,8 +844,11 @@ class Migration(migrations.Migration): "directory", wagtail.blocks.ChoiceBlock( choices=[ - ("send", "send"), - ("familyinfo", "familyinfo"), + ("send", "SEND"), + ( + "familyinfo", + "Family Information Service", + ), ], help_text="Which directory to search", ), @@ -1121,7 +1127,7 @@ class Migration(migrations.Migration): bc.utils.blocks.InsetTextBlock(), ), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -1144,11 +1150,11 @@ class Migration(migrations.Migration): choices=[ ( "send", - "send", + "SEND", ), ( "familyinfo", - "familyinfo", + "Family Information Service", ), ], help_text="Which directory to search", diff --git a/bc/cases/migrations/0025_add_directory_widget.py b/bc/cases/migrations/0025_add_directory_search_block.py similarity index 98% rename from bc/cases/migrations/0025_add_directory_widget.py rename to bc/cases/migrations/0025_add_directory_search_block.py index 852b68a3..d124965e 100644 --- a/bc/cases/migrations/0025_add_directory_widget.py +++ b/bc/cases/migrations/0025_add_directory_search_block.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.11 on 2024-06-27 18:39 +# Generated by Django 4.2.11 on 2024-07-19 10:04 import bc.utils.blocks from django.db import migrations @@ -225,7 +225,7 @@ class Migration(migrations.Migration): ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -245,8 +245,11 @@ class Migration(migrations.Migration): "directory", wagtail.blocks.ChoiceBlock( choices=[ - ("send", "send"), - ("familyinfo", "familyinfo"), + ("send", "SEND"), + ( + "familyinfo", + "Family Information Service", + ), ], help_text="Which directory to search", ), @@ -525,7 +528,7 @@ class Migration(migrations.Migration): bc.utils.blocks.InsetTextBlock(), ), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -548,11 +551,11 @@ class Migration(migrations.Migration): choices=[ ( "send", - "send", + "SEND", ), ( "familyinfo", - "familyinfo", + "Family Information Service", ), ], help_text="Which directory to search", diff --git a/bc/events/migrations/0033_add_directory_widget.py b/bc/events/migrations/0033_add_directory_search_block.py similarity index 98% rename from bc/events/migrations/0033_add_directory_widget.py rename to bc/events/migrations/0033_add_directory_search_block.py index d895f832..df43bc2c 100644 --- a/bc/events/migrations/0033_add_directory_widget.py +++ b/bc/events/migrations/0033_add_directory_search_block.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.11 on 2024-06-27 18:39 +# Generated by Django 4.2.11 on 2024-07-19 10:04 import bc.utils.blocks from django.db import migrations @@ -225,7 +225,7 @@ class Migration(migrations.Migration): ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -245,8 +245,11 @@ class Migration(migrations.Migration): "directory", wagtail.blocks.ChoiceBlock( choices=[ - ("send", "send"), - ("familyinfo", "familyinfo"), + ("send", "SEND"), + ( + "familyinfo", + "Family Information Service", + ), ], help_text="Which directory to search", ), @@ -525,7 +528,7 @@ class Migration(migrations.Migration): bc.utils.blocks.InsetTextBlock(), ), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -548,11 +551,11 @@ class Migration(migrations.Migration): choices=[ ( "send", - "send", + "SEND", ), ( "familyinfo", - "familyinfo", + "Family Information Service", ), ], help_text="Which directory to search", diff --git a/bc/family_information/migrations/0011_add_directory_widget.py b/bc/family_information/migrations/0011_add_directory_search_block.py similarity index 83% rename from bc/family_information/migrations/0011_add_directory_widget.py rename to bc/family_information/migrations/0011_add_directory_search_block.py index 0d34d58a..6c533a1e 100644 --- a/bc/family_information/migrations/0011_add_directory_widget.py +++ b/bc/family_information/migrations/0011_add_directory_search_block.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.11 on 2024-06-27 18:41 +# Generated by Django 4.2.11 on 2024-07-19 10:04 from django.db import migrations import wagtail.blocks @@ -14,11 +14,11 @@ class Migration(migrations.Migration): operations = [ migrations.AddField( model_name="categorypage", - name="fis_directory_widget", + name="directory_search", field=wagtail.fields.StreamField( [ ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -38,8 +38,11 @@ class Migration(migrations.Migration): "directory", wagtail.blocks.ChoiceBlock( choices=[ - ("send", "send"), - ("familyinfo", "familyinfo"), + ("send", "SEND"), + ( + "familyinfo", + "Family Information Service", + ), ], help_text="Which directory to search", ), @@ -61,11 +64,11 @@ class Migration(migrations.Migration): ), migrations.AddField( model_name="categorytypeonepage", - name="fis_directory_widget", + name="directory_search", field=wagtail.fields.StreamField( [ ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -85,8 +88,11 @@ class Migration(migrations.Migration): "directory", wagtail.blocks.ChoiceBlock( choices=[ - ("send", "send"), - ("familyinfo", "familyinfo"), + ("send", "SEND"), + ( + "familyinfo", + "Family Information Service", + ), ], help_text="Which directory to search", ), @@ -108,11 +114,11 @@ class Migration(migrations.Migration): ), migrations.AddField( model_name="categorytypetwopage", - name="fis_directory_widget", + name="directory_search", field=wagtail.fields.StreamField( [ ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -132,8 +138,11 @@ class Migration(migrations.Migration): "directory", wagtail.blocks.ChoiceBlock( choices=[ - ("send", "send"), - ("familyinfo", "familyinfo"), + ("send", "SEND"), + ( + "familyinfo", + "Family Information Service", + ), ], help_text="Which directory to search", ), @@ -155,11 +164,11 @@ class Migration(migrations.Migration): ), migrations.AddField( model_name="subsitehomepage", - name="fis_directory_widget", + name="directory_search", field=wagtail.fields.StreamField( [ ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -179,8 +188,11 @@ class Migration(migrations.Migration): "directory", wagtail.blocks.ChoiceBlock( choices=[ - ("send", "send"), - ("familyinfo", "familyinfo"), + ("send", "SEND"), + ( + "familyinfo", + "Family Information Service", + ), ], help_text="Which directory to search", ), diff --git a/bc/family_information/models.py b/bc/family_information/models.py index 37a27203..ab7b0743 100644 --- a/bc/family_information/models.py +++ b/bc/family_information/models.py @@ -15,7 +15,7 @@ from ..standardpages.models import IndexPage from ..utils.models import BasePage, PageTopTask from .blocks import CardsBlock, ThreeCardRowBlock, TwoCardRowBlock -from ..utils.blocks import DirectoryWidgetBlock +from ..utils.blocks import DirectorySearchBlock from ..utils.models import BasePage @@ -123,8 +123,8 @@ class SubsiteHomePage(FISBannerFields, BasePage): blank=True, default="Get information, advice and guidance", max_length=255 ) - fis_directory_widget = StreamField( - [("fis_directory_widget", DirectoryWidgetBlock())], blank=True, max_num=1 + directory_search = StreamField( + [("directory_search", DirectorySearchBlock())], blank=True, max_num=1 ) call_to_action = models.ForeignKey( @@ -167,7 +167,7 @@ class SubsiteHomePage(FISBannerFields, BasePage): ), FieldPanel("heading"), FieldPanel("highlighted_cards"), - FieldPanel("fis_directory_widget"), + FieldPanel("directory_search"), ] + FISBannerFields.content_panels + [FieldPanel("search_prompt_text"), FieldPanel("call_to_action")] @@ -247,11 +247,11 @@ class BaseCategoryPage(FISBannerFields, BasePage): # Other child pages other_pages_heading = models.CharField(default="Others", max_length=255) - fis_directory_widget = StreamField( + directory_search = StreamField( [ ( - "fis_directory_widget", - DirectoryWidgetBlock( + "directory_search", + DirectorySearchBlock( template="patterns/organisms/search-widget/search-widget.html" ), ) @@ -286,7 +286,7 @@ class BaseCategoryPage(FISBannerFields, BasePage): " isn't displayed.)" ), ), - FieldPanel("fis_directory_widget"), + FieldPanel("directory_search"), ] + FISBannerFields.content_panels ) diff --git a/bc/inlineindex/migrations/0035_add_directory_widget.py b/bc/inlineindex/migrations/0035_add_directory_search_block.py similarity index 98% rename from bc/inlineindex/migrations/0035_add_directory_widget.py rename to bc/inlineindex/migrations/0035_add_directory_search_block.py index 91895eed..a6710b43 100644 --- a/bc/inlineindex/migrations/0035_add_directory_widget.py +++ b/bc/inlineindex/migrations/0035_add_directory_search_block.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.11 on 2024-06-27 18:39 +# Generated by Django 4.2.11 on 2024-07-19 10:04 import bc.utils.blocks from django.db import migrations @@ -225,7 +225,7 @@ class Migration(migrations.Migration): ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -245,8 +245,11 @@ class Migration(migrations.Migration): "directory", wagtail.blocks.ChoiceBlock( choices=[ - ("send", "send"), - ("familyinfo", "familyinfo"), + ("send", "SEND"), + ( + "familyinfo", + "Family Information Service", + ), ], help_text="Which directory to search", ), @@ -525,7 +528,7 @@ class Migration(migrations.Migration): bc.utils.blocks.InsetTextBlock(), ), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -548,11 +551,11 @@ class Migration(migrations.Migration): choices=[ ( "send", - "send", + "SEND", ), ( "familyinfo", - "familyinfo", + "Family Information Service", ), ], help_text="Which directory to search", @@ -821,7 +824,7 @@ class Migration(migrations.Migration): ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -841,8 +844,11 @@ class Migration(migrations.Migration): "directory", wagtail.blocks.ChoiceBlock( choices=[ - ("send", "send"), - ("familyinfo", "familyinfo"), + ("send", "SEND"), + ( + "familyinfo", + "Family Information Service", + ), ], help_text="Which directory to search", ), @@ -1121,7 +1127,7 @@ class Migration(migrations.Migration): bc.utils.blocks.InsetTextBlock(), ), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -1144,11 +1150,11 @@ class Migration(migrations.Migration): choices=[ ( "send", - "send", + "SEND", ), ( "familyinfo", - "familyinfo", + "Family Information Service", ), ], help_text="Which directory to search", diff --git a/bc/location/migrations/0016_add_directory_widget.py b/bc/location/migrations/0016_add_directory_search_block.py similarity index 98% rename from bc/location/migrations/0016_add_directory_widget.py rename to bc/location/migrations/0016_add_directory_search_block.py index c4f42cba..754fe491 100644 --- a/bc/location/migrations/0016_add_directory_widget.py +++ b/bc/location/migrations/0016_add_directory_search_block.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.11 on 2024-06-27 18:39 +# Generated by Django 4.2.11 on 2024-07-19 10:04 import bc.utils.blocks from django.db import migrations @@ -225,7 +225,7 @@ class Migration(migrations.Migration): ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -245,8 +245,11 @@ class Migration(migrations.Migration): "directory", wagtail.blocks.ChoiceBlock( choices=[ - ("send", "send"), - ("familyinfo", "familyinfo"), + ("send", "SEND"), + ( + "familyinfo", + "Family Information Service", + ), ], help_text="Which directory to search", ), @@ -525,7 +528,7 @@ class Migration(migrations.Migration): bc.utils.blocks.InsetTextBlock(), ), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -548,11 +551,11 @@ class Migration(migrations.Migration): choices=[ ( "send", - "send", + "SEND", ), ( "familyinfo", - "familyinfo", + "Family Information Service", ), ], help_text="Which directory to search", @@ -822,7 +825,7 @@ class Migration(migrations.Migration): ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -842,8 +845,11 @@ class Migration(migrations.Migration): "directory", wagtail.blocks.ChoiceBlock( choices=[ - ("send", "send"), - ("familyinfo", "familyinfo"), + ("send", "SEND"), + ( + "familyinfo", + "Family Information Service", + ), ], help_text="Which directory to search", ), @@ -1122,7 +1128,7 @@ class Migration(migrations.Migration): bc.utils.blocks.InsetTextBlock(), ), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -1145,11 +1151,11 @@ class Migration(migrations.Migration): choices=[ ( "send", - "send", + "SEND", ), ( "familyinfo", - "familyinfo", + "Family Information Service", ), ], help_text="Which directory to search", @@ -1420,7 +1426,7 @@ class Migration(migrations.Migration): ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -1440,8 +1446,11 @@ class Migration(migrations.Migration): "directory", wagtail.blocks.ChoiceBlock( choices=[ - ("send", "send"), - ("familyinfo", "familyinfo"), + ("send", "SEND"), + ( + "familyinfo", + "Family Information Service", + ), ], help_text="Which directory to search", ), @@ -1720,7 +1729,7 @@ class Migration(migrations.Migration): bc.utils.blocks.InsetTextBlock(), ), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -1743,11 +1752,11 @@ class Migration(migrations.Migration): choices=[ ( "send", - "send", + "SEND", ), ( "familyinfo", - "familyinfo", + "Family Information Service", ), ], help_text="Which directory to search", diff --git a/bc/longform/migrations/0029_add_directory_widget.py b/bc/longform/migrations/0029_add_directory_search_block.py similarity index 98% rename from bc/longform/migrations/0029_add_directory_widget.py rename to bc/longform/migrations/0029_add_directory_search_block.py index 507a48bf..6d7b7882 100644 --- a/bc/longform/migrations/0029_add_directory_widget.py +++ b/bc/longform/migrations/0029_add_directory_search_block.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.11 on 2024-06-27 18:39 +# Generated by Django 4.2.11 on 2024-07-19 10:04 import bc.longform.blocks import bc.utils.blocks @@ -226,7 +226,7 @@ class Migration(migrations.Migration): ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -246,8 +246,11 @@ class Migration(migrations.Migration): "directory", wagtail.blocks.ChoiceBlock( choices=[ - ("send", "send"), - ("familyinfo", "familyinfo"), + ("send", "SEND"), + ( + "familyinfo", + "Family Information Service", + ), ], help_text="Which directory to search", ), @@ -555,7 +558,7 @@ class Migration(migrations.Migration): bc.utils.blocks.InsetTextBlock(), ), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -578,11 +581,11 @@ class Migration(migrations.Migration): choices=[ ( "send", - "send", + "SEND", ), ( "familyinfo", - "familyinfo", + "Family Information Service", ), ], help_text="Which directory to search", @@ -854,7 +857,7 @@ class Migration(migrations.Migration): ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -874,8 +877,11 @@ class Migration(migrations.Migration): "directory", wagtail.blocks.ChoiceBlock( choices=[ - ("send", "send"), - ("familyinfo", "familyinfo"), + ("send", "SEND"), + ( + "familyinfo", + "Family Information Service", + ), ], help_text="Which directory to search", ), @@ -1183,7 +1189,7 @@ class Migration(migrations.Migration): bc.utils.blocks.InsetTextBlock(), ), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -1206,11 +1212,11 @@ class Migration(migrations.Migration): choices=[ ( "send", - "send", + "SEND", ), ( "familyinfo", - "familyinfo", + "Family Information Service", ), ], help_text="Which directory to search", diff --git a/bc/news/migrations/0034_add_directory_widget.py b/bc/news/migrations/0034_add_directory_search_block.py similarity index 98% rename from bc/news/migrations/0034_add_directory_widget.py rename to bc/news/migrations/0034_add_directory_search_block.py index ab06221e..852875a5 100644 --- a/bc/news/migrations/0034_add_directory_widget.py +++ b/bc/news/migrations/0034_add_directory_search_block.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.11 on 2024-06-27 18:39 +# Generated by Django 4.2.11 on 2024-07-19 10:04 import bc.utils.blocks from django.db import migrations @@ -225,7 +225,7 @@ class Migration(migrations.Migration): ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -245,8 +245,11 @@ class Migration(migrations.Migration): "directory", wagtail.blocks.ChoiceBlock( choices=[ - ("send", "send"), - ("familyinfo", "familyinfo"), + ("send", "SEND"), + ( + "familyinfo", + "Family Information Service", + ), ], help_text="Which directory to search", ), @@ -525,7 +528,7 @@ class Migration(migrations.Migration): bc.utils.blocks.InsetTextBlock(), ), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -548,11 +551,11 @@ class Migration(migrations.Migration): choices=[ ( "send", - "send", + "SEND", ), ( "familyinfo", - "familyinfo", + "Family Information Service", ), ], help_text="Which directory to search", diff --git a/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.html b/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.html index 4ac256b0..287dc8df 100644 --- a/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.html +++ b/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.html @@ -50,8 +50,8 @@

- {% if page.fis_directory_widget %} - {% include_block page.fis_directory_widget %} + {% if page.directory_search %} + {% include_block page.directory_search %} {% endif %} {% include "patterns/molecules/directory-banner/directory-banner.html" with classes="directory-banner--with-space" %} diff --git a/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat1.html b/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat1.html index dfd6b90e..773910f6 100644 --- a/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat1.html +++ b/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat1.html @@ -41,8 +41,8 @@

{{ pa

- {% if page.fis_directory_widget %} - {% include_block page.fis_directory_widget %} + {% if page.directory_search %} + {% include_block page.directory_search %} {% endif %} {% include "patterns/molecules/directory-banner/directory-banner.html" with classes="directory-banner--with-space" %} diff --git a/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat2.html b/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat2.html index 5406fd2e..225bf11d 100644 --- a/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat2.html +++ b/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat2.html @@ -42,8 +42,8 @@

{{ pa - {% if page.fis_directory_widget %} - {% include_block page.fis_directory_widget %} + {% if page.directory_search %} + {% include_block page.directory_search %} {% endif %} {% include "patterns/molecules/directory-banner/directory-banner.html" with classes="directory-banner--with-space" %} diff --git a/bc/recruitment/migrations/0064_add_directory_widget.py b/bc/recruitment/migrations/0064_add_directory_search_block.py similarity index 98% rename from bc/recruitment/migrations/0064_add_directory_widget.py rename to bc/recruitment/migrations/0064_add_directory_search_block.py index 08951463..6929f558 100644 --- a/bc/recruitment/migrations/0064_add_directory_widget.py +++ b/bc/recruitment/migrations/0064_add_directory_search_block.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.11 on 2024-06-27 18:39 +# Generated by Django 4.2.11 on 2024-07-19 10:04 import bc.utils.blocks from django.db import migrations @@ -225,7 +225,7 @@ class Migration(migrations.Migration): ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -245,8 +245,11 @@ class Migration(migrations.Migration): "directory", wagtail.blocks.ChoiceBlock( choices=[ - ("send", "send"), - ("familyinfo", "familyinfo"), + ("send", "SEND"), + ( + "familyinfo", + "Family Information Service", + ), ], help_text="Which directory to search", ), @@ -525,7 +528,7 @@ class Migration(migrations.Migration): bc.utils.blocks.InsetTextBlock(), ), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -548,11 +551,11 @@ class Migration(migrations.Migration): choices=[ ( "send", - "send", + "SEND", ), ( "familyinfo", - "familyinfo", + "Family Information Service", ), ], help_text="Which directory to search", diff --git a/bc/standardpages/migrations/0041_add_directory_widget.py b/bc/standardpages/migrations/0041_add_directory_search_block.py similarity index 98% rename from bc/standardpages/migrations/0041_add_directory_widget.py rename to bc/standardpages/migrations/0041_add_directory_search_block.py index 4732415a..7433b4c6 100644 --- a/bc/standardpages/migrations/0041_add_directory_widget.py +++ b/bc/standardpages/migrations/0041_add_directory_search_block.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.11 on 2024-06-27 18:39 +# Generated by Django 4.2.11 on 2024-07-19 10:04 import bc.utils.blocks from django.db import migrations @@ -225,7 +225,7 @@ class Migration(migrations.Migration): ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -245,8 +245,11 @@ class Migration(migrations.Migration): "directory", wagtail.blocks.ChoiceBlock( choices=[ - ("send", "send"), - ("familyinfo", "familyinfo"), + ("send", "SEND"), + ( + "familyinfo", + "Family Information Service", + ), ], help_text="Which directory to search", ), @@ -525,7 +528,7 @@ class Migration(migrations.Migration): bc.utils.blocks.InsetTextBlock(), ), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -548,11 +551,11 @@ class Migration(migrations.Migration): choices=[ ( "send", - "send", + "SEND", ), ( "familyinfo", - "familyinfo", + "Family Information Service", ), ], help_text="Which directory to search", @@ -821,7 +824,7 @@ class Migration(migrations.Migration): ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -841,8 +844,11 @@ class Migration(migrations.Migration): "directory", wagtail.blocks.ChoiceBlock( choices=[ - ("send", "send"), - ("familyinfo", "familyinfo"), + ("send", "SEND"), + ( + "familyinfo", + "Family Information Service", + ), ], help_text="Which directory to search", ), @@ -1121,7 +1127,7 @@ class Migration(migrations.Migration): bc.utils.blocks.InsetTextBlock(), ), ( - "fis_directory_widget", + "directory_search", wagtail.blocks.StructBlock( [ ( @@ -1144,11 +1150,11 @@ class Migration(migrations.Migration): choices=[ ( "send", - "send", + "SEND", ), ( "familyinfo", - "familyinfo", + "Family Information Service", ), ], help_text="Which directory to search", diff --git a/bc/utils/blocks.py b/bc/utils/blocks.py index 98b293f9..d4806a53 100644 --- a/bc/utils/blocks.py +++ b/bc/utils/blocks.py @@ -1,8 +1,10 @@ import copy +import logging from urllib.parse import parse_qsl from django import forms from django.core.exceptions import ValidationError +from django.db.models import TextChoices from django.forms.utils import ErrorList from django.urls import reverse from django.utils.functional import cached_property @@ -20,6 +22,8 @@ from .utils import convert_markdown_links_to_html, is_number from .widgets import BarChartInput, LineChartInput, PieChartInput +logger = logging.getLogger(__name__) + class TableBlock(BaseTableBlock): def render(self, value, context=None): @@ -581,16 +585,22 @@ def get_context(self, value, parent_context=None): ) -class DirectoryWidgetBlock(blocks.StructBlock): +class Directory(TextChoices): + SEND = "send", "SEND" + FAMILYINFO = "familyinfo", "Family Information Service" + + +def get_directory_url(directory: Directory, /) -> str: + return f"https://directory.{directory.value}.buckinghamshire.gov.uk/" + + +class DirectorySearchBlock(blocks.StructBlock): title = blocks.CharBlock(required=True, help_text="Title of the widget") search_placeholder = blocks.CharBlock( required=False, help_text="Placeholder text for the search input" ) directory = blocks.ChoiceBlock( - choices=[ - ("send", "send"), - ("familyinfo", "familyinfo"), - ], + choices=Directory.choices, required=True, help_text="Which directory to search", ) @@ -604,19 +614,23 @@ class DirectoryWidgetBlock(blocks.StructBlock): class Meta: template = "patterns/molecules/streamfield/blocks/search-widget.html" icon = "link" - label = "FIS Directory Widget" def get_context(self, value, parent_context=None): context = super().get_context(value, parent_context) + try: + directory = Directory(value["directory"]) + except ValueError: + logger.error("Invalid directory value", exc_info=True) + return context + + # Build the query params and the target URL for the directory search. if value["extra_query_params"]: extra_query_params = value["extra_query_params"] if extra_query_params.startswith("?"): extra_query_params = extra_query_params[1:] extra_query_params = parse_qsl(extra_query_params) context["extra_query_params"] = extra_query_params - context["directory_url"] = ( - f'https://directory.{value["directory"]}.buckinghamshire.gov.uk/' - ) + context["directory_url"] = get_directory_url(directory) return context @@ -658,7 +672,7 @@ class BaseStoryBlock(blocks.StreamBlock): highlight = HighlightBlock() inset_text = InsetTextBlock() ehc_co_search = EHCCoSearchBlock(label="EHCCo Search") - fis_directory_widget = DirectoryWidgetBlock() + directory_search = DirectorySearchBlock() class Meta: abstract = True From 182773d8fd8b2c0a13feda883960392549ea5d47 Mon Sep 17 00:00:00 2001 From: Tomasz Knapik Date: Fri, 19 Jul 2024 12:26:54 +0100 Subject: [PATCH 14/59] Re-generate migrations after rebase --- ....py => 0019_add_directory_search_block.py} | 24 +++++++++++-- .../0026_add_directory_search_block.py} | 30 ++++++++++++++-- .../0034_add_directory_search_block.py | 16 +++++++-- ....py => 0015_add_directory_search_block.py} | 4 +-- bc/family_information/models.py | 6 ++-- ....py => 0036_add_directory_search_block.py} | 24 +++++++++++-- ....py => 0017_add_directory_search_block.py} | 34 +++++++++++++++++-- ....py => 0030_add_directory_search_block.py} | 24 +++++++++++-- .../0035_add_directory_search_block.py} | 30 +++++++--------- .../patterns/pages/home/home_page--fis.yaml | 2 -- ....py => 0065_add_directory_search_block.py} | 14 ++++++-- ....py => 0042_add_directory_search_block.py} | 24 +++++++++++-- bc/utils/blocks.py | 2 +- 13 files changed, 191 insertions(+), 43 deletions(-) rename bc/blogs/migrations/{0018_add_directory_search_block.py => 0019_add_directory_search_block.py} (98%) rename bc/{events/migrations/0033_add_directory_search_block.py => cases/migrations/0026_add_directory_search_block.py} (96%) rename bc/{news => events}/migrations/0034_add_directory_search_block.py (98%) rename bc/family_information/migrations/{0011_add_directory_search_block.py => 0015_add_directory_search_block.py} (98%) rename bc/inlineindex/migrations/{0035_add_directory_search_block.py => 0036_add_directory_search_block.py} (98%) rename bc/location/migrations/{0016_add_directory_search_block.py => 0017_add_directory_search_block.py} (98%) rename bc/longform/migrations/{0029_add_directory_search_block.py => 0030_add_directory_search_block.py} (98%) rename bc/{cases/migrations/0025_add_directory_search_block.py => news/migrations/0035_add_directory_search_block.py} (98%) rename bc/recruitment/migrations/{0064_add_directory_search_block.py => 0065_add_directory_search_block.py} (98%) rename bc/standardpages/migrations/{0041_add_directory_search_block.py => 0042_add_directory_search_block.py} (98%) diff --git a/bc/blogs/migrations/0018_add_directory_search_block.py b/bc/blogs/migrations/0019_add_directory_search_block.py similarity index 98% rename from bc/blogs/migrations/0018_add_directory_search_block.py rename to bc/blogs/migrations/0019_add_directory_search_block.py index 73bb9321..539257c3 100644 --- a/bc/blogs/migrations/0018_add_directory_search_block.py +++ b/bc/blogs/migrations/0019_add_directory_search_block.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.11 on 2024-07-19 10:04 +# Generated by Django 4.2.11 on 2024-07-19 11:25 import bc.utils.blocks from django.db import migrations @@ -12,7 +12,7 @@ class Migration(migrations.Migration): dependencies = [ - ("blogs", "0017_tableblock_help_text"), + ("blogs", "0018_add_ehcco_search_widget"), ] operations = [ @@ -224,6 +224,10 @@ class Migration(migrations.Migration): ), ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -527,6 +531,12 @@ class Migration(migrations.Migration): "inset_text", bc.utils.blocks.InsetTextBlock(), ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -823,6 +833,10 @@ class Migration(migrations.Migration): ), ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -1126,6 +1140,12 @@ class Migration(migrations.Migration): "inset_text", bc.utils.blocks.InsetTextBlock(), ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), ( "directory_search", wagtail.blocks.StructBlock( diff --git a/bc/events/migrations/0033_add_directory_search_block.py b/bc/cases/migrations/0026_add_directory_search_block.py similarity index 96% rename from bc/events/migrations/0033_add_directory_search_block.py rename to bc/cases/migrations/0026_add_directory_search_block.py index df43bc2c..ae6d0ff7 100644 --- a/bc/events/migrations/0033_add_directory_search_block.py +++ b/bc/cases/migrations/0026_add_directory_search_block.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.11 on 2024-07-19 10:04 +# Generated by Django 4.2.11 on 2024-07-19 11:25 import bc.utils.blocks from django.db import migrations @@ -12,12 +12,12 @@ class Migration(migrations.Migration): dependencies = [ - ("events", "0032_tableblock_help_text"), + ("cases", "0025_add_ehcco_search_widget"), ] operations = [ migrations.AlterField( - model_name="eventpage", + model_name="apteanrespondcaseformpage", name="body", field=wagtail.fields.StreamField( [ @@ -224,6 +224,10 @@ class Migration(migrations.Migration): ), ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -527,6 +531,12 @@ class Migration(migrations.Migration): "inset_text", bc.utils.blocks.InsetTextBlock(), ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -612,6 +622,20 @@ class Migration(migrations.Migration): ] ), ), + ( + "form_link_button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title", + help_text="The button label", + ), + ) + ] + ), + ), ] ), ), diff --git a/bc/news/migrations/0034_add_directory_search_block.py b/bc/events/migrations/0034_add_directory_search_block.py similarity index 98% rename from bc/news/migrations/0034_add_directory_search_block.py rename to bc/events/migrations/0034_add_directory_search_block.py index 852875a5..0543234a 100644 --- a/bc/news/migrations/0034_add_directory_search_block.py +++ b/bc/events/migrations/0034_add_directory_search_block.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.11 on 2024-07-19 10:04 +# Generated by Django 4.2.11 on 2024-07-19 11:25 import bc.utils.blocks from django.db import migrations @@ -12,12 +12,12 @@ class Migration(migrations.Migration): dependencies = [ - ("news", "0033_django_40_upgrade"), + ("events", "0033_add_ehcco_search_widget"), ] operations = [ migrations.AlterField( - model_name="newspage", + model_name="eventpage", name="body", field=wagtail.fields.StreamField( [ @@ -224,6 +224,10 @@ class Migration(migrations.Migration): ), ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -527,6 +531,12 @@ class Migration(migrations.Migration): "inset_text", bc.utils.blocks.InsetTextBlock(), ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), ( "directory_search", wagtail.blocks.StructBlock( diff --git a/bc/family_information/migrations/0011_add_directory_search_block.py b/bc/family_information/migrations/0015_add_directory_search_block.py similarity index 98% rename from bc/family_information/migrations/0011_add_directory_search_block.py rename to bc/family_information/migrations/0015_add_directory_search_block.py index 6c533a1e..ec94b653 100644 --- a/bc/family_information/migrations/0011_add_directory_search_block.py +++ b/bc/family_information/migrations/0015_add_directory_search_block.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.11 on 2024-07-19 10:04 +# Generated by Django 4.2.11 on 2024-07-19 11:25 from django.db import migrations import wagtail.blocks @@ -8,7 +8,7 @@ class Migration(migrations.Migration): dependencies = [ - ("family_information", "0010_subsitehomepage_heading"), + ("family_information", "0014_merge_20240709_1347"), ] operations = [ diff --git a/bc/family_information/models.py b/bc/family_information/models.py index ab7b0743..f2aa69db 100644 --- a/bc/family_information/models.py +++ b/bc/family_information/models.py @@ -13,10 +13,9 @@ from ..news.models import NewsIndex from ..standardpages.models import IndexPage +from ..utils.blocks import DirectorySearchBlock from ..utils.models import BasePage, PageTopTask from .blocks import CardsBlock, ThreeCardRowBlock, TwoCardRowBlock -from ..utils.blocks import DirectorySearchBlock -from ..utils.models import BasePage class FISBannerFields(models.Model): @@ -287,7 +286,8 @@ class BaseCategoryPage(FISBannerFields, BasePage): ), ), FieldPanel("directory_search"), - ] + FISBannerFields.content_panels + ] + + FISBannerFields.content_panels ) search_fields = BasePage.search_fields + FISBannerFields.search_fields diff --git a/bc/inlineindex/migrations/0035_add_directory_search_block.py b/bc/inlineindex/migrations/0036_add_directory_search_block.py similarity index 98% rename from bc/inlineindex/migrations/0035_add_directory_search_block.py rename to bc/inlineindex/migrations/0036_add_directory_search_block.py index a6710b43..b5f1f1ff 100644 --- a/bc/inlineindex/migrations/0035_add_directory_search_block.py +++ b/bc/inlineindex/migrations/0036_add_directory_search_block.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.11 on 2024-07-19 10:04 +# Generated by Django 4.2.11 on 2024-07-19 11:25 import bc.utils.blocks from django.db import migrations @@ -12,7 +12,7 @@ class Migration(migrations.Migration): dependencies = [ - ("inlineindex", "0034_tableblock_help_text"), + ("inlineindex", "0035_add_ehcco_search_widget"), ] operations = [ @@ -224,6 +224,10 @@ class Migration(migrations.Migration): ), ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -527,6 +531,12 @@ class Migration(migrations.Migration): "inset_text", bc.utils.blocks.InsetTextBlock(), ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -823,6 +833,10 @@ class Migration(migrations.Migration): ), ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -1126,6 +1140,12 @@ class Migration(migrations.Migration): "inset_text", bc.utils.blocks.InsetTextBlock(), ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), ( "directory_search", wagtail.blocks.StructBlock( diff --git a/bc/location/migrations/0016_add_directory_search_block.py b/bc/location/migrations/0017_add_directory_search_block.py similarity index 98% rename from bc/location/migrations/0016_add_directory_search_block.py rename to bc/location/migrations/0017_add_directory_search_block.py index 754fe491..ecd8402d 100644 --- a/bc/location/migrations/0016_add_directory_search_block.py +++ b/bc/location/migrations/0017_add_directory_search_block.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.11 on 2024-07-19 10:04 +# Generated by Django 4.2.11 on 2024-07-19 11:25 import bc.utils.blocks from django.db import migrations @@ -12,7 +12,7 @@ class Migration(migrations.Migration): dependencies = [ - ("location", "0015_tableblock_help_text"), + ("location", "0016_add_ehcco_search_widget"), ] operations = [ @@ -224,6 +224,10 @@ class Migration(migrations.Migration): ), ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -527,6 +531,12 @@ class Migration(migrations.Migration): "inset_text", bc.utils.blocks.InsetTextBlock(), ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -824,6 +834,10 @@ class Migration(migrations.Migration): ), ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -1127,6 +1141,12 @@ class Migration(migrations.Migration): "inset_text", bc.utils.blocks.InsetTextBlock(), ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -1425,6 +1445,10 @@ class Migration(migrations.Migration): ), ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -1728,6 +1752,12 @@ class Migration(migrations.Migration): "inset_text", bc.utils.blocks.InsetTextBlock(), ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), ( "directory_search", wagtail.blocks.StructBlock( diff --git a/bc/longform/migrations/0029_add_directory_search_block.py b/bc/longform/migrations/0030_add_directory_search_block.py similarity index 98% rename from bc/longform/migrations/0029_add_directory_search_block.py rename to bc/longform/migrations/0030_add_directory_search_block.py index 6d7b7882..4e57be1f 100644 --- a/bc/longform/migrations/0029_add_directory_search_block.py +++ b/bc/longform/migrations/0030_add_directory_search_block.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.11 on 2024-07-19 10:04 +# Generated by Django 4.2.11 on 2024-07-19 11:25 import bc.longform.blocks import bc.utils.blocks @@ -13,7 +13,7 @@ class Migration(migrations.Migration): dependencies = [ - ("longform", "0028_tableblock_help_text"), + ("longform", "0029_add_ehcco_search_widget"), ] operations = [ @@ -225,6 +225,10 @@ class Migration(migrations.Migration): ), ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -557,6 +561,12 @@ class Migration(migrations.Migration): "inset_text", bc.utils.blocks.InsetTextBlock(), ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -856,6 +866,10 @@ class Migration(migrations.Migration): ), ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -1188,6 +1202,12 @@ class Migration(migrations.Migration): "inset_text", bc.utils.blocks.InsetTextBlock(), ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), ( "directory_search", wagtail.blocks.StructBlock( diff --git a/bc/cases/migrations/0025_add_directory_search_block.py b/bc/news/migrations/0035_add_directory_search_block.py similarity index 98% rename from bc/cases/migrations/0025_add_directory_search_block.py rename to bc/news/migrations/0035_add_directory_search_block.py index d124965e..823a7fb5 100644 --- a/bc/cases/migrations/0025_add_directory_search_block.py +++ b/bc/news/migrations/0035_add_directory_search_block.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.11 on 2024-07-19 10:04 +# Generated by Django 4.2.11 on 2024-07-19 11:25 import bc.utils.blocks from django.db import migrations @@ -12,12 +12,12 @@ class Migration(migrations.Migration): dependencies = [ - ("cases", "0024_tableblock_help_text"), + ("news", "0034_add_ehcco_search_widget"), ] operations = [ migrations.AlterField( - model_name="apteanrespondcaseformpage", + model_name="newspage", name="body", field=wagtail.fields.StreamField( [ @@ -224,6 +224,10 @@ class Migration(migrations.Migration): ), ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -527,6 +531,12 @@ class Migration(migrations.Migration): "inset_text", bc.utils.blocks.InsetTextBlock(), ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -612,20 +622,6 @@ class Migration(migrations.Migration): ] ), ), - ( - "form_link_button", - wagtail.blocks.StructBlock( - [ - ( - "text", - wagtail.blocks.CharBlock( - form_classname="title", - help_text="The button label", - ), - ) - ] - ), - ), ] ), ), diff --git a/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.yaml b/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.yaml index 132820d5..9f638f4b 100644 --- a/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.yaml +++ b/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.yaml @@ -69,8 +69,6 @@ tags: url: https://picsum.photos/600/540.webp pageurl: - block.value.page: - raw: '#' subpage: raw: '#' block.value.page: diff --git a/bc/recruitment/migrations/0064_add_directory_search_block.py b/bc/recruitment/migrations/0065_add_directory_search_block.py similarity index 98% rename from bc/recruitment/migrations/0064_add_directory_search_block.py rename to bc/recruitment/migrations/0065_add_directory_search_block.py index 6929f558..8bf232f7 100644 --- a/bc/recruitment/migrations/0064_add_directory_search_block.py +++ b/bc/recruitment/migrations/0065_add_directory_search_block.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.11 on 2024-07-19 10:04 +# Generated by Django 4.2.11 on 2024-07-19 11:25 import bc.utils.blocks from django.db import migrations @@ -12,7 +12,7 @@ class Migration(migrations.Migration): dependencies = [ - ("recruitment", "0063_tableblock_help_text"), + ("recruitment", "0064_add_ehcco_search_widget"), ] operations = [ @@ -224,6 +224,10 @@ class Migration(migrations.Migration): ), ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -527,6 +531,12 @@ class Migration(migrations.Migration): "inset_text", bc.utils.blocks.InsetTextBlock(), ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), ( "directory_search", wagtail.blocks.StructBlock( diff --git a/bc/standardpages/migrations/0041_add_directory_search_block.py b/bc/standardpages/migrations/0042_add_directory_search_block.py similarity index 98% rename from bc/standardpages/migrations/0041_add_directory_search_block.py rename to bc/standardpages/migrations/0042_add_directory_search_block.py index 7433b4c6..bd36934f 100644 --- a/bc/standardpages/migrations/0041_add_directory_search_block.py +++ b/bc/standardpages/migrations/0042_add_directory_search_block.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.11 on 2024-07-19 10:04 +# Generated by Django 4.2.11 on 2024-07-19 11:25 import bc.utils.blocks from django.db import migrations @@ -12,7 +12,7 @@ class Migration(migrations.Migration): dependencies = [ - ("standardpages", "0040_tableblock_help_text"), + ("standardpages", "0041_add_ehcco_search_widget"), ] operations = [ @@ -224,6 +224,10 @@ class Migration(migrations.Migration): ), ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -527,6 +531,12 @@ class Migration(migrations.Migration): "inset_text", bc.utils.blocks.InsetTextBlock(), ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -823,6 +833,10 @@ class Migration(migrations.Migration): ), ("highlight", bc.utils.blocks.HighlightBlock()), ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), ( "directory_search", wagtail.blocks.StructBlock( @@ -1126,6 +1140,12 @@ class Migration(migrations.Migration): "inset_text", bc.utils.blocks.InsetTextBlock(), ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), ( "directory_search", wagtail.blocks.StructBlock( diff --git a/bc/utils/blocks.py b/bc/utils/blocks.py index d4806a53..684db6ac 100644 --- a/bc/utils/blocks.py +++ b/bc/utils/blocks.py @@ -613,7 +613,7 @@ class DirectorySearchBlock(blocks.StructBlock): class Meta: template = "patterns/molecules/streamfield/blocks/search-widget.html" - icon = "link" + icon = "search" def get_context(self, value, parent_context=None): context = super().get_context(value, parent_context) From 835b8a47577d089cbb7a7d14f45be7f3a2c2570b Mon Sep 17 00:00:00 2001 From: Tomasz Knapik Date: Fri, 19 Jul 2024 13:24:31 +0100 Subject: [PATCH 15/59] Add missing field panel --- bc/family_information/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bc/family_information/models.py b/bc/family_information/models.py index f2aa69db..3594d5bd 100644 --- a/bc/family_information/models.py +++ b/bc/family_information/models.py @@ -381,6 +381,7 @@ class CategoryPage(BaseCategoryPage): " isn't displayed.)" ), ), + FieldPanel("directory_search") ] + FISBannerFields.content_panels ) From b61d2437068f9f2788f997e19d4ef87c40ddd512 Mon Sep 17 00:00:00 2001 From: Tomasz Knapik Date: Fri, 19 Jul 2024 13:29:48 +0100 Subject: [PATCH 16/59] black --- bc/family_information/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bc/family_information/models.py b/bc/family_information/models.py index 3594d5bd..3fc6dbf3 100644 --- a/bc/family_information/models.py +++ b/bc/family_information/models.py @@ -381,7 +381,7 @@ class CategoryPage(BaseCategoryPage): " isn't displayed.)" ), ), - FieldPanel("directory_search") + FieldPanel("directory_search"), ] + FISBannerFields.content_panels ) From 1d25e878f5eec652c500bd17615c3492e6cdf5e6 Mon Sep 17 00:00:00 2001 From: Chris Lawton Date: Fri, 19 Jul 2024 14:30:03 +0100 Subject: [PATCH 17/59] keep the inputs and buttons on the same line on desktop --- bc/static_src/sass/components/_search-widget.scss | 4 ---- 1 file changed, 4 deletions(-) diff --git a/bc/static_src/sass/components/_search-widget.scss b/bc/static_src/sass/components/_search-widget.scss index 0a11cd0f..39d57e12 100644 --- a/bc/static_src/sass/components/_search-widget.scss +++ b/bc/static_src/sass/components/_search-widget.scss @@ -41,10 +41,6 @@ @include media-query(tablet-landscape) { grid-template-columns: 1fr 1fr 1fr; align-items: flex-end; - - #{$root}--sf & { - grid-template-columns: 1fr 1fr; - } } } From 84ba9e2ec3b2bf2e3725908334d22e674d99a34a Mon Sep 17 00:00:00 2001 From: Chris Lawton Date: Fri, 19 Jul 2024 16:21:04 +0100 Subject: [PATCH 18/59] move the widget under the highlighted cards on the homepage --- .../templates/patterns/pages/home/home_page--fis.html | 8 ++++---- bc/static_src/sass/components/_search-widget.scss | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.html b/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.html index 287dc8df..f5183e03 100644 --- a/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.html +++ b/bc/project_styleguide/templates/patterns/pages/home/home_page--fis.html @@ -43,6 +43,10 @@

{% include_block page.highlighted_cards %} {% endif %} + {% if page.directory_search %} + {% include_block page.directory_search %} + {% endif %} +
{% for subpage in page.other_child_pages %} {% include "patterns/molecules/page-card/page-card.html" with classes="card--fis-home" page=subpage %} @@ -50,10 +54,6 @@

- {% if page.directory_search %} - {% include_block page.directory_search %} - {% endif %} - {% include "patterns/molecules/directory-banner/directory-banner.html" with classes="directory-banner--with-space" %} {% include "patterns/molecules/cta/call_to_action.html" with call_to_action=page.call_to_action %} diff --git a/bc/static_src/sass/components/_search-widget.scss b/bc/static_src/sass/components/_search-widget.scss index 39d57e12..05d47c25 100644 --- a/bc/static_src/sass/components/_search-widget.scss +++ b/bc/static_src/sass/components/_search-widget.scss @@ -4,7 +4,7 @@ border-left: 5px solid $color--river; color: $color--default; width: 100%; - margin-bottom: $grid; + margin-bottom: $grid--large; &__form { max-width: $site-width; From 5a68944ae8d7be44b07a73bf4e797f7637f17b4e Mon Sep 17 00:00:00 2001 From: Chris Lawton Date: Fri, 19 Jul 2024 16:21:46 +0100 Subject: [PATCH 19/59] move the search widget on the category page depending on if the page body has content --- .../standardpages/index_page--fis-cat1.html | 21 +++++++++++++++++-- .../standardpages/index_page--fis-cat2.html | 21 +++++++++++++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat1.html b/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat1.html index 773910f6..45866845 100644 --- a/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat1.html +++ b/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat1.html @@ -26,10 +26,22 @@ If content was added to the page body, use that content. If not, behave like before: display all child pages. {% endcomment %} + {% include_block page.body %} + + {% if page.body %} + {% comment %} + If content was added to page.body put the search widget under that but above the other child pages. + {% endcomment %} + {% if page.directory_search %} + {% include_block page.directory_search %} + {% endif %} + {% endif %} + {% if show_other_pages_heading %}

{{ page.other_pages_heading }}

{% endif %} +
{{ pa
- {% if page.directory_search %} - {% include_block page.directory_search %} + {% if not page.body %} + {% comment %} + If content wasn't added to page.body put the search widget under child pages. + {% endcomment %} + {% if page.directory_search %} + {% include_block page.directory_search %} + {% endif %} {% endif %} {% include "patterns/molecules/directory-banner/directory-banner.html" with classes="directory-banner--with-space" %} diff --git a/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat2.html b/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat2.html index 225bf11d..5360054e 100644 --- a/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat2.html +++ b/bc/project_styleguide/templates/patterns/pages/standardpages/index_page--fis-cat2.html @@ -26,8 +26,20 @@ If content was added to the page body, use that content. If not, behave like before: display all child pages. {% endcomment %} +
+ {% include_block page.body %} + + {% if page.body %} + {% comment %} + If content was added to page.body put the search widget under that but above the other child pages. + {% endcomment %} + {% if page.directory_search %} + {% include_block page.directory_search %} + {% endif %} + {% endif %} + {% if show_other_pages_heading %}

{{ page.other_pages_heading }}

{% endif %} @@ -42,8 +54,13 @@

{{ pa

- {% if page.directory_search %} - {% include_block page.directory_search %} + {% if not page.body %} + {% comment %} + If content wasn't added to page.body put the search widget under child pages. + {% endcomment %} + {% if page.directory_search %} + {% include_block page.directory_search %} + {% endif %} {% endif %} {% include "patterns/molecules/directory-banner/directory-banner.html" with classes="directory-banner--with-space" %} From 5ca6a8865554852407c592afbb788e3e192721b8 Mon Sep 17 00:00:00 2001 From: Chris Lawton Date: Fri, 19 Jul 2024 16:35:41 +0100 Subject: [PATCH 20/59] put the streamfield version into two columns expect for when it's used on the homepage --- .../sass/components/_search-widget.scss | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bc/static_src/sass/components/_search-widget.scss b/bc/static_src/sass/components/_search-widget.scss index 05d47c25..1eb2b280 100644 --- a/bc/static_src/sass/components/_search-widget.scss +++ b/bc/static_src/sass/components/_search-widget.scss @@ -61,4 +61,20 @@ max-width: 100%; } } + + &--sf { + #{$root}__form-layout { + @include media-query(tablet-landscape) { + grid-template-columns: 1fr 1fr; + } + } + } + + .template-fis-home & { + #{$root}__form-layout { + @include media-query(tablet-landscape) { + grid-template-columns: 1fr 1fr 1fr; + } + } + } } From bb18c1f2f784ba1f965ac70e8339a71e2d4b9c45 Mon Sep 17 00:00:00 2001 From: Chris Lawton Date: Thu, 25 Jul 2024 09:28:14 +0100 Subject: [PATCH 21/59] update search widget label and placeholder --- .../patterns/organisms/search-widget/search-widget.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html index 06f834a8..895e7371 100644 --- a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html +++ b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html @@ -5,8 +5,8 @@

{{ value.title|default:"Find activities and organisations near you" }}

- - + +
From 81abd6767f52cfc9ecf0b98dcdf0b11f804b42ab Mon Sep 17 00:00:00 2001 From: Chris Lawton Date: Thu, 25 Jul 2024 09:28:25 +0100 Subject: [PATCH 22/59] add space above search widget --- bc/static_src/sass/components/_search-widget.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bc/static_src/sass/components/_search-widget.scss b/bc/static_src/sass/components/_search-widget.scss index 1eb2b280..a6833ca1 100644 --- a/bc/static_src/sass/components/_search-widget.scss +++ b/bc/static_src/sass/components/_search-widget.scss @@ -4,7 +4,7 @@ border-left: 5px solid $color--river; color: $color--default; width: 100%; - margin-bottom: $grid--large; + margin: $grid--large 0; &__form { max-width: $site-width; From 03eb3b64e9704e13d63a64cc59a9c76cfa7f1eb1 Mon Sep 17 00:00:00 2001 From: Chris Lawton Date: Thu, 25 Jul 2024 14:06:54 +0100 Subject: [PATCH 23/59] remove space under widget when used in reverse wrapper --- bc/static_src/sass/components/_search-widget.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bc/static_src/sass/components/_search-widget.scss b/bc/static_src/sass/components/_search-widget.scss index a6833ca1..a59af257 100644 --- a/bc/static_src/sass/components/_search-widget.scss +++ b/bc/static_src/sass/components/_search-widget.scss @@ -6,6 +6,10 @@ width: 100%; margin: $grid--large 0; + .wrapper--desktop-reverse & { + margin-bottom: 0; + } + &__form { max-width: $site-width; padding: 20px; From c1ba3835bd1e19642f179e6a7b963365609d539c Mon Sep 17 00:00:00 2001 From: Chris Lawton Date: Thu, 25 Jul 2024 14:08:25 +0100 Subject: [PATCH 24/59] tidy up spacing for search widget on mobile when in reverse wrapper --- bc/static_src/sass/components/_search-widget.scss | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bc/static_src/sass/components/_search-widget.scss b/bc/static_src/sass/components/_search-widget.scss index a59af257..1e6b2af4 100644 --- a/bc/static_src/sass/components/_search-widget.scss +++ b/bc/static_src/sass/components/_search-widget.scss @@ -7,7 +7,11 @@ margin: $grid--large 0; .wrapper--desktop-reverse & { - margin-bottom: 0; + margin: 0; + + @include media-query(tablet-landscape) { + margin: $grid--large 0 0; + } } &__form { From 6825d7eee73aa275b2db3b3bc60d64ba8e0575f5 Mon Sep 17 00:00:00 2001 From: Tomasz Knapik Date: Thu, 25 Jul 2024 16:13:11 +0100 Subject: [PATCH 25/59] Address feedback https://trello.com/c/09eNT1iH/6-fis-directory-search-widget-fe-and-be#comment-66a1ea6195dc61af11ba2b47 --- ...lock__add_bucks_online_directory_option.py | 1253 +++++++++++ ...lock__add_bucks_online_directory_option.py | 650 ++++++ ...lock__add_bucks_online_directory_option.py | 636 ++++++ ...lock__add_bucks_online_directory_option.py | 245 +++ bc/family_information/models.py | 2 +- ...lock__add_bucks_online_directory_option.py | 1253 +++++++++++ ...lock__add_bucks_online_directory_option.py | 1874 +++++++++++++++++ ...lock__add_bucks_online_directory_option.py | 1318 ++++++++++++ ...lock__add_bucks_online_directory_option.py | 636 ++++++ .../search-widget/search-widget.html | 46 +- ...lock__add_bucks_online_directory_option.py | 637 ++++++ ...lock__add_bucks_online_directory_option.py | 1254 +++++++++++ bc/utils/blocks.py | 22 +- 13 files changed, 9800 insertions(+), 26 deletions(-) create mode 100644 bc/blogs/migrations/0020_directory_search_block__add_bucks_online_directory_option.py create mode 100644 bc/cases/migrations/0027_directory_search_block__add_bucks_online_directory_option.py create mode 100644 bc/events/migrations/0035_directory_search_block__add_bucks_online_directory_option.py create mode 100644 bc/family_information/migrations/0016_directory_search_block__add_bucks_online_directory_option.py create mode 100644 bc/inlineindex/migrations/0037_directory_search_block__add_bucks_online_directory_option.py create mode 100644 bc/location/migrations/0018_directory_search_block__add_bucks_online_directory_option.py create mode 100644 bc/longform/migrations/0031_directory_search_block__add_bucks_online_directory_option.py create mode 100644 bc/news/migrations/0036_directory_search_block__add_bucks_online_directory_option.py create mode 100644 bc/recruitment/migrations/0066_directory_search_block__add_bucks_online_directory_option.py create mode 100644 bc/standardpages/migrations/0043_directory_search_block__add_bucks_online_directory_option.py diff --git a/bc/blogs/migrations/0020_directory_search_block__add_bucks_online_directory_option.py b/bc/blogs/migrations/0020_directory_search_block__add_bucks_online_directory_option.py new file mode 100644 index 00000000..5339d13e --- /dev/null +++ b/bc/blogs/migrations/0020_directory_search_block__add_bucks_online_directory_option.py @@ -0,0 +1,1253 @@ +# Generated by Django 4.2.14 on 2024-07-25 15:10 + +import bc.utils.blocks +from django.db import migrations +import wagtail.blocks +import wagtail.contrib.typed_table_block.blocks +import wagtail.embeds.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ("blogs", "0019_add_directory_search_block"), + ] + + operations = [ + migrations.AlterField( + model_name="blogaboutpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ("send", "SEND"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ( + "send", + "SEND", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ] + ), + ), + migrations.AlterField( + model_name="blogpostpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ("send", "SEND"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ( + "send", + "SEND", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ] + ), + ), + ] diff --git a/bc/cases/migrations/0027_directory_search_block__add_bucks_online_directory_option.py b/bc/cases/migrations/0027_directory_search_block__add_bucks_online_directory_option.py new file mode 100644 index 00000000..5fed5563 --- /dev/null +++ b/bc/cases/migrations/0027_directory_search_block__add_bucks_online_directory_option.py @@ -0,0 +1,650 @@ +# Generated by Django 4.2.14 on 2024-07-25 15:10 + +import bc.utils.blocks +from django.db import migrations +import wagtail.blocks +import wagtail.contrib.typed_table_block.blocks +import wagtail.embeds.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ("cases", "0026_add_directory_search_block"), + ] + + operations = [ + migrations.AlterField( + model_name="apteanrespondcaseformpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ("send", "SEND"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ( + "send", + "SEND", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ( + "form_link_button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title", + help_text="The button label", + ), + ) + ] + ), + ), + ] + ), + ), + ] diff --git a/bc/events/migrations/0035_directory_search_block__add_bucks_online_directory_option.py b/bc/events/migrations/0035_directory_search_block__add_bucks_online_directory_option.py new file mode 100644 index 00000000..191846ba --- /dev/null +++ b/bc/events/migrations/0035_directory_search_block__add_bucks_online_directory_option.py @@ -0,0 +1,636 @@ +# Generated by Django 4.2.14 on 2024-07-25 15:10 + +import bc.utils.blocks +from django.db import migrations +import wagtail.blocks +import wagtail.contrib.typed_table_block.blocks +import wagtail.embeds.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ("events", "0034_add_directory_search_block"), + ] + + operations = [ + migrations.AlterField( + model_name="eventpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ("send", "SEND"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ( + "send", + "SEND", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ] + ), + ), + ] diff --git a/bc/family_information/migrations/0016_directory_search_block__add_bucks_online_directory_option.py b/bc/family_information/migrations/0016_directory_search_block__add_bucks_online_directory_option.py new file mode 100644 index 00000000..130b7c04 --- /dev/null +++ b/bc/family_information/migrations/0016_directory_search_block__add_bucks_online_directory_option.py @@ -0,0 +1,245 @@ +# Generated by Django 4.2.14 on 2024-07-25 15:10 + +from django.db import migrations, models +import wagtail.blocks +import wagtail.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ("family_information", "0015_add_directory_search_block"), + ] + + operations = [ + migrations.AlterField( + model_name="categorypage", + name="directory_search", + field=wagtail.fields.StreamField( + [ + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ("send", "SEND"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ], + template="patterns/organisms/search-widget/search-widget.html", + ), + ) + ], + blank=True, + ), + ), + migrations.AlterField( + model_name="categorypage", + name="other_pages_heading", + field=models.CharField(blank=True, default="Others", max_length=255), + ), + migrations.AlterField( + model_name="categorytypeonepage", + name="directory_search", + field=wagtail.fields.StreamField( + [ + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ("send", "SEND"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ], + template="patterns/organisms/search-widget/search-widget.html", + ), + ) + ], + blank=True, + ), + ), + migrations.AlterField( + model_name="categorytypeonepage", + name="other_pages_heading", + field=models.CharField(blank=True, default="Others", max_length=255), + ), + migrations.AlterField( + model_name="categorytypetwopage", + name="directory_search", + field=wagtail.fields.StreamField( + [ + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ("send", "SEND"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ], + template="patterns/organisms/search-widget/search-widget.html", + ), + ) + ], + blank=True, + ), + ), + migrations.AlterField( + model_name="categorytypetwopage", + name="other_pages_heading", + field=models.CharField(blank=True, default="Others", max_length=255), + ), + migrations.AlterField( + model_name="subsitehomepage", + name="directory_search", + field=wagtail.fields.StreamField( + [ + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ("send", "SEND"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ) + ], + blank=True, + ), + ), + ] diff --git a/bc/family_information/models.py b/bc/family_information/models.py index 3fc6dbf3..e6868bb9 100644 --- a/bc/family_information/models.py +++ b/bc/family_information/models.py @@ -244,7 +244,7 @@ class BaseCategoryPage(FISBannerFields, BasePage): ) # Other child pages - other_pages_heading = models.CharField(default="Others", max_length=255) + other_pages_heading = models.CharField(default="Others", max_length=255, blank=True) directory_search = StreamField( [ diff --git a/bc/inlineindex/migrations/0037_directory_search_block__add_bucks_online_directory_option.py b/bc/inlineindex/migrations/0037_directory_search_block__add_bucks_online_directory_option.py new file mode 100644 index 00000000..a185c4af --- /dev/null +++ b/bc/inlineindex/migrations/0037_directory_search_block__add_bucks_online_directory_option.py @@ -0,0 +1,1253 @@ +# Generated by Django 4.2.14 on 2024-07-25 15:10 + +import bc.utils.blocks +from django.db import migrations +import wagtail.blocks +import wagtail.contrib.typed_table_block.blocks +import wagtail.embeds.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ("inlineindex", "0036_add_directory_search_block"), + ] + + operations = [ + migrations.AlterField( + model_name="inlineindex", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ("send", "SEND"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ( + "send", + "SEND", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ] + ), + ), + migrations.AlterField( + model_name="inlineindexchild", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ("send", "SEND"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ( + "send", + "SEND", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ] + ), + ), + ] diff --git a/bc/location/migrations/0018_directory_search_block__add_bucks_online_directory_option.py b/bc/location/migrations/0018_directory_search_block__add_bucks_online_directory_option.py new file mode 100644 index 00000000..06e519b0 --- /dev/null +++ b/bc/location/migrations/0018_directory_search_block__add_bucks_online_directory_option.py @@ -0,0 +1,1874 @@ +# Generated by Django 4.2.14 on 2024-07-25 15:10 + +import bc.utils.blocks +from django.db import migrations +import wagtail.blocks +import wagtail.contrib.typed_table_block.blocks +import wagtail.embeds.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ("location", "0017_add_directory_search_block"), + ] + + operations = [ + migrations.AlterField( + model_name="locationindexpage", + name="additional_info", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ("send", "SEND"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ( + "send", + "SEND", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ], + blank=True, + ), + ), + migrations.AlterField( + model_name="locationpage", + name="additional_info", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ("send", "SEND"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ( + "send", + "SEND", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ], + blank=True, + help_text="Additional information about this location like opening times, facilities, etc. This will appear above the map in the template.", + ), + ), + migrations.AlterField( + model_name="locationpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ("send", "SEND"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ( + "send", + "SEND", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ], + help_text="Generic body content. This will appear after the map in the template.", + ), + ), + ] diff --git a/bc/longform/migrations/0031_directory_search_block__add_bucks_online_directory_option.py b/bc/longform/migrations/0031_directory_search_block__add_bucks_online_directory_option.py new file mode 100644 index 00000000..c78a19f9 --- /dev/null +++ b/bc/longform/migrations/0031_directory_search_block__add_bucks_online_directory_option.py @@ -0,0 +1,1318 @@ +# Generated by Django 4.2.14 on 2024-07-25 15:10 + +import bc.longform.blocks +import bc.utils.blocks +from django.db import migrations +import wagtail.blocks +import wagtail.contrib.typed_table_block.blocks +import wagtail.embeds.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ("longform", "0030_add_directory_search_block"), + ] + + operations = [ + migrations.AlterField( + model_name="longformchapterpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ("send", "SEND"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ( + "subsubheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subsubheading uses the subsubheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="H4", + template="patterns/molecules/streamfield/blocks/subsubheading_block.html", + ), + ), + ( + "numbered_heading", + bc.longform.blocks.NumberedHeadingBlock( + help_text='Adds a number to the heading if is_numbered is not enabled on the long-form content page (e.g. 1. My heading). The link to this heading will be "section-x" where x is the heading number.' + ), + ), + ( + "numbered_subheading", + bc.longform.blocks.NumberedSubheadingBlock( + help_text='Adds a number to the subheading (e.g. 1.1. My subheading). The link to this subheading will be "section-x.y" where x is the heading or chapter number, and y is the subheading number.' + ), + ), + ( + "numbered_paragraph", + bc.longform.blocks.NumberedParagraphBlock( + help_text='Adds a number before the paragraph (e.g. 1.1.1.). The link to this paragraph will be "section-x.y.z" where x is the heading or chapter number, y is the subheading number, and z is the paragraph number.' + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ( + "send", + "SEND", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ("bar_chart", bc.utils.blocks.BarChartBlock()), + ("line_graph", bc.utils.blocks.LineChartBlock()), + ("pie_chart", bc.utils.blocks.PieChartBlock()), + ] + ), + ), + migrations.AlterField( + model_name="longformpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ("send", "SEND"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ( + "subsubheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subsubheading uses the subsubheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="H4", + template="patterns/molecules/streamfield/blocks/subsubheading_block.html", + ), + ), + ( + "numbered_heading", + bc.longform.blocks.NumberedHeadingBlock( + help_text='Adds a number to the heading if is_numbered is not enabled on the long-form content page (e.g. 1. My heading). The link to this heading will be "section-x" where x is the heading number.' + ), + ), + ( + "numbered_subheading", + bc.longform.blocks.NumberedSubheadingBlock( + help_text='Adds a number to the subheading (e.g. 1.1. My subheading). The link to this subheading will be "section-x.y" where x is the heading or chapter number, and y is the subheading number.' + ), + ), + ( + "numbered_paragraph", + bc.longform.blocks.NumberedParagraphBlock( + help_text='Adds a number before the paragraph (e.g. 1.1.1.). The link to this paragraph will be "section-x.y.z" where x is the heading or chapter number, y is the subheading number, and z is the paragraph number.' + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ( + "send", + "SEND", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ("bar_chart", bc.utils.blocks.BarChartBlock()), + ("line_graph", bc.utils.blocks.LineChartBlock()), + ("pie_chart", bc.utils.blocks.PieChartBlock()), + ] + ), + ), + ] diff --git a/bc/news/migrations/0036_directory_search_block__add_bucks_online_directory_option.py b/bc/news/migrations/0036_directory_search_block__add_bucks_online_directory_option.py new file mode 100644 index 00000000..8a3a629a --- /dev/null +++ b/bc/news/migrations/0036_directory_search_block__add_bucks_online_directory_option.py @@ -0,0 +1,636 @@ +# Generated by Django 4.2.14 on 2024-07-25 15:10 + +import bc.utils.blocks +from django.db import migrations +import wagtail.blocks +import wagtail.contrib.typed_table_block.blocks +import wagtail.embeds.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ("news", "0035_add_directory_search_block"), + ] + + operations = [ + migrations.AlterField( + model_name="newspage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ("send", "SEND"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ( + "send", + "SEND", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ] + ), + ), + ] diff --git a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html index 895e7371..40c33c4d 100644 --- a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html +++ b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html @@ -1,27 +1,29 @@ {% load wagtailimages_tags %} -
- -

{{ value.title|default:"Find activities and organisations near you" }}

-
-
- - -
+{% if directory_url %} +
+ +

{{ value.title|default:"Find activities and organisations near you" }}

+
+
+ + +
-
- - {% include 'patterns/molecules/location-autocomplete/location-autocomplete.html' with location_autocomplete_id="region-search" location_autocomplete_classes="search-widget__input input" location_autocomplete_placeholder="E.g. Buckingham" %} -
+
+ + {% include 'patterns/molecules/location-autocomplete/location-autocomplete.html' with location_autocomplete_id="region-search" location_autocomplete_classes="search-widget__input input" location_autocomplete_placeholder="E.g. Buckingham" %} +
- {% for key, value in extra_query_params %} - - {% endfor %} + {% for key, value in extra_query_params %} + + {% endfor %} - -
- -
+ +
+ +
+{% endif %} diff --git a/bc/recruitment/migrations/0066_directory_search_block__add_bucks_online_directory_option.py b/bc/recruitment/migrations/0066_directory_search_block__add_bucks_online_directory_option.py new file mode 100644 index 00000000..11f18384 --- /dev/null +++ b/bc/recruitment/migrations/0066_directory_search_block__add_bucks_online_directory_option.py @@ -0,0 +1,637 @@ +# Generated by Django 4.2.14 on 2024-07-25 15:10 + +import bc.utils.blocks +from django.db import migrations +import wagtail.blocks +import wagtail.contrib.typed_table_block.blocks +import wagtail.embeds.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ("recruitment", "0065_add_directory_search_block"), + ] + + operations = [ + migrations.AlterField( + model_name="recruitmentindexpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ("send", "SEND"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ( + "send", + "SEND", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ], + blank=True, + ), + ), + ] diff --git a/bc/standardpages/migrations/0043_directory_search_block__add_bucks_online_directory_option.py b/bc/standardpages/migrations/0043_directory_search_block__add_bucks_online_directory_option.py new file mode 100644 index 00000000..3a080479 --- /dev/null +++ b/bc/standardpages/migrations/0043_directory_search_block__add_bucks_online_directory_option.py @@ -0,0 +1,1254 @@ +# Generated by Django 4.2.14 on 2024-07-25 15:10 + +import bc.utils.blocks +from django.db import migrations +import wagtail.blocks +import wagtail.contrib.typed_table_block.blocks +import wagtail.embeds.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ("standardpages", "0042_add_directory_search_block"), + ] + + operations = [ + migrations.AlterField( + model_name="informationpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ("send", "SEND"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ( + "send", + "SEND", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ] + ), + ), + migrations.AlterField( + model_name="wastewizardpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", required=True + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ("send", "SEND"), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

Find local information

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

While we finish building this new website, we’re keeping some local information on our old council websites

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Enter your postcode to help us redirect you to the right place.

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

Select your local area to help us direct you to the right place:

", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), + ( + "directory_search", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Title of the widget", + required=True, + ), + ), + ( + "search_placeholder", + wagtail.blocks.CharBlock( + help_text="Placeholder text for the search input", + required=False, + ), + ), + ( + "directory", + wagtail.blocks.ChoiceBlock( + choices=[ + ( + "bucks_online_directory", + "Bucks Online Directory", + ), + ( + "familyinfo", + "Family Information Service", + ), + ( + "send", + "SEND", + ), + ], + help_text="Which directory to search", + ), + ), + ( + "extra_query_params", + wagtail.blocks.CharBlock( + help_text="Extra query parameters to add to the search, e.g. ?collection=things-to-do&needs=autism", + required=False, + ), + ), + ] + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ("waste_wizard", bc.utils.blocks.WasteWizardSnippetBlock()), + ] + ), + ), + ] diff --git a/bc/utils/blocks.py b/bc/utils/blocks.py index 684db6ac..50a8651e 100644 --- a/bc/utils/blocks.py +++ b/bc/utils/blocks.py @@ -586,12 +586,22 @@ def get_context(self, value, parent_context=None): class Directory(TextChoices): - SEND = "send", "SEND" + BUCKS_ONLINE_DIRECTORY = "bucks_online_directory", "Bucks Online Directory" FAMILYINFO = "familyinfo", "Family Information Service" + SEND = "send", "SEND" def get_directory_url(directory: Directory, /) -> str: - return f"https://directory.{directory.value}.buckinghamshire.gov.uk/" + if directory is Directory.BUCKS_ONLINE_DIRECTORY: + return "https://directory.buckinghamshire.gov.uk/" + elif any(directory is member for member in [Directory.FAMILYINFO, Directory.SEND]): + return ( + f"https://directory.{directory.value}.buckinghamshire.gov.uk/" # noqa: E231 + ) + else: + raise NotImplementedError( + f"get_directory_url is not implemented for: {repr(directory)}" + ) class DirectorySearchBlock(blocks.StructBlock): @@ -630,7 +640,13 @@ def get_context(self, value, parent_context=None): extra_query_params = extra_query_params[1:] extra_query_params = parse_qsl(extra_query_params) context["extra_query_params"] = extra_query_params - context["directory_url"] = get_directory_url(directory) + + try: + context["directory_url"] = get_directory_url(directory) + except NotImplementedError: + logger.exception("Could not get directory URL.") + context["directory_url"] = None + return context From 566210b889848edf1494a9b904b307b3884e7c29 Mon Sep 17 00:00:00 2001 From: Tomasz Knapik Date: Tue, 6 Aug 2024 10:23:57 +0100 Subject: [PATCH 26/59] Update documentation --- docs/location-autocomplete.md | 15 +++++++++++++++ docs/location-maps-widget.md | 4 +++- mkdocs.yml | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 docs/location-autocomplete.md diff --git a/docs/location-autocomplete.md b/docs/location-autocomplete.md new file mode 100644 index 00000000..e99deed6 --- /dev/null +++ b/docs/location-autocomplete.md @@ -0,0 +1,15 @@ +# Location autocomplete widget + +Directory search widget streamfield block has a location autocomplete field. + +The HTML template of the block can be found at +[bc/project_styleguide/templates/patterns/molecules/location-autocomplete/location-autocomplete.html](https://git.torchbox.com/buckinghamshire-council/bc/-/blob/release/bc/project_styleguide/templates/patterns/molecules/location-autocomplete/location-autocomplete.html). + +The JavaScript component can be found at +[bc/static_src/javascript/components/location-autocomplete.js](https://git.torchbox.com/buckinghamshire-council/bc/-/blob/release/bc/static_src/javascript/components/location-autocomplete.js). + +It uses Google Maps API to provide location suggestions: https://developers.google.com/maps/documentation/javascript/reference/places-autocomplete-service + +## Configuration + +It requires the `GOOGLE_MAPS_V3_APIKEY` environment variable to be configured. This settings is also used by different components on the website (e.g. [location maps widget](location-maps-widget.md)). diff --git a/docs/location-maps-widget.md b/docs/location-maps-widget.md index aa335def..b98ac1cb 100644 --- a/docs/location-maps-widget.md +++ b/docs/location-maps-widget.md @@ -6,4 +6,6 @@ We use [Wagtail-Geo-Widget](https://github.com/Frojd/wagtail-geo-widget/) as a w Set the environment variables -- `GOOGLE_MAPS_V3_APIKEY` ([How to retrieve the api key](https://github.com/Frojd/wagtail-geo-widget/blob/main/docs/getting-started.md#retriving-a-google-maps-api-key)) +- `GOOGLE_MAPS_V3_APIKEY` ([How to retrieve the api key](https://github.com/Frojd/wagtail-geo-widget/blob/main/docs/getting-started-with-google-maps.md#retriving-a-google-maps-api-key)) + +This variable is also used by the [location autocomplete widget](./location-autocomplete.md). diff --git a/mkdocs.yml b/mkdocs.yml index 008fab1d..bf6180e6 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -38,6 +38,7 @@ nav: - 'Recruitment site': 'recruitment-site.md' - 'Complaints and requests': 'complaints-and-requests.md' - 'Live chat client': 'live-chat-client.md' + - 'Location autocomplete': 'location-autocomplete.md' - 'Location maps widget': 'location-maps-widget.md' - 'Postcode lookup': 'postcode-lookup.md' - 'Contributing': 'contributing.md' From b1a2d8f45447ae0c54240e0a8061b53a54a13eab Mon Sep 17 00:00:00 2001 From: Tomasz Knapik Date: Tue, 6 Aug 2024 10:58:50 +0100 Subject: [PATCH 27/59] Address feedback --- .gitlab-ci.yml | 1 + .../patterns/organisms/search-widget/search-widget.html | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 898dc172..8838b59b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -154,6 +154,7 @@ test_python: # Postgres credentials POSTGRES_USER: db_user POSTGRES_PASSWORD: db_pass # pragma: allowlist secret + POSTGRES_HOST_AUTH_METHOD: trust # This is the URL used by databases on our CI. DATABASE_URL: postgres://db_user:db_pass@postgres/postgres # pragma: allowlist secret diff --git a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html index 40c33c4d..d0788c65 100644 --- a/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html +++ b/bc/project_styleguide/templates/patterns/organisms/search-widget/search-widget.html @@ -12,7 +12,7 @@

{{ value.title|default:"F
- {% include 'patterns/molecules/location-autocomplete/location-autocomplete.html' with location_autocomplete_id="region-search" location_autocomplete_classes="search-widget__input input" location_autocomplete_placeholder="E.g. Buckingham" %} + {% include 'patterns/molecules/location-autocomplete/location-autocomplete.html' with location_autocomplete_id="region-search" location_autocomplete_classes="search-widget__input input" location_autocomplete_placeholder="For example, Buckingham" %}
{% for key, value in extra_query_params %} From 026255c38de3c91cda8bb3840803b5a6df458d35 Mon Sep 17 00:00:00 2001 From: Tomasz Knapik Date: Tue, 6 Aug 2024 11:02:32 +0100 Subject: [PATCH 28/59] Remove POSTGRES_HOST_AUTH_METHOD again --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8838b59b..898dc172 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -154,7 +154,6 @@ test_python: # Postgres credentials POSTGRES_USER: db_user POSTGRES_PASSWORD: db_pass # pragma: allowlist secret - POSTGRES_HOST_AUTH_METHOD: trust # This is the URL used by databases on our CI. DATABASE_URL: postgres://db_user:db_pass@postgres/postgres # pragma: allowlist secret From 5e5e537cfd5e1a0fd36f7f12b6c2a45ab4d6d3b1 Mon Sep 17 00:00:00 2001 From: Tomasz Knapik Date: Tue, 6 Aug 2024 11:43:27 +0100 Subject: [PATCH 29/59] Update changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8127985e..80c263d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,9 @@ ## Unreleased -- ... +Compare: + +- [Directory search block](https://trello.com/c/09eNT1iH/6-fis-directory-search-widget-fe-and-be) ([Merge request #712](https://git.torchbox.com/buckinghamshire-council/bc/-/merge_requests/712)) ## 77.0 (2024-07-29) From b63fea3b3846f905325203c2ecff751cb88c79a5 Mon Sep 17 00:00:00 2001 From: Tomasz Knapik Date: Tue, 6 Aug 2024 11:43:27 +0100 Subject: [PATCH 30/59] Release: 78.0 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80c263d4..ea68a8c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## Unreleased +## 78.0 (2024-08-06) Compare: From 1506fad2fbc820707860123d585244a14dab2f7a Mon Sep 17 00:00:00 2001 From: Tomasz Knapik Date: Fri, 19 Jul 2024 17:22:28 +0100 Subject: [PATCH 31/59] WIP/Draft: Service directory block --- bc/location/blocks.py | 6 ++++ bc/location/models.py | 4 ++- bc/service_directory/__init__.py | 0 bc/service_directory/api.py | 0 bc/service_directory/blocks.py | 46 ++++++++++++++++++++++++++ bc/service_directory/client.py | 47 +++++++++++++++++++++++++++ bc/service_directory/resources.py | 46 ++++++++++++++++++++++++++ bc/service_directory/types.py | 54 +++++++++++++++++++++++++++++++ poetry.lock | 51 ++++++++++++++++++++++++++++- pyproject.toml | 1 + 10 files changed, 253 insertions(+), 2 deletions(-) create mode 100644 bc/location/blocks.py create mode 100644 bc/service_directory/__init__.py create mode 100644 bc/service_directory/api.py create mode 100644 bc/service_directory/blocks.py create mode 100644 bc/service_directory/client.py create mode 100644 bc/service_directory/resources.py create mode 100644 bc/service_directory/types.py diff --git a/bc/location/blocks.py b/bc/location/blocks.py new file mode 100644 index 00000000..6c0e31ba --- /dev/null +++ b/bc/location/blocks.py @@ -0,0 +1,6 @@ +from bc.service_directory.blocks import DirectoryActivitiesBlock +from bc.utils.blocks import StoryBlock + + +class LocationPageStoryBlock(StoryBlock): + directory_activities = DirectoryActivitiesBlock(required=False) diff --git a/bc/location/models.py b/bc/location/models.py index 79fa9636..f99d6b8d 100644 --- a/bc/location/models.py +++ b/bc/location/models.py @@ -14,6 +14,8 @@ from bc.utils.blocks import StoryBlock from bc.utils.models import BasePage, RelatedPage +from .blocks import LocationPageStoryBlock + class LocationIndexPage(BasePage): template = "patterns/pages/location/location_index_page.html" @@ -94,7 +96,7 @@ class LocationPage(BasePage): email_address = models.EmailField(blank=True) body = StreamField( - StoryBlock(), + LocationPageStoryBlock(), help_text="Generic body content. This will appear after the map in the template.", ) diff --git a/bc/service_directory/__init__.py b/bc/service_directory/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/bc/service_directory/api.py b/bc/service_directory/api.py new file mode 100644 index 00000000..e69de29b diff --git a/bc/service_directory/blocks.py b/bc/service_directory/blocks.py new file mode 100644 index 00000000..ca02f09f --- /dev/null +++ b/bc/service_directory/blocks.py @@ -0,0 +1,46 @@ +import logging + +from wagtail.core import blocks + +from bc.service_directory.resources import Service, ServiceDirectoryResources + +from .client import RequestsClient +from .types import Directory, Taxonomy + +logger = logging.getLogger(__name__) + + +class DirectoryActivitiesBlock(blocks.StructBlock): + directory = blocks.ChoiceBlock(choices=Directory.choices) + taxonomy = blocks.ChoiceBlock(choices=Taxonomy.choices) + + def get_context(self, value, parent_context=None): + context = super().get_context(value, parent_context=parent_context) + try: + taxonomy = Taxonomy(value["taxonomy"]) + except ValueError: + logger.warning("Invalid taxonomy value", exc_info=True) + return context + + try: + directory = Directory(value["directory"]) + except ValueError: + logger.warning("Invalid directory value", exc_info=True) + return context + + context["activities"] = self.get_activities( + directory=directory, taxonomy=taxonomy + ) + return context + + def get_activities( + self, *, directory: Directory, taxonomy: Taxonomy + ) -> list[Service]: + # TODO: Make client class and parameters configurable. + client = RequestsClient( + base_url="https://api.familyinfo.buckinghamshire.gov.uk/api/v1/" + ) + api = ServiceDirectoryResources(client=client) + return api.get_services( + directories=[directory], taxonomies=[taxonomy], per_page=4, page=1 + ) diff --git a/bc/service_directory/client.py b/bc/service_directory/client.py new file mode 100644 index 00000000..146af8f8 --- /dev/null +++ b/bc/service_directory/client.py @@ -0,0 +1,47 @@ +from collections.abc import Mapping +from typing import Literal + +import requests + + +class BaseOutpostClient: + def get(self, /, path: str, *, params: Mapping[str, str], **kwargs) -> Mapping: + raise NotImplementedError + + +class ClientError(Exception): + pass + + +class RequestsClient(BaseOutpostClient): + timeout: float + base_url: str + + def __init__(self, *, base_url: str, timeout: float = 5): + self.base_url = base_url + self.timeout = timeout + self.session = requests.Session() + + def get(self, /, path: str, *, params: Mapping[str, str], **kwargs) -> Mapping: + return self.call("GET", path, params=params, **kwargs) + + def call(self, /, method: Literal["GET"], path: str, **kwargs) -> Mapping: + kwargs.setdefault("timeout", self.timeout) + url = self.construct_url(path) + try: + response = self.session.request(method, url, **kwargs) + except requests.RequestException as e: + raise ClientError from e + try: + response.raise_for_status() + except requests.HTTPError as e: + raise ClientError from e + try: + return response.json() + except requests.JSONDecodeError as e: + raise ClientError from e + + def construct_url(self, /, path: str, *, base_url: str | None = None) -> str: + if base_url is None: + base_url = self.base_url + return f"{base_url}{path}" diff --git a/bc/service_directory/resources.py b/bc/service_directory/resources.py new file mode 100644 index 00000000..61c1b400 --- /dev/null +++ b/bc/service_directory/resources.py @@ -0,0 +1,46 @@ +from collections.abc import Sequence +from dataclasses import dataclass +from typing import cast + +from dataclasses_json import dataclass_json + +from .client import BaseOutpostClient +from .types import Directory, Taxonomy + + +@dataclass_json +@dataclass +class Service: + id: int + name: str + + +class ServiceDirectoryResources: + client: BaseOutpostClient + + def __init__(self, *, client: BaseOutpostClient): + self.client = client + + def get_services( + self, + *, + directories: Sequence[Directory], + taxonomies: Sequence[Taxonomy], + per_page: int, + page: int + ) -> list[Service]: + """ + https://github.com/wearefuturegov/outpost-api-service/wiki/Search-services + """ + service_schema = Service.schema() + response = self.client.get( + "services", + params={ + "directories": ",".join(directory.value for directory in directories), + "taxonomies": ",".join(taxonomy.value for taxonomy in taxonomies), + "per_page": str(per_page), + "page": str(page), + }, + ) + services = service_schema.load(response["content"], many=True) + return cast(list[Service], services) diff --git a/bc/service_directory/types.py b/bc/service_directory/types.py new file mode 100644 index 00000000..2c353d8e --- /dev/null +++ b/bc/service_directory/types.py @@ -0,0 +1,54 @@ +from django.db.models import TextChoices + +# These are hard-coded from +# https://manage-directory-listing.buckinghamshire.gov.uk/api/v1/taxonomies + + +class Directory(TextChoices): + FIS = "bfis", "Family Information Service" + + +class Taxonomy(TextChoices): + AMERSHAM_FAMILY_CENTRE = "amersham-family-centre", "Amersham Family Centre" + BEACONSFIELD_FAMILY_CENTRE = ( + "beaconsfield-family-centre", + "Beaconsfield Family Centre", + ) + BERRYFIELDS_FAMILY_CENTRE_AYLESBURY = ( + "berryfields-family-centre_aylesbury", + "Berryfields Family Centre, Aylesbury", + ) + BUCKINGHAM_FAMILY_CENTRE = "buckingham-family-centre", "Buckingham Family Centre" + BURNHAM_FAMILY_CENTRE = "burnham-family-centre", "Burnham Family Centre" + CASTLEFIELD_FAMILY_CENTRE_WYCOMBE = ( + "castlefield-family-centre_wycombe", + "Castlefield Family Centre, Wycombe", + ) + ELMHURST_FAMILY_CENTRE_AYLESBURY = ( + "elmhurst-family-centre_aylesbury", + "Elmhurst Family Centre, Aylesbury", + ) + HAMPDEN_WAY_FAMILY_CENTRE_WYCOMBE = ( + "hampden-way-family-centre_wycombe", + "Hampden Way Family Centre, Wycombe", + ) + HITHERCROFT_FAMILY_CENTRE_WYCOMBE = ( + "hithercroft-family-centre_wycombe", + "Hithercroft Family Centre, Wycombe", + ) + WING_FAMILY_CENTRE = "wing-family-centre", "Wing Family Centre" + SOUTHCOURT_FAMILY_CENTRE_PLUS_AYLESBURY = ( + "southcourt-family-centre_plus_aylesbury", + "Southcourt Family Centre Plus, Aylesbury", + ) + THE_IVERS_FAMILY_CENTRE = "the-ivers-family-centre", "The Ivers Family Centre" + NEWTOWN_FAMILY_CENTRE_PLUS_CHESHAM = ( + "newtown-family-centre_plus_chesham", + "Newtown Family Centre Plus, Chesham", + ) + MAPLEDEAN_FAMILY_CENTRE_PLUS_WYCOMBE = ( + "mapledean-family-centre_plus_wycombe", + "Mapledean Family Centre Plus, Wycombe", + ) + MARLOW_FAMILY_CENTRE = "marlow-family-centre", "Marlow Family Centre" + RISBOROUGH_FAMILY_CENTRE = "risborough-family-centre", "Risborough Family Centre" diff --git a/poetry.lock b/poetry.lock index 997cb06f..7f17a053 100644 --- a/poetry.lock +++ b/poetry.lock @@ -417,6 +417,21 @@ files = [ {file = "contextlib2-21.6.0.tar.gz", hash = "sha256:ab1e2bfe1d01d968e1b7e8d9023bc51ef3509bba217bb730cee3827e1ee82869"}, ] +[[package]] +name = "dataclasses-json" +version = "0.6.7" +description = "Easily serialize dataclasses to and from JSON." +optional = false +python-versions = "<4.0,>=3.7" +files = [ + {file = "dataclasses_json-0.6.7-py3-none-any.whl", hash = "sha256:0dbf33f26c8d5305befd61b39d2b3414e8a407bedc2834dea9b8d642666fb40a"}, + {file = "dataclasses_json-0.6.7.tar.gz", hash = "sha256:b6b3e528266ea45b9535223bc53ca645f5208833c29229e847b3f26a1cc55fc0"}, +] + +[package.dependencies] +marshmallow = ">=3.18.0,<4.0.0" +typing-inspect = ">=0.4.0,<1" + [[package]] name = "defusedxml" version = "0.7.1" @@ -1435,6 +1450,25 @@ files = [ {file = "MarkupSafe-2.1.3.tar.gz", hash = "sha256:af598ed32d6ae86f1b747b82783958b1a4ab8f617b06fe68795c7f026abbdcad"}, ] +[[package]] +name = "marshmallow" +version = "3.21.3" +description = "A lightweight library for converting complex datatypes to and from native Python datatypes." +optional = false +python-versions = ">=3.8" +files = [ + {file = "marshmallow-3.21.3-py3-none-any.whl", hash = "sha256:86ce7fb914aa865001a4b2092c4c2872d13bc347f3d42673272cabfdbad386f1"}, + {file = "marshmallow-3.21.3.tar.gz", hash = "sha256:4f57c5e050a54d66361e826f94fba213eb10b67b2fdb02c3e0343ce207ba1662"}, +] + +[package.dependencies] +packaging = ">=17.0" + +[package.extras] +dev = ["marshmallow[tests]", "pre-commit (>=3.5,<4.0)", "tox"] +docs = ["alabaster (==0.7.16)", "autodocsumm (==0.2.12)", "sphinx (==7.3.7)", "sphinx-issues (==4.1.0)", "sphinx-version-warning (==1.1.2)"] +tests = ["pytest", "pytz", "simplejson"] + [[package]] name = "mccabe" version = "0.7.0" @@ -2666,6 +2700,21 @@ files = [ {file = "typing_extensions-4.7.1.tar.gz", hash = "sha256:b75ddc264f0ba5615db7ba217daeb99701ad295353c45f9e95963337ceeeffb2"}, ] +[[package]] +name = "typing-inspect" +version = "0.9.0" +description = "Runtime inspection utilities for typing module." +optional = false +python-versions = "*" +files = [ + {file = "typing_inspect-0.9.0-py3-none-any.whl", hash = "sha256:9ee6fc59062311ef8547596ab6b955e1b8aa46242d854bfc78f4f6b0eff35f9f"}, + {file = "typing_inspect-0.9.0.tar.gz", hash = "sha256:b23fc42ff6f6ef6954e4852c1fb512cdd18dbea03134f91f856a95ccc9461f78"}, +] + +[package.dependencies] +mypy-extensions = ">=0.3.0" +typing-extensions = ">=3.7.4" + [[package]] name = "tzdata" version = "2024.1" @@ -3083,4 +3132,4 @@ gunicorn = ["gunicorn"] [metadata] lock-version = "2.0" python-versions = "~3.8" -content-hash = "a3e261c4d685241c03a21724286ad16dd3f9d245c4c96d983052ff4005669ed6" +content-hash = "a293c575eb3e9c5045bc924a759fb26e921ee94d3ad8f9ca97a7ea9933287f93" diff --git a/pyproject.toml b/pyproject.toml index e33fd970..73668232 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,6 +7,7 @@ authors = ["Torchbox "] [tool.poetry.dependencies] python = "~3.8" bleach = "^6.1.0" +dataclasses-json = "^0.6.7" dj-database-url = "2.2.0" Django = "~4.2" django-basic-auth-ip-whitelist = "^0.6" From 61963647ffda79d1b51b2e81286cbc8634ef82df Mon Sep 17 00:00:00 2001 From: Chris Lawton Date: Tue, 11 Jun 2024 16:32:56 +0100 Subject: [PATCH 32/59] add basic desktop layout for activities listing --- .../activities-listing.html | 18 ++++++ .../activities-listing.yaml | 15 +++++ .../pages/location/location_page.html | 2 + .../pages/location/location_page.yaml | 5 ++ bc/static_src/sass/abstracts/_variables.scss | 1 + .../sass/components/_activities-listing.scss | 63 +++++++++++++++++++ bc/static_src/sass/main.scss | 1 + 7 files changed, 105 insertions(+) create mode 100644 bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.html create mode 100644 bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.yaml create mode 100644 bc/static_src/sass/components/_activities-listing.scss diff --git a/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.html b/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.html new file mode 100644 index 00000000..233b882a --- /dev/null +++ b/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.html @@ -0,0 +1,18 @@ +
+
+

Activities in Amersham Family Centre

+ +
    + {% for activity in activities %} +
  • +

    {{ activity.title }}

    +

    {{ activity.intro|truncatechars:106 }}

    + + {% for tag in activity.tags %} + {{ tag.title }} + {% endfor %} +
  • + {% endfor %} +
+
+
diff --git a/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.yaml b/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.yaml new file mode 100644 index 00000000..1de8caf9 --- /dev/null +++ b/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.yaml @@ -0,0 +1,15 @@ +context: + activities: + - title: Early Signs of Exploitation (Online Workshop) + intro: Parents are invited to attend a workshop that will teach them about the early signs of child exploitation + tags: + - title: Free + - title: Recently Updated + highlight: true + - title: Amersham Gamily Centre + intro: Amersham Family Centre has a varied timetable of activities for families, children and young people aged 0 to 19 years + tags: + - title: Part of local offer + highlight: true + - title: Recently Updated + - title: Free diff --git a/bc/project_styleguide/templates/patterns/pages/location/location_page.html b/bc/project_styleguide/templates/patterns/pages/location/location_page.html index f37c2853..92214aa0 100644 --- a/bc/project_styleguide/templates/patterns/pages/location/location_page.html +++ b/bc/project_styleguide/templates/patterns/pages/location/location_page.html @@ -19,6 +19,8 @@

{{ page.title }}

{% include 'patterns/molecules/map/map.html' %} {% include_block page.body %} + + {% include_block page.activities_listing %}

diff --git a/bc/static_src/sass/components/_activities-listing.scss b/bc/static_src/sass/components/_activities-listing.scss index daf70e16..6c9a54bf 100644 --- a/bc/static_src/sass/components/_activities-listing.scss +++ b/bc/static_src/sass/components/_activities-listing.scss @@ -86,4 +86,9 @@ } } } + + &__cta-wrap { + text-align: center; + margin-top: 30px; + } } From ad0795201df3f891e326eaecffb081147f3f541d Mon Sep 17 00:00:00 2001 From: Chris Lawton Date: Wed, 12 Jun 2024 09:48:37 +0100 Subject: [PATCH 38/59] populate activities listing and location page in pattern lib --- .../activities-listing/activities-listing.yaml | 15 ++++++++++++++- .../patterns/pages/location/location_page.yaml | 16 ++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.yaml b/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.yaml index 1de8caf9..07e63432 100644 --- a/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.yaml +++ b/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.yaml @@ -1,15 +1,28 @@ context: activities: - title: Early Signs of Exploitation (Online Workshop) + href: '#' intro: Parents are invited to attend a workshop that will teach them about the early signs of child exploitation tags: - title: Free - title: Recently Updated - highlight: true - title: Amersham Gamily Centre + href: '#' intro: Amersham Family Centre has a varied timetable of activities for families, children and young people aged 0 to 19 years tags: - title: Part of local offer highlight: true + - title: Free + - title: How To Build Confidence and Self-Esteem for Young People (Online) + href: '#' + intro: Online How to Build Confidence and Self-Esteem Online Course for Young People. Want to feel better about yourself? + tags: + - title: Part of local offer + highlight: true + - title: Free - title: Recently Updated + - title: Thinking about Volunteering On-line Workshop + href: '#' + intro: Thinking about Volunteering Workshop. Join our free two-hour online workshop on Tuesday 26 March, 9:30am to 11:30am. Build + tags: - title: Free diff --git a/bc/project_styleguide/templates/patterns/pages/location/location_page.yaml b/bc/project_styleguide/templates/patterns/pages/location/location_page.yaml index 108acb86..f412aa7f 100644 --- a/bc/project_styleguide/templates/patterns/pages/location/location_page.yaml +++ b/bc/project_styleguide/templates/patterns/pages/location/location_page.yaml @@ -11,6 +11,20 @@ context: telephone: 01296 382415 email_address: lib-ayl@buckinghamshire.gov.uk image: https://placekitten.com/g/700/250 + live_related_pages: + - page: + live: true + specific: + title: Page title + - page: + live: true + specific: + title: Page title + listing_title: Listing title + - page: + live: true + specific: + title: Page title tags: include_block: @@ -21,3 +35,5 @@ tags: pageurl: ancestor_page: raw: '#' + specific_related_page: + raw: '#' From 2d33156a35f5adfe4587d66de0391bfe98f718e8 Mon Sep 17 00:00:00 2001 From: Chris Lawton Date: Wed, 12 Jun 2024 10:45:25 +0100 Subject: [PATCH 39/59] stack the tags on mobile --- .../activities-listing.html | 24 ++++++++------ .../sass/components/_activities-listing.scss | 31 +++++++++++++------ 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.html b/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.html index bdbb2e51..2ae77a27 100644 --- a/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.html +++ b/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.html @@ -12,16 +12,20 @@

{{ activity.intro|truncatechars:106 }}

- {% for tag in activity.tags %} - {% if tag.highlight %} - - {% include "patterns/atoms/icons/icon.html" with name="tick" classname="icon--tag-tick activities-listing__tag-icon" %} - {{ tag.title }} - - {% else %} - {{ tag.title }} - {% endif %} - {% endfor %} + {% if activity.tags|length > 0 %} +
    + {% for tag in activity.tags %} + {% if tag.highlight %} +
  • + {% include "patterns/atoms/icons/icon.html" with name="tick" classname="icon--tag-tick activities-listing__tag-icon" %} + {{ tag.title }} +
  • + {% else %} +
  • {{ tag.title }}
  • + {% endif %} + {% endfor %} +
+ {% endif %} {% endfor %} diff --git a/bc/static_src/sass/components/_activities-listing.scss b/bc/static_src/sass/components/_activities-listing.scss index 6c9a54bf..700d7bde 100644 --- a/bc/static_src/sass/components/_activities-listing.scss +++ b/bc/static_src/sass/components/_activities-listing.scss @@ -54,21 +54,34 @@ color: $color--charcoal; } + &__tags { + display: inline-flex; + flex-direction: column; + + @include media-query(px550) { + display: block; + } + } + &__tag { display: inline-block; position: relative; padding: 0 5px; - margin: 0 5px; + margin: 3px; - &::after { - content: '•'; - position: absolute; - right: -0.6em; - top: 0; - } + @include media-query(px550) { + margin: 0 5px; + + &::after { + content: '•'; + position: absolute; + right: -0.6em; + top: 0; + } - &:first-of-type { - margin-left: -3px; + &:first-of-type { + margin-left: -3px; + } } &:last-of-type::after { From 368ce786317c1315b732304cddee610b8e00d5d0 Mon Sep 17 00:00:00 2001 From: Chris Lawton Date: Wed, 12 Jun 2024 10:49:51 +0100 Subject: [PATCH 40/59] don't hardcode the component title --- .../organisms/activities-listing/activities-listing.html | 2 +- .../organisms/activities-listing/activities-listing.yaml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.html b/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.html index 2ae77a27..7dab32e6 100644 --- a/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.html +++ b/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.html @@ -1,6 +1,6 @@
-

Activities in Amersham Family Centre

+

Activities in {{ page.title }}

    {% for activity in activities %} diff --git a/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.yaml b/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.yaml index 07e63432..12167dca 100644 --- a/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.yaml +++ b/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.yaml @@ -1,4 +1,6 @@ context: + page: + title: Aylesbury Library activities: - title: Early Signs of Exploitation (Online Workshop) href: '#' From 1522b636984865cca4faf3c6e7fe4a8f2810b5bb Mon Sep 17 00:00:00 2001 From: Chris Lawton Date: Wed, 12 Jun 2024 10:50:15 +0100 Subject: [PATCH 41/59] add space under listings and comment the pseudo element --- bc/static_src/sass/components/_activities-listing.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bc/static_src/sass/components/_activities-listing.scss b/bc/static_src/sass/components/_activities-listing.scss index 700d7bde..51981e8b 100644 --- a/bc/static_src/sass/components/_activities-listing.scss +++ b/bc/static_src/sass/components/_activities-listing.scss @@ -2,8 +2,12 @@ background-color: $color--earth-light; padding: 30px 0; position: relative; + margin-bottom: 40px; @include media-query(tablet-landscape) { + // On the location page there is a sidebar which offsets + // this component and leaves a gap on the right. + // This covers the gap with a pseudo element. &::after { content: ''; background-color: $color--earth-light; From 8f78301815a3ff5c764e1947cbfa8c0d754fd30c Mon Sep 17 00:00:00 2001 From: Chris Lawton Date: Wed, 12 Jun 2024 10:52:21 +0100 Subject: [PATCH 42/59] only show the component if there are activities --- .../activities-listing.html | 68 ++++++++++--------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.html b/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.html index 7dab32e6..72976cf8 100644 --- a/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.html +++ b/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.html @@ -1,38 +1,40 @@ -
    -
    -

    Activities in {{ page.title }}

    +{% if activities|length > 0 %} +
    +
    +

    Activities in {{ page.title }}

    -
      - {% for activity in activities %} -
    • -

      - - {{ activity.title }} - -

      -

      {{ activity.intro|truncatechars:106 }}

      +
        + {% for activity in activities %} +
      • +

        + + {{ activity.title }} + +

        +

        {{ activity.intro|truncatechars:106 }}

        - {% if activity.tags|length > 0 %} -
          - {% for tag in activity.tags %} - {% if tag.highlight %} -
        • - {% include "patterns/atoms/icons/icon.html" with name="tick" classname="icon--tag-tick activities-listing__tag-icon" %} - {{ tag.title }} -
        • - {% else %} -
        • {{ tag.title }}
        • - {% endif %} - {% endfor %} -
        - {% endif %} -
      • - {% endfor %} -
      + {% if activity.tags|length > 0 %} +
        + {% for tag in activity.tags %} + {% if tag.highlight %} +
      • + {% include "patterns/atoms/icons/icon.html" with name="tick" classname="icon--tag-tick activities-listing__tag-icon" %} + {{ tag.title }} +
      • + {% else %} +
      • {{ tag.title }}
      • + {% endif %} + {% endfor %} +
      + {% endif %} +
    • + {% endfor %} +
    - {# TODO: Only show button if there's more that X listings and populate 'href' #} -
    - View all activities + {# TODO: Only show button if there's more that X listings and populate 'href' #} +
    -
    +{% endif %} From 09e9abfa9b1c9d5c813c7c23265d2470baac08d8 Mon Sep 17 00:00:00 2001 From: Tomasz Knapik Date: Wed, 24 Jul 2024 16:11:26 +0100 Subject: [PATCH 43/59] Service directory block --- bc/location/blocks.py | 2 +- .../blocks/directory_activities_block.html | 1 + .../activities-listing.html | 23 +- .../activities-listing.yaml | 8 +- bc/service_directory/blocks.py | 131 ++++++++++-- bc/service_directory/client.py | 24 ++- bc/service_directory/resources.py | 29 +-- bc/service_directory/services.py | 56 +++++ bc/service_directory/types.py | 198 +++++++++++++++--- bc/settings/base.py | 4 + bc/utils/blocks.py | 5 - poetry.lock | 2 +- pyproject.toml | 1 + 13 files changed, 390 insertions(+), 94 deletions(-) create mode 100644 bc/project_styleguide/templates/patterns/molecules/streamfield/blocks/directory_activities_block.html create mode 100644 bc/service_directory/services.py diff --git a/bc/location/blocks.py b/bc/location/blocks.py index 6c0e31ba..e7b7df5f 100644 --- a/bc/location/blocks.py +++ b/bc/location/blocks.py @@ -3,4 +3,4 @@ class LocationPageStoryBlock(StoryBlock): - directory_activities = DirectoryActivitiesBlock(required=False) + directory_activities = DirectoryActivitiesBlock() diff --git a/bc/project_styleguide/templates/patterns/molecules/streamfield/blocks/directory_activities_block.html b/bc/project_styleguide/templates/patterns/molecules/streamfield/blocks/directory_activities_block.html new file mode 100644 index 00000000..80d2e1f1 --- /dev/null +++ b/bc/project_styleguide/templates/patterns/molecules/streamfield/blocks/directory_activities_block.html @@ -0,0 +1 @@ +{% include "patterns/organisms/activities-listing/activities-listing.html" %} diff --git a/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.html b/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.html index 72976cf8..f59aa895 100644 --- a/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.html +++ b/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.html @@ -1,19 +1,21 @@ -{% if activities|length > 0 %} +{% if activities %}
    -

    Activities in {{ page.title }}

    + {% if heading %} +

    {{ heading }}

    + {% endif %}
      {% for activity in activities %}
    • - - {{ activity.title }} + + {{ activity.name }}

      -

      {{ activity.intro|truncatechars:106 }}

      +

      {{ activity.intro }}

      - {% if activity.tags|length > 0 %} + {% if activity.tags %}
        {% for tag in activity.tags %} {% if tag.highlight %} @@ -31,10 +33,11 @@

        {% endfor %}

      - {# TODO: Only show button if there's more that X listings and populate 'href' #} - + {% if view_all_activities_url %} + + {% endif %}
    {% endif %} diff --git a/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.yaml b/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.yaml index 12167dca..21e4de73 100644 --- a/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.yaml +++ b/bc/project_styleguide/templates/patterns/organisms/activities-listing/activities-listing.yaml @@ -1,22 +1,24 @@ context: page: title: Aylesbury Library + heading: Activities in Aylesbury + view_all_activities_url: '#' activities: - title: Early Signs of Exploitation (Online Workshop) - href: '#' + url: '#' intro: Parents are invited to attend a workshop that will teach them about the early signs of child exploitation tags: - title: Free - title: Recently Updated - title: Amersham Gamily Centre - href: '#' + url: '#' intro: Amersham Family Centre has a varied timetable of activities for families, children and young people aged 0 to 19 years tags: - title: Part of local offer highlight: true - title: Free - title: How To Build Confidence and Self-Esteem for Young People (Online) - href: '#' + url: '#' intro: Online How to Build Confidence and Self-Esteem Online Course for Young People. Want to feel better about yourself? tags: - title: Part of local offer diff --git a/bc/service_directory/blocks.py b/bc/service_directory/blocks.py index ca02f09f..e373f05e 100644 --- a/bc/service_directory/blocks.py +++ b/bc/service_directory/blocks.py @@ -1,46 +1,139 @@ +import datetime import logging +from typing import List, Optional, Sequence, TypedDict -from wagtail.core import blocks +from django.utils import timezone +from django.utils.text import Truncator -from bc.service_directory.resources import Service, ServiceDirectoryResources +from wagtail import blocks -from .client import RequestsClient -from .types import Directory, Taxonomy +from bc.service_directory.resources import ServiceDirectoryResources +from bc.service_directory.services import ( + get_service_detail_page_url, + get_services_listing_page_url, +) + +from .client import ClientError, RequestsClient +from .types import APIService, Category, Directory logger = logging.getLogger(__name__) +class _ActivityTag(TypedDict): + highlight: bool + title: str + + +class _ActivityContext(TypedDict): + intro: str + name: str + url: str + tags: List[_ActivityTag] + + +class DirectoryActivitiesBlockContext(TypedDict): + activities: Optional[Sequence[_ActivityContext]] + heading: str + + +class CouldNotFetchActivities(Exception): + pass + + class DirectoryActivitiesBlock(blocks.StructBlock): - directory = blocks.ChoiceBlock(choices=Directory.choices) - taxonomy = blocks.ChoiceBlock(choices=Taxonomy.choices) + SERVICE_DESCRIPTION_CHARS = 106 + + heading = blocks.CharBlock(required=False) + directory = blocks.ChoiceBlock(choices=Directory.get_choices()) + category = blocks.ChoiceBlock(choices=Category.get_choices()) - def get_context(self, value, parent_context=None): + class Meta: + template = ( + "patterns/molecules/streamfield/blocks/directory_activities_block.html" + ) + + def get_context( + self, value, parent_context=None + ) -> DirectoryActivitiesBlockContext: context = super().get_context(value, parent_context=parent_context) + try: - taxonomy = Taxonomy(value["taxonomy"]) + directory = Directory(value["directory"]) except ValueError: - logger.warning("Invalid taxonomy value", exc_info=True) + logger.warning("Invalid directory value", exc_info=True) return context try: - directory = Directory(value["directory"]) + category = Category(value["category"]) except ValueError: - logger.warning("Invalid directory value", exc_info=True) + logger.warning("Invalid category value", exc_info=True) return context - context["activities"] = self.get_activities( - directory=directory, taxonomy=taxonomy + try: + context["activities"] = self.get_activities( + directory=directory, category=category + ) + except CouldNotFetchActivities: + logger.exception("There was an issue fetching activities") + context["activities"] = None + + context["view_all_activities_url"] = get_services_listing_page_url( + category_filters=[category], + collection_filter=category.collection, + directory=directory, ) + context["heading"] = value.get("heading", "") return context + @classmethod def get_activities( - self, *, directory: Directory, taxonomy: Taxonomy - ) -> list[Service]: + cls, *, directory: Directory, category: Category + ) -> List[_ActivityContext]: # TODO: Make client class and parameters configurable. client = RequestsClient( - base_url="https://api.familyinfo.buckinghamshire.gov.uk/api/v1/" + base_url=directory.api_url, ) api = ServiceDirectoryResources(client=client) - return api.get_services( - directories=[directory], taxonomies=[taxonomy], per_page=4, page=1 - ) + + try: + services = api.get_services( + directories=[directory], taxonomies=[category], per_page=4, page=1 + ) + except ClientError as e: + raise CouldNotFetchActivities from e + + activities_context: List[_ActivityContext] = [] + for service in services: + tags: List[_ActivityTag] = [] + if service.local_offer: + tags.append({"highlight": True, "title": "Part of local offer"}) + if service.free: + tags.append({"highlight": False, "title": "Free"}) + if service.updated_at <= timezone.now() + datetime.timedelta(days=2): + tags.append({"highlight": False, "title": "Recently updated"}) + + activity_context: _ActivityContext = { + "intro": cls._format_activity_intro(service), + "name": service.name, + "url": get_service_detail_page_url( + service, + category_filters=[category], + collection_filter=category.collection, + directory=directory, + ), + "tags": tags, + } + activities_context.append(activity_context) + return activities_context + + @classmethod + def _format_activity_intro( + cls, service: APIService, /, *, max_length: Optional[int] = None + ) -> str: + """ + Shorten the description, and then remove the newlines. + """ + if max_length is None: + max_length = cls.SERVICE_DESCRIPTION_CHARS + description = Truncator(service.description).chars(max_length) + return " ".join(description.splitlines()) diff --git a/bc/service_directory/client.py b/bc/service_directory/client.py index 146af8f8..d75bec53 100644 --- a/bc/service_directory/client.py +++ b/bc/service_directory/client.py @@ -1,8 +1,10 @@ -from collections.abc import Mapping -from typing import Literal +import logging +from typing import Literal, Mapping, Optional import requests +logger = logging.getLogger(__name__) + class BaseOutpostClient: def get(self, /, path: str, *, params: Mapping[str, str], **kwargs) -> Mapping: @@ -21,15 +23,25 @@ def __init__(self, *, base_url: str, timeout: float = 5): self.base_url = base_url self.timeout = timeout self.session = requests.Session() + self.session.headers["User-Agent"] = "www.buckinghamshire.gov.uk website" def get(self, /, path: str, *, params: Mapping[str, str], **kwargs) -> Mapping: return self.call("GET", path, params=params, **kwargs) - def call(self, /, method: Literal["GET"], path: str, **kwargs) -> Mapping: + def call( + self, + /, + method: Literal["GET"], + path: str, + *, + params: Mapping[str, str], + **kwargs, + ) -> Mapping: kwargs.setdefault("timeout", self.timeout) url = self.construct_url(path) + logger.info("Making %s HTTP call to: %s (%r)", method, url, params) try: - response = self.session.request(method, url, **kwargs) + response = self.session.request(method, url, params=params, **kwargs) except requests.RequestException as e: raise ClientError from e try: @@ -41,7 +53,9 @@ def call(self, /, method: Literal["GET"], path: str, **kwargs) -> Mapping: except requests.JSONDecodeError as e: raise ClientError from e - def construct_url(self, /, path: str, *, base_url: str | None = None) -> str: + def construct_url(self, /, path: str, *, base_url: Optional[str] = None) -> str: if base_url is None: base_url = self.base_url + if base_url.endswith("/") and path.startswith("/"): + base_url = base_url[:-1] return f"{base_url}{path}" diff --git a/bc/service_directory/resources.py b/bc/service_directory/resources.py index 61c1b400..a1f72d86 100644 --- a/bc/service_directory/resources.py +++ b/bc/service_directory/resources.py @@ -1,18 +1,7 @@ -from collections.abc import Sequence -from dataclasses import dataclass -from typing import cast - -from dataclasses_json import dataclass_json +from typing import List, Sequence, cast from .client import BaseOutpostClient -from .types import Directory, Taxonomy - - -@dataclass_json -@dataclass -class Service: - id: int - name: str +from .types import APIService, Category, Directory class ServiceDirectoryResources: @@ -25,22 +14,24 @@ def get_services( self, *, directories: Sequence[Directory], - taxonomies: Sequence[Taxonomy], + taxonomies: Sequence[Category], per_page: int, page: int - ) -> list[Service]: + ) -> List[APIService]: """ https://github.com/wearefuturegov/outpost-api-service/wiki/Search-services """ - service_schema = Service.schema() + service_schema = APIService.schema() response = self.client.get( "services", params={ - "directories": ",".join(directory.value for directory in directories), - "taxonomies": ",".join(taxonomy.value for taxonomy in taxonomies), + "directories": ",".join( + directory.api_value for directory in directories + ), + "taxonomies": ",".join(taxonomy.api_value for taxonomy in taxonomies), "per_page": str(per_page), "page": str(page), }, ) services = service_schema.load(response["content"], many=True) - return cast(list[Service], services) + return cast(List[APIService], services) diff --git a/bc/service_directory/services.py b/bc/service_directory/services.py new file mode 100644 index 00000000..a7cb82a3 --- /dev/null +++ b/bc/service_directory/services.py @@ -0,0 +1,56 @@ +from typing import Optional, Sequence +from urllib.parse import quote_plus + +from django.http import QueryDict + +from bc.service_directory.types import APIService, Category, Collection, Directory + + +def get_service_detail_page_url( + service: APIService, + /, + *, + category_filters: Optional[Sequence[Category]] = None, + collection_filter: Optional[Collection] = None, + directory: Directory, +): + query_dict = QueryDict(mutable=True) + + if collection_filter is not None: + query_dict["collection"] = collection_filter.value + + if category_filters is not None: + for category in category_filters: + query_dict.appendlist("categories", category.value) + + base_url = directory.frontend_url + if base_url.endswith("/"): + base_url = base_url[:-1] + + url = f"{base_url}/service/{quote_plus(str(service.id))}" + + if query_dict: + url += f"?{query_dict.urlencode()}" + return url + + +def get_services_listing_page_url( + *, + category_filters: Optional[Sequence[Category]] = None, + collection_filter: Optional[Collection] = None, + directory: Directory, +): + query_dict = QueryDict(mutable=True) + + if collection_filter is not None: + query_dict["collection"] = collection_filter.value + + if category_filters is not None: + for category in category_filters: + query_dict.appendlist("categories", category.value) + + url = directory.frontend_url + + if query_dict: + url += f"?{query_dict.urlencode()}" + return url diff --git a/bc/service_directory/types.py b/bc/service_directory/types.py index 2c353d8e..7eed95d5 100644 --- a/bc/service_directory/types.py +++ b/bc/service_directory/types.py @@ -1,54 +1,190 @@ +import dataclasses +import datetime +import enum +from typing import Any, Dict, NamedTuple, Optional + from django.db.models import TextChoices -# These are hard-coded from -# https://manage-directory-listing.buckinghamshire.gov.uk/api/v1/taxonomies +import dataclasses_json +from marshmallow import fields as mm_fields + + +class _DirectoryTuple(NamedTuple): + api_url: str + frontend_url: str + label: str + api_value: Optional[str] = None + + +class Directory(enum.Enum): + FAMILY_INFORMATION_SERVICE = "family-information-service", _DirectoryTuple( + api_url="https://api.familyinfo.buckinghamshire.gov.uk/api/v1/", + frontend_url="https://directory.familyinfo.buckinghamshire.gov.uk/", + label="Family Information Service", + api_value="bfis", + ) + def __new__(cls, *args, **kwds) -> "Directory": + obj = object.__new__(cls) + obj._value_ = args[0] + return obj -class Directory(TextChoices): - FIS = "bfis", "Family Information Service" + def __init__(self, value: str, directory: _DirectoryTuple) -> None: + if directory.api_value is None: + self.api_value = value + else: + self.api_value = directory.api_value + self.label = directory.label + self.frontend_url = directory.frontend_url + self.api_url = directory.api_url + + @classmethod + def get_choices(cls): + return [(directory.value, directory.label) for directory in cls] + + +class Collection(TextChoices): + FAMILY_CENTRES = "family-centres", "Family Centres" + + +class _CategoryTuple(NamedTuple): + label: str + collection: Collection + api_value: Optional[str] = None + frontend_value: Optional[str] = None + + +# These are hard-coded from +# https://manage-directory-listing.buckinghamshire.gov.uk/api/v1/taxonomies -class Taxonomy(TextChoices): - AMERSHAM_FAMILY_CENTRE = "amersham-family-centre", "Amersham Family Centre" - BEACONSFIELD_FAMILY_CENTRE = ( - "beaconsfield-family-centre", - "Beaconsfield Family Centre", +class Category(enum.Enum): + AMERSHAM_FAMILY_CENTRE = "amersham-family-centre", _CategoryTuple( + label="Amersham Family Centre", + collection=Collection.FAMILY_CENTRES, + ) + BEACONSFIELD_FAMILY_CENTRE = "beaconsfield-family-centre", _CategoryTuple( + label="Beaconsfield Family Centre", + collection=Collection.FAMILY_CENTRES, ) BERRYFIELDS_FAMILY_CENTRE_AYLESBURY = ( - "berryfields-family-centre_aylesbury", - "Berryfields Family Centre, Aylesbury", + "berryfields-family-centre-aylesbury", + _CategoryTuple( + label="Berryfields Family Centre, Aylesbury", + collection=Collection.FAMILY_CENTRES, + ), + ) + BUCKINGHAM_FAMILY_CENTRE = "buckingham-family-centre", _CategoryTuple( + label="Buckingham Family Centre", + collection=Collection.FAMILY_CENTRES, + ) + BURNHAM_FAMILY_CENTRE = "burnham-family-centre", _CategoryTuple( + label="Burnham Family Centre", + collection=Collection.FAMILY_CENTRES, ) - BUCKINGHAM_FAMILY_CENTRE = "buckingham-family-centre", "Buckingham Family Centre" - BURNHAM_FAMILY_CENTRE = "burnham-family-centre", "Burnham Family Centre" CASTLEFIELD_FAMILY_CENTRE_WYCOMBE = ( - "castlefield-family-centre_wycombe", - "Castlefield Family Centre, Wycombe", + "castlefield-family-centre-wycombe", + _CategoryTuple( + label="Castlefield Family Centre, Wycombe", + collection=Collection.FAMILY_CENTRES, + ), ) ELMHURST_FAMILY_CENTRE_AYLESBURY = ( - "elmhurst-family-centre_aylesbury", - "Elmhurst Family Centre, Aylesbury", + "elmhurst-family-centre-aylesbury", + _CategoryTuple( + label="Elmhurst Family Centre, Aylesbury", + collection=Collection.FAMILY_CENTRES, + ), ) HAMPDEN_WAY_FAMILY_CENTRE_WYCOMBE = ( - "hampden-way-family-centre_wycombe", - "Hampden Way Family Centre, Wycombe", + "hampden-way-family-centre-wycombe", + _CategoryTuple( + label="Hampden Way Family Centre, Wycombe", + collection=Collection.FAMILY_CENTRES, + ), ) HITHERCROFT_FAMILY_CENTRE_WYCOMBE = ( - "hithercroft-family-centre_wycombe", - "Hithercroft Family Centre, Wycombe", + "hithercroft-family-centre-wycombe", + _CategoryTuple( + label="Hithercroft Family Centre, Wycombe", + collection=Collection.FAMILY_CENTRES, + ), + ) + WING_FAMILY_CENTRE = "wing-family-centre", _CategoryTuple( + label="Wing Family Centre", + collection=Collection.FAMILY_CENTRES, ) - WING_FAMILY_CENTRE = "wing-family-centre", "Wing Family Centre" SOUTHCOURT_FAMILY_CENTRE_PLUS_AYLESBURY = ( - "southcourt-family-centre_plus_aylesbury", - "Southcourt Family Centre Plus, Aylesbury", + "southcourt-family-centre-plus-aylesbury", + _CategoryTuple( + label="Southcourt Family Centre Plus, Aylesbury", + collection=Collection.FAMILY_CENTRES, + ), + ) + THE_IVERS_FAMILY_CENTRE = "the-ivers-family-centre", _CategoryTuple( + label="The Ivers Family Centre", + collection=Collection.FAMILY_CENTRES, ) - THE_IVERS_FAMILY_CENTRE = "the-ivers-family-centre", "The Ivers Family Centre" NEWTOWN_FAMILY_CENTRE_PLUS_CHESHAM = ( - "newtown-family-centre_plus_chesham", - "Newtown Family Centre Plus, Chesham", + "newtown-family-centre-plus-chesham", + _CategoryTuple( + label="Newtown Family Centre Plus, Chesham", + collection=Collection.FAMILY_CENTRES, + ), ) MAPLEDEAN_FAMILY_CENTRE_PLUS_WYCOMBE = ( - "mapledean-family-centre_plus_wycombe", - "Mapledean Family Centre Plus, Wycombe", + "mapledean-family-centre-plus-wycombe", + _CategoryTuple( + label="Mapledean Family Centre Plus, Wycombe", + collection=Collection.FAMILY_CENTRES, + ), + ) + MARLOW_FAMILY_CENTRE = "marlow-family-centre", _CategoryTuple( + label="Marlow Family Centre", + collection=Collection.FAMILY_CENTRES, + ) + RISBOROUGH_FAMILY_CENTRE = "risborough-family-centre", _CategoryTuple( + label="Risborough Family Centre", + collection=Collection.FAMILY_CENTRES, + ) + + def __new__(cls, *args, **kwds) -> "Category": + obj = object.__new__(cls) + obj._value_ = args[0] + return obj + + def __init__(self, value: str, category: _CategoryTuple) -> None: + if category.api_value is None: + self.api_value = value + else: + self.api_value = category.api_value + + if category.frontend_value is None: + self.frontend_value = value + else: + self.frontend_value = category.frontend_value + + self.label = category.label + self.collection = category.collection + + @classmethod + def get_choices(cls): + return [(directory.value, directory.label) for directory in cls] + + +@dataclasses_json.dataclass_json(undefined=dataclasses_json.Undefined.EXCLUDE) +@dataclasses.dataclass +class APIService: + description: str + id: int + name: str + url: str + free: Optional[bool] + local_offer: Optional[Dict[str, Any]] + updated_at: datetime.datetime = dataclasses.field( + metadata=dataclasses_json.config( + encoder=datetime.datetime.isoformat, + decoder=datetime.datetime.fromisoformat, + mm_field=mm_fields.DateTime(format="iso"), + ) ) - MARLOW_FAMILY_CENTRE = "marlow-family-centre", "Marlow Family Centre" - RISBOROUGH_FAMILY_CENTRE = "risborough-family-centre", "Risborough Family Centre" diff --git a/bc/settings/base.py b/bc/settings/base.py index 686003fd..ef485ddd 100644 --- a/bc/settings/base.py +++ b/bc/settings/base.py @@ -430,6 +430,10 @@ "format": "[%(asctime)s][%(process)d][%(levelname)s][%(name)s] %(message)s" } }, + "root": { + "handlers": ["console"], + "level": "WARNING", + }, "loggers": { "bc": {"handlers": ["console"], "level": "INFO", "propagate": False}, "wagtail": { diff --git a/bc/utils/blocks.py b/bc/utils/blocks.py index 50a8651e..3d44d1d9 100644 --- a/bc/utils/blocks.py +++ b/bc/utils/blocks.py @@ -1,6 +1,4 @@ import copy -import logging -from urllib.parse import parse_qsl from django import forms from django.core.exceptions import ValidationError @@ -22,8 +20,6 @@ from .utils import convert_markdown_links_to_html, is_number from .widgets import BarChartInput, LineChartInput, PieChartInput -logger = logging.getLogger(__name__) - class TableBlock(BaseTableBlock): def render(self, value, context=None): @@ -688,7 +684,6 @@ class BaseStoryBlock(blocks.StreamBlock): highlight = HighlightBlock() inset_text = InsetTextBlock() ehc_co_search = EHCCoSearchBlock(label="EHCCo Search") - directory_search = DirectorySearchBlock() class Meta: abstract = True diff --git a/poetry.lock b/poetry.lock index 7f17a053..8c311964 100644 --- a/poetry.lock +++ b/poetry.lock @@ -3132,4 +3132,4 @@ gunicorn = ["gunicorn"] [metadata] lock-version = "2.0" python-versions = "~3.8" -content-hash = "a293c575eb3e9c5045bc924a759fb26e921ee94d3ad8f9ca97a7ea9933287f93" +content-hash = "80001db62255002acbab46d79cb6f2243839a32940894e3f569cd60be028cf27" diff --git a/pyproject.toml b/pyproject.toml index 73668232..e41094b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,7 @@ freezegun = "1.5.1" gunicorn = {version = "~22.0", optional = true} psycopg2 = "~2.9" PyJWT = "2.8.0" +requests = "^2.32.3" scout-apm = "~3.1" tabulate = "0.9.0" urllib3 = "1.26.19" From d41e0da0f75e4f76fc584b729808bbbb78a3f4a4 Mon Sep 17 00:00:00 2001 From: Tomasz Knapik Date: Thu, 25 Jul 2024 13:10:27 +0100 Subject: [PATCH 44/59] Add automatic import of taxonomies over API --- bc/location/blocks.py | 4 +- .../0017_add_directory_services_block.py | 570 ++++++++++++++++++ ...ock.html => directory_services_block.html} | 0 bc/service_directory/admin_choosers.py | 31 + bc/service_directory/admin_views.py | 47 ++ .../{client.py => api_client.py} | 40 +- bc/service_directory/api_schema.py | 38 ++ bc/service_directory/blocks.py | 143 +++-- .../{api.py => management/__init__.py} | 0 .../management/commands/__init__.py | 0 .../fetch_service_directory_taxonomies.py | 19 + .../migrations/0001_initial.py | 111 ++++ bc/service_directory/migrations/__init__.py | 0 bc/service_directory/models.py | 122 ++++ bc/service_directory/resources.py | 36 +- bc/service_directory/services.py | 41 +- bc/service_directory/taxonomies.py | 66 ++ bc/service_directory/types.py | 190 ------ bc/service_directory/wagtail_hooks.py | 34 ++ bc/settings/base.py | 1 + 20 files changed, 1211 insertions(+), 282 deletions(-) create mode 100644 bc/location/migrations/0017_add_directory_services_block.py rename bc/project_styleguide/templates/patterns/molecules/streamfield/blocks/{directory_activities_block.html => directory_services_block.html} (100%) create mode 100644 bc/service_directory/admin_choosers.py create mode 100644 bc/service_directory/admin_views.py rename bc/service_directory/{client.py => api_client.py} (52%) create mode 100644 bc/service_directory/api_schema.py rename bc/service_directory/{api.py => management/__init__.py} (100%) create mode 100644 bc/service_directory/management/commands/__init__.py create mode 100644 bc/service_directory/management/commands/fetch_service_directory_taxonomies.py create mode 100644 bc/service_directory/migrations/0001_initial.py create mode 100644 bc/service_directory/migrations/__init__.py create mode 100644 bc/service_directory/models.py create mode 100644 bc/service_directory/taxonomies.py delete mode 100644 bc/service_directory/types.py create mode 100644 bc/service_directory/wagtail_hooks.py diff --git a/bc/location/blocks.py b/bc/location/blocks.py index e7b7df5f..ee97ea67 100644 --- a/bc/location/blocks.py +++ b/bc/location/blocks.py @@ -1,6 +1,6 @@ -from bc.service_directory.blocks import DirectoryActivitiesBlock +from bc.service_directory.blocks import DirectoryServicesBlock from bc.utils.blocks import StoryBlock class LocationPageStoryBlock(StoryBlock): - directory_activities = DirectoryActivitiesBlock() + directory_services = DirectoryServicesBlock() diff --git a/bc/location/migrations/0017_add_directory_services_block.py b/bc/location/migrations/0017_add_directory_services_block.py new file mode 100644 index 00000000..95e777ad --- /dev/null +++ b/bc/location/migrations/0017_add_directory_services_block.py @@ -0,0 +1,570 @@ +# Generated by Django 4.2.11 on 2024-07-25 12:07 + +import bc.service_directory.blocks +import bc.utils.blocks +from django.db import migrations +import wagtail.blocks +import wagtail.contrib.typed_table_block.blocks +import wagtail.embeds.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ("location", "0016_add_ehcco_search_widget"), + ] + + operations = [ + migrations.AlterField( + model_name="locationpage", + name="body", + field=wagtail.fields.StreamField( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ("image", wagtail.images.blocks.ImageChooserBlock()), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ("caption", wagtail.blocks.CharBlock(required=False)), + ] + ), + ), + ("embed", wagtail.embeds.blocks.EmbedBlock()), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

    Find local information

    ", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

    While we finish building this new website, we’re keeping some local information on our old council websites

    ", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

    Enter your postcode to help us redirect you to the right place.

    ", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

    Select your local area to help us direct you to the right place:

    ", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock(label="Aylesbury Vale URL"), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock(label="Chiltern URL"), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock(label="South Bucks URL"), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock(label="Wycombe URL"), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ("caption", wagtail.blocks.TextBlock(required=False)), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock(form_classname="title"), + ), + ("link_url", wagtail.blocks.URLBlock(required=False)), + ( + "link_page", + wagtail.blocks.PageChooserBlock(required=False), + ), + ] + ), + ), + ("highlight", bc.utils.blocks.HighlightBlock()), + ("inset_text", bc.utils.blocks.InsetTextBlock()), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock(label="EHCCo Search"), + ), + ( + "accordion", + wagtail.blocks.StructBlock( + [ + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Accordion title", + ), + ), + ( + "content", + wagtail.blocks.StreamBlock( + [ + ( + "heading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this heading uses the heading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + label="Main heading", + template="patterns/molecules/streamfield/blocks/heading_block.html", + ), + ), + ( + "subheading", + wagtail.blocks.CharBlock( + form_classname="full title", + group="Heading", + help_text='The link to this subheading uses the subheading text in lowercase, with no symbols, and with the spaces replaced with hyphens. e.g. "Lorem @ 2 ipsum" becomes "lorem-2-ipsum"', + icon="title", + template="patterns/molecules/streamfield/blocks/subheading_block.html", + ), + ), + ( + "paragraph", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ] + ), + ), + ( + "image", + wagtail.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock(), + ), + ( + "alt_text", + wagtail.blocks.CharBlock( + help_text="Describe the information, not the picture. Leave blank if the image is purely decorative. Do not repeat captions or content already on the page.", + required=False, + ), + ), + ( + "caption", + wagtail.blocks.CharBlock( + required=False + ), + ), + ] + ), + ), + ( + "embed", + wagtail.embeds.blocks.EmbedBlock(), + ), + ( + "local_area_links", + wagtail.blocks.StructBlock( + [ + ( + "heading", + wagtail.blocks.RichTextBlock( + default="

    Find local information

    ", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "introduction", + wagtail.blocks.RichTextBlock( + default="

    While we finish building this new website, we’re keeping some local information on our old council websites

    ", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ), + ), + ( + "postcode_lookup_text", + wagtail.blocks.RichTextBlock( + default="

    Enter your postcode to help us redirect you to the right place.

    ", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the postcode lookup input", + ), + ), + ( + "area_lookup_text", + wagtail.blocks.RichTextBlock( + default="

    Select your local area to help us direct you to the right place:

    ", + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + help_text="The text that appears on top of the list of local area links", + ), + ), + ( + "aylesbury_vale_url", + wagtail.blocks.URLBlock( + label="Aylesbury Vale URL" + ), + ), + ( + "chiltern_url", + wagtail.blocks.URLBlock( + label="Chiltern URL" + ), + ), + ( + "south_bucks_url", + wagtail.blocks.URLBlock( + label="South Bucks URL" + ), + ), + ( + "wycombe_url", + wagtail.blocks.URLBlock( + label="Wycombe URL" + ), + ), + ] + ), + ), + ( + "plain_text_table", + bc.utils.blocks.TableBlock( + group="Table", + help_text='This table will be displayed as plain text on the page.\n You can add links to individuals cells by using the following\n syntax: [link text](www.gov.uk). This will output as\n link text', + ), + ), + ( + "table", + wagtail.blocks.StructBlock( + [ + ( + "table", + wagtail.contrib.typed_table_block.blocks.TypedTableBlock( + [ + ( + "left_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ( + "right_aligned_column", + wagtail.blocks.StreamBlock( + [ + ( + "numeric", + wagtail.blocks.DecimalBlock(), + ), + ( + "rich_text", + wagtail.blocks.RichTextBlock(), + ), + ] + ), + ), + ] + ), + ), + ( + "caption", + wagtail.blocks.TextBlock( + required=False + ), + ), + ], + group="Table", + ), + ), + ( + "button", + wagtail.blocks.StructBlock( + [ + ( + "text", + wagtail.blocks.CharBlock( + form_classname="title" + ), + ), + ( + "link_url", + wagtail.blocks.URLBlock( + required=False + ), + ), + ( + "link_page", + wagtail.blocks.PageChooserBlock( + required=False + ), + ), + ] + ), + ), + ( + "highlight", + bc.utils.blocks.HighlightBlock(), + ), + ( + "inset_text", + bc.utils.blocks.InsetTextBlock(), + ), + ( + "ehc_co_search", + bc.utils.blocks.EHCCoSearchBlock( + label="EHCCo Search" + ), + ), + ], + label="Accordion content", + ), + ), + ] + ), + label="Accordion items", + ), + ) + ] + ), + ), + ( + "detail", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + form_classname="full title", + icon="title", + label="Detail title", + ), + ), + ( + "content", + wagtail.blocks.RichTextBlock( + features=[ + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + label="Detail content", + ), + ), + ] + ), + ), + ( + "directory_services", + wagtail.blocks.StructBlock( + [ + ("heading", wagtail.blocks.CharBlock(required=False)), + ( + "service_directory", + bc.service_directory.blocks.ServiceDirectoryChooserBlock(), + ), + ( + "categories", + wagtail.blocks.ListBlock( + bc.service_directory.blocks.TaxonomyChooserBlock() + ), + ), + ( + "collection", + bc.service_directory.blocks.TaxonomyChooserBlock( + required=False + ), + ), + ] + ), + ), + ], + help_text="Generic body content. This will appear after the map in the template.", + ), + ), + ] diff --git a/bc/project_styleguide/templates/patterns/molecules/streamfield/blocks/directory_activities_block.html b/bc/project_styleguide/templates/patterns/molecules/streamfield/blocks/directory_services_block.html similarity index 100% rename from bc/project_styleguide/templates/patterns/molecules/streamfield/blocks/directory_activities_block.html rename to bc/project_styleguide/templates/patterns/molecules/streamfield/blocks/directory_services_block.html diff --git a/bc/service_directory/admin_choosers.py b/bc/service_directory/admin_choosers.py new file mode 100644 index 00000000..54194545 --- /dev/null +++ b/bc/service_directory/admin_choosers.py @@ -0,0 +1,31 @@ +from wagtail.admin.viewsets.chooser import ChooserViewSet + +from . import models + + +class ServiceDirectoryChooserViewSet(ChooserViewSet): + choose_another_text = "Choose a directory" + choose_one_text = "Choose a directory" + edit_item_text = "Edit this directory" + icon = "folder-open-inverse" + model = models.ServiceDirectory + + +service_directory_chooser_viewset = ServiceDirectoryChooserViewSet( + "service-directory-chooser" +) + + +class TaxonomyChooserViewSet(ChooserViewSet): + choose_another_text = "Choose a taxonomy" + choose_one_text = "Choose a taxonomy" + edit_item_text = "Edit this taxonomy" + icon = "tag" + model = models.Taxonomy + per_page = 50 + + def get_object_list(self): + return self.model.objects.select_related("fetched_with_directory") + + +taxonomy_chooser_viewset = TaxonomyChooserViewSet("service-directory-taxonomy-chooser") diff --git a/bc/service_directory/admin_views.py b/bc/service_directory/admin_views.py new file mode 100644 index 00000000..24ad81a6 --- /dev/null +++ b/bc/service_directory/admin_views.py @@ -0,0 +1,47 @@ +from wagtail.admin.ui.tables import BooleanColumn +from wagtail.admin.views.generic.models import IndexView +from wagtail.admin.viewsets.model import ModelViewSet, ModelViewSetGroup + +from . import models + + +class ServiceDirectoryModelViewSet(ModelViewSet): + copy_view_enabled = False + icon = "folder-open-inverse" + inspect_view_enabled = True + list_display = ["admin_name", BooleanColumn("is_enabled"), "directory_api_slug"] + list_filter = ["is_enabled"] + menu_label = "Directories" + model = models.ServiceDirectory + + +service_directory_model_viewset = ServiceDirectoryModelViewSet("service-directory") + + +class TaxonomyIndexView(IndexView): + def get_queryset(self): + queryset = super().get_queryset() + if not self.is_searching: + queryset = queryset.select_related("fetched_with_directory") + return queryset + + +class TaxonomyModelViewSet(ModelViewSet): + add_to_settings_menu = True + copy_view_enabled = False + icon = "tag" + index_view_class = TaxonomyIndexView + inspect_view_enabled = True + list_filter = ["fetched_with_directory", "level"] + list_display = ["label", "remote_slug", "level", "fetched_with_directory"] + menu_label = "Taxonomies" + model = models.Taxonomy + + +taxonomy_model_viewset = TaxonomyModelViewSet("service-directory-taxonomy") + + +class ServiceDirectoryModelViewSetGroup(ModelViewSetGroup): + items = (service_directory_model_viewset, taxonomy_model_viewset) + menu_label = "Service Directory" + menu_icon = "folder-open-inverse" diff --git a/bc/service_directory/client.py b/bc/service_directory/api_client.py similarity index 52% rename from bc/service_directory/client.py rename to bc/service_directory/api_client.py index d75bec53..e3c65e2a 100644 --- a/bc/service_directory/client.py +++ b/bc/service_directory/api_client.py @@ -1,31 +1,38 @@ import logging -from typing import Literal, Mapping, Optional +from typing import Literal, Mapping, Optional, Type import requests logger = logging.getLogger(__name__) -class BaseOutpostClient: - def get(self, /, path: str, *, params: Mapping[str, str], **kwargs) -> Mapping: +class BaseServiceDirectoryClient: + def __init__(self, *, base_url: str, timeout: Optional[float] = 5): + raise NotImplementedError + + def get( + self, /, path: str, *, params: Optional[Mapping[str, str]] = None, **kwargs + ) -> Mapping: raise NotImplementedError -class ClientError(Exception): +class ServiceDirectoryClientError(Exception): pass -class RequestsClient(BaseOutpostClient): +class ServiceDirectoryRequestsClient(BaseServiceDirectoryClient): timeout: float base_url: str - def __init__(self, *, base_url: str, timeout: float = 5): + def __init__(self, *, base_url: str, timeout: Optional[float] = 5): self.base_url = base_url self.timeout = timeout self.session = requests.Session() self.session.headers["User-Agent"] = "www.buckinghamshire.gov.uk website" - def get(self, /, path: str, *, params: Mapping[str, str], **kwargs) -> Mapping: + def get( + self, /, path: str, *, params: Optional[Mapping[str, str]] = None, **kwargs + ) -> Mapping: return self.call("GET", path, params=params, **kwargs) def call( @@ -34,7 +41,7 @@ def call( method: Literal["GET"], path: str, *, - params: Mapping[str, str], + params: Optional[Mapping[str, str]] = None, **kwargs, ) -> Mapping: kwargs.setdefault("timeout", self.timeout) @@ -43,19 +50,26 @@ def call( try: response = self.session.request(method, url, params=params, **kwargs) except requests.RequestException as e: - raise ClientError from e + raise ServiceDirectoryClientError from e try: response.raise_for_status() except requests.HTTPError as e: - raise ClientError from e + raise ServiceDirectoryClientError from e try: return response.json() except requests.JSONDecodeError as e: - raise ClientError from e + raise ServiceDirectoryClientError from e def construct_url(self, /, path: str, *, base_url: Optional[str] = None) -> str: if base_url is None: base_url = self.base_url - if base_url.endswith("/") and path.startswith("/"): - base_url = base_url[:-1] + if path.startswith("/"): + path = path[1:] + if not base_url.endswith("/"): + base_url = base_url + "/" return f"{base_url}{path}" + + +def get_api_client_class() -> Type[BaseServiceDirectoryClient]: + # TODO: Implement mock client for local dev and testing. + return ServiceDirectoryRequestsClient diff --git a/bc/service_directory/api_schema.py b/bc/service_directory/api_schema.py new file mode 100644 index 00000000..2d4fd82d --- /dev/null +++ b/bc/service_directory/api_schema.py @@ -0,0 +1,38 @@ +import dataclasses +import datetime +from typing import Any, Dict, List, Optional + +import dataclasses_json +from marshmallow import fields as mm_fields + + +@dataclasses_json.dataclass_json(undefined=dataclasses_json.Undefined.EXCLUDE) +@dataclasses.dataclass +class Service: + description: str + id: int + name: str + url: str + free: Optional[bool] + local_offer: Optional[Dict[str, Any]] + updated_at: datetime.datetime = dataclasses.field( + metadata=dataclasses_json.config( + encoder=datetime.datetime.isoformat, + decoder=datetime.datetime.fromisoformat, + mm_field=mm_fields.DateTime(format="iso"), + ) + ) + + +@dataclasses_json.dataclass_json(undefined=dataclasses_json.Undefined.EXCLUDE) +@dataclasses.dataclass +class Taxonomy: + id: int + label: str + slug: str + level: int + children: List["Taxonomy"] = dataclasses.field( + metadata=dataclasses_json.config( + mm_field=mm_fields.List(mm_fields.Nested(lambda: Taxonomy.schema())) + ) + ) diff --git a/bc/service_directory/blocks.py b/bc/service_directory/blocks.py index e373f05e..d2d92bba 100644 --- a/bc/service_directory/blocks.py +++ b/bc/service_directory/blocks.py @@ -1,20 +1,21 @@ import datetime import logging -from typing import List, Optional, Sequence, TypedDict +from typing import Any, List, Mapping, Optional, Sequence, TypedDict from django.utils import timezone from django.utils.text import Truncator from wagtail import blocks -from bc.service_directory.resources import ServiceDirectoryResources +from bc.service_directory import api_schema +from bc.service_directory.models import ServiceDirectory, Taxonomy +from bc.service_directory.resources import ServiceDirectoryAPIResources from bc.service_directory.services import ( - get_service_detail_page_url, - get_services_listing_page_url, + format_service_detail_page_url, + format_services_listing_page_url, ) -from .client import ClientError, RequestsClient -from .types import APIService, Category, Directory +from . import admin_choosers, api_client logger = logging.getLogger(__name__) @@ -40,68 +41,110 @@ class CouldNotFetchActivities(Exception): pass -class DirectoryActivitiesBlock(blocks.StructBlock): +ServiceDirectoryChooserBlock = ( + admin_choosers.service_directory_chooser_viewset.get_block_class( + name="ServiceDirectoryChooserBlock", module_path="bc.service_directory.blocks" + ) +) +TaxonomyChooserBlock = admin_choosers.taxonomy_chooser_viewset.get_block_class( + name="TaxonomyChooserBlock", module_path="bc.service_directory.blocks" +) + + +class DirectoryServicesBlock(blocks.StructBlock): SERVICE_DESCRIPTION_CHARS = 106 + RECENTLY_UPDATED_TIMEDELTA: datetime.timedelta = datetime.timedelta(days=30) heading = blocks.CharBlock(required=False) - directory = blocks.ChoiceBlock(choices=Directory.get_choices()) - category = blocks.ChoiceBlock(choices=Category.get_choices()) + service_directory = ServiceDirectoryChooserBlock() + categories = blocks.ListBlock(TaxonomyChooserBlock()) + collection = TaxonomyChooserBlock(required=False) class Meta: - template = ( - "patterns/molecules/streamfield/blocks/directory_activities_block.html" - ) + icon = "calendar-alt" + template = "patterns/molecules/streamfield/blocks/directory_services_block.html" + + def clean(self, value) -> Mapping[str, Any]: + cleaned_data = super().clean(value) + directory = cleaned_data.get("service_directory") + categories = cleaned_data.get("categories", []) + collection = cleaned_data.get("collection") + + errors = {} + + for category in categories: + if category.fetched_with_directory != directory: + errors["categories"].setdefault("fetched_with_directory", []).append( + "Categories must be fetched with the same directory as the service directory" + ) + + if collection is not None and collection.fetched_with_directory != directory: + errors["collection"].setdefault("fetched_with_directory", []).append( + "Collection must be fetched with the same directory as the service directory" + ) + + if errors: + raise blocks.StructBlockValidationError(block_errors=errors) + + return cleaned_data def get_context( self, value, parent_context=None ) -> DirectoryActivitiesBlockContext: context = super().get_context(value, parent_context=parent_context) - try: - directory = Directory(value["directory"]) - except ValueError: - logger.warning("Invalid directory value", exc_info=True) - return context + directory = value["service_directory"] + categories = [c for c in value.get("categories", []) if c is not None] + collection = value.get("collection") - try: - category = Category(value["category"]) - except ValueError: - logger.warning("Invalid category value", exc_info=True) + if directory is None: + logger.warning( + "Directory value is empty on a block. It might have been deleted." + ) return context try: context["activities"] = self.get_activities( - directory=directory, category=category + directory=directory, categories=categories, collection=collection ) except CouldNotFetchActivities: logger.exception("There was an issue fetching activities") context["activities"] = None - context["view_all_activities_url"] = get_services_listing_page_url( - category_filters=[category], - collection_filter=category.collection, - directory=directory, + context["view_all_activities_url"] = self.get_view_all_activities_url( + categories=categories, collection=collection, directory=directory ) context["heading"] = value.get("heading", "") return context @classmethod def get_activities( - cls, *, directory: Directory, category: Category + cls, + *, + directory: ServiceDirectory, + categories: Sequence[Taxonomy], + collection: Taxonomy, ) -> List[_ActivityContext]: - # TODO: Make client class and parameters configurable. - client = RequestsClient( - base_url=directory.api_url, + client = api_client.get_api_client_class()( + base_url=directory.directory_api_url, ) - api = ServiceDirectoryResources(client=client) + api = ServiceDirectoryAPIResources(client=client) + taxonomies = [category.remote_slug for category in categories] try: services = api.get_services( - directories=[directory], taxonomies=[category], per_page=4, page=1 + directories=[directory.directory_api_slug], + taxonomies=taxonomies, + per_page=4, + page=1, ) - except ClientError as e: + except api_client.ServiceDirectoryClientError as e: raise CouldNotFetchActivities from e + # Context for building the URL. + collection_filter = collection.remote_slug if collection is not None else None + categories_filter = [category.remote_slug for category in categories] + activities_context: List[_ActivityContext] = [] for service in services: tags: List[_ActivityTag] = [] @@ -109,18 +152,20 @@ def get_activities( tags.append({"highlight": True, "title": "Part of local offer"}) if service.free: tags.append({"highlight": False, "title": "Free"}) - if service.updated_at <= timezone.now() + datetime.timedelta(days=2): + if service.updated_at <= timezone.now() + cls.RECENTLY_UPDATED_TIMEDELTA: tags.append({"highlight": False, "title": "Recently updated"}) + url = format_service_detail_page_url( + service, + category_filters=categories_filter, + collection_filter=collection_filter, + frontend_url=directory.frontend_url, + ) + activity_context: _ActivityContext = { "intro": cls._format_activity_intro(service), "name": service.name, - "url": get_service_detail_page_url( - service, - category_filters=[category], - collection_filter=category.collection, - directory=directory, - ), + "url": url, "tags": tags, } activities_context.append(activity_context) @@ -128,7 +173,7 @@ def get_activities( @classmethod def _format_activity_intro( - cls, service: APIService, /, *, max_length: Optional[int] = None + cls, service: api_schema.Service, /, *, max_length: Optional[int] = None ) -> str: """ Shorten the description, and then remove the newlines. @@ -137,3 +182,19 @@ def _format_activity_intro( max_length = cls.SERVICE_DESCRIPTION_CHARS description = Truncator(service.description).chars(max_length) return " ".join(description.splitlines()) + + @classmethod + def get_view_all_activities_url( + cls, + *, + directory: ServiceDirectory, + categories: Sequence[Taxonomy], + collection: Taxonomy, + ) -> str: + category_filters = [category.remote_slug for category in categories] + collection_filter = collection.remote_slug if collection is not None else None + return format_services_listing_page_url( + category_filters=category_filters, + collection_filter=collection_filter, + frontend_url=directory.frontend_url, + ) diff --git a/bc/service_directory/api.py b/bc/service_directory/management/__init__.py similarity index 100% rename from bc/service_directory/api.py rename to bc/service_directory/management/__init__.py diff --git a/bc/service_directory/management/commands/__init__.py b/bc/service_directory/management/commands/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/bc/service_directory/management/commands/fetch_service_directory_taxonomies.py b/bc/service_directory/management/commands/fetch_service_directory_taxonomies.py new file mode 100644 index 00000000..f6c45c45 --- /dev/null +++ b/bc/service_directory/management/commands/fetch_service_directory_taxonomies.py @@ -0,0 +1,19 @@ +from django.core.management.base import BaseCommand + +from bc.service_directory import taxonomies +from bc.service_directory.models import ServiceDirectory + + +class Command(BaseCommand): + help = "Fetch and create service directory taxonomies from the API" + + def handle(self, *args, **options) -> None: + for directory in ServiceDirectory.objects.all(): + try: + taxonomies.fetch_and_create_taxonomies(directory, api_timeout=60) + except taxonomies.DirectoryIsNotEnabled: + self.stdout.write( + self.style.WARNING( + f"Directory {directory.name} (PK={directory.pk}) is not enabled. Skipping." + ) + ) diff --git a/bc/service_directory/migrations/0001_initial.py b/bc/service_directory/migrations/0001_initial.py new file mode 100644 index 00000000..cc7df90f --- /dev/null +++ b/bc/service_directory/migrations/0001_initial.py @@ -0,0 +1,111 @@ +# Generated by Django 4.2.11 on 2024-07-25 12:06 + +from django.db import migrations, models +import django.db.models.deletion +import wagtail.search.index + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [] + + operations = [ + migrations.CreateModel( + name="ServiceDirectory", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("is_enabled", models.BooleanField(default=True)), + ( + "frontend_url", + models.URLField( + help_text='What URL users use to access the directory interface, e.g. "https://directory.familyinfo.buckinghamshire.gov.uk/". This is used to generate links to the directory services', + verbose_name="frontend interface URL", + ), + ), + ("admin_name", models.CharField(max_length=128)), + ( + "directory_api_url", + models.URLField( + help_text='What URL the specific directory API is available at, e.g. "https://api.familyinfo.buckinghamshire.gov.uk/api/v1"', + verbose_name="directory API URL", + ), + ), + ( + "directory_api_slug", + models.CharField( + help_text='Slug used to identify this directory in the directory API, e.g. "bfis"', + max_length=255, + verbose_name="directory API slug", + ), + ), + ( + "management_api_url", + models.URLField( + help_text='What URL the management directory API is available at, e.g. "https://manage-directory-listing.buckinghamshire.gov.uk/api/v1"', + verbose_name="management API URL", + ), + ), + ], + options={ + "verbose_name_plural": "service directories", + }, + bases=(wagtail.search.index.Indexed, models.Model), + ), + migrations.CreateModel( + name="Taxonomy", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("label", models.CharField(max_length=255)), + ("level", models.IntegerField()), + ("remote_id", models.BigIntegerField(verbose_name="remote ID")), + ("remote_slug", models.CharField(max_length=255)), + ( + "fetched_with_directory", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="taxonomies", + to="service_directory.servicedirectory", + ), + ), + ( + "parent", + models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.CASCADE, + related_name="child_taxonomies", + to="service_directory.taxonomy", + ), + ), + ], + options={ + "verbose_name": "service directory taxonomy", + "verbose_name_plural": "service directory taxonomies", + }, + bases=(wagtail.search.index.Indexed, models.Model), + ), + migrations.AddConstraint( + model_name="taxonomy", + constraint=models.UniqueConstraint( + fields=("fetched_with_directory", "remote_id"), + name="unique_remote_id_per_directory", + ), + ), + ] diff --git a/bc/service_directory/migrations/__init__.py b/bc/service_directory/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/bc/service_directory/models.py b/bc/service_directory/models.py new file mode 100644 index 00000000..b989f842 --- /dev/null +++ b/bc/service_directory/models.py @@ -0,0 +1,122 @@ +from django.db import models +from django.utils.html import format_html + +from wagtail.admin.panels import FieldPanel, HelpPanel, MultiFieldPanel +from wagtail.search import index + + +class ServiceDirectory(index.Indexed, models.Model): + FRONTEND_URL_HELP_TEXT = ( + "What URL users use to access the directory interface, " + 'e.g. "https://directory.familyinfo.buckinghamshire.gov.uk/". ' + "This is used to generate links to the directory services" + ) + DIRECTORY_API_URL_HELP_TEXT = ( + "What URL the specific directory API is available at, " + 'e.g. "https://api.familyinfo.buckinghamshire.gov.uk/api/v1"' + ) + MANAGEMENT_API_URL_HELP_TEXT = ( + "What URL the management directory API is available at, e.g. " + '"https://manage-directory-listing.buckinghamshire.gov.uk/api/v1"' + ) + + is_enabled = models.BooleanField(default=True) + frontend_url = models.URLField( + verbose_name="frontend interface URL", help_text=FRONTEND_URL_HELP_TEXT + ) + admin_name = models.CharField(max_length=128) + directory_api_url = models.URLField( + verbose_name="directory API URL", + help_text=DIRECTORY_API_URL_HELP_TEXT, + ) + directory_api_slug = models.CharField( + max_length=255, + verbose_name="directory API slug", + help_text='Slug used to identify this directory in the directory API, e.g. "bfis"', + ) + management_api_url = models.URLField( + verbose_name="management API URL", help_text=MANAGEMENT_API_URL_HELP_TEXT + ) + + panels = [ + FieldPanel("admin_name"), + FieldPanel("is_enabled"), + FieldPanel("frontend_url"), + MultiFieldPanel( + [ + FieldPanel("directory_api_url"), + FieldPanel("directory_api_slug"), + ], + heading="Directory API", + ), + FieldPanel("management_api_url"), + ] + + search_fields = [ + index.SearchField("admin_name"), + index.AutocompleteField("admin_name"), + index.FilterField("is_enabled"), + index.SearchField("directory_api_slug"), + index.AutocompleteField("directory_api_slug"), + ] + + class Meta: + verbose_name_plural = "service directories" + + def __str__(self) -> str: + return self.admin_name + + +class Taxonomy(index.Indexed, models.Model): + HELP_PANEL_HTML = format_html( + "{}", + "Do not edit these values as they come from the API! This is enabled for debugging purposes only.", + ) + fetched_with_directory = models.ForeignKey( + ServiceDirectory, on_delete=models.CASCADE, related_name="taxonomies" + ) + label = models.CharField(max_length=255) + level = models.IntegerField() + parent = models.ForeignKey( + "self", on_delete=models.CASCADE, related_name="child_taxonomies", null=True + ) + remote_id = models.BigIntegerField(verbose_name="remote ID") + remote_slug = models.CharField(max_length=255) + + search_fields = [ + index.SearchField("label"), + index.AutocompleteField("label"), + index.SearchField("remote_slug"), + index.AutocompleteField("remote_slug"), + index.RelatedFields( + "fetched_with_directory", + [ + index.SearchField("admin_name"), + index.AutocompleteField("admin_name"), + ], + ), + index.FilterField("fetched_with_directory"), + index.FilterField("level"), + ] + + panels = [ + HelpPanel(HELP_PANEL_HTML), + FieldPanel("label"), + FieldPanel("level"), + FieldPanel("parent"), + FieldPanel("remote_id"), + FieldPanel("remote_slug"), + ] + + class Meta: + constraints = [ + models.UniqueConstraint( + fields=["fetched_with_directory", "remote_id"], + name="unique_remote_id_per_directory", + ), + ] + verbose_name = "service directory taxonomy" + verbose_name_plural = "service directory taxonomies" + + def __str__(self) -> str: + return f"{self.label} ({self.fetched_with_directory})" diff --git a/bc/service_directory/resources.py b/bc/service_directory/resources.py index a1f72d86..c9ca8c3e 100644 --- a/bc/service_directory/resources.py +++ b/bc/service_directory/resources.py @@ -1,37 +1,45 @@ from typing import List, Sequence, cast -from .client import BaseOutpostClient -from .types import APIService, Category, Directory +from . import api_schema +from .api_client import BaseServiceDirectoryClient -class ServiceDirectoryResources: - client: BaseOutpostClient +class BaseResources: + client: BaseServiceDirectoryClient - def __init__(self, *, client: BaseOutpostClient): + def __init__(self, *, client: BaseServiceDirectoryClient): self.client = client + +class ServiceDirectoryAPIResources(BaseResources): def get_services( self, *, - directories: Sequence[Directory], - taxonomies: Sequence[Category], + directories: Sequence[str], + taxonomies: Sequence[str], per_page: int, page: int - ) -> List[APIService]: + ) -> List[api_schema.Service]: """ https://github.com/wearefuturegov/outpost-api-service/wiki/Search-services """ - service_schema = APIService.schema() + service_schema = api_schema.Service.schema() response = self.client.get( "services", params={ - "directories": ",".join( - directory.api_value for directory in directories - ), - "taxonomies": ",".join(taxonomy.api_value for taxonomy in taxonomies), + "directories": ",".join(directories), + "taxonomies": ",".join(taxonomies), "per_page": str(per_page), "page": str(page), }, ) services = service_schema.load(response["content"], many=True) - return cast(List[APIService], services) + return cast(List[api_schema.Service], services) + + +class ManageDirectoryAPIResources(BaseResources): + def get_taxonomies(self) -> List[api_schema.Taxonomy]: + taxonomy_schema = api_schema.Taxonomy.schema() + response = self.client.get("taxonomies") + services = taxonomy_schema.load(response, many=True) + return cast(List[api_schema.Taxonomy], services) diff --git a/bc/service_directory/services.py b/bc/service_directory/services.py index a7cb82a3..c8987683 100644 --- a/bc/service_directory/services.py +++ b/bc/service_directory/services.py @@ -3,54 +3,51 @@ from django.http import QueryDict -from bc.service_directory.types import APIService, Category, Collection, Directory +from . import api_schema -def get_service_detail_page_url( - service: APIService, +def format_service_detail_page_url( + service: api_schema.Service, /, *, - category_filters: Optional[Sequence[Category]] = None, - collection_filter: Optional[Collection] = None, - directory: Directory, + category_filters: Optional[Sequence[str]] = None, + collection_filter: Optional[str] = None, + frontend_url: str, ): query_dict = QueryDict(mutable=True) if collection_filter is not None: - query_dict["collection"] = collection_filter.value + query_dict["collection"] = collection_filter if category_filters is not None: for category in category_filters: - query_dict.appendlist("categories", category.value) + query_dict.appendlist("categories", category) - base_url = directory.frontend_url - if base_url.endswith("/"): - base_url = base_url[:-1] + if frontend_url.endswith("/"): + frontend_url = frontend_url[:-1] - url = f"{base_url}/service/{quote_plus(str(service.id))}" + url = f"{frontend_url}/service/{quote_plus(str(service.id))}" if query_dict: url += f"?{query_dict.urlencode()}" return url -def get_services_listing_page_url( +def format_services_listing_page_url( *, - category_filters: Optional[Sequence[Category]] = None, - collection_filter: Optional[Collection] = None, - directory: Directory, + category_filters: Optional[Sequence[str]] = None, + collection_filter: Optional[str] = None, + frontend_url: str, ): query_dict = QueryDict(mutable=True) if collection_filter is not None: - query_dict["collection"] = collection_filter.value + query_dict["collection"] = collection_filter if category_filters is not None: for category in category_filters: - query_dict.appendlist("categories", category.value) - - url = directory.frontend_url + query_dict.appendlist("categories", category) if query_dict: - url += f"?{query_dict.urlencode()}" - return url + frontend_url += f"?{query_dict.urlencode()}" + return frontend_url diff --git a/bc/service_directory/taxonomies.py b/bc/service_directory/taxonomies.py new file mode 100644 index 00000000..d7625988 --- /dev/null +++ b/bc/service_directory/taxonomies.py @@ -0,0 +1,66 @@ +import logging +from typing import Optional + +from bc.service_directory import api_schema +from bc.service_directory.resources import ManageDirectoryAPIResources + +from .api_client import get_api_client_class +from .models import ServiceDirectory, Taxonomy + +logger = logging.getLogger(__name__) + + +class DirectoryIsNotEnabled(Exception): + pass + + +def fetch_and_create_taxonomies( + directory: ServiceDirectory, /, *, api_timeout: Optional[float] +) -> None: + if not directory.is_enabled: + raise DirectoryIsNotEnabled(directory.pk) + + client = get_api_client_class()( + base_url=directory.management_api_url, timeout=api_timeout + ) + api_resource = ManageDirectoryAPIResources(client=client) + + for api_taxonomy in api_resource.get_taxonomies(): + created_taxonomy = _create_taxonomy( + api_taxonomy=api_taxonomy, directory=directory, parent=None + ) + _traverse_children( + api_taxonomy=api_taxonomy, directory=directory, parent=created_taxonomy + ) + + +def _create_taxonomy( + *, + api_taxonomy: api_schema.Taxonomy, + directory: ServiceDirectory, + parent: Optional[Taxonomy], +) -> Taxonomy: + created_taxonomy = Taxonomy.objects.update_or_create( + fetched_with_directory=directory, + remote_id=api_taxonomy.id, + defaults={ + "label": api_taxonomy.label, + "level": api_taxonomy.level, + "parent": parent, + "remote_slug": api_taxonomy.slug, + }, + )[0] + _traverse_children( + api_taxonomy=api_taxonomy, directory=directory, parent=created_taxonomy + ) + return created_taxonomy + + +def _traverse_children( + *, + api_taxonomy: api_schema.Taxonomy, + directory: ServiceDirectory, + parent: Optional[Taxonomy], +) -> None: + for child in api_taxonomy.children: + _create_taxonomy(api_taxonomy=child, directory=directory, parent=parent) diff --git a/bc/service_directory/types.py b/bc/service_directory/types.py deleted file mode 100644 index 7eed95d5..00000000 --- a/bc/service_directory/types.py +++ /dev/null @@ -1,190 +0,0 @@ -import dataclasses -import datetime -import enum -from typing import Any, Dict, NamedTuple, Optional - -from django.db.models import TextChoices - -import dataclasses_json -from marshmallow import fields as mm_fields - - -class _DirectoryTuple(NamedTuple): - api_url: str - frontend_url: str - label: str - api_value: Optional[str] = None - - -class Directory(enum.Enum): - FAMILY_INFORMATION_SERVICE = "family-information-service", _DirectoryTuple( - api_url="https://api.familyinfo.buckinghamshire.gov.uk/api/v1/", - frontend_url="https://directory.familyinfo.buckinghamshire.gov.uk/", - label="Family Information Service", - api_value="bfis", - ) - - def __new__(cls, *args, **kwds) -> "Directory": - obj = object.__new__(cls) - obj._value_ = args[0] - return obj - - def __init__(self, value: str, directory: _DirectoryTuple) -> None: - if directory.api_value is None: - self.api_value = value - else: - self.api_value = directory.api_value - self.label = directory.label - self.frontend_url = directory.frontend_url - self.api_url = directory.api_url - - @classmethod - def get_choices(cls): - return [(directory.value, directory.label) for directory in cls] - - -class Collection(TextChoices): - FAMILY_CENTRES = "family-centres", "Family Centres" - - -class _CategoryTuple(NamedTuple): - label: str - collection: Collection - api_value: Optional[str] = None - frontend_value: Optional[str] = None - - -# These are hard-coded from -# https://manage-directory-listing.buckinghamshire.gov.uk/api/v1/taxonomies - - -class Category(enum.Enum): - AMERSHAM_FAMILY_CENTRE = "amersham-family-centre", _CategoryTuple( - label="Amersham Family Centre", - collection=Collection.FAMILY_CENTRES, - ) - BEACONSFIELD_FAMILY_CENTRE = "beaconsfield-family-centre", _CategoryTuple( - label="Beaconsfield Family Centre", - collection=Collection.FAMILY_CENTRES, - ) - BERRYFIELDS_FAMILY_CENTRE_AYLESBURY = ( - "berryfields-family-centre-aylesbury", - _CategoryTuple( - label="Berryfields Family Centre, Aylesbury", - collection=Collection.FAMILY_CENTRES, - ), - ) - BUCKINGHAM_FAMILY_CENTRE = "buckingham-family-centre", _CategoryTuple( - label="Buckingham Family Centre", - collection=Collection.FAMILY_CENTRES, - ) - BURNHAM_FAMILY_CENTRE = "burnham-family-centre", _CategoryTuple( - label="Burnham Family Centre", - collection=Collection.FAMILY_CENTRES, - ) - CASTLEFIELD_FAMILY_CENTRE_WYCOMBE = ( - "castlefield-family-centre-wycombe", - _CategoryTuple( - label="Castlefield Family Centre, Wycombe", - collection=Collection.FAMILY_CENTRES, - ), - ) - ELMHURST_FAMILY_CENTRE_AYLESBURY = ( - "elmhurst-family-centre-aylesbury", - _CategoryTuple( - label="Elmhurst Family Centre, Aylesbury", - collection=Collection.FAMILY_CENTRES, - ), - ) - HAMPDEN_WAY_FAMILY_CENTRE_WYCOMBE = ( - "hampden-way-family-centre-wycombe", - _CategoryTuple( - label="Hampden Way Family Centre, Wycombe", - collection=Collection.FAMILY_CENTRES, - ), - ) - HITHERCROFT_FAMILY_CENTRE_WYCOMBE = ( - "hithercroft-family-centre-wycombe", - _CategoryTuple( - label="Hithercroft Family Centre, Wycombe", - collection=Collection.FAMILY_CENTRES, - ), - ) - WING_FAMILY_CENTRE = "wing-family-centre", _CategoryTuple( - label="Wing Family Centre", - collection=Collection.FAMILY_CENTRES, - ) - SOUTHCOURT_FAMILY_CENTRE_PLUS_AYLESBURY = ( - "southcourt-family-centre-plus-aylesbury", - _CategoryTuple( - label="Southcourt Family Centre Plus, Aylesbury", - collection=Collection.FAMILY_CENTRES, - ), - ) - THE_IVERS_FAMILY_CENTRE = "the-ivers-family-centre", _CategoryTuple( - label="The Ivers Family Centre", - collection=Collection.FAMILY_CENTRES, - ) - NEWTOWN_FAMILY_CENTRE_PLUS_CHESHAM = ( - "newtown-family-centre-plus-chesham", - _CategoryTuple( - label="Newtown Family Centre Plus, Chesham", - collection=Collection.FAMILY_CENTRES, - ), - ) - MAPLEDEAN_FAMILY_CENTRE_PLUS_WYCOMBE = ( - "mapledean-family-centre-plus-wycombe", - _CategoryTuple( - label="Mapledean Family Centre Plus, Wycombe", - collection=Collection.FAMILY_CENTRES, - ), - ) - MARLOW_FAMILY_CENTRE = "marlow-family-centre", _CategoryTuple( - label="Marlow Family Centre", - collection=Collection.FAMILY_CENTRES, - ) - RISBOROUGH_FAMILY_CENTRE = "risborough-family-centre", _CategoryTuple( - label="Risborough Family Centre", - collection=Collection.FAMILY_CENTRES, - ) - - def __new__(cls, *args, **kwds) -> "Category": - obj = object.__new__(cls) - obj._value_ = args[0] - return obj - - def __init__(self, value: str, category: _CategoryTuple) -> None: - if category.api_value is None: - self.api_value = value - else: - self.api_value = category.api_value - - if category.frontend_value is None: - self.frontend_value = value - else: - self.frontend_value = category.frontend_value - - self.label = category.label - self.collection = category.collection - - @classmethod - def get_choices(cls): - return [(directory.value, directory.label) for directory in cls] - - -@dataclasses_json.dataclass_json(undefined=dataclasses_json.Undefined.EXCLUDE) -@dataclasses.dataclass -class APIService: - description: str - id: int - name: str - url: str - free: Optional[bool] - local_offer: Optional[Dict[str, Any]] - updated_at: datetime.datetime = dataclasses.field( - metadata=dataclasses_json.config( - encoder=datetime.datetime.isoformat, - decoder=datetime.datetime.fromisoformat, - mm_field=mm_fields.DateTime(format="iso"), - ) - ) diff --git a/bc/service_directory/wagtail_hooks.py b/bc/service_directory/wagtail_hooks.py new file mode 100644 index 00000000..c6c0e896 --- /dev/null +++ b/bc/service_directory/wagtail_hooks.py @@ -0,0 +1,34 @@ +from django.contrib.auth.models import Permission +from django.contrib.contenttypes.models import ContentType + +import wagtail +from wagtail import hooks + +from . import admin_choosers, admin_views, models + + +@hooks.register("register_admin_viewset") +def register_service_directory_chooser_viewset(): + return admin_choosers.service_directory_chooser_viewset + + +@hooks.register("register_admin_viewset") +def register_taxonomy_chooser_viewset(): + return admin_choosers.taxonomy_chooser_viewset + + +@hooks.register("register_admin_viewset") +def register_service_directory_model_viewset_group(): + return admin_views.ServiceDirectoryModelViewSetGroup() + + +@hooks.register("register_permissions") +def register_service_directory_permissions(): + if wagtail.VERSION >= (6, 2): + raise Exception( + "Those permissions should be registered automatically on Wagtail 6.2" + ) + content_types = ContentType.objects.get_for_models( + [models.ServiceDirectory, models.Taxonomy] + ) + return Permission.objects.filter(content_type__in=content_types) diff --git a/bc/settings/base.py b/bc/settings/base.py index ef485ddd..497ad6a8 100644 --- a/bc/settings/base.py +++ b/bc/settings/base.py @@ -87,6 +87,7 @@ "bc.recruitment", "bc.recruitment_api", "bc.search.apps.SearchConfig", + "bc.service_directory", "bc.standardpages", "bc.step_by_step", "bc.users", From ebdd70af726e2fc4cd04da66b1b86230d34e57ce Mon Sep 17 00:00:00 2001 From: Tomasz Knapik Date: Thu, 25 Jul 2024 13:17:22 +0100 Subject: [PATCH 45/59] Remove redundant template code --- .../templates/patterns/pages/location/location_page.html | 2 -- .../templates/patterns/pages/location/location_page.yaml | 2 -- 2 files changed, 4 deletions(-) diff --git a/bc/project_styleguide/templates/patterns/pages/location/location_page.html b/bc/project_styleguide/templates/patterns/pages/location/location_page.html index 92214aa0..f37c2853 100644 --- a/bc/project_styleguide/templates/patterns/pages/location/location_page.html +++ b/bc/project_styleguide/templates/patterns/pages/location/location_page.html @@ -19,8 +19,6 @@

    {{ page.title }}

    {% include 'patterns/molecules/map/map.html' %} {% include_block page.body %} - - {% include_block page.activities_listing %}