Example #1
0
def delete_scenario(scenario_id):
    errors = []
    if scenario_id == '':
        return json.dumps([gettext('Scenario not found')]), 404

    scenario = Scenario.query.filter_by(id=scenario_id).first()
    if scenario is None:
        return json.dumps([gettext('Scenario not found')]), 404

    if g.user is None or (not g.user.is_admin() and scenario.owner != g.user):
        return json.dumps([gettext('Scenario not found')]), 404

    db.session.delete(scenario)
    db.session.commit()
    delete_file('static/images/scenario_previews', scenario.id + '.png')

    return json.dumps({'success': True}), 200
Example #2
0
def delete_scenario(scenario_id):
    errors = []
    if scenario_id == '':
        return json.dumps([gettext('Scenario not found')]), 404

    scenario = Scenario.query.filter_by(id=scenario_id).first()
    if scenario is None:
        return json.dumps([gettext('Scenario not found')]), 404

    if g.user is None or (not g.user.is_admin() and scenario.owner != g.user):
        return json.dumps([gettext('Scenario not found')]), 404
    
    db.session.delete(scenario)
    db.session.commit()
    delete_file('static/images/scenario_previews', scenario.id + '.png')

    return json.dumps({
        'success': True
    }), 200
Example #3
0
 def test_remotion_of_file( self ):
     self.assertTrue( app.delete_file( './test-storage/test.json' ) )