Class: Decidim::Plans::Admin::BudgetsExportsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/decidim/plans/admin/budgets_exports_controller.rb', line 13

def create
  enforce_permission_to :export_budgets, :plans

  @form = form(Admin::PlanExportBudgetsForm).from_params(params)
  Admin::ExportPlansToBudgets.call(@form) do
    on(:ok) do |projects|
      flash[:notice] = I18n.t("budgets_exports.create.success", scope: "decidim.plans.admin", number: projects.length)
      redirect_to EngineRouter.admin_proxy(current_component).root_path
    end

    on(:invalid) do
      flash[:alert] = I18n.t("budgets_exports.create.invalid", scope: "decidim.plans.admin")
      render action: "new"
    end
  end
end

#newObject



7
8
9
10
11
# File 'app/controllers/decidim/plans/admin/budgets_exports_controller.rb', line 7

def new
  enforce_permission_to :export_budgets, :plans

  @form = form(Admin::PlanExportBudgetsForm).instance
end