If the developer had overridden MESSAGE_TAGS in their site, Wagtail
messages used these classes in the admin. This caused the messages to
lose their styles.
Wagtail now ignores the MESSAGE_TAGS setting, using the default classes
defined in `django.contrib.messages.constants.LEVEL_TAGS`.
Fixes#2551
Conflicts:
wagtail/tests/testapp/urls.py
wagtail/wagtailadmin/templatetags/wagtailadmin_tags.py
Instead of using `User.objects.create_user`, `User.objects.create` was
used, which does not correctly set the password. The user was then not
logged in, as they had an incorrect password. This error was not caught
by the log in method, or the following tests, as the behaviour for a
user with incorrect permissions was the same as for anonymous users.
The code now uses the correct method, and the tests now assert that the
user is actually logged in.
Two new assertions have been added: `assertAllowedSubpageTypes` and
`assertAllowedParentPageTypes`. They both take a Page class, and a set
of Page classes, and compares the allowed subpage / parent page models
for the Page class to the set passed in.
`wagtail.tests.utils.WagtailPageTests` is a new `TestCase` subclass that
helps developers write tests for their Wagtail sites. It currently
includes three assert methods:
`assertCanCreateAt(parent_model, child_model)`, which asserts that a
child page of a certain type could be created underneath a parent page.
This is useful for making assertions around the business rules of your
site.
`assertCanNotCreateAt(parent_model, child_model)` is the inverse of the
above.
`assertCanCreate(parent, child_model, data)` asserts that a child page
can be added underneath the given parent page, by POSTing `data` at the
correct page in the Wagtail admin. This checks that the developer has
correctly configured their `content_panels` and related options.
These methods are just a start, and could be expanded further. More
methods could be added, asserting that Snippets can be created, for
example. The current methods could be extended further, to validate more
about the Wagtail admin page editor.
Previously, if a developer wanted to use a custom Manager on their Page
subclass, some fairly hacky hacks were required. Now, the `objects`
attribute is only overridden if it is a plain `Manager`. If it is
anything else, it is left alone. A system check has been added to ensure
that all `Page` managers inherit from `PageManager`
These two tests are used when checking if a new page type can be created
under a page instance, or if an existing page type can move under a page
instance.
This was required when Page was absent from PAGE_MODEL_CLASSES (due to
it being 'abstract' / non-creatable) and thus never appeared in a
parent_page_types list. Now it appears in PAGE_MODEL_CLASSES, and is
a valid parent page type for page types that do not specify
parent_page_types (or explicitly include Page in the list).