Models

Main models

class groups_manager.models.Group(*args, **kwargs)[source]

This model represents the group. Each group could have a parent group (via the parent attribute).

Parameters:
  • name: (required)
  • codename: NON unique codename; if not set, it’s autogenerated by slugifying the label (lower case)
  • description: text field
  • comment: text field
  • full_name: auto generated full name starting from tree root
  • properties: jsonfield properties
  • group_members: m2m to Member, through GroupMember model (related name: groups)
  • group_type: foreign key to GroupType (related name: groups)
  • group_entities: m2m to GroupEntity (related name: groups)
  • django_group: django auth related group
  • django_auth_sync: synchronize or not the group (if setting DJANGO_AUTH_SYNC is True) (default: True)
  • level: django-mptt level attribute (default: True)

Note

If you want to add a custom manager for a sublcass of Group, use django-mppt mptt.models.TreeManager.

add_member(member, roles=[])[source]

Add a member to the group.

Parameters:
  • member: member (required)
  • roles: list of roles. Each role could be a role id, a role label or codename, a role instance (optional, default: [])
assign_object(obj, **kwargs)[source]

Assign an object to the group.

Parameters:
  • obj: the object to assign (required)
Kwargs:
  • custom_permissions: a full or partial redefinition of PERMISSIONS setting.

Note

This method needs django-guardian.

Todo

Create a method that allows to assign_objects directly to group.

entities[source]

Return group entities.

get_entities(subgroups=False)[source]

Return group entities.

Parameters:
  • subgroups: return also descendants entities (default: False)
get_members(subgroups=False)[source]

Return group members.

Parameters:
  • subgroups: return also descendants members (default: False)
members[source]

Return group members.

users[source]

Return group django users.

class groups_manager.models.Member(*args, **kwargs)[source]

Member represents a person that can be related to one or more groups.

Parameters:
  • first_name: member’s first name (required)
  • last_name: member’s last name (required)
  • username: member’s username, used as base for django auth’s integration
  • email: member’s email
  • django_user: django auth related User (related name: groups_manager_member)
  • django_auth_sync: synchronize or not the member (if setting DJANGO_AUTH_SYNC is True) (default: True)
assign_object(group, obj, **kwargs)[source]

Assign an object to the member honours the group relation.

Parameters:
  • group: the member group (required)
  • obj: the object to assign (required)
Kwargs:
  • custom_permissions: a full or partial redefinition of PERMISSIONS setting.

Note

This method needs django-guardian.

has_perm(perm, obj=None)[source]

Bind of django user’s has_perm method (use it as a shortcut).

has_perms(perm_list, obj=None)[source]

Bind of django user’s has_perms method (use it as a shortcut).

Group Models

class groups_manager.models.GroupType(*args, **kwargs)[source]

This model represents the kind of the group. One group could have only one type. This objects could describe the group’s nature (i.e. Organization, Division, ecc).

Parameters:
  • label: (required)
  • codename: unique codename; if not set, it’s autogenerated by slugifying the label (lower case)
class groups_manager.models.GroupEntity(*args, **kwargs)[source]

This model represents the entities of a group. One group could have more than one entity. This objects could describe the group’s properties (i.e. Administrators, Users, ecc).

Parameters:
  • label: (required)
  • codename: unique codename; if not set, it’s autogenerated by slugifying the label (lower case)

Relation Management

class groups_manager.models.GroupMember(*args, **kwargs)[source]

This model represents the intermediate model of the relation between a Member and a Group. This middleware can have one or more GroupMemberRole associated. A member could be in a group only once (group - member pair is unique).

Parameters:
  • group: Group (required)
  • member: Member (required)
  • roles: m2m to GroupMemberRole
assign_object(obj, **kwargs)[source]

Assign an object to the member.

Parameters:
  • obj: the object to assign (required)
Kwargs:
  • custom_permissions: a full or partial redefinition of PERMISSIONS setting.

Note

This method needs django-guardian.

class groups_manager.models.GroupMemberRole(*args, **kwargs)[source]

This model represents the role of a user in a relation with a group (i.e. Administrator, User, ecc).

Parameters:
  • label: (required)
  • codename: unique codename; if not set, it’s autogenerated by slugifying the label (lower case)