https://github.com/rcmachado/django-pieguard
django-pieguard is a simple authorization class for tastypie that uses django-guardian to handle object permissions.
https://github.com/rcmachado/django-pieguard
Last synced: 3 months ago
JSON representation
django-pieguard is a simple authorization class for tastypie that uses django-guardian to handle object permissions.
- Host: GitHub
- URL: https://github.com/rcmachado/django-pieguard
- Owner: rcmachado
- License: mit
- Created: 2014-11-29T16:51:52.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-12-26T20:15:18.000Z (over 2 years ago)
- Last Synced: 2024-02-24T00:04:10.100Z (over 1 year ago)
- Language: Python
- Size: 15.6 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.rst
- Changelog: HISTORY.rst
- Contributing: CONTRIBUTING.rst
- License: LICENSE
Awesome Lists containing this project
README
===============
django-pieguard
===============django-pieguard is a simple authorization class for tastypie that uses
django-guardian to handle object permissions.This was inspired by gist https://gist.github.com/7wonders/6557760.
Requirements
------------* Python 2.7+
* Django_ 1.7
* django-guardian_ 1.2.4
* tastypie_ 0.12.1Not tested in other versions yet.
Quickstart
----------Install django-pieguard:
.. code-block:: shell
pip install django-pieguard
Then use it in a tastypie project:
.. code-block:: python
from pieguard.authorization import GuardianAuthorization
from tastypie.resources import Resource
from django.db import modelsclass MyModel(models.Model):
class Meta:
permissions = (
('view_mymodel', 'View my model'),
)class MyResource(ModelResource):
class Meta:
authorization = GuardianAuthorization
# ... your other optionsNotes on permissions
--------------------django-pieguard uses a special `view_modelname` permission to control if user
can view that resource or not. As Django only creates `add`, `change` and
`delete` permissions by default, you need to add the relevant permission on
your model Meta class.TODO
----* Tests
* Docs
* Python 3 official supportLicense
-------This work is licensed under MIT license.
.. _Django: http://www.djangoproject.com
.. _tastypie: https://github.com/toastdriven/django-tastypie
.. _django-guardian: https://github.com/lukaszb/django-guardian