Module collectives.models.user_group#

Handle dynamic user groups, for restricting or payment options

class collectives.models.user_group.GroupEventCondition(**kwargs)#

Relationship indicating that group members must participate (or lead) a given event.

clone() collectives.models.user_group.GroupEventCondition#
Returns

a deep copy of this object

event#

Event associated with this condition

Type

list(collectives.models.event.Event)

event_id#

ID of the activity to which the user role should relate to.

Type

int

get_condition()#
Returns

the SQLAlchemy expression corresponding to this condition

group_id#

ID of the group this condition applies to

Type

int

id#

Database primary key

Type

int

is_leader#

Whether group members should be leaders of the activity or normal users. If null, both are allowed.

Type

int

class collectives.models.user_group.GroupLicenseCondition(**kwargs)#

Relationship indicating that group members must have a certain license type

clone() collectives.models.user_group.GroupLicenseCondition#
Returns

a deep copy of this object

group_id#

ID of the group this condition applies to

Type

int

id#

Database primary key

Type

int

license_category#

User club license category.

Type

string (2 char)

class collectives.models.user_group.GroupRoleCondition(**kwargs)#

Relationship indicating that group members must have a certain role

activity#

Activity type associated with this condition

Type

list(collectives.models.activity_type.ActivityType)

activity_id#

ID of the activity to which the user role should relate to. If null, any activity is allowed

Type

int

clone() collectives.models.user_group.GroupRoleCondition#
Returns

a deep copy of this object

get_condition()#
Returns

the SQLAlchemy expression corresponding to this condition

group_id#

ID of the group this condition applies to

Type

int

id#

Database primary key

Type

int

role_id#

Id of the role that group members must have. If null, any role is allowed

Type

collectives.models.RoleId`

class collectives.models.user_group.UserGroup(**kwargs)#

Dynamically-defined set of users based on various conditions.

Currently three type of conditions are available:

  • Role: User must have a specific role, optionnaly for a given activity

  • Event: User must be registered or be a leader to a given event

  • Licence: Use must have a specific licence type

Those conditions are multiplicative, i.e. the user must satisfy all conditions (“and”). However, within each condition, allowed values are additive (“or”) All three types of conditions are also optional.

For instance, a user group may be defined as follow: Users which have ((the role President) or (the role Leader for activity “Ski”)) and ((lead event “Foo”) or (are registered to event “Bar”))

clone() collectives.models.user_group.UserGroup#
Returns

a deep copy of this object, cloning all conditions

contains(user: collectives.models.user.User) bool#
Returns

Whether a given user is a member of the group

event_conditions#

List of event conditions associated with this group

Type

list(collectives.models.user_group.GroupRoleCondition)

get_members() List[collectives.models.user.User]#
Returns

the list of group members

has_conditions() bool#
Returns

whether the group defines at least one condition

id#

Database primary key

Type

int

license_conditions#

List of license conditions associated with this group

Type

list(collectives.models.user_group.GroupRoleCondition)

role_conditions#

List of role conditions associated with this group

Type

list(collectives.models.user_group.GroupRoleCondition)