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

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#project, #projects

Methods inherited from Admin::Components::BaseController

#current_component, #current_participatory_space, #parent_path, #permission_class_chain, #permission_scope, #permissions_context, #skip_manage_component_permission

Methods included from RegistersPermissions

register_permissions

Methods inherited from Admin::ApplicationController

#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path

Methods included from HttpCachingDisabler

#disable_http_caching

Methods included from NeedsSnippets

#snippets

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#createObject


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

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.budgets.admin", number: projects.length)
      redirect_to budget_projects_path(budget)
    end

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

#newObject


9
10
11
12
13
# File 'decidim-budgets/app/controllers/decidim/budgets/admin/proposals_imports_controller.rb', line 9

def new
  enforce_permission_to :import_proposals, :projects

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