Skip to content

structs/tasks.py

structs.tasks

Tasks Structs

TaskItem

Bases: BaseModel

TaskItem

Source code in structs/tasks.py
class 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
class 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
def 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
def gen_uuid() -> str:
    ''' gen_uuid '''
    return f'{uuid4().fields[0]:08x}'