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

Provide an equivalent hook to after_publish_page for publishing translations #837

Open
gasman opened this issue Nov 5, 2024 · 0 comments

Comments

@gasman
Copy link
Contributor

gasman commented Nov 5, 2024

A client has defined an after_publish_page hook in their project, to perform an action after a page is published. They would like this action to be triggered on publishing a translation too, but since wagtail-localize uses the before_edit_page hook to completely bypass the usual Wagtail edit view, the code path that calls the after_publish_page hook is not reached.

The page_published signal still works, but this doesn't provide access to the request/response cycle, e.g. to output a custom 'success' message or redirect the user elsewhere.

I propose that the publish action for translations should invoke either the after_publish_page hook, or a new after_publish_translation hook. I would lean slightly toward the latter, as hook functions receive the request object and existing projects might have logic that assumes certain properties of the request (such as POST parameters) that are valid for the regular view but not the translation form, and we don't want those to break suddenly when we start calling the hook from a new place. (Digging into things like POST parameters is undocumented behaviour though, so it probably would be fair game to break it.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant