feat: foundations for the manager conversion (platform-v2 step 6.1)
- Backend: every HTTPException in routers/ is an error code now (260 raises, ~105 new codes, texts in en + el); XeniaError(detail=...) keeps the three v1-shaped answers old pages read; bad / unknown tokens answer auth.session_ended; test_errors refuses new HTTPExceptions. - Manager: v2.json is the list of pages on the v2 rules: scripts/lint.mjs lints them, tests/v2-guards.test.mjs refuses Greek and colour literals, `strict` paths make set-state-in-effect an error. - src/live/useLiveQuery.js (react-query + live events + refresh on reconnect); Signed in now uses it. - Dead manager files removed (3.1k lines unreachable from main.jsx). - Tests: backend 544 passed, manager unit 33, run-all (no Android) passed (manager's live bell check passed on a rerun). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@ import json
|
||||
from datetime import datetime, timezone
|
||||
from typing import List, Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from fastapi import APIRouter, Depends, status
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from database import get_db
|
||||
@@ -22,6 +22,7 @@ from schemas.pricing import (
|
||||
)
|
||||
from routers.deps import get_current_user, require_manager
|
||||
from models.user import User
|
||||
from core.errors import XeniaError
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@@ -71,7 +72,7 @@ def update_price_group(
|
||||
):
|
||||
pg = db.query(PriceGroup).filter(PriceGroup.id == group_id).first()
|
||||
if not pg:
|
||||
raise HTTPException(status_code=404, detail="Price group not found")
|
||||
raise XeniaError("price_group.not_found")
|
||||
pg.name = body.name
|
||||
pg.description = body.description
|
||||
pg.color = body.color
|
||||
@@ -92,7 +93,7 @@ def toggle_price_group(
|
||||
):
|
||||
pg = db.query(PriceGroup).filter(PriceGroup.id == group_id).first()
|
||||
if not pg:
|
||||
raise HTTPException(status_code=404, detail="Price group not found")
|
||||
raise XeniaError("price_group.not_found")
|
||||
pg.is_active = 0 if pg.is_active else 1
|
||||
db.commit()
|
||||
db.refresh(pg)
|
||||
@@ -107,7 +108,7 @@ def delete_price_group(
|
||||
):
|
||||
pg = db.query(PriceGroup).filter(PriceGroup.id == group_id).first()
|
||||
if not pg:
|
||||
raise HTTPException(status_code=404, detail="Price group not found")
|
||||
raise XeniaError("price_group.not_found")
|
||||
db.delete(pg)
|
||||
db.commit()
|
||||
|
||||
@@ -184,7 +185,7 @@ def update_modifier(
|
||||
):
|
||||
m = db.query(PriceModifier).filter(PriceModifier.id == modifier_id).first()
|
||||
if not m:
|
||||
raise HTTPException(status_code=404, detail="Modifier not found")
|
||||
raise XeniaError("modifier.not_found")
|
||||
m.name = body.name
|
||||
m.description = body.description
|
||||
m.color = body.color
|
||||
@@ -220,7 +221,7 @@ def toggle_modifier(
|
||||
):
|
||||
m = db.query(PriceModifier).filter(PriceModifier.id == modifier_id).first()
|
||||
if not m:
|
||||
raise HTTPException(status_code=404, detail="Modifier not found")
|
||||
raise XeniaError("modifier.not_found")
|
||||
m.is_active = 0 if m.is_active else 1
|
||||
m.updated_at = utcnow()
|
||||
m.updated_by = user.id
|
||||
@@ -251,7 +252,7 @@ def delete_modifier(
|
||||
):
|
||||
m = db.query(PriceModifier).filter(PriceModifier.id == modifier_id).first()
|
||||
if not m:
|
||||
raise HTTPException(status_code=404, detail="Modifier not found")
|
||||
raise XeniaError("modifier.not_found")
|
||||
db.delete(m)
|
||||
db.commit()
|
||||
|
||||
@@ -310,7 +311,7 @@ def update_deal(
|
||||
):
|
||||
d = db.query(Deal).filter(Deal.id == deal_id).first()
|
||||
if not d:
|
||||
raise HTTPException(status_code=404, detail="Deal not found")
|
||||
raise XeniaError("deal.not_found")
|
||||
d.name = body.name
|
||||
d.description = body.description
|
||||
d.color = body.color
|
||||
@@ -346,7 +347,7 @@ def toggle_deal(
|
||||
):
|
||||
d = db.query(Deal).filter(Deal.id == deal_id).first()
|
||||
if not d:
|
||||
raise HTTPException(status_code=404, detail="Deal not found")
|
||||
raise XeniaError("deal.not_found")
|
||||
d.is_active = 0 if d.is_active else 1
|
||||
db.commit()
|
||||
db.refresh(d)
|
||||
@@ -361,7 +362,7 @@ def delete_deal(
|
||||
):
|
||||
d = db.query(Deal).filter(Deal.id == deal_id).first()
|
||||
if not d:
|
||||
raise HTTPException(status_code=404, detail="Deal not found")
|
||||
raise XeniaError("deal.not_found")
|
||||
db.delete(d)
|
||||
db.commit()
|
||||
|
||||
@@ -535,11 +536,11 @@ def accept_deal_offer(
|
||||
|
||||
deal = db.query(Deal).filter(Deal.id == deal_id).first()
|
||||
if not deal:
|
||||
raise HTTPException(status_code=404, detail="Deal not found")
|
||||
raise XeniaError("deal.not_found")
|
||||
|
||||
order = db.query(Order).filter(Order.id == order_id).first()
|
||||
if not order:
|
||||
raise HTTPException(status_code=404, detail="Order not found")
|
||||
raise XeniaError("order.not_found", order_id=order_id)
|
||||
|
||||
added_item_ids = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user