Example #1
0
def new_scenario(request=None, new_name=None):
    copy_blank_to_session()

    update_db_version()
    if new_name:
        try:
            scenario_filename(new_name, check_duplicates=True)
        except: pass  # validation may kick it back in which case they'll need to rename it in a file browser
    return redirect('/setup/Scenario/1/')
Example #2
0
def open_scenario(request, target, wrap_target=True):
    if wrap_target:
        target = workspace_path(target)
    print("Copying ", target, "to", db_path(), ". This could take several minutes...")
    close_old_connections()
    shutil.copy(target, db_path(name='scenario_db'))
    scenario_filename(os.path.basename(target))
    print('Sessions overwritten with ', target)
    update_db_version()
    unsaved_changes(False)  # File is now in sync
    SmSession.objects.all().update(iteration_text = '', simulation_has_started=outputs_exist())  # This is also reset from delete_all_outputs
    # else:
    #     print('File does not exist')
    return redirect('/setup/Scenario/1/')