Exclude open-ended questions from managing physical votes

Also make the :yes_no factory trait create a votation_type_unique
by default, since yes/no questions should always be unique.
This commit is contained in:
taitus
2025-08-22 14:26:25 +02:00
parent f3050a1aa5
commit b1cb6f8372
10 changed files with 55 additions and 5 deletions

View File

@@ -8,7 +8,7 @@
</div>
</div>
<% poll.questions.each do |question| %>
<% poll.questions.for_physical_votes.each do |question| %>
<fieldset class="row">
<legend class="column"><%= question.title %></legend>
<% question.question_options.each_with_index do |option, i| %>

View File

@@ -29,7 +29,7 @@
</tbody>
</table>
<% @poll.questions.each do |question| %>
<% @poll.questions.for_physical_votes.each do |question| %>
<%= render Admin::Poll::Results::QuestionComponent.new(question, @partial_results) %>
<% end %>
</div>

View File

@@ -31,6 +31,7 @@ class Poll::Question < ApplicationRecord
scope :sort_for_list, -> { order(Arel.sql("poll_questions.proposal_id IS NULL"), :created_at) }
scope :for_render, -> { includes(:author, :proposal) }
scope :for_physical_votes, -> { left_joins(:votation_type).merge(VotationType.accepts_options) }
def copy_attributes_from_proposal(proposal)
if proposal.present?

View File

@@ -11,6 +11,8 @@ class VotationType < ApplicationRecord
validates :questionable_type, inclusion: { in: ->(*) { QUESTIONABLE_TYPES }}
validates :max_votes, presence: true, if: :max_votes_required?
scope :accepts_options, -> { where.not(vote_type: "open") }
def accepts_options?
!open?
end