cloud-api/src/organisation/dependencies.py

29 lines
645 B
Python
Raw Normal View History

2026-04-06 12:41:49 +01:00
"""
Router dependencies for organisation module
Classes:
- List: Description
- Classes: Description
Functions:
- List: Description
- Functions: Description
"""
from typing import Annotated
from fastapi import HTTPException, Depends
from src.database import db_dependency
from src.organisation.models import Organisation as Org
def get_org_model(db: db_dependency, org_id: int) -> type[Org]:
org_model = db.query(Org).filter(Org.id == org_id).first()
if org_model is None:
raise HTTPException(status_code=404, detail="Organisation not found")
return org_model
org_model_dependency = Annotated[type[Org], Depends(get_org_model)]