Module collectives.models.user_group
Module collectives.models.user_group
#
Handle dynamic user groups, for restricting or payment options
- class collectives.models.user_group.GroupBadgeCondition(**kwargs)#
Relationship indicating that group members must have a certain badge
- activity#
Activity type associated with this condition
- activity_id#
ID of the activity to which the user role should relate to. If null, any activity is allowed
- Type
int
- badge_id#
Id of the role that group members must have. If null, any role is allowed
- Type
collectives.models.RoleId`
- clone() collectives.models.user_group.GroupBadgeCondition #
- Returns
a deep copy of this object
- get_condition(time: datetime.datetime)#
- 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
- invert#
Whether this condition should be inverted, i.e. whether the user should not match the condition to be part of the group
- Type
bool
- class collectives.models.user_group.GroupConditionBase#
Base class with common fields for all group conditions.
- group_id = Column(None, Integer(), ForeignKey('user_groups.id'), table=None, nullable=False)#
ID of the group this condition applies to
- Type
int
- id = Column(None, Integer(), table=None, primary_key=True, nullable=False)#
Database primary key
- Type
int
- invert = Column(None, Boolean(), table=None, nullable=False, default=ScalarElementColumnDefault(False))#
Whether this condition should be inverted, i.e. whether the user should not match the condition to be part of the group
- Type
bool
- 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
- 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
- invert#
Whether this condition should be inverted, i.e. whether the user should not match the condition to be part of the group
- Type
bool
- 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
- invert#
Whether this condition should be inverted, i.e. whether the user should not match the condition to be part of the group
- Type
bool
- 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
- 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
- invert#
Whether this condition should be inverted, i.e. whether the user should not match the condition to be part of the group
- Type
bool
- 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”))
- badge_conditions#
List of badge conditions associated with this group
- clone() collectives.models.user_group.UserGroup #
- Returns
a deep copy of this object, cloning all conditions
- contains(user: collectives.models.user.User, time: datetime.datetime) bool #
Checks if a given user is a member of the group at a specific time. The time is used to check for badge expiry.
- Returns
Whether a given user is a member of the group
- event_conditions#
List of event conditions associated with this group
- get_members(time: Optional[datetime.datetime] = None) 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
- property negative_badge_conditions: List[collectives.models.user_group.GroupBadgeCondition]#
- Returns
the list of negative badge conditions
- property negative_event_conditions: List[collectives.models.user_group.GroupEventCondition]#
- Returns
the list of negative event conditions
- property negative_license_conditions: List[collectives.models.user_group.GroupLicenseCondition]#
- Returns
the list of negative license conditions
- property negative_role_conditions: List[collectives.models.user_group.GroupRoleCondition]#
- Returns
the list of negative role conditions
- property positive_badge_conditions: List[collectives.models.user_group.GroupBadgeCondition]#
- Returns
the list of positive badge conditions
- property positive_event_conditions: List[collectives.models.user_group.GroupEventCondition]#
- Returns
the list of positive event conditions
- property positive_license_conditions: List[collectives.models.user_group.GroupLicenseCondition]#
- Returns
the list of positive license conditions
- property positive_role_conditions: List[collectives.models.user_group.GroupRoleCondition]#
- Returns
the list of positive role conditions
- role_conditions#
List of role conditions associated with this group