88from models_library .api_schemas_webserver .projects_ui import StudyUI
99from models_library .folders import FolderID
1010from models_library .groups import GroupID
11- from models_library .projects import ClassifierID , NodesDict , ProjectID
11+ from models_library .projects import (
12+ ClassifierID ,
13+ NodesDict ,
14+ ProjectID ,
15+ ProjectTemplateType ,
16+ ProjectType ,
17+ )
1218from models_library .users import UserID
1319from models_library .utils .common_validators import (
1420 empty_str_to_none_pre_validator ,
1521 none_to_empty_str_pre_validator ,
1622)
1723from models_library .workspaces import WorkspaceID
18- from pydantic import BaseModel , ConfigDict , HttpUrl , field_validator
19- from simcore_postgres_database .models .projects import ProjectType
24+ from pydantic import BaseModel , ConfigDict , HttpUrl , ValidationInfo , field_validator
2025
2126ProjectDict : TypeAlias = dict [str , Any ]
2227ProjectProxy : TypeAlias = RowProxy
@@ -40,6 +45,7 @@ class ProjectDBGet(BaseModel):
4045 # NOTE: model intented to read one-to-one columns of the `projects` table
4146 id : int
4247 type : ProjectType
48+ template_type : ProjectTemplateType | None
4349 uuid : ProjectID
4450 name : str
4551 description : str
@@ -70,6 +76,20 @@ class ProjectDBGet(BaseModel):
7076 none_to_empty_str_pre_validator
7177 )
7278
79+ @field_validator ("template_type" )
80+ @classmethod
81+ def validate_template_type (
82+ cls , v : ProjectTemplateType | None , info : ValidationInfo
83+ ) -> ProjectTemplateType | None :
84+ type_value = info .data .get ("type" )
85+ if type_value == ProjectType .STANDARD and v is not None :
86+ msg = "template_type must be None when type is STANDARD"
87+ raise ValueError (msg )
88+ if type_value == ProjectType .TEMPLATE and v is None :
89+ msg = "template_type must not be None when type is TEMPLATE"
90+ raise ValueError (msg )
91+ return v
92+
7393
7494class ProjectJobDBGet (ProjectDBGet ):
7595 workbench : NodesDict
0 commit comments