bank-statement-api / routers /practices.py
pratik-befree's picture
practices added for the classification
c58f0d0
Raw History Blame Contribute Delete
585 Bytes
from fastapi import APIRouter
from auth.database import SessionLocal
from auth.rule_models import Practice
router = APIRouter(tags=["practices"])
@router.get("/api/practices")
async def get_practices():
"""Return all active practices for the dropdown seed."""
db = SessionLocal()
try:
practices = (
db.query(Practice)
.filter(Practice.is_active == True)
.order_by(Practice.name.asc())
.all()
)
return {"practices": [{"id": p.id, "name": p.name} for p in practices]}
finally:
db.close()