Skip to content

Commit c3f8bd7

Browse files
committed
projects schema, domain and data models
1 parent 059286c commit c3f8bd7

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

packages/models-library/src/models_library/api_schemas_webserver/projects.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from ..projects_access import AccessRights, GroupIDStr
2727
from ..projects_state import ProjectState
2828
from ..projects_ui import StudyUI
29-
from ..users import UserID
3029
from ..utils._original_fastapi_encoders import jsonable_encoder
3130
from ..utils.common_validators import (
3231
empty_str_to_none_pre_validator,
@@ -35,6 +34,7 @@
3534
)
3635
from ..workspaces import WorkspaceID
3736
from ._base import EmptyModel, InputSchema, OutputSchema
37+
from .groups import GroupID
3838
from .permalinks import ProjectPermalink
3939

4040

@@ -97,7 +97,9 @@ class ProjectGet(OutputSchema):
9797
folder_id: FolderID | None
9898

9999
trashed_at: datetime | None
100-
trashed_by: UserID | None
100+
trashed_by: Annotated[
101+
GroupID | None, Field(description="The primary gid of the user who trashed")
102+
]
101103

102104
_empty_description = field_validator("description", mode="before")(
103105
none_to_empty_str_pre_validator
@@ -109,8 +111,16 @@ class ProjectGet(OutputSchema):
109111
def from_domain_model(cls, project_data: dict[str, Any]) -> Self:
110112
return cls.model_validate(
111113
remap_keys(
112-
project_data,
113-
rename={"trashed": "trashed_at"},
114+
{
115+
k: v
116+
for k, v in project_data.items()
117+
if k not in {"trashed_by", "trashedBy"}
118+
},
119+
rename={
120+
"trashed": "trashed_at",
121+
"trashed_by_primary_gid": "trashed_by",
122+
"trashedByPrimaryGid": "trashedBy",
123+
},
114124
)
115125
)
116126

packages/models-library/src/models_library/projects.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
from .basic_regex import DATE_RE, UUID_RE_BASE
1717
from .emails import LowerCaseEmailStr
18+
from .groups import GroupID
1819
from .projects_access import AccessRights, GroupIDStr
1920
from .projects_nodes import Node
2021
from .projects_nodes_io import NodeIDStr
@@ -106,7 +107,7 @@ class ProjectAtDB(BaseProjectModel):
106107

107108
@field_validator("project_type", mode="before")
108109
@classmethod
109-
def convert_sql_alchemy_enum(cls, v):
110+
def _convert_sql_alchemy_enum(cls, v):
110111
if isinstance(v, Enum):
111112
return v.value
112113
return v
@@ -185,8 +186,12 @@ class Project(BaseProjectModel):
185186

186187
trashed: datetime | None = None
187188
trashed_by: Annotated[UserID | None, Field(alias="trashedBy")] = None
189+
trashed_by_primary_gid: Annotated[
190+
GroupID | None, Field(alias="trashedByPrimaryGid")
191+
] = None
188192
trashed_explicitly: Annotated[bool, Field(alias="trashedExplicitly")] = False
189193

190194
model_config = ConfigDict(
195+
# NOTE: this is a security measure until we get rid of the ProjectDict variants
191196
extra="forbid",
192197
)

packages/postgres-database/src/simcore_postgres_database/models/projects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class ProjectType(enum.Enum):
9393
JSONB,
9494
nullable=False,
9595
server_default=sa.text("'{}'::jsonb"),
96-
doc="Read/write/delete access rights of each group (gid) on this project",
96+
doc="DEPRECATED: Read/write/delete access rights of each group (gid) on this project",
9797
),
9898
sa.Column(
9999
"workbench",

services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12581,6 +12581,7 @@ components:
1258112581
minimum: 0
1258212582
- type: 'null'
1258312583
title: Trashedby
12584+
description: The primary gid of the user who trashed
1258412585
type: object
1258512586
required:
1258612587
- uuid
@@ -12837,6 +12838,7 @@ components:
1283712838
minimum: 0
1283812839
- type: 'null'
1283912840
title: Trashedby
12841+
description: The primary gid of the user who trashed
1284012842
type: object
1284112843
required:
1284212844
- uuid

0 commit comments

Comments
 (0)