Sha256: 3e7d0846a53dfdd509c37f9d21db9c52649375a6a2461d08feb7f1786bf4991e
Contents?: true
Size: 1.43 KB
Versions: 8
Compression:
Stored size: 1.43 KB
Contents
# frozen_string_literal: true module Decidim module Elections # Exposes the elections resources so users can participate on them class VotesController < Decidim::Elections::ApplicationController layout "decidim/election_votes" include FormFactory helper VotesHelper helper_method :elections, :election, :questions, :questions_count, :booth_mode delegate :count, to: :questions, prefix: true def new redirect_to(return_path, alert: t("votes.messages.not_allowed", scope: "decidim.elections")) unless booth_mode end private def booth_mode @booth_mode ||= if allowed_to? :vote, :election, election: election :vote elsif allowed_to? :preview, :election, election: election :preview end end def return_path @return_path ||= if allowed_to? :view, :election, election: election election_path(election) else elections_path end end def elections @elections ||= Election.where(component: current_component) end def election @election ||= elections.find(params[:election_id]) end def questions @questions ||= election.questions.includes(:answers).order(weight: :asc, id: :asc) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems