Exemple #1
0
def _add_user_permissions(session, user, **permission_filters):
    """add permissions to a user."""
    from compass.db.api import permission as permission_api
    for api_permission in permission_api.list_permissions_internal(
        session, **permission_filters
    ):
        utils.add_db_object(
            session, models.UserPermission, False,
            user.id, api_permission.id
        )
Exemple #2
0
def _remove_user_permissions(session, user, **permission_filters):
    """remove permissions to a user."""
    from compass.db.api import permission as permission_api
    permission_ids = [
        api_permission.id
        for api_permission in permission_api.list_permissions_internal(
            session, **permission_filters
        )
    ]
    utils.del_db_objects(
        session, models.UserPermission,
        user_id=user.id, permission_id=permission_ids
    )