Remove delete functionality from vehicles and buildings

- Remove DELETE endpoints for vehicles and buildings from api.py
- Remove delete_vehicle() method from vehicle service
- Remove delete buttons from vehicles.html and buildings.html
This commit is contained in:
Reditus committed 2026-05-19 05:56:27 +01:00
1 parent 6e7a850ba2
commit e977f8cd5b
4 files changed
+2 -71

No files matched your search

+1 -30
View File
@@ -126,33 +126,4 @@ class VehicleService:
ORDER BY id
""", [vehicle_id]) or []
def delete_vehicle(self, vehicle_id):
conn = self.db.get_connection()
if not conn:
return False, "Database connection failed"
cur = None
try:
cur = conn.cursor()
cur.execute("SET session_replication_role = replica")
cur.execute("DELETE FROM dune.vehicles WHERE id = %s RETURNING id", [vehicle_id])
deleted = cur.fetchone()
if deleted:
cur.execute("DELETE FROM dune.actors WHERE id = %s RETURNING id", [vehicle_id])
conn.commit()
cur.execute("SET session_replication_role = default")
return True, f"Vehicle {vehicle_id} deleted"
else:
conn.rollback()
cur.execute("SET session_replication_role = default")
return False, "Vehicle not found"
except Exception as e:
logger.error(f"Failed to delete vehicle {vehicle_id}: {e}")
try:
cur.execute("SET session_replication_role = default")
except Exception:
pass
return False, str(e)
finally:
if cur:
cur.close()
self.db.return_connection(conn)