feat(surveys): anonymous mode, response delete, confirmation message - #1477
Open
leahpeker wants to merge 2 commits into
Open
feat(surveys): anonymous mode, response delete, confirmation message#1477leahpeker wants to merge 2 commits into
leahpeker wants to merge 2 commits into
Conversation
The anonymous flag stopped the user FK being written, but three paths still carried the responder's identity: - audit_log persisted actor + IP on every submit, so an anonymous response could be re-linked to its submitter by timestamp. Adds an anonymize_actor flag and uses it on survey_response_submitted. - the admin response list returned user_id/user_name for responses collected before a survey was flipped to anonymous. - poll tallies returned voter names/photos for the same pre-flip rows. Also fixes the delete-response mutation swallowing errors silently, and useUpdateSurvey dropping anonymous/confirmation_message from the PATCH body.
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
Closes #1466
Survey.anonymous: when true,submit_survey_responsestoresuser=Noneeven for authenticated submitters and skips the one-response-per-user upsert (nothing to key it on).get_survey_public/_survey_outno longer surfacemy_response_id/my_answersfor anonymous surveys.DELETE /surveys/{survey_id}/responses/{response_id}/, gated bymanage_surveys(403 without it, 404 if the response isn't in that survey). New_surveys_responses.pymodule (list + delete admin response endpoints) split out of_surveys.pyto stay under the repo's 500-line file limit. Frontend: a delete column onSurveyResponsesScreenusinguseConfirm, wired to a newuseDeleteSurveyResponsehook that invalidates the responses query.Survey.confirmation_message(optional, max 1000 chars): set via a new textarea inCreateSurveyDialog(alongside an "anonymous responses" checkbox), shown lowercased onSurveyScreenin place of the generic "saved ✓" after a successful submit.0095_survey_anonymous_confirmation_message.pyadds both fields toSurvey. Migration-number collisions with concurrently-open sibling survey PRs are expected and get resolved at merge time.Sibling PR #1461 is adding an anonymous-response token; once that lands it should take over identifying/deduping anonymous responses. This PR intentionally does not depend on it — anonymous mode here just means "store no user," per the issue's stated fallback ("otherwise is disabled").
Verification
Run manually this session (not as a final pre-push gate — see below):
rufflint andtytypecheck clean; targeted pytest (tests/test_surveys_public.py+ newtests/test_surveys_admin.py) — 13/13 passing, covering anonymous submit storing no user, one-per-user upsert being skipped for anonymous surveys,my_response_id/my_answersomitted for anonymous surveys, admin delete succeeding, 403 withoutmanage_surveys, and 404 for a response belonging to another survey.tsctypecheck clean,eslint+prettierclean, fullvitestsuite green (1287 passed / 1 skipped across 159 files), including two new tests covering the response-delete confirm flow and the post-submit confirmation message render.make frontend-typesre-run to regeneratetypes.gen.ts/openapi_schema.json/validationCodes.gen.tsafter the schema and router changes.Not run as a final gate before opening this PR: the full
make agent-ciumbrella and a full (non-scoped)make agent-testbackend run. The last full backend run (done earlier, before the final router split) showed 7 pre-existing failures unrelated to this change —test_sse.py(needspg_notify),test_poll_finalize_race.pyandtest_rsvp_capacity_race.py(need real Postgres row locking) — all documented in the Makefile as SQLite-vs-Postgres environmental gaps, not regressions from this branch. GitHub CI on this PR (which runs against Postgres) is the authoritative signal for final verification; please check it before merging.Test plan
manage_surveys, delete a single response fromSurveyResponsesScreenvia the confirm dialog and confirm it's removed