discussion.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:idealoom 作者: conversence 项目源码 文件源码
def etalab_get_discussions(request):
    # According to the Etalab API specification, an Instance object must have the following fields:
    # - url: we send discussion.get_url(). Note: a discussion may have 2 URLs (HTTP and HTTPS). For this, see discussion.get_discussion_urls()
    # - name: we use discussion.topic
    # - adminEmail: email of the discussion creator, who made the API request to create a discusison (so in our case the field will not show if the discussion has been created by another mean)
    # - adminName: name of this guy, also provided in the discussion creation request (so in our case the field will not show if the discussion has been created by another mean)
    # - createdAt: creation date
    # We also send the following optional fields:
    # - id: this field is not in specification's optional nor mandatory fields
    # - status: "running"
    # - metadata: metadata.creation_date => will probably be renamed, see above
    view = "etalab"
    user_id = authenticated_userid(request) or Everyone
    permissions = request.permissions
    if P_READ not in permissions:
        raise HTTPUnauthorized()
    discussions = discussions_with_access(user_id)
    return {"items": [discussion.generic_json(view, user_id, permissions)
                      for discussion in discussions]}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号