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:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user