Cleanup before platform-v2 phase 3 (owner-approved). - KI-008: GET /api/reports/orders/export read order_history's dicts as ORM rows and always failed with 500; it also ignored business_day_id (the Today page sends it). Rebuilt on the dicts, header even when empty. tests/test_reports_export.py. - KI-010: OnlineOrdersPage listened on /api/stream (never existed: no live refresh, a 404 every few seconds). It now refetches on the shared live connection (online_order_received / online_order_updated / ready); 20 s polling stays as a fallback. manager.mjs checks nothing asks for /api/stream. - KI-007: the setup wizard seeds the 10 default table flags and 5 quick messages in the venue language (services/defaults.py), only when none exist. v1's seed never worked (NOT NULL columns missing). Managers edit them in Settings -> Operation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
2.8 KiB
Python
51 lines
2.8 KiB
Python
"""Starter content for a new venue (KI-007, platform-v2 cleanup before phase 3).
|
|
|
|
The setup wizard (POST /api/setup/init) calls seed_starter_content() once, in the language
|
|
the owner picked. It is ordinary data: managers rename, hide or delete it under
|
|
Settings -> Operation (table flags, quick messages). Nothing is added when a table already
|
|
has rows (a re-run, or data brought over by the v1 migration, 7.1).
|
|
|
|
v1 tried to seed the same lists in main.py, but its INSERTs left out NOT NULL columns and
|
|
failed silently, so no v1 site ever got them.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
# (emoji, colour, {language: name}) — the v1 list, in its order
|
|
TABLE_FLAGS = (
|
|
("🧹", "#ef4444", {"en": "Needs cleaning", "el": "Χρειάζεται καθάρισμα"}),
|
|
("🆘", "#f97316", {"en": "Needs help", "el": "Χρειάζεται βοήθεια"}),
|
|
("🔔", "#eab308", {"en": "Wants a waiter", "el": "Χρειάζεται σερβιτόρο"}),
|
|
("💳", "#3b82f6", {"en": "Waiting to pay", "el": "Περιμένει να πληρώσει"}),
|
|
("⭐", "#8b5cf6", {"en": "VIP", "el": "VIP"}),
|
|
("😊", "#22c55e", {"en": "Friendly guests", "el": "Ευγενικός πελάτης"}),
|
|
("😤", "#dc2626", {"en": "Difficult guests", "el": "Αγενής πελάτης"}),
|
|
("⚠️", "#f59e0b", {"en": "Allergies", "el": "Αλλεργίες"}),
|
|
("👶", "#06b6d4", {"en": "Children at the table", "el": "Παιδιά στο τραπέζι"}),
|
|
("🎂", "#ec4899", {"en": "Anniversary / birthday", "el": "Επέτειος / γενέθλια"}),
|
|
)
|
|
|
|
QUICK_MESSAGES = (
|
|
{"en": "I need you now", "el": "Σε χρειάζομαι τώρα"},
|
|
{"en": "Take a break", "el": "Πάρε διάλειμμα"},
|
|
{"en": "Get ready to close", "el": "Ετοιμάσου για κλείσιμο"},
|
|
{"en": "New guests have arrived", "el": "Ήρθε νέος πελάτης"},
|
|
{"en": "A guest is waiting to pay", "el": "Ο πελάτης περιμένει να πληρώσει"},
|
|
)
|
|
|
|
|
|
def seed_starter_content(db, language: str | None) -> dict:
|
|
"""Add the default table flags and quick messages if none exist. Doesn't commit."""
|
|
from models.flag import TableFlagDef
|
|
from models.message import QuickMessageTemplate
|
|
lang = language if language in ("en", "el") else "en"
|
|
added = {"flags": 0, "quick_messages": 0}
|
|
if db.query(TableFlagDef).count() == 0:
|
|
for i, (emoji, color, names) in enumerate(TABLE_FLAGS, start=1):
|
|
db.add(TableFlagDef(name=names[lang], emoji=emoji, color=color, sort_order=i, is_active=True))
|
|
added["flags"] = len(TABLE_FLAGS)
|
|
if db.query(QuickMessageTemplate).count() == 0:
|
|
for i, bodies in enumerate(QUICK_MESSAGES, start=1):
|
|
db.add(QuickMessageTemplate(body=bodies[lang], sort_order=i, is_active=True))
|
|
added["quick_messages"] = len(QUICK_MESSAGES)
|
|
return added
|