Skip to content

Commit

Permalink
Merge pull request #2 from mozmeao/15291--hotfix--page-creation-blocked
Browse files Browse the repository at this point in the history
Hotfix: page creation was broken by addition to Action Menu 🤦
  • Loading branch information
stevejalim authored Oct 14, 2024
2 parents 6349819 + ad1be8f commit ae9034c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
[project]
name = "wagtaildraftsharing"
version = "0.0.4"
version = "0.1.1"
description = "Share wagtail drafts with private URLs."
readme = "README.md"
requires-python = ">=3.9"
license = {text = "CC0"}
authors = [
{name = "Shohan Dutta Roy", email = "[email protected]" }
]
maintainers = [
{name = "Steve Jalim", email = "[email protected]" }
]
dependencies = [
"wagtail>=5.1",
]
Expand Down
5 changes: 5 additions & 0 deletions wagtaildraftsharing/tests/test_wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,8 @@ def test_action_menu_hook__is_shown(self):

mock_page.has_unpublished_changes = True
self.assertTrue(menu_item.is_shown({"page": mock_page}))

def test_action_menu_hook__is_shown__no_page_in_context(self):
menu_item = wagtail_hooks.DraftsharingPageActionMenuItem()
self.assertFalse(menu_item.is_shown({}))
self.assertFalse(menu_item.is_shown({"something_that_is_not_a_page": "here"}))
3 changes: 2 additions & 1 deletion wagtaildraftsharing/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ class DraftsharingPageActionMenuItem(ActionMenuItem):

def get_context_data(self, parent_context):
context_data = super().get_context_data(parent_context)

context_data["revision"] = context_data["page"].latest_revision
return context_data

def is_shown(self, context):
return context["page"].has_unpublished_changes
return "page" in context and context["page"].has_unpublished_changes


@hooks.register("register_page_action_menu_item")
Expand Down

0 comments on commit ae9034c

Please sign in to comment.