kopia lustrzana https://github.com/wagtail/wagtail
rodzic
30c398c91a
commit
68b2dc01c2
|
@ -23,6 +23,7 @@ Changelog
|
|||
* Remove sticky footer on small devices, so that content is not blocked and more easily editable (Saeed Tahmasebi)
|
||||
* Add ``alt`` property to ``ImageRenditionField`` api representation (Liam Mullens)
|
||||
* Add ``purge_revisions`` management command to purge old page revisions (Jacob Topp-Mugglestone, Tom Dyson)
|
||||
* Render the Wagtail User Bar on non ``Page`` views (Caitlin White, Coen van der Kamp)
|
||||
* Fix: Support IPv6 domain (Alex Gleason, Coen van der Kamp)
|
||||
* Fix: Ensure link to add a new user works when no users are visible in the users list (LB (Ben Johnston))
|
||||
* Fix: `AbstractEmailForm` saved submission fields are now aligned with the email content fields, `form.cleaned_data` will be used instead of `form.fields` (Haydn Greatnews)
|
||||
|
|
|
@ -459,6 +459,7 @@ Contributors
|
|||
* Luke Hardwick
|
||||
* Saeed Tahmasebi
|
||||
* Liam Mullens
|
||||
* Caitlin White
|
||||
|
||||
Translators
|
||||
===========
|
||||
|
|
|
@ -32,6 +32,7 @@ Other features
|
|||
* Add ability to replace the default Wagtail logo in the userbar, via ``branding_logo`` block (Meteor0id)
|
||||
* Add `alt` property to `ImageRenditionField` api representation (Liam Mullens)
|
||||
* Add `purge_revisions` management command to purge old page revisions (Jacob Topp-Mugglestone, Tom Dyson)
|
||||
* Render the Wagtail User Bar on non `Page` views (Caitlin White, Coen van der Kamp)
|
||||
|
||||
|
||||
Bug fixes
|
||||
|
|
|
@ -242,6 +242,8 @@ Wagtail User Bar
|
|||
|
||||
This tag provides a contextual flyout menu for logged-in users. The menu gives editors the ability to edit the current page or add a child page, besides the options to show the page in the Wagtail page explorer or jump to the Wagtail admin dashboard. Moderators are also given the ability to accept or reject a page being previewed as part of content moderation.
|
||||
|
||||
This tag may be used on regular Django views, without page object. The user bar will contain one item pointing to the admin.
|
||||
|
||||
.. code-block:: html+django
|
||||
|
||||
{% load wagtailuserbar %}
|
||||
|
|
|
@ -7,8 +7,6 @@ from wagtail.admin.userbar import (
|
|||
from wagtail.core import hooks
|
||||
from wagtail.core.models import PAGE_TEMPLATE_VAR, Page, PageRevision
|
||||
|
||||
# from django.contrib.auth.decorators import permission_required
|
||||
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
@ -49,36 +47,36 @@ def wagtailuserbar(context, position='bottom-right'):
|
|||
if getattr(request, 'is_preview', False):
|
||||
return ''
|
||||
|
||||
# Only render if the context contains a variable referencing a saved page
|
||||
page = get_page_instance(context)
|
||||
if page is None:
|
||||
return ''
|
||||
|
||||
# Dont render anything if the page has not been saved - i.e. a preview
|
||||
if page.pk is None:
|
||||
return ''
|
||||
|
||||
try:
|
||||
revision_id = request.revision_id
|
||||
except AttributeError:
|
||||
revision_id = None
|
||||
|
||||
if revision_id is None:
|
||||
items = [
|
||||
AdminItem(),
|
||||
ExplorePageItem(Page.objects.get(id=page.id)),
|
||||
EditPageItem(Page.objects.get(id=page.id)),
|
||||
AddPageItem(Page.objects.get(id=page.id)),
|
||||
]
|
||||
if page and page.id:
|
||||
# Saved page.
|
||||
if revision_id is None:
|
||||
items = [
|
||||
AdminItem(),
|
||||
ExplorePageItem(Page.objects.get(id=page.id)),
|
||||
EditPageItem(Page.objects.get(id=page.id)),
|
||||
AddPageItem(Page.objects.get(id=page.id)),
|
||||
]
|
||||
else:
|
||||
items = [
|
||||
AdminItem(),
|
||||
ExplorePageItem(PageRevision.objects.get(id=revision_id).page),
|
||||
EditPageItem(PageRevision.objects.get(id=revision_id).page),
|
||||
AddPageItem(PageRevision.objects.get(id=revision_id).page),
|
||||
ApproveModerationEditPageItem(PageRevision.objects.get(id=revision_id)),
|
||||
RejectModerationEditPageItem(PageRevision.objects.get(id=revision_id)),
|
||||
]
|
||||
elif page:
|
||||
# A page without an id is a preview.
|
||||
return ""
|
||||
else:
|
||||
items = [
|
||||
AdminItem(),
|
||||
ExplorePageItem(PageRevision.objects.get(id=revision_id).page),
|
||||
EditPageItem(PageRevision.objects.get(id=revision_id).page),
|
||||
AddPageItem(PageRevision.objects.get(id=revision_id).page),
|
||||
ApproveModerationEditPageItem(PageRevision.objects.get(id=revision_id)),
|
||||
RejectModerationEditPageItem(PageRevision.objects.get(id=revision_id)),
|
||||
]
|
||||
# Not a page.
|
||||
items = [AdminItem()]
|
||||
|
||||
for fn in hooks.get_hooks('construct_wagtail_userbar'):
|
||||
fn(request, items)
|
||||
|
|
|
@ -62,6 +62,14 @@ class TestUserbarTag(TestCase):
|
|||
# Make sure nothing was rendered
|
||||
self.assertEqual(content, '')
|
||||
|
||||
def test_userbar_tag_no_page(self):
|
||||
template = Template("{% load wagtailuserbar %}{% wagtailuserbar %}")
|
||||
content = template.render(Context({
|
||||
'request': self.dummy_request(self.user),
|
||||
}))
|
||||
|
||||
self.assertIn("<!-- Wagtail user bar embed code -->", content)
|
||||
|
||||
|
||||
class TestUserbarFrontend(TestCase, WagtailTestUtils):
|
||||
def setUp(self):
|
||||
|
|
Ładowanie…
Reference in New Issue