Skip to main content

django-fperms-iscore

https://badge.fury.io/py/django-fperms-iscore.svg https://travis-ci.org/Formulka/django-fperms-iscore.svg?branch=master https://codecov.io/gh/Formulka/django-fperms-iscore/branch/master/graph/badge.svg

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:

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:

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:

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.

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.

...
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>'

...
# 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:

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.

Metadata

Release files for skip-django-fperms-iscore 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for skip-django-fperms-iscore 0.5.0
File Size Uploaded Provenance Actions
skip_django_fperms_iscore-0.5.0.tar.gz 13.9 kB Without provenance Details for skip_django_fperms_iscore-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for skip-django-fperms-iscore 0.5.0
File Interpreter ABI Platform Actions
skip_django_fperms_iscore-0.5.0-py2.py3-none-any.whl Python 3, Python 2 none any Details for skip_django_fperms_iscore-0.5.0-py2.py3-none-any.whl

Total release size: 27.1 kB

Release files / skip_django_fperms_iscore-0.5.0.tar.gz

Download URL skip_django_fperms_iscore-0.5.0.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8221ec9feaf64be60476fc1c82e914810d4122a9f60ae3dacf6dd8dff12f510d
BLAKE2b-256 checksum
How to use checksums
d67d4542966982f1ce5878e241abddbd19f679ad2ebcd563bd8bb1e2c262b443
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / skip_django_fperms_iscore-0.5.0-py2.py3-none-any.whl

Download URL skip_django_fperms_iscore-0.5.0-py2.py3-none-any.whl
Size 13.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
a750d35f86189f886a18d3ec1ae90eecf1bbddaf69c409916d0ce9480eb2615d
BLAKE2b-256 checksum
How to use checksums
d083fc13c8e8e9ed629311b11079ad747f793708240525f044954001a8b1f47c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for skip-django-fperms-iscore 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page