Files
xenia-pos-cloud/cloud_backend/models/site.py
T
bonaminandClaude Opus 5.5 7ee059d834 feat(sysadmin): the venue's menu and ordering links from PUBLIC_APPS_URL; 3S pack notes
Plan phase 3S, step S.99.
- SiteOut.apps_url (the cloud's PUBLIC_APPS_URL; a Site property, not stored per site).
- Sysadmin site page: the QR menu and online ordering links/QR codes are built from it
  (were a hard-coded IP and a "/menu/<site>/order" route that never existed); a note when
  PUBLIC_APPS_URL isn't set, and that table codes are printed by the venue.
- Pack README: connect_frontend and /api/menu rows for phase 3S, CL-9 (rate limits are per
  process), CL-10 (table QR tokens: hashes only).
- Test: the sysadmin gets the apps address.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 01:35:50 +02:00

51 lines
2.4 KiB
Python

from sqlalchemy import JSON, Column, Integer, String, Boolean, DateTime
from sqlalchemy.sql import func
from database import Base
class Site(Base):
__tablename__ = "sites"
id = Column(Integer, primary_key=True, index=True)
site_id = Column(String, unique=True, nullable=False, index=True)
name = Column(String, nullable=False)
owner_name = Column(String, nullable=False)
contact_email = Column(String, nullable=False)
secret_key_hash = Column(String, nullable=False)
is_active = Column(Boolean, default=True)
is_locked = Column(Boolean, default=False)
lock_reason = Column(String, nullable=True)
license_expires_at = Column(DateTime(timezone=True), nullable=False)
created_at = Column(DateTime(timezone=True), server_default=func.now())
last_seen_at = Column(DateTime(timezone=True), nullable=True)
last_seen_ip = Column(String, nullable=True)
last_seen_local_ip = Column(String, nullable=True)
waiter_domain = Column(String, nullable=True)
# Monotonically incrementing counter used to generate public_ref for online orders
order_counter = Column(Integer, default=0, nullable=False)
# QR menu branding/config
menu_mode = Column(String, nullable=False, default="order") # "order" | "view_only"
menu_display_name = Column(String, nullable=True)
menu_tagline_en = Column(String, nullable=True)
menu_tagline_gr = Column(String, nullable=True)
menu_blurb_en = Column(String, nullable=True)
menu_blurb_gr = Column(String, nullable=True)
menu_hours = Column(String, nullable=True)
menu_header_image_url = Column(String, nullable=True)
# Licensed modules (APPS_PLATFORM D-3, §5.2): the `modules` map of the site's v2 license
# token, e.g. {"ordering": {}, "kds": {"limits": {"devices": 2}}, "caller_id": {"exp": "..."}}.
# Edited in the sysadmin panel, usually by applying a plan preset first.
modules = Column(JSON, nullable=False, default=dict)
# What the site reported it can run (heartbeat `module_catalog`, D-20): drives the editor.
module_catalog = Column(JSON, nullable=True)
module_catalog_at = Column(DateTime(timezone=True), nullable=True)
@property
def apps_url(self) -> str | None:
"""Where customers open this cloud's apps (PUBLIC_APPS_URL; phase 3S): the sysadmin's
menu and ordering links are built from it. Not stored per site."""
from config import settings
return settings.PUBLIC_APPS_URL.rstrip("/") or None