feat: connect project and scenario routers to new Jinja2 views with forms and error handling

This commit is contained in:
2025-11-09 17:32:23 +01:00
parent 191500aeb7
commit d36611606d
6 changed files with 531 additions and 6 deletions

View File

@@ -5,7 +5,7 @@ from typing import Sequence
from sqlalchemy import select
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm import Session, joinedload
from sqlalchemy.orm import Session, joinedload, selectinload
from models import FinancialInput, Project, Scenario, SimulationParameter
from services.exceptions import EntityConflictError, EntityNotFoundError
@@ -17,8 +17,10 @@ class ProjectRepository:
def __init__(self, session: Session) -> None:
self.session = session
def list(self) -> Sequence[Project]:
def list(self, *, with_children: bool = False) -> Sequence[Project]:
stmt = select(Project).order_by(Project.created_at)
if with_children:
stmt = stmt.options(selectinload(Project.scenarios))
return self.session.execute(stmt).scalars().all()
def get(self, project_id: int, *, with_children: bool = False) -> Project: