Class: Decidim::Lausanne::Budgets::Admin::ProposalsImportsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/decidim/lausanne/budgets/admin/proposals_imports_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#project, #projects

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/decidim/lausanne/budgets/admin/proposals_imports_controller.rb', line 17

def create
  enforce_permission_to :import_proposals, :projects

  @form = form(Admin::ProjectImportProposalsForm).from_params(params, budget: budget)
  Admin::ImportProposalsToBudgets.call(@form) do
    on(:ok) do |projects|
      flash[:notice] = I18n.t("proposals_imports.create.success", scope: "decidim.lausanne_budgets.admin", number: projects.length)
      redirect_to lausanne_budget_projects_path(lausanne_budget: budget)
    end

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

#newObject



10
11
12
13
14
15
# File 'app/controllers/decidim/lausanne/budgets/admin/proposals_imports_controller.rb', line 10

def new
  enforce_permission_to :import_proposals, :projects

  @form = form(Admin::ProjectImportProposalsForm).instance
  @form.context.budget = budget
end