当前位置: 首页>>代码示例>>Python>>正文


Python Role.by_id方法代码示例

本文整理汇总了Python中aleph.model.Role.by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Role.by_id方法的具体用法?Python Role.by_id怎么用?Python Role.by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在aleph.model.Role的用法示例。


在下文中一共展示了Role.by_id方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: view

# 需要导入模块: from aleph.model import Role [as 别名]
# 或者: from aleph.model.Role import by_id [as 别名]
def view(id):
    authz.require(authz.logged_in())
    role = obj_or_404(Role.by_id(id))
    data = role.to_dict()
    if role.id != request.auth_role.id:
        del data["email"]
    return jsonify(data)
开发者ID:CodeForAfrica,项目名称:aleph,代码行数:9,代码来源:roles_api.py

示例2: create

# 需要导入模块: from aleph.model import Role [as 别名]
# 或者: from aleph.model.Role import by_id [as 别名]
def create():
    require(request.authz.logged_in)
    data = parse_request(CollectionCreateSchema)
    role = Role.by_id(request.authz.id)
    sync = get_flag('sync')
    collection = create_collection(data, role=role, sync=sync)
    return CollectionSerializer.jsonify(collection)
开发者ID:pudo,项目名称:aleph,代码行数:9,代码来源:collections_api.py

示例3: update

# 需要导入模块: from aleph.model import Role [as 别名]
# 或者: from aleph.model.Role import by_id [as 别名]
def update(id):
    role = obj_or_404(Role.by_id(id))
    authz.require(authz.logged_in())
    authz.require(role.id == request.auth_role.id)
    role.update(request_data())
    db.session.add(role)
    db.session.commit()
    return jsonify(role)
开发者ID:adamchainz,项目名称:aleph,代码行数:10,代码来源:roles_api.py

示例4: index

# 需要导入模块: from aleph.model import Role [as 别名]
# 或者: from aleph.model.Role import by_id [as 别名]
def index():
    require(request.authz.logged_in)
    role = Role.by_id(request.authz.id)
    query = Notification.by_channels(get_role_channels(role),
                                     since=role.notified_at,
                                     exclude_actor_id=role.id)
    result = DatabaseQueryResult(request, query)
    return NotificationSerializer.jsonify_result(result)
开发者ID:pudo,项目名称:aleph,代码行数:10,代码来源:notifications_api.py

示例5: update

# 需要导入模块: from aleph.model import Role [as 别名]
# 或者: from aleph.model.Role import by_id [as 别名]
def update(id):
    role = obj_or_404(Role.by_id(id))
    require(request.authz.session_write)
    require(check_editable(role, request.authz))
    data = parse_request(RoleSchema)
    role.update(data)
    db.session.add(role)
    db.session.commit()
    update_role(role)
    return RoleSerializer.jsonify(role)
开发者ID:pudo,项目名称:aleph,代码行数:12,代码来源:roles_api.py

示例6: check_alerts

# 需要导入模块: from aleph.model import Role [as 别名]
# 或者: from aleph.model.Role import by_id [as 别名]
def check_alerts():
    for role_id, in Role.notifiable():
        with current_app.test_request_context('/'):
            role = Role.by_id(role_id)
            request.auth_role = role
            request.logged_in = True
            # FIXME: can't re-gain access to implicit oauth rules.
            # -> https://github.com/pudo/aleph/issues/14
            request.auth_roles = [Role.system(Role.SYSTEM_USER),
                                  Role.system(Role.SYSTEM_GUEST),
                                  role.id]
            check_role_alerts(role)
开发者ID:CodeForAfrica,项目名称:aleph,代码行数:14,代码来源:__init__.py

示例7: get_role

# 需要导入模块: from aleph.model import Role [as 别名]
# 或者: from aleph.model.Role import by_id [as 别名]
def get_role(role_id):
    if role_id is None:
        return
    key = cache.object_key(Role, role_id)
    data = cache.get_complex(key)
    if data is None:
        log.debug("Role [%s]: object cache miss", role_id)
        role = Role.by_id(role_id)
        if role is None:
            return
        data = role.to_dict()
        cache.set_complex(key, data, expire=cache.EXPIRE)
    return data
开发者ID:pudo,项目名称:aleph,代码行数:15,代码来源:roles.py

示例8: update

# 需要导入模块: from aleph.model import Role [as 别名]
# 或者: from aleph.model.Role import by_id [as 别名]
def update(id):
    collection = get_db_collection(id, request.authz.WRITE)
    for permission in parse_request(PermissionSchema, many=True):
        role_id = permission.get('role_id')
        role = Role.by_id(role_id)
        if not check_visible(role, request.authz):
            continue
        if role.is_public:
            permission['write'] = False
        if collection.casefile and role.is_public:
            permission['read'] = False

        update_permission(role,
                          collection,
                          permission['read'],
                          permission['write'],
                          editor_id=request.authz.id)
    update_collection(collection)
    return index(id)
开发者ID:pudo,项目名称:aleph,代码行数:21,代码来源:permissions_api.py

示例9: load_role

# 需要导入模块: from aleph.model import Role [as 别名]
# 或者: from aleph.model.Role import by_id [as 别名]
def load_role():
    request.auth_roles = set([Role.system(Role.SYSTEM_GUEST)])
    request.auth_role = None
    request.logged_in = False

    if session.get('user'):
        request.auth_roles.update(session.get('roles', []))
        request.auth_role = Role.by_id(session.get('user'))
        request.logged_in = True
    else:
        api_key = request.args.get('api_key')
        if api_key is None:
            auth_header = request.headers.get('Authorization') or ''
            if auth_header.lower().startswith('apikey'):
                api_key = auth_header.split(' ', 1).pop()
        role = Role.by_api_key(api_key)
        if role is None:
            return
        request.auth_role = role
        request.auth_roles.update([Role.system(Role.SYSTEM_USER), role.id])
        request.logged_in = True
开发者ID:rlugojr,项目名称:aleph,代码行数:23,代码来源:sessions_api.py

示例10: view

# 需要导入模块: from aleph.model import Role [as 别名]
# 或者: from aleph.model.Role import by_id [as 别名]
def view(id):
    role = obj_or_404(Role.by_id(id))
    require(check_editable(role, request.authz))
    return RoleSerializer.jsonify(role)
开发者ID:pudo,项目名称:aleph,代码行数:6,代码来源:roles_api.py

示例11: view

# 需要导入模块: from aleph.model import Role [as 别名]
# 或者: from aleph.model.Role import by_id [as 别名]
def view(id):
    role = obj_or_404(Role.by_id(id))
    data = role.to_dict()
    if role.id != request.auth_role.id:
        del data['email']
    return jsonify(data)
开发者ID:DavidLemayian,项目名称:aleph,代码行数:8,代码来源:roles_api.py

示例12: mark_read

# 需要导入模块: from aleph.model import Role [as 别名]
# 或者: from aleph.model.Role import by_id [as 别名]
def mark_read():
    require(request.authz.logged_in)
    role = Role.by_id(request.authz.id)
    role.notified_at = datetime.utcnow()
    db.session.commit()
    return jsonify({'status': 'ok'}, status=202)
开发者ID:pudo,项目名称:aleph,代码行数:8,代码来源:notifications_api.py


注:本文中的aleph.model.Role.by_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。