Replace internal todos with Vikunja API wrapper

- New app/vikunja.py: get_tasks, create_task, update_task, delete_task
- /todos page now reads from and writes to Vikunja (create, mark done, delete)
- Auto-todos (clean build plate, filament low) post to Vikunja after DB commit
- /api/todos router proxies to Vikunja
- .env.install: VIKUNJA_URL, VIKUNJA_API_TOKEN, VIKUNJA_PROJECT_ID

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Martin Hohenberg
2026-06-19 07:40:54 +02:00
parent 223a1b7f1e
commit a2e8c9e194
5 changed files with 171 additions and 34 deletions

View File

@@ -1,21 +1,24 @@
from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from app.db import get_db
from app.models.todo import Todo
from fastapi import APIRouter
from app.vikunja import create_task, delete_task, get_tasks, update_task
router = APIRouter(prefix="/todos", tags=["todos"])
@router.get("/")
def list_todos(db: Session = Depends(get_db)):
return [t.to_dict() for t in db.query(Todo).all()]
def list_todos():
return get_tasks()
@router.get("/{todo_id}")
def get_todo(todo_id: int, db: Session = Depends(get_db)):
todo = db.query(Todo).filter(Todo.id == todo_id).first()
if not todo:
from fastapi import HTTPException
raise HTTPException(status_code=404, detail="Todo not found")
return todo.to_dict()
@router.post("/")
def create_todo(body: dict):
return create_task(body.get("title", ""))
@router.post("/{task_id}")
def update_todo(task_id: int, body: dict):
update_task(task_id, **body)
@router.delete("/{task_id}")
def delete_todo(task_id: int):
delete_task(task_id)