當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。