permission.logics package
Submodules
permission.logics.base module
- class permission.logics.base.PermissionLogic[source]
Bases:
object
Abstract permission logic class
- has_perm(user_obj, perm, obj=None)[source]
Check if user have permission (of object)
- Parameters
user_obj (django user model instance) – A django user model instance which be checked
perm (string) – app_label.codename formatted permission string
obj (None or django model instance) – None or django model instance for object permission
- Returns
boolean – Whether the specified user have specified permission (of specified object).
.. note:: – Sub class must override this method.
permission.logics.collaborators module
Permission logic module for collaborators based permission system
- class permission.logics.collaborators.CollaboratorsPermissionLogic(field_name=None, any_permission=None, change_permission=None, delete_permission=None)[source]
Bases:
PermissionLogic
Permission logic class for collaborators based permission system
- has_perm(user_obj, perm, obj=None)[source]
Check if user have permission (of object)
If the user_obj is not authenticated, it return
False
.If no object is specified, it return
True
when the corresponding permission was specified toTrue
(changed from v0.7.0). This behavior is based on the django system. https://code.djangoproject.com/wiki/RowLevelPermissionsIf an object is specified, it will return
True
if the user is found infield_name
of the object (e.g.obj.collaborators
). So once the object store the user as a collaborator infield_name
attribute (default:collaborators
), the collaborator can change or delete the object (you can change this behavior to setany_permission
,change_permission
ordelete_permission
attributes of this instance).- Parameters
user_obj (django user model instance) – A django user model instance which be checked
perm (string) – app_label.codename formatted permission string
obj (None or django model instance) – None or django model instance for object permission
- Returns
Whether the specified user have specified permission (of specified object).
- Return type
boolean
permission.logics.groupin module
Permission logic module for group based permission system
- class permission.logics.groupin.GroupInPermissionLogic(group_names, any_permission=None, add_permission=None, change_permission=None, delete_permission=None)[source]
Bases:
PermissionLogic
Permission logic class for group based permission system
- has_perm(user_obj, perm, obj=None)[source]
Check if user have permission (of object)
If the user_obj is not authenticated, it return
False
.If no object is specified, it return
True
when the corresponding permission was specified toTrue
(changed from v0.7.0). This behavior is based on the django system. https://code.djangoproject.com/wiki/RowLevelPermissionsIf an object is specified, it will return
True
if the user is in group specified ingroup_names
of this instance. This permission logic is used mainly for group based role permission system. You can change this behavior to setany_permission
,add_permission
,change_permission
, ordelete_permission
attributes of this instance.- Parameters
user_obj (django user model instance) – A django user model instance which be checked
perm (string) – app_label.codename formatted permission string
obj (None or django model instance) – None or django model instance for object permission
- Returns
Whether the specified user have specified permission (of specified object).
- Return type
boolean
permission.logics.oneself module
Permission logic module to manage users’ self-modifications
- class permission.logics.oneself.OneselfPermissionLogic(any_permission=None, change_permission=None, delete_permission=None)[source]
Bases:
PermissionLogic
Permission logic class to manage users’ self-modifications
Written by quasiyoke. https://github.com/lambdalisue/django-permission/pull/27
- has_perm(user_obj, perm, obj=None)[source]
Check if user have permission of himself
If the user_obj is not authenticated, it return
False
.If no object is specified, it return
True
when the corresponding permission was specified toTrue
(changed from v0.7.0). This behavior is based on the django system. https://code.djangoproject.com/wiki/RowLevelPermissionsIf an object is specified, it will return
True
if the object is the user. So users can change or delete themselves (you can change this behavior to setany_permission
,change_permissino
ordelete_permission
attributes of this instance).- Parameters
user_obj (django user model instance) – A django user model instance which be checked
perm (string) – app_label.codename formatted permission string
obj (None or django model instance) – None or django model instance for object permission
- Returns
Whether the specified user have specified permission (of specified object).
- Return type
boolean
permission.logics.staff module
Permission logic module for author based permission system
- class permission.logics.staff.StaffPermissionLogic(any_permission=None, add_permission=None, change_permission=None, delete_permission=None)[source]
Bases:
PermissionLogic
Permission logic class for is_staff authority based permission system
- has_perm(user_obj, perm, obj=None)[source]
Check if user have permission (of object)
If the user_obj is not authenticated, it return
False
.If no object is specified, it return
True
when the corresponding permission was specified toTrue
(changed from v0.7.0). This behavior is based on the django system. https://code.djangoproject.com/wiki/RowLevelPermissionsIf an object is specified, it will return
True
if the user is staff. The staff can add, change or delete the object (you can change this behavior to setany_permission
,add_permission
,change_permission
, ordelete_permission
attributes of this instance).- Parameters
user_obj (django user model instance) – A django user model instance which be checked
perm (string) – app_label.codename formatted permission string
obj (None or django model instance) – None or django model instance for object permission
- Returns
Weather the specified user have specified permission (of specified object).
- Return type
boolean
Module contents
Permission logic module