API Reference¶
REST endpoints¶
Full endpoint documentation: Smart Groups on ReDoc ⧉
| Method | Path | Description |
|---|---|---|
GET |
/smart-groups/ |
List all smart groups |
GET |
/smart-groups/<smart_group_id> |
Get a single smart group |
GET |
/smart-groups/<smart_group_id>/members |
Get current members |
GET |
/smart-groups/<smart_group_id>/members/<date> |
Get members on a specific date (past: from DB history, future: computed from definition) |
Code reference¶
apps.eu_tools.alan_home.models.smart_group.SmartGroup ¶
Bases: BaseAlanGroup
can_be_used_as_smart_roster
class-attribute
instance-attribute
¶
can_be_used_as_smart_roster = mapped_column(
Boolean,
default=True,
server_default=true(),
nullable=False,
)
external_users
class-attribute
instance-attribute
¶
external_users = relationship(
"ExternalUser",
secondary="smart_group_membership",
primaryjoin="and_(SmartGroup.id == SmartGroupMembership.smart_group_id, SmartGroupMembership.is_active)",
secondaryjoin="SmartGroupMembership.external_user_id == ExternalUser.id",
back_populates="smart_groups",
uselist=True,
)
github_parent_group_id
class-attribute
instance-attribute
¶
members
class-attribute
instance-attribute
¶
members = relationship(
"Alaner",
secondary="smart_group_membership",
primaryjoin="and_(SmartGroup.id == SmartGroupMembership.smart_group_id, SmartGroupMembership.is_active)",
secondaryjoin="SmartGroupMembership.alaner_id == Alaner.id",
back_populates="smart_groups",
uselist=True,
)
ownership
class-attribute
instance-attribute
¶
ownership = relationship(
"Ownership",
foreign_keys="Ownership.smart_group_id",
primaryjoin="Ownership.smart_group_id == SmartGroup.id",
back_populates="smart_group",
uselist=True,
order_by="Ownership.created_at.asc()",
)
smart_group_definition_id
class-attribute
instance-attribute
¶
apps.eu_tools.alan_home.models.smart_group_membership.SmartGroupMembership ¶
Bases: HistorizableAlanerRelation
__table_args__
class-attribute
instance-attribute
¶
__table_args__ = (
ExcludeConstraint(
("alaner_id", "="),
("smart_group_id", "="),
(
text("daterange(start_date, end_date, '[]')"),
"&&",
),
where="is_cancelled = false",
name="non_overlapping_active_membership_per_alaner_and_smart_group",
),
ExcludeConstraint(
("external_user_id", "="),
("smart_group_id", "="),
(
text("daterange(start_date, end_date, '[]')"),
"&&",
),
where="is_cancelled = false",
name="non_overlapping_active_membership_per_external_and_smart_group",
),
CheckConstraint(
"num_nonnulls(alaner_id, external_user_id) = 1",
name="smart_group_membership_alaner_xor_external_user_id_set",
),
*(__table_args__),
)
external_user
class-attribute
instance-attribute
¶
external_user = relationship(
"ExternalUser",
primaryjoin="foreign(SmartGroupMembership.external_user_id) == ExternalUser.id",
uselist=False,
)
external_user_id
class-attribute
instance-attribute
¶
smart_group
class-attribute
instance-attribute
¶
smart_group_id
class-attribute
instance-attribute
¶
apps.eu_tools.alan_home.commands.smart_groups.smart_group_definition.BaseSmartGroupDefinition ¶
Bases: ABC
active_external_users
classmethod
¶
active_members
classmethod
¶
external_users
classmethod
¶
external_users_on
classmethod
¶
members
classmethod
¶
Deprecated: Override members_on instead. This default implementation delegates to members_on with today's date.
Source code in apps/eu_tools/alan_home/commands/smart_groups/smart_group_definition.py
members_on
classmethod
¶
Default implementation delegates to legacy members() method. New classes should override this method instead of members().
Source code in apps/eu_tools/alan_home/commands/smart_groups/smart_group_definition.py
sanity_check
classmethod
¶
Override to perform a custom sanity check and raise an exception (e.g. ValueError) if the group members should NOT be updated
apps.eu_tools.alan_home.commands.smart_groups.smart_group_definition.SmartGroupDefinition ¶
Bases: BaseSmartGroupDefinition