Class: Decidim::Accountability::Admin::ProjectsImportController
- Inherits:
-
ApplicationController
- Object
- Decidim::Admin::Components::BaseController
- ApplicationController
- Decidim::Accountability::Admin::ProjectsImportController
- Defined in:
- app/controllers/decidim/accountability/admin/projects_import_controller.rb
Overview
This controller allows an admin to import results from a csv file for the Accountability component
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/decidim/accountability/admin/projects_import_controller.rb', line 13 def create :create, :import_projects @form = form(Admin::ResultImportProjectsForm).from_params(params, accountability_component: current_component) Admin::ImportProjectsToAccountability.call(@form) do on(:ok) do |projects| flash[:notice] = I18n.t("projects_import.new.success", scope: "decidim.accountability.admin", count: projects) redirect_to results_path end on(:invalid) do flash[:alert] = I18n.t("projects_import.create.invalid", scope: "decidim.accountability.admin") render action: "new" end end end |
#new ⇒ Object
8 9 10 11 |
# File 'app/controllers/decidim/accountability/admin/projects_import_controller.rb', line 8 def new :create, :import_projects @form = form(Admin::ResultImportProjectsForm).instance end |