Initial commit

This commit is contained in:
Chris Milne 2026-04-06 12:41:49 +01:00
commit 376a7a9fe5
71 changed files with 2326 additions and 0 deletions

7
src/admin/config.py Normal file
View file

@ -0,0 +1,7 @@
"""
Configurations for the admin module
Configurations:
- List: Description
- Configs: Description
"""

7
src/admin/constants.py Normal file
View file

@ -0,0 +1,7 @@
"""
Constants and error codes for the admin module
Constants:
- List: Description
- Consts: Description
"""

11
src/admin/dependencies.py Normal file
View file

@ -0,0 +1,11 @@
"""
Router dependencies for the admin module
Classes:
- List: Description
- Classes: Description
Functions:
- List: Description
- Functions: Description
"""

7
src/admin/exceptions.py Normal file
View file

@ -0,0 +1,7 @@
"""
Module specific exceptions for the admin module
Exceptions:
- List: Description
- Exceptions: Description
"""

7
src/admin/models.py Normal file
View file

@ -0,0 +1,7 @@
"""
Database models for the admin module
Models:
- List: Description
- Models: Description
"""

50
src/admin/router.py Normal file
View file

@ -0,0 +1,50 @@
"""
Router endpoints for the admin module
Endpoints:
- List: Description
- Endpoints: Description
"""
from fastapi import APIRouter, HTTPException
from fastapi.params import Path
from sqlalchemy.sql import exists
from src.organisation.constants import ContactType
from src.organisation.schemas import OrgContactGetResponse
from src.organisation.models import Organisation as Org
from src.contact.models import Contact
from src.user.models import User
from src.user.schemas import UserResponse, OIDCUser, OrgResponse
from src.organisation.models import OrgUsers, Organisation
from src.auth.service import claims_dependency, org_user_dependency, org_admin_dependency
from src.database import db_dependency
router = APIRouter(
tags=["admin"],
prefix="/admin",
)
@router.get("/{org_id}/contact/{contact_type}", response_model=OrgContactGetResponse)
async def get_contact(db: db_dependency, user: claims_dependency, is_org_admin: org_user_dependency, contact_type: ContactType, org_id: int = Path(gt=0)):
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")
match contact_type:
case "billing":
contact_id = org_model.billing_contact_id
case "security":
contact_id = org_model.security_contact_id
case "owner":
contact_id = org_model.owner_contact_id
case _:
raise HTTPException(status_code=422, detail="Invalid contact type")
contact_model = (db.query(Contact).filter(Contact.id == contact_id).first())
if contact_model is None:
raise HTTPException(status_code=404, detail="Contact not found")
return contact_model

7
src/admin/schemas.py Normal file
View file

@ -0,0 +1,7 @@
"""
Pydantic models for the admin module
Models:
- List: Description
- Models: Description
"""

11
src/admin/service.py Normal file
View file

@ -0,0 +1,11 @@
"""
Module specific business logic for the admin module
Classes:
- List: Description
- Classes: Description
Functions:
- List: Description
- Functions: Description
"""

11
src/admin/utils.py Normal file
View file

@ -0,0 +1,11 @@
"""
Non-business logic reusable functions and classes for the admin module
Classes:
- List: Description
- Classes: Description
Functions:
- List: Description
- Functions: Description
"""