feat: connect project and scenario routers to new Jinja2 views with forms and error handling
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user