fix(engine): wire notes into post and page rendering (#59)#72
Merged
Conversation
Fetch notes from NotesService in post and page routers instead of hardcoding empty list. Public notes visible to all users, private notes only to admins. Extract shared is_admin helper to dependencies.py. Closes #59 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Test correct path format, admin vs anonymous visibility, notes passed to templates, and empty notes rendering for both post and page routers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Wires database-backed notes into post and static page rendering so templates receive the correct notes list, with private notes gated to admins.
Changes:
- Fetch notes via
NotesService.get_for_path()inget_postandget_pageinstead of hardcoding[]. - Add DB session injection to post/page render routes to support notes queries.
- Extract
is_adminhelper todependencies.pyand update tests to match.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/squishmark/routers/posts.py |
Injects DB session and fetches notes for /posts/{slug} during post rendering. |
src/squishmark/routers/pages.py |
Injects DB session and fetches notes for /{slug} during page rendering. |
src/squishmark/dependencies.py |
Introduces shared is_admin(request) helper. |
tests/test_posts.py |
Updates admin-detection tests to import/patch the moved is_admin. |
tests/test_notes_rendering.py |
Adds coverage asserting notes are fetched and passed to theme rendering for posts/pages. |
tests/test_nav_pages.py |
Updates router tests to account for new DB/notes dependencies. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NotesService.get_for_path()in post and page routers instead of hardcoding[]is_adminhelper fromposts.pytodependencies.pyto avoid duplicationNotesServicedependencyCloses #59
Test plan
python scripts/run-checks.py— 4/4 checks pass (format, lint, 137 tests, pyright)🤖 Generated with Claude Code