Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions rca/home/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
def related_news_events_formatter(
page, long_description=False, editorial_meta_label=""
):
if not page:
return {}

# Organsises data into a digestable format for the template.
editorial_meta = editorial_meta_label
PAGE_META_MAPPING = {
Expand Down Expand Up @@ -55,6 +58,9 @@ def partnerships_slides_formatter(slides):
}
)
elif slide.block_type == "page":
if not slide.value:
continue

page_type = None
page_type_mapping = {
"GuidePage": "GUIDE",
Expand Down
11 changes: 10 additions & 1 deletion rca/landingpages/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ def get_page_list(self):
}
item["related_items"].append(page)
if page_block.block_type == "page":
if not page_block.value:
continue
item["related_items"].append(page_block.value.specific)
items.append(item)
return items
Expand All @@ -461,6 +463,9 @@ def _format_slideshow_pages(self, slideshow_pages):
# The template is formatted to work with blocks, so we need to match the
# data structure to now work with pages chooser values
for slide in slideshow_pages.all():
if not slide.page:
continue

page = slide.page.specific
if not page.live:
continue
Expand Down Expand Up @@ -836,7 +841,11 @@ def featured_events(self):

def get_stories(self):
pages = self.related_editorial_story_pages.all().select_related("page")
return [editorial_teaser_formatter(page.page.specific) for page in pages]
return [
editorial_teaser_formatter(page.page.specific)
for page in pages
if page.page
]

@property
def news_view_all(self):
Expand Down
6 changes: 6 additions & 0 deletions rca/utils/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def related_list_block_slideshow(slides):
}
)
elif block.block_type == "page":
if not block.value:
continue

page = block.value.specific
page_type = page_type_mapping.get(page.__class__.__name__, None)
summary = (
Expand Down Expand Up @@ -71,6 +74,9 @@ def format_page_teasers(obj):
}
)
elif block.block_type == "page":
if not block.value:
continue

page = block.value.specific
summary = (
page.introduction
Expand Down