Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
projects schema, domain and data models
Browse files Browse the repository at this point in the history
pcrespov committed Jan 17, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 059286c commit c3f8bd7
Showing 4 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -26,7 +26,6 @@
from ..projects_access import AccessRights, GroupIDStr
from ..projects_state import ProjectState
from ..projects_ui import StudyUI
from ..users import UserID
from ..utils._original_fastapi_encoders import jsonable_encoder
from ..utils.common_validators import (
empty_str_to_none_pre_validator,
@@ -35,6 +34,7 @@
)
from ..workspaces import WorkspaceID
from ._base import EmptyModel, InputSchema, OutputSchema
from .groups import GroupID
from .permalinks import ProjectPermalink


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

trashed_at: datetime | None
trashed_by: UserID | None
trashed_by: Annotated[
GroupID | None, Field(description="The primary gid of the user who trashed")
]

_empty_description = field_validator("description", mode="before")(
none_to_empty_str_pre_validator
@@ -109,8 +111,16 @@ class ProjectGet(OutputSchema):
def from_domain_model(cls, project_data: dict[str, Any]) -> Self:
return cls.model_validate(
remap_keys(
project_data,
rename={"trashed": "trashed_at"},
{
k: v
for k, v in project_data.items()
if k not in {"trashed_by", "trashedBy"}
},
rename={
"trashed": "trashed_at",
"trashed_by_primary_gid": "trashed_by",
"trashedByPrimaryGid": "trashedBy",
},
)
)

7 changes: 6 additions & 1 deletion packages/models-library/src/models_library/projects.py
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@

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

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

trashed: datetime | None = None
trashed_by: Annotated[UserID | None, Field(alias="trashedBy")] = None
trashed_by_primary_gid: Annotated[
GroupID | None, Field(alias="trashedByPrimaryGid")
] = None
trashed_explicitly: Annotated[bool, Field(alias="trashedExplicitly")] = False

model_config = ConfigDict(
# NOTE: this is a security measure until we get rid of the ProjectDict variants
extra="forbid",
)
Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@ class ProjectType(enum.Enum):
JSONB,
nullable=False,
server_default=sa.text("'{}'::jsonb"),
doc="Read/write/delete access rights of each group (gid) on this project",
doc="DEPRECATED: Read/write/delete access rights of each group (gid) on this project",
),
sa.Column(
"workbench",
Original file line number Diff line number Diff line change
@@ -12581,6 +12581,7 @@ components:
minimum: 0
- type: 'null'
title: Trashedby
description: The primary gid of the user who trashed
type: object
required:
- uuid
@@ -12837,6 +12838,7 @@ components:
minimum: 0
- type: 'null'
title: Trashedby
description: The primary gid of the user who trashed
type: object
required:
- uuid

0 comments on commit c3f8bd7

Please sign in to comment.