Class: Decidim::Consultations::QuestionMultipleVotesController

Inherits:
ApplicationController show all
Includes:
NeedsQuestion, FormFactory
Defined in:
decidim-consultations/app/controllers/decidim/consultations/question_multiple_votes_controller.rb

Instance Method Summary collapse

Methods included from NeedsQuestion

enhance_controller, extended, included

Methods included from RegistersPermissions

register_permissions

Methods included from UserBlockedChecker

#check_user_block_status, #check_user_not_blocked

Methods included from NeedsSnippets

#snippets

Methods included from HttpCachingDisabler

#disable_http_caching

Methods included from HasStoredPath

#skip_store_location?, #store_current_location

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#createObject


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'decidim-consultations/app/controllers/decidim/consultations/question_multiple_votes_controller.rb', line 20

def create
  enforce_permission_to :vote, :question, question: current_question

  multivote_form = form(MultiVoteForm).from_params(params, current_question: current_question)

  MultipleVoteQuestion.call(multivote_form, current_user) do
    on(:ok) do
      redirect_to question_path(current_question)
    end

    on(:invalid) do |_form, error|
      flash[:error] = I18n.t("question_votes.create.error", scope: "decidim.consultations")
      flash[:error] << " (#{error})" if error
      redirect_to question_question_multiple_votes_path
    end
  end
end

#showObject

Non-ajax votings (such as multi-reponses) have a html page


15
16
17
18
# File 'decidim-consultations/app/controllers/decidim/consultations/question_multiple_votes_controller.rb', line 15

def show
  enforce_permission_to :vote, :question, question: current_question
  @form = form(MultiVoteForm).instance(current_question: current_question)
end