Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding description to grant and revoke permission docs #29

Merged
merged 1 commit into from
Oct 28, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions docs/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ Shortcuts
.. function:: get_user_role(user)

.. code-block:: python

from rolepermissions.shortcuts import get_user_role

role = get_user_role(user)

.. function:: available_perm_status(user)
Returns a dictionary containg all permissions available to the role of the specified user.
Permissions are the keys of the dictionary, and values are ``True`` or ``False`` indicating if the

Returns a dictionary containg all permissions available to the role of the specified user.
Permissions are the keys of the dictionary, and values are ``True`` or ``False`` indicating if the
permission is granted or not.

.. code-block:: python

from rolepermissions.shortcuts import available_perm_status

permissions = available_perm_status(user)
Expand All @@ -30,24 +30,29 @@ permission is granted or not.

.. function:: grant_permission(user, permission_name)

Grants a permission to a user. Will not grant a permission that is not listed in the role
``available_permissions``.

.. code-block:: python

from rolepermissions.shortcuts import grant_permission

grant_permission(user, 'create_medical_record')

.. function:: revoke_permission(user, permission_name)

Revokes a permission.

.. code-block:: python

from rolepermissions.shortcuts import revoke_permission

revoke_permission(user, 'create_medical_record')

.. function:: retrieve_role(role_name)

.. code-block:: python

from rolepermissions.shortcuts import retrieve_role
from my_project.roles import Doctor

Expand All @@ -62,7 +67,7 @@ The following functions will always return ``True`` for users with supper_user s

.. function:: has_role(user, roles)

Receives a user and a role and returns ``True`` if user has the specified role. Roles can be passed as
Receives a user and a role and returns ``True`` if user has the specified role. Roles can be passed as
object, camel cased string representation or inside a list.

.. code-block:: python
Expand Down