diff --git a/app/routers/systems.py b/app/routers/systems.py index cfc31de..90bbc17 100644 --- a/app/routers/systems.py +++ b/app/routers/systems.py @@ -134,21 +134,19 @@ async def update_system_route(system_id: str): @systems_bp.route('/', methods=['DELETE']) async def delete_system_route(system_id: str): try: - deleted_system = await current_app.sys_db_h.delete_system({"_id", system_id}) + query = {"_id": system_id} + delete_count = await current_app.d_id_db_h.delete_discord_id(query) - if deleted_system: - print("Deleted system:", deleted_system) - return jsonify(deleted_system), 201 + if delete_count is not None: + if delete_count > 0: + return jsonify({"message": f"Successfully deleted {delete_count} Discord ID(s)."}), 200 + else: + abort(404, "System not found.") else: - abort(500, "Failed to delete system in the database.") - - except HTTPException: - raise + abort(500, "Failed to delete System.") except Exception as e: - print(f"Error deleting system: {e}") - # Catch any other unexpected errors - abort(500, f"Internal server error: {e}") - + print(f"Error in delete_system_route: {e}") + abort(500, f"An internal error occurred: {e}") @systems_bp.route('//assign', methods=['POST']) async def assign_client_to_system_route(system_id: str):