Files
xenia-pos-local/local_backend/models/all.py
T
bonaminandClaude Opus 5.5 238f8ec5a0 feat(backend): media library: files once by hash, WebP sizes, cached, protected while used (platform-v2 step 5.1)
- Table `media` (Alembic 0026): kind, name, original name, type, sha256
  (unique), bytes, width/height, video length, who and when.
- Files under /app/data/media/<sha[:2]>/<sha>/: the original, and for
  pictures thumb (200 px) / card (600) / full (1920) WebP, upright from
  EXIF, never enlarged, transparency kept. Videos (MP4, WebM) kept as
  uploaded; an MP4's length and size come from its header.
- GET/POST /api/media, GET/PATCH/DELETE /api/media/{id} for whoever manages
  the menu, customer display, signage or menu tablets. The same file again
  returns the existing item. The type comes from the bytes; 20 MB pictures,
  200 MB videos, 60 MP; refused uploads leave nothing behind.
- GET /api/media/file/<sha>/<variant>: public (LAN), Cache-Control
  public, max-age=1 year, immutable; byte ranges for video; a missing size
  is made again from the original.
- register_usage(kind, fn): what uses media (products, displays, signage
  from 5.2-5.4) declares it; delete is refused with media.in_use listing
  the users.
- tests: test_media.py (12); stack.mjs uploads 3 MB through both nginx hops
  and fetches a size with its cache headers (compose stack: all passed).
  Backend suite: 490 passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 13:22:26 +02:00

42 lines
2.6 KiB
Python

"""Import every model module so Base.metadata knows the whole schema.
Used by main.py (app startup), migrations/env.py (Alembic autogenerate) and
the tests. Agent note: a new model module MUST be added here, or Alembic
autogenerate will not see it and the drift guard (tests/guards) will not
catch it either.
"""
import models.user # noqa: F401 also registers WaiterZone
import models.table # noqa: F401
import models.printer # noqa: F401
import models.product # noqa: F401
import models.customers # noqa: F401
import models.phone_call # noqa: F401
import models.order # noqa: F401 also registers OrderAuditLog, OrderDiscount, PrintJob
import models.business_day # noqa: F401
import models.shift # noqa: F401 WaiterShift, ShiftBreak
import models.settings # noqa: F401
import models.flag # noqa: F401 TableFlagDef, TableFlagAssignment
import models.message # noqa: F401 StaffMessage, StaffMessageAck, QuickMessageTemplate
import models.reservation # noqa: F401
import models.notes # noqa: F401 SiteNote, SiteTodo
import models.expenses # noqa: F401 Contact, Expense, ExpensePayment
import models.tabs # noqa: F401 Tab, TabEntry, TabPayment
import models.waste # noqa: F401 WasteLog
import models.schedule # noqa: F401 ScheduledShift
import models.chat # noqa: F401 Conversation, ConversationParticipant, ChatMessage
import models.prep_zone # noqa: F401 PrepZone, prep_zone_printers, product_prep_zones
import models.pricing # noqa: F401 PriceGroup, PriceModifier, Deal, PriceEventLog, WaiterDiscountSettings
import models.recovery_code # noqa: F401
import models.sync_event # noqa: F401
import models.site_module # noqa: F401 SiteModule (module enablement, step 1.3)
import models.user_permission # noqa: F401 UserPermission (permission keys, step 1.5)
import models.role_permission # noqa: F401 RolePermission (venue role defaults, step 4.3)
import models.session # noqa: F401 LoginSession (step 1.6)
import models.device # noqa: F401 Device, DevicePairRequest (step 1.8)
import models.access_override # noqa: F401 AccessOverride (manager override, step 1.9)
import models.support_challenge # noqa: F401 SupportChallenge (support access, step 1.10)
import models.notification # noqa: F401 Notification, NotificationRead (step 1.11)
import models.fees # noqa: F401 DeliveryArea, FeeRule (phase 3S, S.3)
import models.refund # noqa: F401 Refund, RefundItem (step 3.3e)
import models.media # noqa: F401 Media (media library, step 5.1)