page
This commit is contained in:
parent
59891ef4c8
commit
e311b481c3
41
features.py
41
features.py
@ -90,7 +90,48 @@ def attachment_kind_from_name_and_mime(
|
||||
if mime_type.startswith(VIDEO_MIME_PREFIX) or ext in VIDEO_EXTENSIONS:
|
||||
return "video"
|
||||
return "file"
|
||||
|
||||
def page_payload(app_module, page, user: Optional[dict]) -> dict:
|
||||
can_read = bool(
|
||||
page["visibility"] == "public"
|
||||
or (
|
||||
user
|
||||
and (
|
||||
user["role"] in {"moderator", "admin"}
|
||||
or app_module.is_team_member(page["team_id"], user["id"])
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
rendered_html = app_module.render_markdown_to_safe_html(page["body"] or "")
|
||||
|
||||
return {
|
||||
"id": page["id"],
|
||||
"team_id": page["team_id"],
|
||||
"team_slug": page["team_slug"],
|
||||
"team_name": page["team_name"],
|
||||
"channel_id": page["channel_id"],
|
||||
"channel_slug": page["channel_slug"],
|
||||
"channel_name": page["channel_name"],
|
||||
"slug": page["slug"],
|
||||
"title": page["title"],
|
||||
"body": page["body"],
|
||||
"body_html": rendered_html,
|
||||
"visibility": page["visibility"],
|
||||
"page_type": page["page_type"],
|
||||
"created_by_user_id": page["created_by_user_id"],
|
||||
"updated_by_user_id": page["updated_by_user_id"],
|
||||
"created_at": page["created_at"],
|
||||
"updated_at": page["updated_at"],
|
||||
"can_read": can_read,
|
||||
"can_edit": bool(
|
||||
user
|
||||
and (
|
||||
user["role"] in {"moderator", "admin"}
|
||||
or app_module.is_team_admin(page["team_id"], user)
|
||||
)
|
||||
),
|
||||
}
|
||||
|
||||
def attachment_payload_from_row(row) -> Optional[dict]:
|
||||
if not row or not row["id"]:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user