app/controllers/decidim/admin/participatory_processes_controller.rb in decidim-admin-0.0.1.alpha9 vs app/controllers/decidim/admin/participatory_processes_controller.rb in decidim-admin-0.0.1
- old
+ new
@@ -4,25 +4,28 @@
module Decidim
module Admin
# Controller that allows managing all the Admins.
#
class ParticipatoryProcessesController < ApplicationController
+ helper_method :participatory_process
+ layout "decidim/admin/participatory_process", only: [:show, :edit]
+
def index
authorize! :index, Decidim::ParticipatoryProcess
@participatory_processes = collection
end
def new
authorize! :new, Decidim::ParticipatoryProcess
- @form = ParticipatoryProcessForm.new
+ @form = form(ParticipatoryProcessForm).instance
end
def create
authorize! :new, Decidim::ParticipatoryProcess
- @form = ParticipatoryProcessForm.from_params(params)
+ @form = form(ParticipatoryProcessForm).from_params(params)
- CreateParticipatoryProcess.call(@form, current_organization) do
+ CreateParticipatoryProcess.call(@form) do
on(:ok) do
flash[:notice] = I18n.t("participatory_processes.create.success", scope: "decidim.admin")
redirect_to participatory_processes_path
end
@@ -34,17 +37,17 @@
end
def edit
@participatory_process = collection.find(params[:id])
authorize! :update, @participatory_process
- @form = ParticipatoryProcessForm.from_model(@participatory_process)
+ @form = form(ParticipatoryProcessForm).from_model(@participatory_process)
end
def update
@participatory_process = collection.find(params[:id])
authorize! :update, @participatory_process
- @form = ParticipatoryProcessForm.from_params(params)
+ @form = form(ParticipatoryProcessForm).from_params(params)
UpdateParticipatoryProcess.call(@participatory_process, @form) do
on(:ok) do
flash[:notice] = I18n.t("participatory_processes.update.success", scope: "decidim.admin")
redirect_to participatory_processes_path
@@ -72,11 +75,13 @@
redirect_to participatory_processes_path
end
private
+ attr_reader :participatory_process
+
def collection
- current_organization.participatory_processes
+ @collection ||= ManageableParticipatoryProcessesForUser.for(current_user)
end
end
end
end