Merge tasks into notes: a task is just a note with task attributes
A task is now a note with status/priority/due_date columns set (status IS NOT NULL). This eliminates the separate tasks table, companion note system, cascade deletes, bidirectional title sync, and _skip_cascade flags. Migration (0004): - Add status, priority, due_date columns to notes table - Migrate task data from companion notes and orphan tasks - Drop tasks table and old enum types Backend: - models/note.py: Add TaskStatus/TaskPriority enums, task columns, is_task property - models/task.py: Deleted (merged into note.py) - models/__init__.py: Re-export enums from note.py, remove Task import - services/notes.py: Remove companion/cascade logic, add is_task filter, convert_note_to_task, convert_task_to_note, simplified backlinks - services/tasks.py: Rewritten as thin wrappers around notes service - routes/notes.py: Add is_task filter (default false), task fields in CRUD, convert-to-note endpoint - routes/tasks.py: description→body (with fallback), remove note_id filter Frontend: - types/note.ts: Add TaskStatus, TaskPriority, task fields to Note interface - types/task.ts: Task is now a re-export alias for Note - stores/notes.ts: Simplify convertToTask, add convertToNote - stores/tasks.ts: description→body in createTask/updateTask - TaskEditorView: description→body, remove companion note UI - TaskViewerView: description→body, remove companion note link, add Convert to Note - NoteViewerView: Remove companion task UI, simplify convert-to-task - TaskCard: description→body, non-null assertions for status/priority Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@ from datetime import date
|
||||
|
||||
from quart import Blueprint, jsonify, request
|
||||
|
||||
from fabledassistant.models.task import TaskPriority, TaskStatus
|
||||
from fabledassistant.models.note import TaskPriority, TaskStatus
|
||||
from fabledassistant.services.tasks import (
|
||||
create_task,
|
||||
delete_task,
|
||||
@@ -21,7 +21,6 @@ async def list_tasks_route():
|
||||
tag = request.args.getlist("tag")
|
||||
status = request.args.get("status")
|
||||
priority = request.args.get("priority")
|
||||
note_id = request.args.get("note_id", type=int)
|
||||
sort = request.args.get("sort", "updated_at")
|
||||
order = request.args.get("order", "desc")
|
||||
limit = request.args.get("limit", 50, type=int)
|
||||
@@ -32,7 +31,6 @@ async def list_tasks_route():
|
||||
tags=tag or None,
|
||||
status=status,
|
||||
priority=priority,
|
||||
note_id=note_id,
|
||||
sort=sort,
|
||||
order=order,
|
||||
limit=limit,
|
||||
@@ -44,21 +42,21 @@ async def list_tasks_route():
|
||||
@tasks_bp.route("", methods=["POST"])
|
||||
async def create_task_route():
|
||||
data = await request.get_json()
|
||||
description = data.get("description", "")
|
||||
tags = extract_tags(description)
|
||||
body = data.get("body", "") or data.get("description", "")
|
||||
tags = extract_tags(body)
|
||||
|
||||
due_date = None
|
||||
if data.get("due_date"):
|
||||
due_date = date.fromisoformat(data["due_date"])
|
||||
|
||||
status = TaskStatus(data["status"]) if "status" in data else TaskStatus.todo
|
||||
status = TaskStatus(data["status"]).value if "status" in data else TaskStatus.todo.value
|
||||
priority = (
|
||||
TaskPriority(data["priority"]) if "priority" in data else TaskPriority.none
|
||||
TaskPriority(data["priority"]).value if "priority" in data else TaskPriority.none.value
|
||||
)
|
||||
|
||||
task = await create_task(
|
||||
title=data.get("title", ""),
|
||||
description=description,
|
||||
body=body,
|
||||
status=status,
|
||||
priority=priority,
|
||||
due_date=due_date,
|
||||
@@ -79,17 +77,23 @@ async def get_task_route(task_id: int):
|
||||
async def update_task_route(task_id: int):
|
||||
data = await request.get_json()
|
||||
fields = {}
|
||||
for key in ("title", "description", "status", "priority"):
|
||||
for key in ("title", "status", "priority"):
|
||||
if key in data:
|
||||
fields[key] = data[key]
|
||||
|
||||
# Accept both "body" and "description" (prefer body)
|
||||
if "body" in data:
|
||||
fields["body"] = data["body"]
|
||||
elif "description" in data:
|
||||
fields["body"] = data["description"]
|
||||
|
||||
if "due_date" in data:
|
||||
fields["due_date"] = (
|
||||
date.fromisoformat(data["due_date"]) if data["due_date"] else None
|
||||
)
|
||||
|
||||
if "description" in fields:
|
||||
fields["tags"] = extract_tags(fields["description"])
|
||||
if "body" in fields:
|
||||
fields["tags"] = extract_tags(fields["body"])
|
||||
|
||||
task = await update_task(task_id, **fields)
|
||||
if task is None:
|
||||
|
||||
Reference in New Issue
Block a user