skip-django-fperms-iscore


Nameskip-django-fperms-iscore JSON
Version 0.3.0 PyPI version JSON
download
home_pagehttps://github.com/skip-pay/django-fperms-iscore
SummaryPerms for iscore library
upload_time2024-04-19 10:48:09
maintainerNone
docs_urlNone
authorPetr Olah
requires_pythonNone
licenseMIT
keywords django-fperms-iscore
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            =============================
django-fperms-iscore
=============================

.. image:: https://badge.fury.io/py/django-fperms-iscore.svg
    :target: https://badge.fury.io/py/django-fperms-iscore

.. image:: https://travis-ci.org/Formulka/django-fperms-iscore.svg?branch=master
    :target: https://travis-ci.org/druids/django-fperms-iscore

.. image:: https://codecov.io/gh/Formulka/django-fperms-iscore/branch/master/graph/badge.svg
    :target: https://codecov.io/gh/druids/django-fperms-iscore

Perms for iscore library

Documentation
-------------

The full documentation is at https://django-perms-iscore.readthedocs.io.


Quickstart
----------

Install django-fperms-iscore::

    pip install skip-django-fperms-iscore

Add it to your `INSTALLED_APPS`:

.. code-block:: python

    INSTALLED_APPS = (
        ...
        'fperms_iscore.apps.FPermsConfig',
        ...
    )


It includes all the basic permissions from http://github.com/formulka/django-fperms and adds a new type:

- **core**: for iscore specific resources

Usage
-----

A superuser has for all intents and purposes permission to do everything. For regular users you can assign permissions directly or via a user group.

**Creating a new permission**:

You can create a new permission directly via its model or via a specially formated string:

.. code-block:: python

    from fperms_iscore import enums
    from fperms_iscore.models import IsCorePerm

    IsCorePerm.objects.create(
        type=enums.PERM_TYPE_CORE,
        codename='create',
        core='issue_tracker.IssueIsCore',
    )
    IsCorePerm.objects.create_from_str('core.issue_tracker.IssueIsCore.create')

**Assigning a permission**:

You can assign existing permission via the custom ``perms`` manager available for both User (including custom ones) and Group models. You can add single permission or multiple both directly via its instance or using the formated string:

.. code-block:: python

    from django.auth.models import User, Group

    from fperms_iscore.models import IsCorePerm

    perm = IsCorePerm.objects.create_from_str('core.issue_tracker.IssueIsCore.create')

    user = User.objects.get(pk=1)
    user.perms.add_perm(perm)

    group = Group.objects.get(pk=1)
    group.perms.add_perm('core.issue_tracker.IssueIsCore.create')

By default if said permission does not exist, it will raise an exception. You can override this behavior by setting ``PERM_AUTO_CREATE`` variable in your project settings to ``True``, assigning a permission will then create it as well if it does not exist.

**Retrieving permission instance**:

You can get a permission instance directly from the model or via the string representation.

.. code-block:: python

    perm = IsCorePerm.objects.get(
        type=enums.PERM_TYPE_CORE,
        codename='create',
        core='issue_tracker.IssueIsCore',
    )
    perm = IsCorePerm.objects.get_from_str('core.issue_tracker.IssueIsCore.create')

**Checking permission**:

You can check whether the user or group has a required permission via ``has_perm`` method of the ``perms`` manager again using both the permission instance or the string representation.

.. code-block:: python

    ...
    perm = IsCorePerm.objects.create(
        type=enums.PERM_TYPE_CORE,
        codename='create',
        core='issue_tracker.IssueIsCore',
    )

    assert user.perms.has_perm(perm)
    assert user.perms.has_perm('core.issue_tracker.IssueIsCore.create')

New perm type
-------------------

**core**

- permission for iscore specific resources
- type is defined as ``fperms_iscore.enums.PERM_TYPE_CORE``
- codename is usually one of the CRUD operations (create, read, update, delete)
- it requires ``type``, ``codename`` and ``core`` fields
- string representation is ``'core.<app_label>.<core_name>.<codename>'``

.. code-block:: python

    ...
    # equivalent results:
    IsCorePerm.objects.create(
        type=enums.PERM_TYPE_CORE,
        codename='create',
        core='issue_tracker.IssueIsCore',
    )
    IsCorePerm.objects.create_from_str('core.issue_tracker.IssueIsCore.create')

Running Tests
-------------

Does the code actually work?

::

    source <YOURVIRTUALENV>/bin/activate
    (myenv) $ pip install tox
    (myenv) $ tox


Running Tests
-------------

Does the code actually work?

::

    source <YOURVIRTUALENV>/bin/activate
    (myenv) $ pip install tox
    (myenv) $ tox

Credits
-------

Tools used in rendering this package:

*  Cookiecutter_
*  `cookiecutter-djangopackage`_

.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage




History
-------

0.2.16 (2020-11-03)
+++++++++++++++++++

* Better cache for user permissions

0.2.15 (2020-10-24)
+++++++++++++++++++

* New django-fperms library and related changes

0.2.14 (2020-10-22)
+++++++++++++++++++

* Better verbose name of default permission
* Improved sync_permissions command, unchanged permissions are not printed as updated


0.1.0 (2018-03-13)
++++++++++++++++++

* First release on PyPI.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/skip-pay/django-fperms-iscore",
    "name": "skip-django-fperms-iscore",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "django-fperms-iscore",
    "author": "Petr Olah",
    "author_email": "djangoguru@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d2/b4/527d518d9073ffd67274d111341c0d5ce5efeb4109fe4b0429fec2da4406/skip_django_fperms_iscore-0.3.0.tar.gz",
    "platform": null,
    "description": "=============================\ndjango-fperms-iscore\n=============================\n\n.. image:: https://badge.fury.io/py/django-fperms-iscore.svg\n    :target: https://badge.fury.io/py/django-fperms-iscore\n\n.. image:: https://travis-ci.org/Formulka/django-fperms-iscore.svg?branch=master\n    :target: https://travis-ci.org/druids/django-fperms-iscore\n\n.. image:: https://codecov.io/gh/Formulka/django-fperms-iscore/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/druids/django-fperms-iscore\n\nPerms for iscore library\n\nDocumentation\n-------------\n\nThe full documentation is at https://django-perms-iscore.readthedocs.io.\n\n\nQuickstart\n----------\n\nInstall django-fperms-iscore::\n\n    pip install skip-django-fperms-iscore\n\nAdd it to your `INSTALLED_APPS`:\n\n.. code-block:: python\n\n    INSTALLED_APPS = (\n        ...\n        'fperms_iscore.apps.FPermsConfig',\n        ...\n    )\n\n\nIt includes all the basic permissions from http://github.com/formulka/django-fperms and adds a new type:\n\n- **core**: for iscore specific resources\n\nUsage\n-----\n\nA superuser has for all intents and purposes permission to do everything. For regular users you can assign permissions directly or via a user group.\n\n**Creating a new permission**:\n\nYou can create a new permission directly via its model or via a specially formated string:\n\n.. code-block:: python\n\n    from fperms_iscore import enums\n    from fperms_iscore.models import IsCorePerm\n\n    IsCorePerm.objects.create(\n        type=enums.PERM_TYPE_CORE,\n        codename='create',\n        core='issue_tracker.IssueIsCore',\n    )\n    IsCorePerm.objects.create_from_str('core.issue_tracker.IssueIsCore.create')\n\n**Assigning a permission**:\n\nYou can assign existing permission via the custom ``perms`` manager available for both User (including custom ones) and Group models. You can add single permission or multiple both directly via its instance or using the formated string:\n\n.. code-block:: python\n\n    from django.auth.models import User, Group\n\n    from fperms_iscore.models import IsCorePerm\n\n    perm = IsCorePerm.objects.create_from_str('core.issue_tracker.IssueIsCore.create')\n\n    user = User.objects.get(pk=1)\n    user.perms.add_perm(perm)\n\n    group = Group.objects.get(pk=1)\n    group.perms.add_perm('core.issue_tracker.IssueIsCore.create')\n\nBy default if said permission does not exist, it will raise an exception. You can override this behavior by setting ``PERM_AUTO_CREATE`` variable in your project settings to ``True``, assigning a permission will then create it as well if it does not exist.\n\n**Retrieving permission instance**:\n\nYou can get a permission instance directly from the model or via the string representation.\n\n.. code-block:: python\n\n    perm = IsCorePerm.objects.get(\n        type=enums.PERM_TYPE_CORE,\n        codename='create',\n        core='issue_tracker.IssueIsCore',\n    )\n    perm = IsCorePerm.objects.get_from_str('core.issue_tracker.IssueIsCore.create')\n\n**Checking permission**:\n\nYou can check whether the user or group has a required permission via ``has_perm`` method of the ``perms`` manager again using both the permission instance or the string representation.\n\n.. code-block:: python\n\n    ...\n    perm = IsCorePerm.objects.create(\n        type=enums.PERM_TYPE_CORE,\n        codename='create',\n        core='issue_tracker.IssueIsCore',\n    )\n\n    assert user.perms.has_perm(perm)\n    assert user.perms.has_perm('core.issue_tracker.IssueIsCore.create')\n\nNew perm type\n-------------------\n\n**core**\n\n- permission for iscore specific resources\n- type is defined as ``fperms_iscore.enums.PERM_TYPE_CORE``\n- codename is usually one of the CRUD operations (create, read, update, delete)\n- it requires ``type``, ``codename`` and ``core`` fields\n- string representation is ``'core.<app_label>.<core_name>.<codename>'``\n\n.. code-block:: python\n\n    ...\n    # equivalent results:\n    IsCorePerm.objects.create(\n        type=enums.PERM_TYPE_CORE,\n        codename='create',\n        core='issue_tracker.IssueIsCore',\n    )\n    IsCorePerm.objects.create_from_str('core.issue_tracker.IssueIsCore.create')\n\nRunning Tests\n-------------\n\nDoes the code actually work?\n\n::\n\n    source <YOURVIRTUALENV>/bin/activate\n    (myenv) $ pip install tox\n    (myenv) $ tox\n\n\nRunning Tests\n-------------\n\nDoes the code actually work?\n\n::\n\n    source <YOURVIRTUALENV>/bin/activate\n    (myenv) $ pip install tox\n    (myenv) $ tox\n\nCredits\n-------\n\nTools used in rendering this package:\n\n*  Cookiecutter_\n*  `cookiecutter-djangopackage`_\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage\n\n\n\n\nHistory\n-------\n\n0.2.16 (2020-11-03)\n+++++++++++++++++++\n\n* Better cache for user permissions\n\n0.2.15 (2020-10-24)\n+++++++++++++++++++\n\n* New django-fperms library and related changes\n\n0.2.14 (2020-10-22)\n+++++++++++++++++++\n\n* Better verbose name of default permission\n* Improved sync_permissions command, unchanged permissions are not printed as updated\n\n\n0.1.0 (2018-03-13)\n++++++++++++++++++\n\n* First release on PyPI.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Perms for iscore library",
    "version": "0.3.0",
    "project_urls": {
        "Download": "https://github.com/skip-pay/django-fperms-iscore/archive/0.3.0.tar.gz",
        "Homepage": "https://github.com/skip-pay/django-fperms-iscore"
    },
    "split_keywords": [
        "django-fperms-iscore"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "86571b7ea43fe71951f652e6806010ef5ecdd4d5f3cd11ee2f672391afcfbb97",
                "md5": "8f5498750c0a2fe387352bb5fa528bb0",
                "sha256": "2ee17f903289488e429b08c5f828c22fcda9c47a86590185f18758971b840ea2"
            },
            "downloads": -1,
            "filename": "skip_django_fperms_iscore-0.3.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8f5498750c0a2fe387352bb5fa528bb0",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 12144,
            "upload_time": "2024-04-19T10:48:08",
            "upload_time_iso_8601": "2024-04-19T10:48:08.128155Z",
            "url": "https://files.pythonhosted.org/packages/86/57/1b7ea43fe71951f652e6806010ef5ecdd4d5f3cd11ee2f672391afcfbb97/skip_django_fperms_iscore-0.3.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d2b4527d518d9073ffd67274d111341c0d5ce5efeb4109fe4b0429fec2da4406",
                "md5": "16ef4ed6b57458d59ec7928aaca82303",
                "sha256": "c9ef42405f0f44e79e7d9cb94097c84b41ab8edab09b457b915ac9e3f07a934e"
            },
            "downloads": -1,
            "filename": "skip_django_fperms_iscore-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "16ef4ed6b57458d59ec7928aaca82303",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 12946,
            "upload_time": "2024-04-19T10:48:09",
            "upload_time_iso_8601": "2024-04-19T10:48:09.716598Z",
            "url": "https://files.pythonhosted.org/packages/d2/b4/527d518d9073ffd67274d111341c0d5ce5efeb4109fe4b0429fec2da4406/skip_django_fperms_iscore-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-19 10:48:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "skip-pay",
    "github_project": "django-fperms-iscore",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "skip-django-fperms-iscore"
}
        
Elapsed time: 0.45962s