From 1c58ae3b25120ac670b897665bac7d8f18156220 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Tue, 30 Jun 2020 14:01:17 +0200 Subject: Fix more violations and ensure experimentIds handling --- web-server/opendc/api/v2/simulations/endpoint.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'web-server/opendc/api/v2/simulations/endpoint.py') diff --git a/web-server/opendc/api/v2/simulations/endpoint.py b/web-server/opendc/api/v2/simulations/endpoint.py index 232df2ff..b48ad71b 100644 --- a/web-server/opendc/api/v2/simulations/endpoint.py +++ b/web-server/opendc/api/v2/simulations/endpoint.py @@ -3,7 +3,6 @@ from datetime import datetime from opendc.models.simulation import Simulation from opendc.models.topology import Topology from opendc.models.user import User -from opendc.util import exceptions from opendc.util.database import Database from opendc.util.rest import Response @@ -13,7 +12,7 @@ def POST(request): request.check_required_parameters(body={'simulation': {'name': 'string'}}) - topology = Topology({'name': 'Default topology'}) + topology = Topology({'name': 'Default topology', 'rooms': []}) topology.insert() simulation = Simulation({'simulation': request.params_body['simulation']}) -- cgit v1.2.3 From a27598ee4755423ebd2f0ad8c505644d644cf2c8 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Tue, 30 Jun 2020 14:07:51 +0200 Subject: Make accessing the ID easer --- web-server/opendc/api/v2/simulations/endpoint.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'web-server/opendc/api/v2/simulations/endpoint.py') diff --git a/web-server/opendc/api/v2/simulations/endpoint.py b/web-server/opendc/api/v2/simulations/endpoint.py index b48ad71b..c978fad7 100644 --- a/web-server/opendc/api/v2/simulations/endpoint.py +++ b/web-server/opendc/api/v2/simulations/endpoint.py @@ -18,12 +18,12 @@ def POST(request): simulation = Simulation({'simulation': request.params_body['simulation']}) simulation.set_property('datetimeCreated', Database.datetime_to_string(datetime.now())) simulation.set_property('datetimeLastEdited', Database.datetime_to_string(datetime.now())) - simulation.set_property('topologyIds', [topology.obj['_id']]) + simulation.set_property('topologyIds', [topology.get_id()]) simulation.set_property('experimentIds', []) simulation.insert() user = User.from_google_id(request.google_id) - user.obj['authorizations'].append({'simulationId': simulation.obj['_id'], 'authorizationLevel': 'OWN'}) + user.obj['authorizations'].append({'simulationId': simulation.get_id(), 'authorizationLevel': 'OWN'}) user.update() return Response(200, 'Successfully created simulation.', simulation.obj) -- cgit v1.2.3