Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/luzfcb/django-permissionsx
PermissionsX - Authorization for Django
https://github.com/luzfcb/django-permissionsx
Last synced: 25 days ago
JSON representation
PermissionsX - Authorization for Django
- Host: GitHub
- URL: https://github.com/luzfcb/django-permissionsx
- Owner: luzfcb
- License: other
- Created: 2014-01-28T19:13:33.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-01-27T22:18:23.000Z (almost 11 years ago)
- Last Synced: 2024-04-16T02:29:19.397Z (7 months ago)
- Language: Python
- Homepage:
- Size: 198 KB
- Stars: 0
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/thinkingpotato/django-permissionsx.png?branch=master)](https://travis-ci.org/thinkingpotato/django-permissionsx)
[![Coverage Status](https://coveralls.io/repos/thinkingpotato/django-permissionsx/badge.png)](https://coveralls.io/r/thinkingpotato/django-permissionsx)
[![PyPi version](https://pypip.in/v/django-permissionsx/badge.png)](https://crate.io/packages/django-permissionsx/)
[![PyPi downloads](https://pypip.in/d/django-permissionsx/badge.png)](https://crate.io/packages/django-permissionsx/)# django-permissionsx
* [Documentation](http://django-permissionsx.readthedocs.org/)
* [Changelog](http://django-permissionsx.readthedocs.org/en/latest/changelog.html)
* [Python package](http://pypi.python.org/pypi/django-permissionsx/)
* [Example project](http://github.com/thinkingpotato/django-permissionsx-example)## Quick Start
### 1. Install *django-permissionsx* package:
pip install django-permissionsx
### 2. Define permissions in a module of your choice:
from permissionsx.models import P
from permissionsx.models import Permissionsclass ManagerPermissions(Permissions):
permissions = P(user__is_staff=True) & P(user__get_profile__is_manager=True)
### 3. Add permissions to your views, e.g.:
from permissionsx.contrib.django.views import PermissionsListView
from example.profiles.permissions import ManagerPermissions
class AuthenticatedListView(PermissionsListView):
queryset = Item.objects.all()
permissions = Permissions(
P(user__is_authenticated=True)
)class ManagerListView(PermissionsListView):
queryset = Item.objects.all()
permissions = ManagerPermissions()### 4. Don't forget to add *permissionsx* to your *INSTALLED_APPS*:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.staticfiles',
[...]
'permissionsx',### 5. Apply permissions in templates if you need:
{% load permissionsx_tags %}
{% permissions 'example.profiles.permissions.ManagerPermissions' as user_is_manager %}
{% if user_is_manager %}
Publish article
{% endif %}
### 6. That's all!
User will be redirected to *LOGIN_URL* by default, if:
* not logged in and tries to access *AuthenticatedListView*;
* not a staff member, *request.user.profile.is_manager* is set to *False* and tries to access *ManagerListView*;
* *Publish article* option will be displayed only if user meets *ManagerPermissions* conditions.