Fix #114: Add API support for vote value 0 to allow vote retraction #128
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "typosaurus/ticket-114"
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?
Resolves #114.
Plan
Implementation Plan: Add Vote Value 0 for Retraction
Objective
Enable the
POST /votes/{target_type}/{target_uid}endpoint to accept{"value": 0}as a valid request, allowing clients to retract a vote in a single call. The core logic (apply_vote) already handlesvalue=0; only the Pydantic validator blocks it.Changes Required
devplacepy/models.py:442(1, -1)to(-1, 0, 1)(order irrelevant)0.devplacepy/services/devii/actions/catalog/engagement.py:25-28valueparameter description to include0for retraction (e.g.,"Vote value: 1 to upvote, -1 to downvote, 0 to retract.")tests/api/votes.pytest_explicit_zero_retracts_votethat:1. Inserts an upvote (value=1).
2. Sends
{"value": 0}.3. Validates the response has
"value": 0and"net": 0(or unchanged from initial).4. Optionally verifies the row is soft-deleted or updated correctly.
value=0has no test coverage. Adding one ensures the new path is exercised.Do not modify any other files. No database, content logic, template, or documentation changes are required.
Execution Steps (for a competent engineer)
git checkout -b vote-zero-retractionoffmainordevelop).Do not attempt to rebase onto a branch that has unresolved conflicts.
sed.test_owns_instance_true_for_creatorfailure observed in earlier attempts is not caused by these changes (no file touched affectscontent.py). If that test fails, it indicates a pre-existing issue in the base branch or environment; the engineer should flag it but not consider it a blocker for this change unless it is newly introduced. (Verification of this commit on a clean base should produce a clean run.)Allow vote value 0 for retractionand push.Definition of Done
devplacepy/models.py:442accepts value0in addition to1and-1.devplacepy/services/devii/actions/catalog/engagement.py:25mentions0as a valid vote value for retraction.test_explicit_zero_retracts_voteexists intests/api/votes.pyand passes.ruff check .passes with no new violations.make test-unitpasses (all tests green, ignoring any pre-existing failures unrelated to this change).Opened automatically by Typosaurus.
Checkout
From your project repository, check out a new branch and test the changes.