lavkach3

Форк
0
70 строк · 2.8 Кб
1
from typing import Optional, List
2

3
from fastapi_filter.contrib.sqlalchemy import Filter
4
from pydantic.types import UUID4
5
from core.schemas.basic_schemes import BasicField as Field, bollean
6

7
from app.inventory.location.enums import LocationClass
8
from app.inventory.location.models import Location
9
from core.schemas import BaseFilter
10
from core.schemas.basic_schemes import BasicModel
11
from core.schemas.list_schema import GenericListSchema
12
from core.schemas.timestamps import TimeStampScheme
13

14

15
class LocationBaseScheme(BasicModel):
16
    vars: Optional[dict] = None
17
    location_class: LocationClass
18
    title: str
19
    store_id: UUID4 = Field(title='Store', model='store')
20
    location_id: Optional[UUID4] = Field(default=None, title='Parent Location', model='location')
21
    is_active: bollean = Field(default=True, title='Is Active')
22
    location_type_id: UUID4 = Field(title='Location Type', model='location_type')
23
    partner_id: Optional[UUID4] = Field(default=None, title='Partner', model='partner')
24

25
    location_class: LocationClass = Field(default=LocationClass.PLACE, title='Location Class')
26
    lot_id: Optional[UUID4] = Field(default=None, title='Lot')
27
    is_can_negative: bollean = Field(default=False, title='Can Negative')
28
    allowed_package_ids: Optional[list[UUID4]] = Field(default=[], title='Allowed Packages')  # Разрешенные типы упаковок
29
    exclude_package_ids: Optional[list[UUID4]] = Field(default=[], title='Exclude Packages')  # Разрешенные типы упаковок
30

31
    class Config:
32
        extra = 'allow'
33
        from_attributes = True
34
        orm_model = Location
35

36
class LocationUpdateScheme(LocationBaseScheme):
37
    ...
38

39

40
class LocationCreateScheme(LocationBaseScheme):
41
    ...
42

43

44
class LocationScheme(LocationCreateScheme, TimeStampScheme):
45
    company_id: UUID4 = Field(model='company', title='Company')
46
    lsn: int
47
    id: UUID4
48

49
    class Config:
50
        from_attributes = True
51

52

53
class LocationFilter(BaseFilter):
54
    title: Optional[str] = Field(default=None, title='Title')
55
    store_id__in: Optional[List[UUID4]] = Field(default=None, title='Store', model='store')
56
    location_type_id__in: Optional[List[UUID4]] = Field(default=None, title='Location Type', model='location_type')
57
    location_class__in: Optional[List[LocationClass]] = Field(default=None, title='Class')
58
    location_class__not_in: Optional[List[LocationClass]] = Field(default=None, title='Class')
59
    is_active: Optional[bool] = Field(default=None, title='Active')
60
    is_can_negative: Optional[bool] = Field(default=None, title='Is can negative')
61

62
    class Constants(Filter.Constants):
63
        model = Location
64
        ordering_field_name = "order_by"
65
        search_field_name = "search"
66
        search_model_fields = ["title"]
67

68

69
class LocationListSchema(GenericListSchema):
70
    data: Optional[List[LocationScheme]]
71

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.