Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix: page creation was broken by addition to Action Menu 🤦 #2

Merged
merged 2 commits into from
Oct 14, 2024
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
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