def delete_user_task(uid, id): # Fetch the user user = User.fetch_user_by_id(uid) if user: user_tasks = tasks_schema.dump(user.tasks).data task_ids = [] for task in user_tasks: task_ids.append(int(task['id'])) if int(id) in task_ids: if Task.delete_by_id(id): return jsonify({"message": "Task deleted successfully"}), 200 else: return jsonify({ "message": "Error deleting task. Contact the administrator" }), 500 else: return jsonify({"message": "Task not found"}), 404 else: return jsonify({"message": "User not found"}), 404
def delete_task(id): task = Task() if task.delete_by_id(id): return jsonify({"message": "Task deleted successfully"}), 200 else: return jsonify({"message": "Error deleting task. Task not found"}), 404