A bit of intermediate refactoring to make it clearer what the next step is doing...
is_saving is true in the code paths where the form is valid and unlocked, so rename this condition to is_valid. cancel_workflow is the one action that is allowed while is_valid is false, so split that into identical "cancel workflow while valid" and "cancel workflow while invalid" cases. This way, all code paths are cleanly partitioned into is_valid and (not is_valid) branches, which we can reorganise in the next step.
D200: One-line docstring should fit on one line with quotes
D202: No blank lines allowed after function docstring
D204: 1 blank line required after docstring
D205: 1 blank line required between summary line and description
D209: Multi-line docstring closing quotes should be on a separate line
No occurances of any of these exist in Wagtail at the moment
- Add anyascii to replace unidecode
- Update wagtail.core.utils.string_to_ascii to use anyascii.
- Anyascii has a similar but not exactly the same encoding - see updates to tests.
Refs https://github.com/wagtail/wagtail/issues/3311
Fixes #6288
Many of the oembed endpoints currently listed with an http:// URL now redirect to https://. Changing these to https:// saves a redundant redirect and avoids failures where the http URL has been blocked (see #6288). Also simplified the patterns for matching http or https - the group in `http(?:s)?` is redundant and should just be `https?`.
There's currently a number of places where we test hooks by registering
hook functions from test methods. These are never cleaned up so that
hook remains registered in future tests. This can cause issues with
tests not working consistently when you run a subset of the tests.
This adds a `register_temporarily` function to the hooks module. This
function can be used either as a decorator or a context manager. It'll
always remove the hook after the decorated function or with block exits,
even if it exits through an exception.