logics Package

logics Package

Permission logic module

author Module

Permission logic module for author based permission system

class permission.logics.author.AuthorPermissionLogic(field_name=None, any_permission=None, change_permission=None, delete_permission=None)[source]

Bases: permission.logics.base.PermissionLogic

Permission logic class for author based permission system

Methods

has_perm(user_obj, perm, obj=None)[source]

Check if user have permission (of object)

If no object is specified, it always return False so you need to add add permission to users in normal way.

If an object is specified, it will return True if the user is specified in field_name of the object (e.g. obj.author). So once user create an object and the object store who is the author in field_name attribute (default: author), the author can change or delete the object (you can change this behavior to set any_permission, change_permissino or delete_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:

boolean :

Wheter the specified user have specified permission (of specified object).

base Module

class permission.logics.base.PermissionLogic[source]

Bases: object

Abstract permission logic class

Methods

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 :

Wheter the specified user have specified permission (of specified object).

.. note:: :

Sub class must override this method.

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: permission.logics.base.PermissionLogic

Permission logic class for collaborators based permission system

Methods

has_perm(user_obj, perm, obj=None)[source]

Check if user have permission (of object)

If no object is specified, it always return False so you need to add add permission to users in normal way.

If an object is specified, it will return True if the user is found in field_name of the object (e.g. obj.collaborators). So once the object store the user as a collaborator in field_name attribute (default: collaborators), the collaborator can change or delete the object (you can change this behavior to set any_permission, change_permission or delete_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:

boolean :

Wheter the specified user have specified permission (of specified object).