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]}
评论列表
文章目录