Skip to content

Commit

Permalink
Merge branch 'feature/category-page-featured-images' into 'release'
Browse files Browse the repository at this point in the history
Add option to display images for first three pages in category page

See merge request buckinghamshire-council/bc!737
  • Loading branch information
KIRA009 committed Aug 20, 2024
2 parents 1923b1f + df0417c commit ae96916
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- EHCCo widget: Update widget heading text
- EHCCo widget: Make emails clickable by converting them to links
- EHCCo widget: Change fallback text from TBC to awaiting allocation
- Add option to display images for first three pages in category page

## 78.2 (2024-08-14)

Expand Down
3 changes: 3 additions & 0 deletions bc/family_information/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ def get_context(self, value, parent_context=None):

# Get the page's class.
context["page_class"] = parent_context["page"]._meta.object_name
context["display_featured_images"] = getattr(
parent_context["page"], "display_featured_images", False
)

# Check if the block is preceded by a heading.
blocks_under_headings = parent_context.get("blocks_under_headings", [])
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 4.2.14 on 2024-08-13 08:09

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
(
"family_information",
"0016_directory_search_block__add_bucks_online_directory_option",
),
]

operations = [
migrations.AddField(
model_name="categorypage",
name="display_featured_images",
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name="categorytypeonepage",
name="display_featured_images",
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name="categorytypetwopage",
name="display_featured_images",
field=models.BooleanField(default=False),
),
]
7 changes: 7 additions & 0 deletions bc/family_information/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ class BaseCategoryPage(FISBannerFields, BasePage):
default="What do you want to do?", max_length=255
)

display_featured_images = models.BooleanField(default=False)

# Content
body = StreamField(
[
Expand Down Expand Up @@ -262,6 +264,7 @@ class BaseCategoryPage(FISBannerFields, BasePage):
content_panels = (
BasePage.content_panels
+ [
FieldPanel("display_featured_images"),
MultiFieldPanel(
[
FieldPanel("top_tasks_heading", heading="Heading"),
Expand Down Expand Up @@ -301,6 +304,10 @@ def allowed_subpage_models(cls):
resolve_model_string("standardpages.IndexPage")
]

@cached_property
def has_featured_pages(self):
return any(row.block_type == "cards" for row in self.body)

@cached_property
def other_child_pages(self):
"""Get child pages for the current category page, excluding children that are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
data-height-equalizer
>
{% for card in value %}
{% include "patterns/molecules/page-card/page-card.html" with classes="card--fis-index" has_heading=has_heading page=card.value.specific %}
{% if display_featured_images and forloop.counter <= 3 %}
{% include "patterns/molecules/page-card/page-card.html" with classes="card--fis-index" has_heading=has_heading page=card.value.specific show_image=True %}
{% else %}
{% include "patterns/molecules/page-card/page-card.html" with classes="card--fis-index" has_heading=has_heading page=card.value.specific show_image=False %}
{% endif %}
{% endfor %}
</section>
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ <h2 class="heading heading--l" id="{{ page.other_pages_heading|slugify }}">{{ pa
data-height-equalizer
>
{% for subpage in page.other_child_pages %}
{% include "patterns/molecules/page-card/page-card.html" with classes="card--fis-index" has_heading=show_other_pages_heading page=subpage %}
{% if not page.has_featured_pages and page.display_featured_images and forloop.counter <= 3 %}
{% include "patterns/molecules/page-card/page-card.html" with show_image=True classes="card--fis-index" has_heading=show_other_pages_heading page=subpage %}
{% else %}
{% include "patterns/molecules/page-card/page-card.html" with show_image=False classes="card--fis-index" has_heading=show_other_pages_heading page=subpage %}
{% endif %}
{% endfor %}
</section>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ <h2 class="heading heading--l" id="{{ page.other_pages_heading|slugify }}">{{ pa
data-height-equalizer
>
{% for subpage in page.other_child_pages %}
{% include "patterns/molecules/page-card/page-card.html" with classes="card--fis-index" has_heading=show_other_pages_heading page=subpage %}
{% if not page.has_featured_pages and page.display_featured_images and forloop.counter <= 3 %}
{% include "patterns/molecules/page-card/page-card.html" with show_image=True classes="card--fis-index" has_heading=show_other_pages_heading page=subpage %}
{% else %}
{% include "patterns/molecules/page-card/page-card.html" with show_image=False classes="card--fis-index" has_heading=show_other_pages_heading page=subpage %}
{% endif %}
{% endfor %}
</div>
</section>
Expand Down

0 comments on commit ae96916

Please sign in to comment.