Questions and articles both pointed at `question_categories`; decks had no
category at all, so the three content types could not be filtered together and a
topic's cards were unreachable from its category.
- `flashcard_decks.category_id` references the same tree (migration
t2f3a4b5c697), so one category now spans questions, articles and cards.
- `GET /flashcards/` takes `category_id` and includes descendants, so a parent
category picks up everything filed beneath it.
- `PATCH /flashcards/{id}` files or unfiles a deck, refusing a category id that
does not exist rather than storing a dangling reference.
- The cards page shows each deck's category as a selector.
Tests: 5 new backend (all three types resolve to the same id, descendant
filtering, file and unfile, unknown category refused, renaming leaves the
category alone) and 1 new frontend. Full suites green: 101 backend,
136 frontend, build clean.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PpfzbZ1QTLMeVYxM2kyq8m
32 lines
754 B
Python
32 lines
754 B
Python
from datetime import datetime
|
|
from pydantic import BaseModel
|
|
|
|
class FlashcardDeckCreate(BaseModel):
|
|
model_config = {"protected_namespaces": ()}
|
|
|
|
section_id: int
|
|
title: str
|
|
model_id: str | None = None
|
|
|
|
class FlashcardResponse(BaseModel):
|
|
id: int
|
|
front: str
|
|
back: str
|
|
page_reference: int | None = None
|
|
image_path: str | None = None
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
class FlashcardDeckResponse(BaseModel):
|
|
id: int
|
|
title: str
|
|
section_id: int | None = None
|
|
category_id: int | None = None
|
|
user_id: int
|
|
card_count: int
|
|
created_at: datetime
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
class FlashcardDeckDetail(FlashcardDeckResponse):
|
|
cards: list[FlashcardResponse] = []
|