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