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/elections/admin/steps_controller.rb', line 21
def update
enforce_permission_to(: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
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 |message|
flash.now[:alert] = message || I18n.t("steps.#{current_step}.invalid", scope: "decidim.elections.admin")
end
end
render :index
end
|