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:
29 files changed
+2465
-1658
No files matched your search
@@ -3,7 +3,7 @@
|
||||
import pytest
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
|
||||
from models import Article, Author, Category, Item, User, slugify
|
||||
from models import Article, Author, Category, User, slugify
|
||||
|
||||
|
||||
class TestAuthor:
|
||||
@@ -162,34 +162,3 @@ class TestArticle:
|
||||
with pytest.raises(IntegrityError):
|
||||
session.commit()
|
||||
session.rollback()
|
||||
|
||||
|
||||
class TestItem:
|
||||
def test_create_and_commit_defaults(self, session) -> None:
|
||||
item = Item(title="Breaking: things happen")
|
||||
session.add(item)
|
||||
session.commit()
|
||||
session.refresh(item)
|
||||
assert item.id is not None
|
||||
assert item.url == ""
|
||||
assert item.points == 0
|
||||
assert item.username == "anonymous"
|
||||
assert item.content == ""
|
||||
assert item.created_at is not None
|
||||
|
||||
def test_create_with_all_fields(self, session) -> None:
|
||||
item = Item(
|
||||
title="Show HN: a new tool",
|
||||
url="https://example.com/show-hn",
|
||||
points=42,
|
||||
username="alice",
|
||||
content="<p>Hello <strong>world</strong></p>",
|
||||
)
|
||||
session.add(item)
|
||||
session.commit()
|
||||
session.refresh(item)
|
||||
assert item.title == "Show HN: a new tool"
|
||||
assert item.url == "https://example.com/show-hn"
|
||||
assert item.points == 42
|
||||
assert item.username == "alice"
|
||||
assert item.content == "<p>Hello <strong>world</strong></p>"
|
||||
Reference in new issue
Block a user