- Implemented a comprehensive end-to-end testing script for the Sag module's HTTP API, covering various functionalities including case creation, updates, and file uploads. - Introduced a safe HTML sanitizer utility to ensure safe rendering of HTML content in the BMC Hub UI. - Added database migrations for new features including WAN connection marking for wall outlets, permanent audit trails for supplier invoices, and dedicated permissions for the Sag module. - Created a migration center for manual subscription and invoice migrations with relevant tables and indexes. - Added tests for migration center functionalities, ensuring stability and correctness of the new features.
44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
"""
|
|
Subscriptions Frontend Views
|
|
"""
|
|
from fastapi import APIRouter, Request
|
|
from fastapi.responses import HTMLResponse, RedirectResponse
|
|
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
|
|
})
|
|
|
|
|
|
@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
|
|
})
|
|
|
|
|
|
@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)
|