<commit_before>=====
Usage
=====

.. warning::

    django-permissions is in alpha state. Please consider the API as supposed 
    to be changed until it reaches beta state.

Create a new permission
-----------------------

.. code-block:: python

    from permissions.utils import register_permission
    permission = register_permission("View", "view")

Create a new group
------------------

.. code-block:: python

    from permissions.utils import register_group
    brights = register_group("Brights")
    
This will create a default Django group.

Create a FlatPage
-----------------

.. code-block:: python

    from django.contrib.flatpages.models import FlatPage
    content = FlatPage.objects.create(title="Example", url="example")

Grant permission
----------------

.. code-block:: python

    from permission.utils import grant_permission
    grant_permission("view", brights, content)

Now all users which are member of the group "Brights" have the permission to
view object "content". You can also grant permission to single users.

Check permission
----------------

.. code-block:: python

    from permission.utils import has_permission
    result = has_permission("view", request.user, content)

    if result == False:
        print "Alert!"

This will check whether the current user has the permission "View" for the 
FlatPage "content".<commit_msg>Updated docs<commit_after>=====
Usage
=====

.. warning::

    django-permissions is in alpha state. Please consider the API as supposed 
    to be changed until it reaches beta state.

Create a new permission
-----------------------

.. code-block:: python

    from permissions.utils import register_permission
    permission = register_permission("View", "view")

Create a new group
------------------

.. code-block:: python

    from permissions.utils import register_group
    brights = register_group("Brights")
    
This will create a default Django group.

Create a content object
-----------------------

.. code-block:: python

    from django.contrib.flatpages.models import FlatPage
    content = FlatPage.objects.create(title="Example", url="example")

Grant permission
----------------

.. code-block:: python

    from permission.utils import grant_permission
    grant_permission("view", brights, content)

Now all users which are member of the group "Brights" have the permission to
view object "content". 

.. note::

    You can also grant permission to single users.

Check permission
----------------

.. code-block:: python

    from permission.utils import has_permission
    result = has_permission("view", request.user, content)

    if result == False:
        print "Alert!"

This will check whether the current user has the permission "View" for the 
FlatPage "content".
{'fraction_non_alphanumeric': 0.1472924187725632, 'fraction_numerical': 0.0, 'mean_word_length': 2.734501347708895, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5850070', 'n_tokens_mistral': 709, 'n_tokens_neox': 672, 'n_words': 270}