Class: Decidim::Admin::ImportsController
- Inherits:
-
ApplicationController
- Object
- DecidimController
- ApplicationController
- Decidim::Admin::ImportsController
- Includes:
- ComponentPathHelper
- Defined in:
- app/controllers/decidim/admin/imports_controller.rb
Overview
This controller allows admins to import resources from a file.
Instance Method Summary collapse
Methods inherited from ApplicationController
#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/decidim/admin/imports_controller.rb', line 21 def create :import, :component_data, component: current_component @form = form(Admin::ImportForm).from_params( params, current_component: current_component, current_organization: current_organization ) CreateImport.call(@form) do on(:ok) do |imported_data| flash[:notice] = t("decidim.admin.imports.notice", number: imported_data.length, resource_name: imported_data.first.resource_manifest.name.pluralize) redirect_to manage_component_path(current_component) end on(:invalid) do flash.now[:alert] = t("decidim.admin.imports.error") render :new end end end |
#new ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/decidim/admin/imports_controller.rb', line 9 def new :import, :component_data, component: current_component @form = form(Admin::ImportForm).from_params( { # We need to set "default" creator because form-class doesn't have context / current_component # when it sets it's default values. creator: current_component.manifest.import_manifests.first.creator }, current_component: current_component ) end |