feat(menu): the menu in English and Greek (platform-v2 step 6.4, D-29)
- products.translations / categories.translations (Alembic 0033, core/menu_languages.py: el + en,
name / description / quick options by their base name; catalog.translation). Empty = the text
as typed; no machine translation (owner).
- In the manager's product editor ("In English" / "In Greek", quick extras), the category dialog,
and a menu board's Language (signage MenuContent.language).
- Customer screens only: cloud snapshot names / descriptions per language (C-2), the menu tablet's
EL / EN switch the names (localize), signage boards; tickets, KDS, counter, phones keep the base.
- Catalogue bundles carry translations; @xenia/access menuLanguages.js (a backend test compares).
- e2e: manager (the other language saved), menu tablet (EN / EL names), QR table (English on
the menu, the base name on the kitchen's order, Greek page as typed).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ from typing import Optional, List, Any, Literal, Dict
|
||||
|
||||
from core.sales_points import ALL as _SALES_POINTS, sold_at as _sold_at
|
||||
from core.allergens import of as _allergens_of
|
||||
from core.menu_languages import of as _menu_tr_of, _load as _menu_tr
|
||||
|
||||
SalesPoint = Literal["in_store", "in_store_takeaway", "qr_table", "online_takeaway", "online_delivery", "online_preorder"]
|
||||
|
||||
@@ -16,6 +17,7 @@ class CategoryCreate(BaseModel):
|
||||
general_sort_order: int = 0
|
||||
auto_expanded: bool = False
|
||||
media_id: Optional[int] = None # its picture in the media library (5.2)
|
||||
translations: Dict[str, Dict[str, str]] = {} # 6.4: {"en": {"name": "…"}}
|
||||
|
||||
|
||||
class CategoryUpdate(BaseModel):
|
||||
@@ -26,6 +28,7 @@ class CategoryUpdate(BaseModel):
|
||||
general_sort_order: Optional[int] = None
|
||||
auto_expanded: Optional[bool] = None
|
||||
media_id: Optional[int] = None # null clears it (sent explicitly)
|
||||
translations: Optional[Dict[str, Dict[str, str]]] = None # None = unchanged
|
||||
|
||||
|
||||
class CategoryOut(BaseModel):
|
||||
@@ -38,9 +41,15 @@ class CategoryOut(BaseModel):
|
||||
auto_expanded: bool = False
|
||||
media_id: Optional[int] = None
|
||||
image: Optional[dict] = None # {id, name, thumb, card, full} (services/media.image_of)
|
||||
translations: Dict[str, Dict[str, str]] = {}
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
@field_validator("translations", mode="before")
|
||||
@classmethod
|
||||
def _tr(cls, v):
|
||||
return _menu_tr(v)
|
||||
|
||||
|
||||
class CategoryReparentRequest(BaseModel):
|
||||
parent_id: Optional[int] = None
|
||||
@@ -349,6 +358,8 @@ class ProductBase(BaseModel):
|
||||
tags: Optional[List[str]] = None
|
||||
# The EU allergens (plan step 6.3): {key: "contains" | "may_contain"}, core/allergens.py
|
||||
allergens: Dict[str, str] = {}
|
||||
# The menu in other languages (6.4, core/menu_languages.py)
|
||||
translations: Dict[str, Dict[str, Any]] = {}
|
||||
# Service item flag
|
||||
is_service_item: bool = False
|
||||
# Fiscal printer (ΦΗΜ)
|
||||
@@ -397,6 +408,7 @@ class ProductUpdate(BaseModel):
|
||||
# Tags
|
||||
tags: Optional[List[str]] = None
|
||||
allergens: Optional[Dict[str, str]] = None # None = unchanged, {} = none
|
||||
translations: Optional[Dict[str, Dict[str, Any]]] = None # None = unchanged, {} = none
|
||||
# Service item flag
|
||||
is_service_item: Optional[bool] = None
|
||||
# Fiscal printer (ΦΗΜ)
|
||||
@@ -468,6 +480,7 @@ class ProductOut(ProductBase):
|
||||
'quick_add_enabled': getattr(data, 'quick_add_enabled', True),
|
||||
'tags': json.loads(data.tags) if isinstance(getattr(data, 'tags', None), str) else (getattr(data, 'tags', None) or []),
|
||||
'allergens': _allergens_of(data),
|
||||
'translations': _menu_tr_of(data),
|
||||
'is_service_item': bool(getattr(data, 'is_service_item', False)),
|
||||
'fiscal_name': getattr(data, 'fiscal_name', None),
|
||||
'fiscal_vat_group_id': getattr(data, 'fiscal_vat_group_id', None),
|
||||
|
||||
Reference in New Issue
Block a user