Module: Decidim::Elections::HasVoteFlow
- Extended by:
- ActiveSupport::Concern
- Included in:
- ElectionVoteCtaCell, 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
- #ballot_questions ⇒ Object
- #can_preview? ⇒ Boolean
- #default_vote_flow ⇒ Object
- #preview_mode? ⇒ Boolean
- #vote_flow ⇒ Object
Instance Method Details
#ballot_questions ⇒ Object
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
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:) end |
#default_vote_flow ⇒ Object
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:) end end |
#preview_mode? ⇒ 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_flow ⇒ Object
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 |