Sha256: dedc27b47bf90d06f75e848a2f9bebf14537455f930ffa65e58b111e4835fcf7

Contents?: true

Size: 1.12 KB

Versions: 54

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module Decidim
  module Proposals
    module Admin
      # This controller allows admins to answer proposals in a participatory process.
      class ProposalAnswersController < Admin::ApplicationController
        helper_method :proposal

        def edit
          authorize! :update, proposal
          @form = form(Admin::ProposalAnswerForm).from_model(proposal)
        end

        def update
          authorize! :update, proposal
          @form = form(Admin::ProposalAnswerForm).from_params(params)

          Admin::AnswerProposal.call(@form, proposal) do
            on(:ok) do
              flash[:notice] = I18n.t("proposals.answer.success", scope: "decidim.proposals.admin")
              redirect_to proposals_path
            end

            on(:invalid) do
              flash.now[:alert] = I18n.t("proposals.answer.invalid", scope: "decidim.proposals.admin")
              render action: "edit"
            end
          end
        end

        private

        def proposal
          @proposals ||= Proposal.where(feature: current_feature).find(params[:id])
        end
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 2 rubygems

Version Path
decidim-proposals-0.9.3 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.9.2 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.9.1 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.9.0 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.8.4 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.8.3 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.8.2 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.8.1 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.8.0 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.7.4 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.7.3 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.7.2 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.7.1 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.7.0 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.6.8 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-0.6.8 decidim-proposals/app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.6.7 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-0.6.7 decidim-proposals/app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.6.6 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-0.6.6 decidim-proposals/app/controllers/decidim/proposals/admin/proposal_answers_controller.rb