There is a hardcoded list of methods/endpoints for which the status check isn't done. i.e. the endpoints which need to be accessed before the org is approved. Resolves #11
27 lines
813 B
Python
27 lines
813 B
Python
"""
|
|
Module specific exceptions for organisation module
|
|
|
|
Exceptions:
|
|
- List: Description
|
|
- Exceptions: Description
|
|
"""
|
|
from typing import Optional
|
|
|
|
from fastapi import HTTPException, status
|
|
|
|
|
|
class OrgNotFoundException(HTTPException):
|
|
def __init__(self, org_id: Optional[int] = None) -> None:
|
|
detail = "Organisation not found" if org_id is None else f"Organisation with ID '{org_id}' was not found."
|
|
super().__init__(
|
|
status_code=status.HTTP_404_NOT_FOUND,
|
|
detail=detail,
|
|
)
|
|
|
|
class AwaitingApprovalException(HTTPException):
|
|
def __init__(self, org_id: Optional[int] = None) -> None:
|
|
detail = "Organisation has not been approved." if org_id is None else f"Organisation with ID '{org_id}' has not been approved."
|
|
super().__init__(
|
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
detail=detail,
|
|
)
|