feat(comments): v2 — HTMX, Turnstile, reactions, design refresh #44
Reference in New Issue
Block a user
Delete Branch "feature/comments-v2"
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
Implements Comments System v2 as specified in #43, incorporating all review feedback.
What changed
HTMX Progressive Enhancement
?after_id=Nprevents duplicates)Vary: HX-Requestheader on all HTMX-capable endpointshtmx.min.jsv2.0.4 (no CDN, minimal CSP surface)Cloudflare Turnstile
is_approved=FalseTURNSTILE_SECRET_KEYis unsetsecret/shared/cloudflare-turnstyleComment Reactions
CommentReactionmodel withUniqueConstraint(session-based dedup)get_or_create+IntegrityErrorhandlingDesign Refresh
shadow-neon-cyan), solid hover shadows on comment cardsborder-l-2 border-l-brand-cyanon reply indentationfocus:shadow-neon-pinkglow on form inputsbg-grid-patternempty state_comment.html,_comment_form.html,_comment_list.html,_reply_form.html,_reactions.html,_comment_success.htmlModeration & Admin
challenges.cloudflare.comadded to script-src, connect-src, frame-srcCommentReaction.session_keyTests
18 new tests covering:
All 150 tests pass, 95% coverage.
Deployment notes
manage.py migratefor the newCommentReactiontableTURNSTILE_SITE_KEY,TURNSTILE_SECRET_KEY, optionalTURNSTILE_EXPECTED_HOSTNAMEsecret/shared/cloudflare-turnstyleCloses #43
Requesting changes — I found several blocking correctness issues:
Please address these before merge; I’m happy to re-review quickly after an update.
Follow-up with precise blocking findings (to avoid formatting loss):
These are merge blockers for correctness. Happy to re-review once addressed.
Re-review result: requesting changes.
I rechecked the previously reported five blockers; those specific items were addressed, but I found two new blocking correctness issues:
Net effect on invalid input:
Net effect:
Please fix these before merge, then I can re-review quickly.
Re-review result: requesting changes.
Most of the previous blockers are fixed, but I found one remaining correctness issue that can still produce broken HTMX behavior (and potentially a 500 on crafted input):
_render_htmx_errortrusts rawparent_idfromrequest.POST.Comment.objects.filter(pk=parent_id, article=article).first()using unvalidated POST data.parent_idmay be non-numeric/tampered. This can raise lookup conversion errors for integer PKs, or returnNoneand render_reply_form.htmlwith an emptycomment.idtarget.Why this is blocking:
Suggested fix:
_render_htmx_error, parse/validateparent_iddefensively (int coercion with fallback), and if parent is missing/invalid, return the top-level_comment_form.htmlerror response instead of reply-form partial.Also: the PR status currently still shows
CI / cifailing, so merge readiness is not yet proven.Re-review complete. The prior blocker around HTMX error-path handling is now fixed (defensive coercion + safe fallback), and the additional regression test coverage is in place. I don’t see remaining blocking issues in this round. LGTM.