diff --git a/app/rollerverbrauch/__init__.py b/app/rollerverbrauch/__init__.py index 6811f1c..e2ddb9f 100644 --- a/app/rollerverbrauch/__init__.py +++ b/app/rollerverbrauch/__init__.py @@ -92,6 +92,11 @@ def edit_vehicle(vid): @login_required def delete_vehicle(vid): vehicle = Vehicle.query.filter(Vehicle.id == vid).first() + + # prevent deletion of foreign vehicles + if not vehicle in current_user.vehicles: + return redirect(url_for('get_account_page')) + form = DeleteVehicleForm() if form.validate_on_submit(): @@ -216,4 +221,4 @@ def prepare_pit_stops(pss): curr_date = curr['date'] curr['days'] = (curr_date - last_date).days pitstops.reverse() - return pitstops \ No newline at end of file + return pitstops