diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-07-07 20:45:06 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-07-08 10:53:25 +0200 |
| commit | 5ec19973eb3d23046d874b097275857a58c23082 (patch) | |
| tree | a601cd975f8917fb2d4af28e8a3fb228e0cb769e /opendc-web/opendc-web-api/opendc/models/scenario.py | |
| parent | 02a2f0f89cb1f39a5f8856bca1971a4e1b12374f (diff) | |
api: Add endpoints for accessing project relations
This change adds additional endpoints to the REST API to access the
project relations, the portfolios and topologies that belong to a
project.
Diffstat (limited to 'opendc-web/opendc-web-api/opendc/models/scenario.py')
| -rw-r--r-- | opendc-web/opendc-web-api/opendc/models/scenario.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/opendc-web/opendc-web-api/opendc/models/scenario.py b/opendc-web/opendc-web-api/opendc/models/scenario.py index 0fb6c453..63160448 100644 --- a/opendc-web/opendc-web-api/opendc/models/scenario.py +++ b/opendc-web/opendc-web-api/opendc/models/scenario.py @@ -1,5 +1,6 @@ from datetime import datetime +from bson import ObjectId from marshmallow import Schema, fields from opendc.exts import db @@ -65,6 +66,11 @@ class Scenario(Model): """ return cls(db.fetch_all({'simulation.state': 'QUEUED'}, cls.collection_name)) + @classmethod + def get_for_portfolio(cls, portfolio_id): + """Get all scenarios for the specified portfolio id.""" + return db.fetch_all({'portfolioId': ObjectId(portfolio_id)}, cls.collection_name) + def update_state(self, new_state, results=None): """Atomically update the state of the Scenario. """ |
