docs(i18n): document CMS template translations and multi-language content pages
Add sections covering CMS locale file structure, translated template inventory, TranslatableText pattern for sections, and the new title_translations/content_translations model API with migration cms_002. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
72
app/modules/hosting/routes/api/admin_services.py
Normal file
72
app/modules/hosting/routes/api/admin_services.py
Normal file
@@ -0,0 +1,72 @@
|
||||
# app/modules/hosting/routes/api/admin_services.py
|
||||
"""
|
||||
Admin API routes for client service management.
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from fastapi import APIRouter, Depends, Path
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.api.deps import get_current_admin_api
|
||||
from app.core.database import get_db
|
||||
from app.modules.hosting.schemas.client_service import (
|
||||
ClientServiceCreate,
|
||||
ClientServiceResponse,
|
||||
ClientServiceUpdate,
|
||||
)
|
||||
from app.modules.hosting.services.client_service_service import client_service_service
|
||||
from app.modules.tenancy.schemas.auth import UserContext
|
||||
|
||||
router = APIRouter(prefix="/sites/{site_id}/services")
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@router.get("", response_model=list[ClientServiceResponse])
|
||||
def list_services(
|
||||
site_id: int = Path(...),
|
||||
db: Session = Depends(get_db),
|
||||
current_admin: UserContext = Depends(get_current_admin_api),
|
||||
):
|
||||
"""List services for a hosted site."""
|
||||
return client_service_service.get_for_site(db, site_id)
|
||||
|
||||
|
||||
@router.post("", response_model=ClientServiceResponse)
|
||||
def create_service(
|
||||
data: ClientServiceCreate,
|
||||
site_id: int = Path(...),
|
||||
db: Session = Depends(get_db),
|
||||
current_admin: UserContext = Depends(get_current_admin_api),
|
||||
):
|
||||
"""Create a new service for a hosted site."""
|
||||
service = client_service_service.create(db, site_id, data.model_dump(exclude_none=True))
|
||||
db.commit()
|
||||
return service
|
||||
|
||||
|
||||
@router.put("/{service_id}", response_model=ClientServiceResponse)
|
||||
def update_service(
|
||||
data: ClientServiceUpdate,
|
||||
site_id: int = Path(...),
|
||||
service_id: int = Path(...),
|
||||
db: Session = Depends(get_db),
|
||||
current_admin: UserContext = Depends(get_current_admin_api),
|
||||
):
|
||||
"""Update a client service."""
|
||||
service = client_service_service.update(db, service_id, data.model_dump(exclude_none=True))
|
||||
db.commit()
|
||||
return service
|
||||
|
||||
|
||||
@router.delete("/{service_id}")
|
||||
def delete_service(
|
||||
site_id: int = Path(...),
|
||||
service_id: int = Path(...),
|
||||
db: Session = Depends(get_db),
|
||||
current_admin: UserContext = Depends(get_current_admin_api),
|
||||
):
|
||||
"""Delete a client service."""
|
||||
client_service_service.delete(db, service_id)
|
||||
db.commit()
|
||||
return {"message": "Service deleted"} # noqa: API001
|
||||
Reference in New Issue
Block a user