diff --git a/src/organisation/dependencies.py b/src/organisation/dependencies.py index 51ee569..ec8805c 100644 --- a/src/organisation/dependencies.py +++ b/src/organisation/dependencies.py @@ -6,6 +6,7 @@ Exports: - org_model_body_dependency: org_model: Gets org model from db, if it exists. Uses org_id from request body. Also verifies if the org has been approved. """ from typing import Annotated, Optional +from sqlalchemy.orm import Session from fastapi import Depends, Query, Request @@ -17,12 +18,14 @@ from src.organisation.exceptions import OrgNotFoundException, AwaitingApprovalEx from src.organisation.constants import Status as OrgStatus -def get_org_model(db, request: Request, org_id: int): +def get_org_model(db: Session, request: Request, org_id: int): org_model = db.get(Org, org_id) if org_model is None: raise OrgNotFoundException(org_id) - pre_approval_endpoints = ["PATCH/org/status", "PATCH/org/questionnaire", "GET/org/id", "GET/org/contact", "PATCH/org/contact"] + root = "/api/v1" + + pre_approval_endpoints = [f"PATCH{root}/org/status", f"PATCH{root}/org/questionnaire", f"GET{root}/org/id", f"GET{root}/org/contact", f"PATCH{root}/org/contact"] current_request = f"{request.method}{request.url.path}" if current_request not in pre_approval_endpoints and org_model.status != OrgStatus.APPROVED: raise AwaitingApprovalException(org_id)