Sha256: 79b01f6c4d999537a745d61b5c4c6bf32dd48621d6380e4e9daf55cb2e2cfc77

Contents?: true

Size: 1.59 KB

Versions: 47

Compression:

Stored size: 1.59 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

        helper Proposals::ApplicationHelper
        helper Decidim::Proposals::Admin::ProposalsHelper
        helper Decidim::Proposals::Admin::ProposalRankingsHelper
        helper Decidim::Messaging::ConversationHelper

        def edit
          enforce_permission_to :create, :proposal_answer, proposal: proposal
          @form = form(Admin::ProposalAnswerForm).from_model(proposal)
        end

        def update
          enforce_permission_to :create, :proposal_answer, proposal: proposal
          @notes_form = form(ProposalNoteForm).instance
          @answer_form = form(Admin::ProposalAnswerForm).from_params(params)

          Admin::AnswerProposal.call(@answer_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.keep[:alert] = I18n.t("proposals.answer.invalid", scope: "decidim.proposals.admin")
              render template: "decidim/proposals/admin/proposals/show"
            end
          end
        end

        private

        def skip_manage_component_permission
          true
        end

        def proposal
          @proposal ||= Proposal.where(component: current_component).find(params[:id])
        end
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
decidim-proposals-0.27.9 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.27.8 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.27.7 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.27.6 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.26.10 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.26.9 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.27.5 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.26.8 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.27.4 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.27.3 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.26.7 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.26.5 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.27.2 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.27.1 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.26.4 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.27.0 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.26.3 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.27.0.rc2 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.27.0.rc1 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb
decidim-proposals-0.26.2 app/controllers/decidim/proposals/admin/proposal_answers_controller.rb