Allow blank votes in polls via web

With the old interface, there wasn't a clear way to send a blank ballot.
But now that we've got a form, there's an easy way: clicking on "Vote"
while leaving the form blank.
This commit is contained in:
Javi Martín
2025-07-09 12:50:16 +02:00
parent cd134ed44f
commit 7ea4f63b07
13 changed files with 49 additions and 23 deletions

View File

@@ -23,6 +23,7 @@ class Poll < ApplicationRecord
has_many :officer_assignments, through: :booth_assignments
has_many :officers, through: :officer_assignments
has_many :questions, inverse_of: :poll, dependent: :destroy
has_many :answers, through: :questions
has_many :comments, as: :commentable, inverse_of: :commentable
has_many :ballot_sheets

View File

@@ -42,11 +42,11 @@ class Poll::Stats
end
def total_web_valid
voters.where(origin: "web").count - total_web_white
voters.where(origin: "web", user_id: poll.answers.select(:author_id).distinct).count
end
def total_web_white
0
voters.where(origin: "web").count - total_web_valid
end
def total_web_null

View File

@@ -14,10 +14,6 @@ class Poll::WebVote
all_valid = true
user.with_lock do
unless questions.any? { |question| params.dig(question.id.to_s, :option_id).present? }
Poll::Voter.find_by(user: user, poll: poll, origin: "web")&.destroy!
end
questions.each do |question|
question.answers.where(author: user).destroy_all
next unless params[question.id.to_s]