Module: Decidim::Elections::HasVoteFlow

Extended by:
ActiveSupport::Concern
Included in:
ElectionsController, FeedbacksController, VotesController, Votings::PollingOfficerZone::InPersonVotesController, Votings::VotingsController
Defined in:
decidim-elections/app/controllers/concerns/decidim/elections/has_vote_flow.rb

Overview

Common logic for the vote flow

Instance Method Summary collapse

Instance Method Details

#ballot_questionsObject


38
39
40
# File 'decidim-elections/app/controllers/concerns/decidim/elections/has_vote_flow.rb', line 38

def ballot_questions
  vote_flow.questions_for(election)
end

#can_preview?Boolean

Returns:

  • (Boolean)

32
33
34
35
36
# File 'decidim-elections/app/controllers/concerns/decidim/elections/has_vote_flow.rb', line 32

def can_preview?
  return @can_preview if defined?(@can_preview)

  @preview_mode = allowed_to?(:preview, :election, election: election)
end

#default_vote_flowObject


20
21
22
23
24
# File 'decidim-elections/app/controllers/concerns/decidim/elections/has_vote_flow.rb', line 20

def default_vote_flow
  Decidim::Elections::CurrentUserVoteFlow.new(election, current_user) do
    allowed_to?(:user_vote, :election, election: election)
  end
end

#preview_mode?Boolean

Returns:

  • (Boolean)

26
27
28
29
30
# File 'decidim-elections/app/controllers/concerns/decidim/elections/has_vote_flow.rb', line 26

def preview_mode?
  return @preview_mode if defined?(@preview_mode)

  @preview_mode = !election.published? || !election.started?
end

#vote_flowObject


16
17
18
# File 'decidim-elections/app/controllers/concerns/decidim/elections/has_vote_flow.rb', line 16

def vote_flow
  @vote_flow ||= election.participatory_space.try(:vote_flow_for, election) || default_vote_flow
end