- Introduced a new template for listing scenarios associated with a project. - Added metrics for total, active, draft, and archived scenarios. - Implemented quick actions for creating new scenarios and reviewing project overview. - Enhanced navigation with breadcrumbs for better user experience. refactor: update Opex and Profitability templates for consistency - Changed titles and button labels for clarity in Opex and Profitability templates. - Updated form IDs and action URLs for better alignment with new naming conventions. - Improved navigation links to include scenario and project overviews. test: add integration tests for Opex calculations - Created new tests for Opex calculation HTML and JSON flows. - Validated successful calculations and ensured correct data persistence. - Implemented tests for currency mismatch and unsupported frequency scenarios. test: enhance project and scenario route tests - Added tests to verify scenario list rendering and calculator shortcuts. - Ensured scenario detail pages link back to the portfolio correctly. - Validated project detail pages show associated scenarios accurately.
110 lines
2.4 KiB
Python
110 lines
2.4 KiB
Python
from __future__ import annotations
|
|
|
|
from fastapi import APIRouter, Depends, Request
|
|
from fastapi.responses import HTMLResponse
|
|
|
|
from dependencies import require_any_role_html, require_roles_html
|
|
from models import User
|
|
from routes.template_filters import create_templates
|
|
|
|
router = APIRouter(tags=["UI"])
|
|
templates = create_templates()
|
|
|
|
READ_ROLES = ("viewer", "analyst", "project_manager", "admin")
|
|
MANAGE_ROLES = ("project_manager", "admin")
|
|
|
|
|
|
@router.get(
|
|
"/ui/simulations",
|
|
response_class=HTMLResponse,
|
|
include_in_schema=False,
|
|
name="ui.simulations",
|
|
)
|
|
def simulations_dashboard(
|
|
request: Request,
|
|
_: User = Depends(require_any_role_html(*READ_ROLES)),
|
|
) -> HTMLResponse:
|
|
return templates.TemplateResponse(
|
|
request,
|
|
"simulations.html",
|
|
{
|
|
"title": "Simulations",
|
|
},
|
|
)
|
|
|
|
|
|
@router.get(
|
|
"/ui/reporting",
|
|
response_class=HTMLResponse,
|
|
include_in_schema=False,
|
|
name="ui.reporting",
|
|
)
|
|
def reporting_dashboard(
|
|
request: Request,
|
|
_: User = Depends(require_any_role_html(*READ_ROLES)),
|
|
) -> HTMLResponse:
|
|
return templates.TemplateResponse(
|
|
request,
|
|
"reporting.html",
|
|
{
|
|
"title": "Reporting",
|
|
},
|
|
)
|
|
|
|
|
|
@router.get(
|
|
"/ui/settings",
|
|
response_class=HTMLResponse,
|
|
include_in_schema=False,
|
|
name="ui.settings",
|
|
)
|
|
def settings_page(
|
|
request: Request,
|
|
_: User = Depends(require_any_role_html(*READ_ROLES)),
|
|
) -> HTMLResponse:
|
|
return templates.TemplateResponse(
|
|
request,
|
|
"settings.html",
|
|
{
|
|
"title": "Settings",
|
|
},
|
|
)
|
|
|
|
|
|
@router.get(
|
|
"/theme-settings",
|
|
response_class=HTMLResponse,
|
|
include_in_schema=False,
|
|
name="ui.theme_settings",
|
|
)
|
|
def theme_settings_page(
|
|
request: Request,
|
|
_: User = Depends(require_any_role_html(*READ_ROLES)),
|
|
) -> HTMLResponse:
|
|
return templates.TemplateResponse(
|
|
request,
|
|
"theme_settings.html",
|
|
{
|
|
"title": "Theme Settings",
|
|
},
|
|
)
|
|
|
|
|
|
@router.get(
|
|
"/ui/currencies",
|
|
response_class=HTMLResponse,
|
|
include_in_schema=False,
|
|
name="ui.currencies",
|
|
)
|
|
def currencies_page(
|
|
request: Request,
|
|
_: User = Depends(require_roles_html(*MANAGE_ROLES)),
|
|
) -> HTMLResponse:
|
|
return templates.TemplateResponse(
|
|
request,
|
|
"currencies.html",
|
|
{
|
|
"title": "Currency Management",
|
|
},
|
|
)
|