diff --git a/app/routes/api.py b/app/routes/api.py index 2645a15..963894c 100644 --- a/app/routes/api.py +++ b/app/routes/api.py @@ -608,49 +608,11 @@ def register_api_routes(app, services, settings): return jsonify({'success': False, 'error': str(e)}) # Delete vehicle - @app.route('/api/vehicles/', methods=['DELETE']) - @auth_req - def delete_vehicle(vehicle_id): - success, message = vehicle_svc.delete_vehicle(vehicle_id) + if success: return jsonify({'success': True, 'message': message}) return jsonify({'success': False, 'error': message}), 404 if 'not found' in message.lower() else 500 - # Delete building - @app.route('/api/buildings/', methods=['DELETE']) - @auth_req - def delete_building(building_id): - conn = db.get_connection() - if not conn: - return jsonify({'success': False, 'error': 'Database connection failed'}), 500 - cur = None - try: - cur = conn.cursor() - cur.execute("SET session_replication_role = replica") - cur.execute("DELETE FROM dune.building_instances WHERE building_id = %s", [building_id]) - cur.execute("DELETE FROM dune.buildings WHERE id = %s RETURNING id", [building_id]) - deleted = cur.fetchone() - if deleted: - cur.execute("DELETE FROM dune.actors WHERE id = %s RETURNING id", [building_id]) - conn.commit() - cur.execute("SET session_replication_role = default") - return jsonify({'success': True, 'message': f'Building {building_id} deleted'}) - else: - conn.rollback() - cur.execute("SET session_replication_role = default") - return jsonify({'success': False, 'error': 'Building not found'}), 404 - except Exception as e: - logger.error(f"Failed to delete building {building_id}: {e}") - try: - cur.execute("SET session_replication_role = default") - except Exception: - pass - return jsonify({'success': False, 'error': str(e)}), 500 - finally: - if cur: - cur.close() - db.return_connection(conn) - # Debug endpoints (should be restricted in production) @app.route('/api/debug/vehicle_properties/') @auth_req diff --git a/app/services/vehicle.py b/app/services/vehicle.py index 7c50eb2..b896763 100644 --- a/app/services/vehicle.py +++ b/app/services/vehicle.py @@ -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) + diff --git a/templates/buildings.html b/templates/buildings.html index a28e44b..636b881 100644 --- a/templates/buildings.html +++ b/templates/buildings.html @@ -38,7 +38,6 @@ {% if b.is_powered == 'True' %}Powered{% elif b.is_powered == 'False' %}Unpowered{% else %}?{% endif %} {{ b.instance_count }} {{ b.transform_text or '' }} - {% else %} No buildings found diff --git a/templates/vehicles.html b/templates/vehicles.html index cb948fd..c12ae37 100644 --- a/templates/vehicles.html +++ b/templates/vehicles.html @@ -57,7 +57,6 @@ {% if v.pilot_name %}Active {{ v.pilot_name }}{% else %}—{% endif %} {{ v.map or 'N/A' }} {{ v.transform_text or '' }} - {% else %} No vehicles found