discourse/plugins/discourse-topic-voting/app/controllers/discourse_topic_voting
Régis Hanol 224ac3145f
FEATURE: Add setting to disable vote limits in topic voting (#38823)
TL-based vote limits add complexity to category setup and may discourage
users from voting at all. Currently, setting a limit to 0 means "no
votes allowed" rather than "unlimited", forcing admins to use
workarounds like setting limits to 999.

Add a `topic_voting_enable_vote_limits` boolean setting (default: true)
that acts as a master toggle for all vote limits.

When disabled:
- Users can cast unlimited votes
- `vote_limit` and `votes_left` return nil throughout the stack
- The 6 dependent settings (TL0-TL4 limits + alert threshold) are hidden
in the admin UI via `depends_on`/`depends_behavior`
- The frontend hides "X/Y votes left" and shows "See your votes"

Backend: centralize limit logic in UserExtension (`can_vote?`,
`votes_left`, `vote_limit`) so the serializer and controller delegate
directly without conditionals. Extract duplicated response hash in
VotesController into `voting_response` helper.

Frontend: add `@tracked vote_limit` on the user model so `limitsEnabled`
reacts to AJAX responses. Sync `vote_limit` from server on vote/unvote.

Re-enabling limits after disabling is safe: users keep existing votes
but cannot add more until under their TL limit.

Ref - t/180367
2026-03-26 10:03:11 +01:00
..
votes_controller.rb FEATURE: Add setting to disable vote limits in topic voting (#38823) 2026-03-26 10:03:11 +01:00