Fix test failures and workload/websocket behavior
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic import BaseModel, Field, computed_field, model_validator
|
||||
from typing import Optional
|
||||
from datetime import datetime, date
|
||||
from decimal import Decimal
|
||||
@@ -19,9 +19,22 @@ class ProjectBase(BaseModel):
|
||||
end_date: Optional[date] = None
|
||||
security_level: SecurityLevel = SecurityLevel.DEPARTMENT
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def apply_name_alias(cls, values):
|
||||
if isinstance(values, dict) and not values.get("title") and values.get("name"):
|
||||
values["title"] = values["name"]
|
||||
return values
|
||||
|
||||
@computed_field
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self.title
|
||||
|
||||
|
||||
class ProjectCreate(ProjectBase):
|
||||
department_id: Optional[str] = None
|
||||
template_id: Optional[str] = None
|
||||
|
||||
|
||||
class ProjectUpdate(BaseModel):
|
||||
@@ -34,6 +47,13 @@ class ProjectUpdate(BaseModel):
|
||||
status: Optional[str] = Field(None, max_length=50)
|
||||
department_id: Optional[str] = None
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def apply_name_alias(cls, values):
|
||||
if isinstance(values, dict) and not values.get("title") and values.get("name"):
|
||||
values["title"] = values["name"]
|
||||
return values
|
||||
|
||||
|
||||
class ProjectResponse(ProjectBase):
|
||||
id: str
|
||||
|
||||
Reference in New Issue
Block a user