mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-29 17:36:49 +01:00
Rename construct_wagtail_edit_bird hook
This commit is contained in:
parent
3fcf04f8a3
commit
c174de8724
@ -46,9 +46,9 @@ The available hooks are:
|
||||
return HttpResponse("<h1>bad googlebot no cookie</h1>")
|
||||
|
||||
|
||||
.. _construct_wagtail_edit_bird:
|
||||
.. _construct_wagtail_userbar:
|
||||
|
||||
``construct_wagtail_edit_bird``
|
||||
``construct_wagtail_userbar``
|
||||
Add or remove items from the wagtail userbar. Add, edit, and moderation tools are provided by default. The callable passed into the hook must take the ``request`` object and a list of menu objects, ``items``. The menu item objects must have a ``render`` method which can take a ``request`` object and return the HTML string representing the menu item. See the userbar templates and menu item classes for more information.
|
||||
|
||||
.. code-block:: python
|
||||
@ -60,7 +60,7 @@ The available hooks are:
|
||||
return '<li><a href="http://cuteoverload.com/tag/puppehs/" ' \
|
||||
+ 'target="_parent" class="action icon icon-wagtail">Puppies!</a></li>'
|
||||
|
||||
@hooks.register('construct_wagtail_edit_bird')
|
||||
@hooks.register('construct_wagtail_userbar')
|
||||
def add_puppy_link_item(request, items):
|
||||
return items.append( UserbarPuppyLinkItem() )
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
import warnings
|
||||
|
||||
from django.shortcuts import render
|
||||
from django.contrib.auth.decorators import permission_required
|
||||
|
||||
@ -5,6 +7,8 @@ from wagtail.wagtailadmin.userbar import EditPageItem, AddPageItem, ApproveModer
|
||||
from wagtail.wagtailcore import hooks
|
||||
from wagtail.wagtailcore.models import Page, PageRevision
|
||||
|
||||
from wagtail.utils.deprecation import RemovedInWagtail11Warning
|
||||
|
||||
|
||||
@permission_required('wagtailadmin.access_admin', raise_exception=True)
|
||||
def for_frontend(request, page_id):
|
||||
@ -16,6 +20,14 @@ def for_frontend(request, page_id):
|
||||
for fn in hooks.get_hooks('construct_wagtail_edit_bird'):
|
||||
fn(request, items)
|
||||
|
||||
warnings.warn(
|
||||
"The 'construct_wagtail_edit_bird' hook has been renamed to 'construct_wagtail_userbar'."
|
||||
"Please update function '%s' in '%s'." % (fn.__name__, fn.__module__), RemovedInWagtail11Warning
|
||||
)
|
||||
|
||||
for fn in hooks.get_hooks('construct_wagtail_userbar'):
|
||||
fn(request, items)
|
||||
|
||||
# Render the items
|
||||
rendered_items = [item.render(request) for item in items]
|
||||
|
||||
@ -40,6 +52,14 @@ def for_moderation(request, revision_id):
|
||||
for fn in hooks.get_hooks('construct_wagtail_edit_bird'):
|
||||
fn(request, items)
|
||||
|
||||
warnings.warn(
|
||||
"The 'construct_wagtail_edit_bird' hook has been renamed to 'construct_wagtail_userbar'."
|
||||
"Please update function '%s' in '%s'." % (fn.__name__, fn.__module__), RemovedInWagtail11Warning
|
||||
)
|
||||
|
||||
for fn in hooks.get_hooks('construct_wagtail_userbar'):
|
||||
fn(request, items)
|
||||
|
||||
# Render the items
|
||||
rendered_items = [item.render(request) for item in items]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user