feat: add is_public + page_note_id FK to projects table #29
No reviewers
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/pal-e-api!29
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "schema-phase1-project-fk"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
is_publicandpage_note_idFK to projects table, making project visibility and page relationships explicit in the schemaChanges
src/pal_e_docs/models.py: Addis_public(Boolean, default True) +page_note_id(FK to notes.id, nullable, UNIQUE, ON DELETE RESTRICT) +page_noterelationship (lazy="joined")src/pal_e_docs/schemas.py: Addis_publicandpage_note_slugto ProjectCreate/ProjectUpdate,PageNoteInfonested schema, update ProjectOutsrc/pal_e_docs/routes/frontend.py:_apply_project_public_filter()helper, project filtering on landing + browse, login redirect for private projects, removedis_publicfilter on linked notessrc/pal_e_docs/routes/projects.py:_resolve_page_note_id()helper for slug-to-FK resolution with uniqueness checksrc/pal_e_docs/routes/notes.py: Fixed ambiguous FK join inlist_notes, 409 on RESTRICT deletesrc/pal_e_docs/templates/landing.html: PRIVATE badge for private projectssrc/pal_e_docs/templates/projects.html: PRIVATE badge for private projectssrc/pal_e_docs/templates/project_notes.html: PRIVATE badge in project headingalembic/versions/c3d4e5f6a7b8_*.py: Migration + data migration (auto-link project pages, set Private to is_public=false)tests/test_project_schema.py: 22 new tests covering filtering, FK constraints, data migrationtests/test_auth.py: Updated linked notes tests (titles now visible)tests/conftest.py: FK-safe teardown (disable FK checks during drop_all)Test Plan
Review Checklist
Related Notes
issue-pal-e-docs-project-is-public— the issue this PR addressesplan-2026-02-26-schema-entity-links— Phase 1 of the schema entity links planplan-2026-02-25-private-notes-auth— predecessor plan (auth system)Schema Phase 1: Add two columns to the projects table with full API, browse frontend, and test coverage. is_public (Boolean, default True): - Filter private projects from landing/browse pages for unauthenticated users - Redirect to login when unauthenticated user accesses private project URL - Show "PRIVATE" badge on private projects for authenticated users page_note_id (FK to notes.id, nullable, UNIQUE, ON DELETE RESTRICT): - Links a project to its page note via foreign key - API accepts page_note_slug for create/update, resolves to FK - ProjectOut schema includes nested PageNoteInfo - Uniqueness enforced: one note per project Additional changes: - Alembic migration with data migration (auto-links project-{slug} notes, sets private project is_public=false) - Remove is_public filter on linked notes (titles visible, click redirects) - Handle IntegrityError on note delete (409 instead of unhandled 500) - Fix ambiguous FK join in notes list-by-project query - Fix circular FK teardown in test conftest Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>Review: PASS
Reviewer: Betty Sue (main session)
What was checked:
is_public+page_note_idFK with UNIQUE + ON DELETE RESTRICT. Properforeign_keysdisambiguation for circular FK between projects/notes.lazy="joined"for eager loading.PageNoteInfonested schema returns id/title/slug (not full content).page_note_slugas API input resolved to FK internally — clean API surface._apply_project_public_filter()mirrors existing note pattern. Login redirect follows same pattern as private notes. Linked notesis_publicfilter removed._resolve_page_note_id()handles slug-to-FK with uniqueness check. Update correctly distinguishes "not provided" from "explicitly null" viamodel_fields_set.project-{slug}notes and sets Privateis_public=false. Proper downgrade. Revision chain verified:b2c3d4e5f6a7→c3d4e5f6a7b8.No issues found.
Ready for merge pending Lucas's approval.