Class: Decidim::Elections::Admin::StepsController
- Inherits:
-
ApplicationController
- Object
- DecidimController
- Admin::ApplicationController
- Admin::Components::BaseController
- ApplicationController
- Decidim::Elections::Admin::StepsController
- Defined in:
- decidim-elections/app/controllers/decidim/elections/admin/steps_controller.rb
Overview
This controller allows to manage the steps of an election.
Instance Method Summary collapse
Methods inherited from Admin::Components::BaseController
#current_component, #current_participatory_space, #parent_path, #permission_class_chain, #permission_scope, #permissions_context, #set_component_breadcrumb_item, #skip_manage_component_permission
Methods included from RegistersPermissions
Methods inherited from Admin::ApplicationController
#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path
Methods included from Headers::HttpCachingDisabler
Methods included from NeedsSnippets
Methods included from NeedsOrganization
enhance_controller, extended, included
Instance Method Details
#index ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'decidim-elections/app/controllers/decidim/elections/admin/steps_controller.rb', line 12 def index (:read, :steps, election:) if current_step_form_class @form = form(current_step_form_class).instance(election:) @form.valid? end end |
#stats ⇒ Object
45 46 47 |
# File 'decidim-elections/app/controllers/decidim/elections/admin/steps_controller.rb', line 45 def stats render "decidim/elections/admin/steps/_vote_stats", layout: false end |
#update ⇒ 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 'decidim-elections/app/controllers/decidim/elections/admin/steps_controller.rb', line 21 def update (:update, :steps, election:) redirect_to election_steps_path(election) && return unless params[:id] == current_step @form = form(current_step_form_class).from_params(params, election:) Decidim::Elections::Admin::UpdateActionStatus.call(@form.pending_action) if @form.pending_action # check pending action status mode return render json: { status: @form.pending_action&.status } if params[:check_pending_action] return redirect_to election_steps_path(election) if @form.pending_action current_step_command_class.call(@form) do on(:ok) do flash[:notice] = I18n.t("steps.#{current_step}.success", scope: "decidim.elections.admin") return redirect_to election_steps_path(election) end on(:invalid) do || flash.now[:alert] = || I18n.t("steps.#{current_step}.invalid", scope: "decidim.elections.admin") end end render :index end |