Skip to content

Commit

Permalink
changed the naming to disable/enable_roles_acquisition
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTango committed May 11, 2017
1 parent 2e193c1 commit a1f7326
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions docs/content.rst
Expand Up @@ -462,44 +462,44 @@ These arguments can be saved to your transition using custom workflow variables
.. invisible-code-block: python
.. _content_disable_acquire_local_roles_example:
.. _content_disable_roles_acquisition_example:

Disable local roles acquisition
===============================

To disable the acquisition of local roles for an object, use the :meth:`api.content.disable_acquire_local_roles` method.
To disable the acquisition of local roles for an object, use the :meth:`api.content.disable_roles_acquisition` method.

.. code-block:: python
from plone import api
portal = api.portal.get()
api.content.disable_acquire_local_roles(obj=portal['about'])
api.content.disable_roles_acquisition(obj=portal['about'])
.. invisible-code-block: python
ac_flag = getattr(portal['about'], '__ac_local_roles_block__', None)
self.assertTrue(ac_flag)
.. _content_enable_acquire_local_roles_example:
.. _content_enable_roles_acquisition_example:

Enable local roles acquisition
==============================

To enable the acquisition of local roles for an object, use the :meth:`api.content.enable_acquire_local_roles` method.
To enable the acquisition of local roles for an object, use the :meth:`api.content.enable_roles_acquisition` method.

.. code-block:: python
from plone import api
portal = api.portal.get()
api.content.enable_acquire_local_roles(obj=portal['about'])
api.content.enable_roles_acquisition(obj=portal['about'])
.. invisible-code-block: python
# As __ac_local_roles_block__ is None by default, we have to set it,
# before we can test the enabling method.
portal['about'].__ac_local_roles_block__ = 1
api.content.enable_acquire_local_roles(obj=portal['about'])
api.content.enable_roles_acquisition(obj=portal['about'])
ac_flag = getattr(portal['about'], '__ac_local_roles_block__', None)
self.assertFalse(ac_flag)
Expand Down
8 changes: 4 additions & 4 deletions src/plone/api/content.py
Expand Up @@ -486,26 +486,26 @@ def transition(obj=None, transition=None, to_state=None, **kwargs):


@required_parameters('obj')
def disable_acquire_local_roles(obj=None):
def disable_roles_acquisition(obj=None):
"""Disable acquisition of local roles on given obj.
Set __ac_local_roles_block__ = 1 on obj.
:param obj: [required] Context object to block the acquisition on.
:type obj: Content object
:Example: :ref:`content_disable_acquire_local_roles_example`
:Example: :ref:`content_disable_roles_acquisition_example`
"""
plone_utils = portal.get_tool('plone_utils')
plone_utils.acquireLocalRoles(obj, status=0)


@required_parameters('obj')
def enable_acquire_local_roles(obj=None):
def enable_roles_acquisition(obj=None):
"""Enable acquisition of local roles on given obj.
Set __ac_local_roles_block__ = 0 on obj.
:param obj: [required] Context object to enable the acquisition on.
:type obj: Content object
:Example: :ref:`content_enable_acquire_local_roles_example`
:Example: :ref:`content_enable_roles_acquisition_example`
"""
plone_utils = portal.get_tool('plone_utils')
plone_utils.acquireLocalRoles(obj, status=1)
Expand Down
12 changes: 6 additions & 6 deletions src/plone/api/tests/test_content.py
Expand Up @@ -934,31 +934,31 @@ def test_transition(self):
'internally_published',
)

def test_diable_acquire_local_roles(self):
def test_diable_roles_acquisition(self):
""" Test disabling local roles acquisition.
"""
# This should fail because an content item is mandatory
from plone.api.exc import MissingParameterError
with self.assertRaises(MissingParameterError):
api.content.disable_acquire_local_roles()
api.content.disable_roles_acquisition()

api.content.disable_acquire_local_roles(obj=self.blog)
api.content.disable_roles_acquisition(obj=self.blog)
blog_ac_flag = getattr(self.blog, '__ac_local_roles_block__', None)
self.assertTrue(blog_ac_flag)

def test_enable_acquire_local_roles(self):
def test_enable_roles_acquisition(self):
""" Test enabling local roles acquisition.
"""
# This should fail because an content item is mandatory
from plone.api.exc import MissingParameterError
with self.assertRaises(MissingParameterError):
api.content.enable_acquire_local_roles()
api.content.enable_roles_acquisition()

# As __ac_local_roles_block__ is None by default, we have to set it,
# before we can test the enabling method.
self.blog.__ac_local_roles_block__ = 1

api.content.enable_acquire_local_roles(obj=self.blog)
api.content.enable_roles_acquisition(obj=self.blog)
blog_ac_flag = getattr(self.blog, '__ac_local_roles_block__', None)
self.assertFalse(blog_ac_flag)

Expand Down

0 comments on commit a1f7326

Please sign in to comment.