feat: add coupon management and redemption
Deploy Development / deploy (push) Successful in 56s
Build Test / lint-backend (push) Successful in 1s
Build Test / build-frontend (push) Successful in 12s

New router: routers/coupons.py

Admin endpoints:
- GET /api/coupons - List all coupons with stats
- POST /api/coupons - Create new coupon
- PUT /api/coupons/{id} - Update coupon
- DELETE /api/coupons/{id} - Soft-delete (set active=false)
- GET /api/coupons/{id}/redemptions - Redemption history

User endpoints:
- POST /api/coupons/redeem - Redeem coupon code

Features:
- Three coupon types: single_use, period, wellpass
- Wellpass logic: Pauses existing personal grants, resumes after expiry
- Max redemptions limit (NULL = unlimited)
- Validity period checks
- Activity logging
- Duplicate redemption prevention

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Opus 4.6 committed 2026-03-19 13:07:09 +01:00
1 parent ae47652d0c
commit ae9743d6ed
2 files changed
+284 -1

No files matched your search

+2 -1
View File
@@ -17,7 +17,7 @@ from db import init_db
# Import routers
from routers import auth, profiles, weight, circumference, caliper
from routers import activity, nutrition, photos, insights, prompts
from routers import admin, stats, exportdata, importdata, subscription
from routers import admin, stats, exportdata, importdata, subscription, coupons
# ── App Configuration ─────────────────────────────────────────────────────────
DATA_DIR = Path(os.getenv("DATA_DIR", "./data"))
@@ -74,6 +74,7 @@ app.include_router(stats.router) # /api/stats
app.include_router(exportdata.router) # /api/export/*
app.include_router(importdata.router) # /api/import/*
app.include_router(subscription.router) # /api/subscription/*
app.include_router(coupons.router) # /api/coupons/*
# ── Health Check ──────────────────────────────────────────────────────────────
@app.get("/")