Sha256: ac618ee4878f838bd61ab2266a44976f36785dde2c1c06843ee408c7ac22a321

Contents?: true

Size: 1.15 KB

Versions: 47

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

module Decidim
  module Proposals
    module Admin
      # This controller allows admins to make private notes on proposals in a participatory process.
      class ProposalNotesController < Admin::ApplicationController
        helper_method :proposal

        def create
          enforce_permission_to :create, :proposal_note, proposal: proposal
          @form = form(ProposalNoteForm).from_params(params)

          CreateProposalNote.call(@form, proposal) do
            on(:ok) do
              flash[:notice] = I18n.t("proposal_notes.create.success", scope: "decidim.proposals.admin")
              redirect_to proposal_path(id: proposal.id)
            end

            on(:invalid) do
              flash.keep[:alert] = I18n.t("proposal_notes.create.error", scope: "decidim.proposals.admin")
              redirect_to proposal_path(id: proposal.id)
            end
          end
        end

        private

        def skip_manage_component_permission
          true
        end

        def proposal
          @proposal ||= Proposal.where(component: current_component).find(params[:proposal_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_notes_controller.rb
decidim-proposals-0.27.8 app/controllers/decidim/proposals/admin/proposal_notes_controller.rb
decidim-proposals-0.27.7 app/controllers/decidim/proposals/admin/proposal_notes_controller.rb
decidim-proposals-0.27.6 app/controllers/decidim/proposals/admin/proposal_notes_controller.rb
decidim-proposals-0.26.10 app/controllers/decidim/proposals/admin/proposal_notes_controller.rb
decidim-proposals-0.26.9 app/controllers/decidim/proposals/admin/proposal_notes_controller.rb
decidim-proposals-0.27.5 app/controllers/decidim/proposals/admin/proposal_notes_controller.rb
decidim-proposals-0.26.8 app/controllers/decidim/proposals/admin/proposal_notes_controller.rb
decidim-proposals-0.27.4 app/controllers/decidim/proposals/admin/proposal_notes_controller.rb
decidim-proposals-0.27.3 app/controllers/decidim/proposals/admin/proposal_notes_controller.rb
decidim-proposals-0.26.7 app/controllers/decidim/proposals/admin/proposal_notes_controller.rb
decidim-proposals-0.26.5 app/controllers/decidim/proposals/admin/proposal_notes_controller.rb
decidim-proposals-0.27.2 app/controllers/decidim/proposals/admin/proposal_notes_controller.rb
decidim-proposals-0.27.1 app/controllers/decidim/proposals/admin/proposal_notes_controller.rb
decidim-proposals-0.26.4 app/controllers/decidim/proposals/admin/proposal_notes_controller.rb
decidim-proposals-0.27.0 app/controllers/decidim/proposals/admin/proposal_notes_controller.rb
decidim-proposals-0.26.3 app/controllers/decidim/proposals/admin/proposal_notes_controller.rb
decidim-proposals-0.27.0.rc2 app/controllers/decidim/proposals/admin/proposal_notes_controller.rb
decidim-proposals-0.27.0.rc1 app/controllers/decidim/proposals/admin/proposal_notes_controller.rb
decidim-proposals-0.26.2 app/controllers/decidim/proposals/admin/proposal_notes_controller.rb