Sha256: ead20f1f75fb7d465c94f988e5d4f16277ec748055562d1d714b65ceb536ef3c

Contents?: true

Size: 1 KB

Versions: 20

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

module Decidim
  module Budgets
    module Admin
      class ProposalsImportsController < Admin::ApplicationController
        def new
          enforce_permission_to :import_proposals, :projects

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

        def create
          enforce_permission_to :import_proposals, :projects

          @form = form(Admin::ProjectImportProposalsForm).from_params(params)
          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 EngineRouter.admin_proxy(current_component).root_path
            end

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
decidim-budgets-0.22.0 app/controllers/decidim/budgets/admin/proposals_imports_controller.rb
decidim-budgets-0.21.0 app/controllers/decidim/budgets/admin/proposals_imports_controller.rb
decidim-budgets-0.20.1 app/controllers/decidim/budgets/admin/proposals_imports_controller.rb
decidim-budgets-0.20.0 app/controllers/decidim/budgets/admin/proposals_imports_controller.rb
decidim-budgets-0.19.1 app/controllers/decidim/budgets/admin/proposals_imports_controller.rb
decidim-budgets-0.18.1 app/controllers/decidim/budgets/admin/proposals_imports_controller.rb
decidim-budgets-0.19.0 app/controllers/decidim/budgets/admin/proposals_imports_controller.rb
decidim-budgets-0.17.2 app/controllers/decidim/budgets/admin/proposals_imports_controller.rb
decidim-budgets-0.18.0 app/controllers/decidim/budgets/admin/proposals_imports_controller.rb
decidim-budgets-0.17.1 app/controllers/decidim/budgets/admin/proposals_imports_controller.rb
decidim-budgets-0.16.1 app/controllers/decidim/budgets/admin/proposals_imports_controller.rb
decidim-budgets-0.17.0 app/controllers/decidim/budgets/admin/proposals_imports_controller.rb
decidim-budgets-0.16.0 app/controllers/decidim/budgets/admin/proposals_imports_controller.rb
decidim-budgets-0.15.2 app/controllers/decidim/budgets/admin/proposals_imports_controller.rb
decidim-budgets-0.15.1 app/controllers/decidim/budgets/admin/proposals_imports_controller.rb
decidim-budgets-0.15.0 app/controllers/decidim/budgets/admin/proposals_imports_controller.rb
decidim-budgets-0.14.4 app/controllers/decidim/budgets/admin/proposals_imports_controller.rb
decidim-budgets-0.14.3 app/controllers/decidim/budgets/admin/proposals_imports_controller.rb
decidim-budgets-0.14.2 app/controllers/decidim/budgets/admin/proposals_imports_controller.rb
decidim-budgets-0.14.1 app/controllers/decidim/budgets/admin/proposals_imports_controller.rb