user.models.role_mapping

Classes

RoleMapping

Defines a generic role mapping between user and/or group and any

Module Contents

class user.models.role_mapping.RoleMapping[source]

Bases: onegov.core.orm.Base, onegov.core.orm.mixins.ContentMixin, onegov.core.orm.mixins.TimestampMixin

Defines a generic role mapping between user and/or group and any other model (content).

The model does not define the relationship to the content. Instead, the realtionship should be defined in the content model when needed:

role_mappings = relationship(
    RoleMapping,
    primaryjoin=(
        "and_("
        "foreign(RoleMapping.content_id) == cast(MyModel.id, TEXT),"
        "RoleMapping.content_type == 'my_models'"
        ")"
    ),
    viewonly=True
)
__tablename__ = 'role_mappings'[source]
type: Column[str][source]
__mapper_args__[source]
id: Column[UUIDType][source]
role: Column[str][source]
group_id: Column[UUIDType | None][source]
group: relationship[UserGroup | None][source]
username: Column[str | None][source]
user: relationship[User | None][source]
content_id: Column[str][source]
content_type: Column[str][source]