2026-02-08 12:42:19 +01:00
|
|
|
"""
|
|
|
|
|
Subscriptions Frontend Views
|
|
|
|
|
"""
|
|
|
|
|
from fastapi import APIRouter, Request
|
2026-07-28 14:18:24 +02:00
|
|
|
from fastapi.responses import HTMLResponse, RedirectResponse
|
2026-02-08 12:42:19 +01:00
|
|
|
from fastapi.templating import Jinja2Templates
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
router = APIRouter()
|
|
|
|
|
templates = Jinja2Templates(directory="app")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.get("/subscriptions", response_class=HTMLResponse)
|
|
|
|
|
async def subscriptions_list(request: Request):
|
|
|
|
|
"""List all active subscriptions."""
|
|
|
|
|
return templates.TemplateResponse("subscriptions/frontend/list.html", {
|
|
|
|
|
"request": request
|
|
|
|
|
})
|
2026-02-17 08:29:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.get("/subscriptions/simply-imports", response_class=HTMLResponse)
|
|
|
|
|
async def subscriptions_simply_imports(request: Request):
|
|
|
|
|
"""Dedicated page for Simply subscription import parking/staging overview."""
|
|
|
|
|
return templates.TemplateResponse("subscriptions/frontend/simply_imports.html", {
|
|
|
|
|
"request": request
|
|
|
|
|
})
|
2026-07-28 14:18:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.get("/subscriptions/{subscription_id}")
|
|
|
|
|
async def subscription_detail_redirect(subscription_id: int):
|
|
|
|
|
"""Compatibility detail URL: subscriptions are edited on their associated case."""
|
|
|
|
|
from app.core.database import execute_query_single
|
|
|
|
|
|
|
|
|
|
subscription = execute_query_single(
|
|
|
|
|
"SELECT id, sag_id FROM sag_subscriptions WHERE id = %s",
|
|
|
|
|
(subscription_id,),
|
|
|
|
|
)
|
|
|
|
|
if not subscription:
|
|
|
|
|
return RedirectResponse(url="/subscriptions", status_code=303)
|
|
|
|
|
if subscription.get("sag_id"):
|
|
|
|
|
return RedirectResponse(url=f"/sag/{subscription['sag_id']}/v3", status_code=303)
|
|
|
|
|
return RedirectResponse(url="/subscriptions", status_code=303)
|