0
I Use This!
Activity Not Available

Project Summary

Django Granular Permissions allow you to setup per-row permissions.

ver 0.2 adds NewForms-Admin support.

This project is injecting new methods into Django's auth.User and auth.Group in a non-invasive way (doesn't require modifying Django's code).

Simple permission checks within views and templates with templatetags.

You just simply have to install django-granular-permissions somewhere on your PYTHONPATH and add 'django_granular_permissions' to your installed apps and invoke

python manage.py syncdbNote: superusers will always have True returned on has_row_perm(), also not active users will always get False

Example:

# adding permission 'edit' to a user 'Bart' on an instance of a MyObject from myapp.models
>>> from django.contrib.auth.models import User, Group
>>> from myapp.models import MyObject
>>> user = User.objects.get(username='Bart')
>>> obj = MyObject()
>>> obj.save()
>>> user.add_row_perm(obj, 'edit')
>>> user.has_row_perm(obj, 'edit')
True
>>> user.has_row_perm(obj, 'delete')
False

# similar for groups
>>> group = Group.objects.get(pk=1) # get first group in the db
>>> group.add_row_perm(obj, 'read')

# now we'll add the user to the group and he will inherit the 'read' permission
>>> user.groups.add(group)
>>> user.has_row_perm(obj, 'read')
True

# now to remove permission
>>> user.del_row_perm(obj, 'edit')
>>> user.has_row_perm(obj, 'edit')
False

# note that when you try to remove a permission from a user that is granted to him through group nothing changes
>>> user.del_row_perm(obj, 'read')
>>> user.has_row_perm(obj, 'read')
True

# get all rows for a MyObject table that given user has 'read' permission
>>> user.get_rows_with_permission(MyObject(), 'read')
# same method exists for groups

Tags

crud django granular permissions python

In a Nutshell, django-granular-permissions...

 No code available to analyze

Open Hub computes statistics on FOSS projects by examining source code and commit history in source code management systems. This project has no code locations, and so Open Hub cannot perform this analysis

Is this project's source code hosted in a publicly available repository? Do you know the URL? If you do, click the button below and tell us so that Open Hub can generate statistics! It's fast and easy - try it and see!

Add a code location

Apache License 2.0
Permitted

Place Warranty

Sub-License

Private Use

Use Patent Claims

Commercial Use

Modify

Distribute

Forbidden

Hold Liable

Use Trademarks

Required

Include Copyright

State Changes

Include License

Include Notice

These details are provided for information only. No information here is legal advice and should not be used as such.

All Licenses

This Project has No vulnerabilities Reported Against it

Did You Know...

  • ...
    Black Duck offers a free trial so you can discover if there are open source vulnerabilities in your code
  • ...
    compare projects before you chose one to use
  • ...
    55% of companies leverage OSS for production infrastructure
  • ...
    you can subscribe to e-mail newsletters to receive update from the Open Hub blog

 No code available to analyze

Open Hub computes statistics on FOSS projects by examining source code and commit history in source code management systems. This project has no code locations, and so Open Hub cannot perform this analysis

Is this project's source code hosted in a publicly available repository? Do you know the URL? If you do, click the button below and tell us so that Open Hub can generate statistics! It's fast and easy - try it and see!

Add a code location

Community Rating

Be the first to rate this project
Click to add your rating
   Spinner
Review this Project!
Sample ohloh analysis