mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
Docs for new hooks
This commit is contained in:
parent
0b9bb1d9ad
commit
8b9b2ced36
@ -278,12 +278,12 @@ Hooks for customising the editing interface for pages and snippets.
|
||||
Add additional CSS files or snippets to all admin pages.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
||||
from django.utils.html import format_html
|
||||
from django.contrib.staticfiles.templatetags.staticfiles import static
|
||||
|
||||
|
||||
from wagtail.wagtailcore import hooks
|
||||
|
||||
|
||||
@hooks.register('insert_global_admin_css')
|
||||
def global_admin_css():
|
||||
return format_html('<link rel="stylesheet" href="{}">', static('my/wagtail/theme.css'))
|
||||
@ -364,6 +364,34 @@ Hooks for customising the way users are directed through the process of creating
|
||||
return HttpResponse("Congrats on making content!", content_type="text/plain")
|
||||
|
||||
|
||||
.. _before_create_page:
|
||||
|
||||
``before_create_page``
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Called at the beginning of the "create page" view passing in the request, the parent page and page model class.
|
||||
|
||||
The function does not have to return anything, but if an object with a ``status_code`` property is returned, Wagtail will use it as a response object and skip the rest of the view.
|
||||
|
||||
Unlike, ``after_create_page``, this is run both for both ``GET`` and ``POST`` requests.
|
||||
|
||||
This can be used to completely override the editor on a per-view basis:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from django.http import HttpResponse
|
||||
|
||||
from wagtail.wagtailcore import hooks
|
||||
|
||||
from .models import AwesomePage
|
||||
from .admin_views import edit_awesome_page
|
||||
|
||||
@hooks.register('before_create_page')
|
||||
def before_create_page(request, parent_page, page_class):
|
||||
# Use a custom create view for the AwesomePage model
|
||||
if page_class == AwesomePage:
|
||||
return create_awesome_page(request, parent_page)
|
||||
|
||||
.. _after_delete_page:
|
||||
|
||||
``after_delete_page``
|
||||
@ -372,6 +400,16 @@ Hooks for customising the way users are directed through the process of creating
|
||||
Do something after a ``Page`` object is deleted. Uses the same behavior as ``after_create_page``.
|
||||
|
||||
|
||||
.. _before_delete_page:
|
||||
|
||||
``before_delete_page``
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Called at the beginning of the "delete page" view passing in the request and the page object.
|
||||
|
||||
Uses the same behavior as ``before_create_page``.
|
||||
|
||||
|
||||
.. _after_edit_page:
|
||||
|
||||
``after_edit_page``
|
||||
@ -380,6 +418,16 @@ Hooks for customising the way users are directed through the process of creating
|
||||
Do something with a ``Page`` object after it has been updated. Uses the same behavior as ``after_create_page``.
|
||||
|
||||
|
||||
.. _before_edit_page:
|
||||
|
||||
``before_edit_page``
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Called at the beginning of the "edit page" view passing in the request and the page object.
|
||||
|
||||
Uses the same behavior as ``before_create_page``.
|
||||
|
||||
|
||||
.. _construct_wagtail_userbar:
|
||||
|
||||
``construct_wagtail_userbar``
|
||||
|
Loading…
Reference in New Issue
Block a user