feat(admin): rebuild admin area around the Article domain

The admin area was managing a Hacker News-style Item model that the
public site never consumed, so the homepage always fell back to sample
data. Rebuild the admin area around the real public content model.

Backend:
- Remove the Item model, schema and admin API
- Admin API now manages articles at /api/v1/admin/articles (CRUD) with
  /api/v1/admin/authors and /api/v1/admin/categories reference data
- Add public read-only article endpoints (/api/v1/articles,
  /api/v1/articles/{id}): no auth, published-only, newest-first
- Rewrite Article schemas; ArticleRead embeds author and category
- Add idempotent seed_content.py dev seeder (3 authors, 4 categories,
  6 published articles)

Frontend:
- Admin UI rewritten around articles: AdminDashboard list, new
  EditArticlePage (create/edit, author/category selects, published
  toggle, Lexical editor, debounced auto-save)
- Replace AdminItem types and api client with the article domain
- Update App routes, AdminLayout sidebar, DeleteConfirmation, Lexical
  editor labels and Home/client comments to article terminology

Tests:
- Rewrite admin unit tests and the Playwright admin e2e spec for the
  article domain; add test_articles.py for the public endpoints and
  seeder
This commit is contained in:
Daniel Samson committed 2026-10-31 18:31:05 +00:00
1 parent de96d0b152
commit afa399776f
29 files changed
+2465 -1658

No files matched your search

+1 -2
View File
@@ -4,7 +4,6 @@ from models.article import Article
from models.author import Author
from models.base import Base
from models.category import Category, slugify
from models.item import Item
from models.user import User
__all__ = ["Article", "Author", "Base", "Category", "Item", "User", "slugify"]
__all__ = ["Article", "Author", "Base", "Category", "User", "slugify"]
-43
View File
@@ -1,43 +0,0 @@
"""Item model: a news story managed through the admin area.
Unlike ``Article`` (long-form pieces filed under an author and category),
an ``Item`` is a lightweight news entry — headline, optional external URL,
community points and an optional HTML body — created and maintained by
administrators through the admin API (see ``api.v1.admin``).
"""
from __future__ import annotations
from datetime import datetime, timezone
from sqlalchemy import DateTime, Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column
from models.base import Base
def _utcnow() -> datetime:
return datetime.now(timezone.utc)
class Item(Base):
"""A news item (story) listed on the front page and managed by admins.
``username`` stores the (denormalized) name of the user the item
belongs to, defaulting to the account that created it.
"""
__tablename__ = "items"
id: Mapped[int] = mapped_column(primary_key=True)
title: Mapped[str] = mapped_column(String(300), nullable=False, index=True)
url: Mapped[str] = mapped_column(String(500), default="", nullable=False)
points: Mapped[int] = mapped_column(Integer, default=0, nullable=False)
username: Mapped[str] = mapped_column(String(60), default="anonymous", nullable=False)
content: Mapped[str] = mapped_column(Text, default="", nullable=False)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), default=_utcnow, nullable=False
)
def __repr__(self) -> str: # pragma: no cover
return f"<Item id={self.id} title={self.title!r}>"