Skip to content

Commit

Permalink
Merge abb68a5 into f4c8448
Browse files Browse the repository at this point in the history
  • Loading branch information
czpython committed Sep 7, 2016
2 parents f4c8448 + abb68a5 commit 83555a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
15 changes: 5 additions & 10 deletions docs/how_to/extending_page_title.rst
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,16 @@ Complete toolbar API

The example above uses the :ref:`simplified_extension_toolbar`.

.. _complete_toolbar_api:

If you need complete control over the layout of your extension toolbar items you can still use the
low-level API to edit the toolbar according to your needs::

from cms.api import get_page_draft
from cms.toolbar_pool import toolbar_pool
from cms.toolbar_base import CMSToolbar
from cms.utils import get_cms_setting
from cms.utils.permissions import has_page_change_permission
from cms.utils.page_permissions import user_can_change_page
from django.core.urlresolvers import reverse, NoReverseMatch
from django.utils.translation import ugettext_lazy as _
from .models import IconExtension
Expand All @@ -291,14 +293,7 @@ low-level API to edit the toolbar according to your needs::
# Nothing to do
return

# check global permissions if CMS_PERMISSION is active
if get_cms_setting('PERMISSION'):
has_global_current_page_change_permission = has_page_change_permission(self.request)
else:
has_global_current_page_change_permission = False
# check if user has page edit permission
can_change = self.request.current_page and self.request.current_page.has_change_permission(self.request)
if has_global_current_page_change_permission or can_change:
if user_can_change_page(user=self.request.user, page=self.page):
try:
icon_extension = IconExtension.objects.get(extended_object_id=self.page.id)
except IconExtension.DoesNotExist:
Expand Down Expand Up @@ -344,4 +339,4 @@ which provides the following API:
(or `None` if not exists) and the admin urls for each title of the current page;

* :meth:`cms.toolbar.toolbar.CMSToolbar.get_or_create_menu`
* :meth:`cms.extensions.toolbar.ExtensionToolbar._setup_extension_toolbar`
* :meth:`cms.extensions.toolbar.ExtensionToolbar._setup_extension_toolbar`
7 changes: 7 additions & 0 deletions docs/upgrade/3.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Functions removed:
* ``load_view_restrictions``
* ``get_any_page_view_permissions``


The following methods were changed to require a user parameter instead of a request:

* ``Page.has_view_permission``
Expand All @@ -99,6 +100,12 @@ The following methods were changed to require a user parameter instead of a requ

These are also deprecated in favor of their counterparts in ``cms.utils.page_permissions``.

.. warning::

If you have a custom ``Page`` extension with a configured toolbar,
please see the updated :ref:`example <complete_toolbar_api>`.
It uses the new the new permission internals.


Manual plugin rendering
=======================
Expand Down

0 comments on commit 83555a5

Please sign in to comment.