1
from __future__ import annotations
2
from typing import Optional, List
4
from celery.worker.strategy import default
5
from fastapi_filter.contrib.sqlalchemy import Filter
6
from pydantic import BaseModel, Field, computed_field
7
from pydantic.types import UUID4
9
from app.inventory.order.enums.order_enum import SuggestStatus
10
from app.inventory.order.models import Suggest, SuggestType
11
from core.schemas import BaseFilter
12
from core.schemas.basic_schemes import ActionBaseSchame, BasicModel
13
from core.schemas.list_schema import GenericListSchema
14
from core.schemas.timestamps import TimeStampScheme
17
class SuggestBaseScheme(BasicModel):
18
move_id: UUID4 = Field(title='Move ID', model='move', readonly=True)
19
priority: int = Field(title='Priority', readonly=True)
20
type: SuggestType = Field(title='Type', readonly=True, table=True)
21
value: Optional[str] = Field(default=None, title='Value', readonly=True, table=True)
22
result_value: Optional[str] = Field(default=None, title='Result value', table=True)
23
user_id: Optional[UUID4] = Field(default=None, title='User Done ID', model='user', readonly=True)
24
status: SuggestStatus = Field(default=SuggestStatus.WAITING, title='Status', readonly=True)
29
class SuggestUpdateScheme(SuggestBaseScheme):
30
move_id: Optional[UUID4] = Field(default=None, title='Move ID', model='move', readonly=True)
31
priority: Optional[int] = Field(default=None, title='Priority', readonly=True)
35
class SuggestCreateScheme(SuggestBaseScheme):
40
class SuggestScheme(SuggestCreateScheme, TimeStampScheme):
41
company_id: UUID4 = Field(title='Company ID', model='company')
47
def title(self) -> str:
48
return f'[{self.type.name}] - {self.priority}'
51
class SuggestFilter(BaseFilter):
52
move_id__in: Optional[List[UUID4]] = Field(default=None, title='Move')
55
populate_by_name = True
57
class Constants(Filter.Constants):
59
ordering_field_name = "order_by"
60
search_field_name = "search"
61
search_model_fields = ["id", "move_id"]
64
class SuggestListSchema(GenericListSchema):
65
data: Optional[List[SuggestScheme]]
68
class SuggestConfirmScheme(ActionBaseSchame):
69
value: str = Field(title='Result value')