Skip to content

Commit

Permalink
Optionally supply a scenario ID to create to update a scenario instead
Browse files Browse the repository at this point in the history
Closes #93
  • Loading branch information
noracato authored and redekok committed May 4, 2023
1 parent a8a4cd0 commit 6755a34
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/api/v1/create_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
location='form'
)
import_parser.add_argument('energy_system_title', type=str, required=False, location='form')
import_parser.add_argument(
'scenario_id',
type=int,
required=False,
location='form',
help='If you want to update an existing scenario instead of creating an ew one, please specify the ID here.'
)

## Controller
@api.route('/')
Expand All @@ -48,7 +55,12 @@ def post(self):
)

converter = EsdlToScenarioConverter(self.energy_system_handler)
self.__create_new_scenario_id(converter.area)

# NOTE: we don't validate if this scenario matches the area!
if args['scenario_id']:
self.scenario_id = args['scenario_id']
else:
self.__create_new_scenario_id(converter.area)

with HaltGarbageCollection():
self.__set_sliders_in_etm(self.__filter_on_hold(converter.calculate()))
Expand Down

0 comments on commit 6755a34

Please sign in to comment.