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: sqlalchemy.Column[str][source]
__mapper_args__[source]
id: sqlalchemy.Column[uuid.UUID][source]
role: sqlalchemy.Column[str][source]
group_id: sqlalchemy.Column[uuid.UUID | None][source]
group: sqlalchemy.orm.relationship[onegov.user.models.group.UserGroup | None][source]
username: sqlalchemy.Column[str | None][source]
user: sqlalchemy.orm.relationship[onegov.user.models.user.User | None][source]
content_id: sqlalchemy.Column[str][source]
content_type: sqlalchemy.Column[str][source]