Skip to content

Commit

Permalink
Ignore key errors when page isn't in context
Browse files Browse the repository at this point in the history
  • Loading branch information
wpears committed Oct 11, 2024
1 parent dd4e368 commit b3873ba
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions cfgov/v1/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,20 @@ def get_url(self, context):

@hooks.register("construct_page_action_menu")
def add_language_links(menu_items, request, context):
page = context["page"]
return menu_items.extend(
[
LanguageMenuItem(
f"Edit {languages[translation.language]} page",
f"/admin/pages/{translation.pk}/edit/",
)
for translation in page.get_translations()
if translation.language != page.language
]
)
try:
page = context["page"]
return menu_items.extend(
[
LanguageMenuItem(
f"Edit {languages[translation.language]} page",
f"/admin/pages/{translation.pk}/edit/",
)
for translation in page.get_translations()
if translation.language != page.language
]
)
except KeyError:
pass


@hooks.register("after_delete_page")
Expand Down

0 comments on commit b3873ba

Please sign in to comment.