Backend overhaul: new models, routers, schemas for shifts, business day, flags, messages, settings

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-29 12:12:05 +03:00
parent 603fd45eaa
commit defc49f84f
31 changed files with 2626 additions and 55 deletions

View File

@@ -7,12 +7,18 @@ class CategoryCreate(BaseModel):
name: str
color: Optional[str] = None
sort_order: int = 0
parent_id: Optional[int] = None
general_sort_order: int = 0
auto_expanded: bool = False
class CategoryUpdate(BaseModel):
name: Optional[str] = None
color: Optional[str] = None
sort_order: Optional[int] = None
parent_id: Optional[int] = None
general_sort_order: Optional[int] = None
auto_expanded: Optional[bool] = None
class CategoryOut(BaseModel):
@@ -20,6 +26,9 @@ class CategoryOut(BaseModel):
name: str
color: Optional[str] = None
sort_order: int = 0
parent_id: Optional[int] = None
general_sort_order: int = 0
auto_expanded: bool = False
model_config = {"from_attributes": True}
@@ -29,6 +38,40 @@ class CategoryReorderItem(BaseModel):
sort_order: int
class SubcategoryReorderItem(BaseModel):
id: int
sort_order: int # position among subcategories within the parent
class ParentGeneralReorderItem(BaseModel):
id: int # parent category id
general_sort_order: int
# ── Quick Options ─────────────────────────────────────────────────────────────
class ProductQuickOptionCreate(BaseModel):
name: str
price: float = 0.0
allow_multiple: bool = False
sort_order: int = 0
is_favorite: bool = False
favorite_sort_order: int = 0
class ProductQuickOptionOut(BaseModel):
id: int
product_id: int
name: str
price: float = 0.0
allow_multiple: bool = False
sort_order: int = 0
is_favorite: bool = False
favorite_sort_order: int = 0
model_config = {"from_attributes": True}
# ── Options ──────────────────────────────────────────────────────────────────
class OptionSubChoice(BaseModel):
@@ -40,6 +83,9 @@ class OptionSubChoice(BaseModel):
class ProductOptionBase(BaseModel):
name: str
extra_cost: float = 0.0
allow_multiple: bool = False
is_favorite: bool = False
favorite_sort_order: int = 0
class ProductOptionCreate(ProductOptionBase):
@@ -64,7 +110,10 @@ class ProductOptionOut(ProductOptionBase):
'product_id': data.product_id,
'name': data.name,
'extra_cost': data.extra_cost,
'allow_multiple': getattr(data, 'allow_multiple', False) or False,
'sub_choices': parsed,
'is_favorite': getattr(data, 'is_favorite', False) or False,
'favorite_sort_order': getattr(data, 'favorite_sort_order', 0) or 0,
}
return data
@@ -74,6 +123,8 @@ class ProductOptionOut(ProductOptionBase):
class ProductIngredientBase(BaseModel):
name: str
extra_cost: float = 0.0
is_favorite: bool = False
favorite_sort_order: int = 0
class ProductIngredientCreate(ProductIngredientBase):
@@ -155,6 +206,8 @@ class PreferenceSetCreate(BaseModel):
choices: List[PreferenceChoiceCreate] = []
default_choice_index: Optional[int] = None # index into choices (0-based)
shared_subset: Optional[SharedSubset] = None
is_favorite: bool = False
favorite_sort_order: int = 0
class PreferenceSetOut(BaseModel):
@@ -164,6 +217,8 @@ class PreferenceSetOut(BaseModel):
choices: List[PreferenceChoiceOut] = []
default_choice_id: Optional[int] = None
shared_subset: Optional[SharedSubset] = None
is_favorite: bool = False
favorite_sort_order: int = 0
model_config = {"from_attributes": True}
@@ -186,6 +241,8 @@ class PreferenceSetOut(BaseModel):
'choices': list(data.choices),
'default_choice_id': data.default_choice_id,
'shared_subset': parsed,
'is_favorite': getattr(data, 'is_favorite', False) or False,
'favorite_sort_order': getattr(data, 'favorite_sort_order', 0) or 0,
}
return data
@@ -197,11 +254,13 @@ class ProductBase(BaseModel):
category_id: Optional[int] = None
base_price: float
is_available: bool = True
lifecycle_status: str = "active"
printer_zone_id: Optional[int] = None
sort_order: int = 0
class ProductCreate(ProductBase):
quick_options: List[ProductQuickOptionCreate] = []
options: List[ProductOptionCreate] = []
ingredients: List[ProductIngredientCreate] = []
preference_sets: List[PreferenceSetCreate] = []
@@ -212,8 +271,10 @@ class ProductUpdate(BaseModel):
category_id: Optional[int] = None
base_price: Optional[float] = None
is_available: Optional[bool] = None
lifecycle_status: Optional[str] = None
printer_zone_id: Optional[int] = None
sort_order: Optional[int] = None
quick_options: Optional[List[ProductQuickOptionCreate]] = None
options: Optional[List[ProductOptionCreate]] = None
ingredients: Optional[List[ProductIngredientCreate]] = None
preference_sets: Optional[List[PreferenceSetCreate]] = None
@@ -226,6 +287,7 @@ class ProductReorderItem(BaseModel):
class ProductOut(ProductBase):
id: int
quick_options: List[ProductQuickOptionOut] = []
options: List[ProductOptionOut] = []
ingredients: List[ProductIngredientOut] = []
preference_sets: List[PreferenceSetOut] = []