mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-05 03:41:24 +08:00
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 |
||
|---|---|---|
| .. | ||
| votes_controller.rb | ||