feat(plan): REST /api/tasks/planning endpoint
This commit is contained in:
@@ -16,6 +16,7 @@ from fabledassistant.services.notes import (
|
||||
list_notes,
|
||||
update_note,
|
||||
)
|
||||
from fabledassistant.services.planning import start_planning as svc_start_planning
|
||||
from fabledassistant.services.recurrence import calculate_next_due, validate_recurrence_rule
|
||||
|
||||
tasks_bp = Blueprint("tasks", __name__, url_prefix="/api/tasks")
|
||||
@@ -143,6 +144,24 @@ async def create_task_route():
|
||||
return jsonify(task.to_dict()), 201
|
||||
|
||||
|
||||
@tasks_bp.route("/planning", methods=["POST"])
|
||||
@login_required
|
||||
async def start_planning_route():
|
||||
uid = get_current_user_id()
|
||||
data = await request.get_json() or {}
|
||||
project_id = data.get("project_id")
|
||||
title = (data.get("title") or "").strip()
|
||||
if not project_id or not title:
|
||||
return jsonify({"error": "project_id and title are required"}), 400
|
||||
try:
|
||||
result = await svc_start_planning(
|
||||
user_id=uid, project_id=int(project_id), title=title,
|
||||
)
|
||||
except ValueError as exc:
|
||||
return jsonify({"error": str(exc)}), 404
|
||||
return jsonify(result), 201
|
||||
|
||||
|
||||
@tasks_bp.route("/<int:task_id>", methods=["GET"])
|
||||
@login_required
|
||||
async def get_task_route(task_id: int):
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import inspect
|
||||
|
||||
|
||||
def test_planning_handler_callable():
|
||||
from fabledassistant.routes import tasks as tasks_routes
|
||||
assert callable(tasks_routes.start_planning_route)
|
||||
|
||||
|
||||
def test_planning_service_signature():
|
||||
from fabledassistant.services.planning import start_planning
|
||||
params = inspect.signature(start_planning).parameters
|
||||
assert "user_id" in params and "project_id" in params and "title" in params
|
||||
Reference in New Issue
Block a user