Fix require_cap TypeError, rewrite /analysis/comparison, add room category sync

- require_cap was a Depends-factory but every call site uses it inline;
  make it an inline checker (fixes 500 on /analysis/hotels, /direct/*)
- /analysis/comparison returned a per-date matrix the frontend never read;
  return per-hotel aggregates (our/their avg, price index) and default to
  all active competitors so the Market Comparison table works without params
- Room categories were never populated (lost in port): add sites_list fetch
  to the Newbook client, categories list/sync/toggle endpoints, and a
  Settings card — without included categories every rates sync exits early

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-05 13:47:10 +00:00
parent c9f2dc804c
commit 69c9b16a2b
6 changed files with 5787 additions and 52 deletions

View file

@ -52,15 +52,12 @@ def has_cap(user: dict, cap: str) -> bool:
return user.get("is_admin", False) or cap in user.get("caps", [])
def require_cap(cap: str):
async def checker(user: dict = Depends(get_current_user)):
if not has_cap(user, cap):
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail=f"Missing capability: {cap}",
)
return user
return checker
def require_cap(user: dict, cap: str) -> None:
if not has_cap(user, cap):
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail=f"Missing capability: {cap}",
)
async def get_admin_user(user: dict = Depends(get_current_user)) -> dict: