From c174de8724b5911667059ea520606de1b37c7793 Mon Sep 17 00:00:00 2001 From: Dan Braghis Date: Fri, 3 Apr 2015 13:36:32 +0100 Subject: [PATCH 1/5] Rename construct_wagtail_edit_bird hook --- docs/reference/hooks.rst | 6 +++--- wagtail/wagtailadmin/views/userbar.py | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/docs/reference/hooks.rst b/docs/reference/hooks.rst index 11515129c5..9c7a3f5f1f 100644 --- a/docs/reference/hooks.rst +++ b/docs/reference/hooks.rst @@ -46,9 +46,9 @@ The available hooks are: return HttpResponse("

bad googlebot no cookie

") -.. _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 '
  • Puppies!
  • ' - @hooks.register('construct_wagtail_edit_bird') + @hooks.register('construct_wagtail_userbar') def add_puppy_link_item(request, items): return items.append( UserbarPuppyLinkItem() ) diff --git a/wagtail/wagtailadmin/views/userbar.py b/wagtail/wagtailadmin/views/userbar.py index c41b5aed1d..d5689d2cad 100644 --- a/wagtail/wagtailadmin/views/userbar.py +++ b/wagtail/wagtailadmin/views/userbar.py @@ -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] From 63672e09765937c53b2cdde6b82404eb0d18785e Mon Sep 17 00:00:00 2001 From: Dan Braghis Date: Fri, 3 Apr 2015 13:39:46 +0100 Subject: [PATCH 2/5] Add CHANGELOG and release notes for edit_bird hook rename --- CHANGELOG.txt | 1 + docs/releases/1.0.rst | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index a4847f3d70..e243281a07 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -42,6 +42,7 @@ Changelog * Added hook `construct_homepage_summary_items` for customising the site summary panel on the admin homepage * No longer automatically tries to use Celery for sending notification emails * Added "Add child page" button to admin userbar (Eric Drechsel) + * Renamed the `construct_wagtail_edit_bird` hook to `construct_wagtail_edit_bird` 0.8.6 (10.03.2015) diff --git a/docs/releases/1.0.rst b/docs/releases/1.0.rst index f694a45c4d..bfdb0f33b6 100644 --- a/docs/releases/1.0.rst +++ b/docs/releases/1.0.rst @@ -87,6 +87,8 @@ Admin * Added cache-control headers to all admin views. This allows Varnish/Squid/CDN to run on vanilla settings in front of a Wagtail site * Date / time pickers now consistently use times without seconds, to prevent Javascript behaviour glitches when focusing / unfocusing fields * Added hook ``construct_homepage_summary_items`` for customising the site summary panel on the admin homepage + * Renamed the ``construct_wagtail_edit_bird`` hook to ``construct_wagtail_edit_bird`` + Project template @@ -197,7 +199,7 @@ Celery no longer automatically used for sending notification emails Previously, Wagtail would try to use Celery whenever the ``djcelery`` module was installed, even if Celery wasn't actually set up. This could cause a very hard -to track down problem where notification emails would not be sent so this +to track down problem where notification emails would not be sent so this functionality has now been removed. If you would like to keep using Celery for sending notification emails, have a From aa5fe7574b4d2bf3a38575e37a737c049367203e Mon Sep 17 00:00:00 2001 From: Dan Braghis Date: Fri, 3 Apr 2015 18:34:03 +0100 Subject: [PATCH 3/5] Tweak code and docs based on feedback --- CHANGELOG.txt | 2 +- docs/reference/hooks.rst | 6 ++++++ docs/releases/1.0.rst | 2 +- wagtail/wagtailadmin/views/userbar.py | 28 +++++++++++++-------------- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index e243281a07..23c6cb8d8f 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -42,7 +42,7 @@ Changelog * Added hook `construct_homepage_summary_items` for customising the site summary panel on the admin homepage * No longer automatically tries to use Celery for sending notification emails * Added "Add child page" button to admin userbar (Eric Drechsel) - * Renamed the `construct_wagtail_edit_bird` hook to `construct_wagtail_edit_bird` + * Renamed the `construct_wagtail_edit_bird` hook to `construct_wagtail_userbar` 0.8.6 (10.03.2015) diff --git a/docs/reference/hooks.rst b/docs/reference/hooks.rst index 9c7a3f5f1f..bc355896a0 100644 --- a/docs/reference/hooks.rst +++ b/docs/reference/hooks.rst @@ -48,6 +48,12 @@ The available hooks are: .. _construct_wagtail_userbar: +.. versionadded:: 0.3 + +.. versionchanged:: 1.0 + + The hook was renamed from ``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. diff --git a/docs/releases/1.0.rst b/docs/releases/1.0.rst index bfdb0f33b6..79fd9825f5 100644 --- a/docs/releases/1.0.rst +++ b/docs/releases/1.0.rst @@ -87,7 +87,7 @@ Admin * Added cache-control headers to all admin views. This allows Varnish/Squid/CDN to run on vanilla settings in front of a Wagtail site * Date / time pickers now consistently use times without seconds, to prevent Javascript behaviour glitches when focusing / unfocusing fields * Added hook ``construct_homepage_summary_items`` for customising the site summary panel on the admin homepage - * Renamed the ``construct_wagtail_edit_bird`` hook to ``construct_wagtail_edit_bird`` + * Renamed the ``construct_wagtail_edit_bird`` hook to ``construct_wagtail_userbar`` diff --git a/wagtail/wagtailadmin/views/userbar.py b/wagtail/wagtailadmin/views/userbar.py index d5689d2cad..8260a40aa4 100644 --- a/wagtail/wagtailadmin/views/userbar.py +++ b/wagtail/wagtailadmin/views/userbar.py @@ -17,13 +17,8 @@ def for_frontend(request, page_id): AddPageItem(Page.objects.get(id=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 - ) + # TODO: Remove in 1.1 release + run_deprecated_edit_bird_hook(request, items) for fn in hooks.get_hooks('construct_wagtail_userbar'): fn(request, items) @@ -49,13 +44,8 @@ def for_moderation(request, revision_id): RejectModerationEditPageItem(PageRevision.objects.get(id=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 - ) + # TODO: Remove in 1.1 release + run_deprecated_edit_bird_hook(request, items) for fn in hooks.get_hooks('construct_wagtail_userbar'): fn(request, items) @@ -70,3 +60,13 @@ def for_moderation(request, revision_id): return render(request, 'wagtailadmin/userbar/base.html', { 'items': rendered_items, }) + + +def run_deprecated_edit_bird_hook(request, items): + 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 + ) From 5c197593bc7b7fdee0e5fa072fd49f5be51973d3 Mon Sep 17 00:00:00 2001 From: Dan Braghis Date: Thu, 9 Apr 2015 14:09:30 +0100 Subject: [PATCH 4/5] Add upgrade considerations --- docs/releases/1.0.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/releases/1.0.rst b/docs/releases/1.0.rst index 79fd9825f5..4aad89539e 100644 --- a/docs/releases/1.0.rst +++ b/docs/releases/1.0.rst @@ -293,3 +293,11 @@ Wagtail organises panels into three tabs: 'Content', 'Promote' and 'Settings'. D ObjectList(BlogPage.promote_panels, heading='Promote'), ObjectList(BlogPage.settings_panels, heading='Settings', classname="settings"), ]) + +The ``construct_wagtail_edit_bird`` has changed +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Previously you could customize the Wagtail userbar using the ``construct_wagtail_edit_bird`` hook. +The hook has been renamed to ``construct_wagtail_userbar``. + +The old hook is now deprecated; all existing ``construct_wagtail_edit_bird`` declarations should be updated to the new hook. From bb7076f978fe35cf7348c9fc98e1f3fdc79d29f6 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Thu, 9 Apr 2015 14:13:11 +0100 Subject: [PATCH 5/5] better heading --- docs/releases/1.0.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/releases/1.0.rst b/docs/releases/1.0.rst index 2c792b8cc3..5cccae6f0a 100644 --- a/docs/releases/1.0.rst +++ b/docs/releases/1.0.rst @@ -295,8 +295,8 @@ Wagtail organises panels into three tabs: 'Content', 'Promote' and 'Settings'. D ObjectList(BlogPage.settings_panels, heading='Settings', classname="settings"), ]) -The ``construct_wagtail_edit_bird`` has changed -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +``construct_wagtail_edit_bird`` hook has been renamed +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Previously you could customize the Wagtail userbar using the ``construct_wagtail_edit_bird`` hook. The hook has been renamed to ``construct_wagtail_userbar``.