[loggi-6ye] DRY entry lookup + access check boilerplate in routes.py #123
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Bead ID:
loggi-6yeType: task
Priority: P2
Status: closed
Close reason: Extracted _require_entry() helper in routes.py. Refactored 8 API endpoints (entry_detail, entry_records, entry_active_record, record_detail, share_entry, list_shares, manage_share, create_pin) to use it. Supports min_role parameter for admin-only and write-only access checks. All 174 tests pass, Docker build and smoke test confirmed.
routes.py repeats a 4-line entry-lookup + access-check pattern in 8 API endpoints:
Extract a
_get_entry_or_error(entry_id)helper that returns(entry, role)or a JSON error response. This reduces ~32 lines of boilerplate and makes endpoints more readable. The helper should be usable from routes.py (and optionally export.py which has the same pattern once).Variants to handle:
Previously identified in code-health-final.md item #4, deferred from loggi-6e4.