Class: Decidim::Proposals::Admin::ProposalsMergesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/decidim/proposals/admin/proposals_merges_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/decidim/proposals/admin/proposals_merges_controller.rb', line 7

def create
  enforce_permission_to :merge, :proposals

  @form = form(Admin::ProposalsMergeForm).from_params(params)

  Admin::MergeProposals.call(@form) do
    on(:ok) do |_proposal|
      flash[:notice] = I18n.t("proposals_merges.create.success", scope: "decidim.proposals.admin")
      redirect_to EngineRouter.admin_proxy(@form.target_component).root_path
    end

    on(:invalid) do
      flash[:alert_html] = Decidim::ValidationErrorsPresenter.new(
        I18n.t("proposals_merges.create.invalid", scope: "decidim.proposals.admin"),
        @form
      ).message
      redirect_to EngineRouter.admin_proxy(current_component).root_path
    end
  end
end