update: filter by owner / visibility
This commit is contained in:
@@ -63,9 +63,13 @@ def resource_payload(
|
||||
|
||||
|
||||
def can_view(resource: DataResources, context: RequestContext) -> bool:
|
||||
# 2026-08-11: 临时取消"用户间目录互相不可见"约束
|
||||
# 同一 workspace 内的成员现在可以查看彼此的 private 资源。
|
||||
# 还原: 取消下方注释,恢复 owner_user_id 检查。
|
||||
return (
|
||||
resource.owner_user_id == context.user.user_id
|
||||
or resource.visibility in {"workspace", "public"}
|
||||
# resource.owner_user_id == context.user.user_id
|
||||
# or
|
||||
resource.visibility in {"workspace", "public"}
|
||||
or context.is_admin
|
||||
)
|
||||
|
||||
@@ -215,13 +219,16 @@ async def list_resources(
|
||||
)
|
||||
.order_by(DataResources.updated_at.desc())
|
||||
)
|
||||
if not context.is_admin:
|
||||
statement = statement.where(
|
||||
or_(
|
||||
DataResources.owner_user_id == context.user.user_id,
|
||||
DataResources.visibility.in_(["workspace", "public"]),
|
||||
)
|
||||
)
|
||||
# 2026-08-11: 临时取消"用户间目录互相不可见"约束
|
||||
# 列表接口现在返回 workspace 内全部 active 资源(不再按 owner / visibility 过滤)。
|
||||
# 还原: 删除下面这段注释,恢复原来的 if not context.is_admin: ... 块。
|
||||
# if not context.is_admin:
|
||||
# statement = statement.where(
|
||||
# or_(
|
||||
# DataResources.owner_user_id == context.user.user_id,
|
||||
# DataResources.visibility.in_(["workspace", "public"]),
|
||||
# )
|
||||
# )
|
||||
if visibility:
|
||||
if visibility not in {"private", "workspace", "public"}:
|
||||
raise HTTPException(
|
||||
|
||||
Reference in New Issue
Block a user