structs/tasks.py¶ structs.tasks ¶ Tasks Structs TaskItem ¶ Bases: BaseModel TaskItem Source code in structs/tasks.py 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46class TaskItem(BaseModel): ''' TaskItem ''' id: str = Field(description='task id', default_factory=gen_uuid, alias='_id') pid: str = Field(description='project id') title: str = Field(default='', description='title') cate: str = Field(default='', description='cate') created_at: datetime = Field( default_factory=datetime.now, description='created at') created_by: str = Field(description='created by') desc: str = Field(description='desc') starttime: datetime = Field( default_factory=datetime.now, description='task start') endtime: datetime = Field( default_factory=datetime.now, description='task end') limit: int = Field(default=1, ge=1, description='expect required users') people: list[str] = Field(default_factory=list, description='list of users') _validate_convert_datetime = validator( 'created_at', 'starttime', 'endtime', pre=True, allow_reuse=True, always=True)(convert_datetime) class Config: # pylint: disable=too-few-public-methods ''' Config ''' anystr_strip_whitespace = True validate_assignment = True Config ¶ Config Source code in structs/tasks.py 43 44 45 46class Config: # pylint: disable=too-few-public-methods ''' Config ''' anystr_strip_whitespace = True validate_assignment = True convert_datetime ¶ convert_datetime(value: Any) -> datetime convert action_date to date Source code in structs/tasks.py 10 11 12def convert_datetime(value: Any) -> datetime: ''' convert `action_date` to date ''' return arrow.get(value).naive gen_uuid ¶ gen_uuid() -> str gen_uuid Source code in structs/tasks.py 15 16 17def gen_uuid() -> str: ''' gen_uuid ''' return f'{uuid4().fields[0]:08x}'