Class: Decidim::Admin::ParticipatoryProcessesController
Overview
Controller that allows managing participatory processes.
Instance Method Summary
collapse
#current_ability_klass, #user_not_authorized_path
Instance Method Details
#copy ⇒ Object
76
77
78
|
# File 'app/controllers/decidim/admin/participatory_processes_controller.rb', line 76
def copy
authorize! :create, Decidim::ParticipatoryProcess
end
|
#create ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'app/controllers/decidim/admin/participatory_processes_controller.rb', line 23
def create
authorize! :new, Decidim::ParticipatoryProcess
@form = form(ParticipatoryProcessForm).from_params(params)
CreateParticipatoryProcess.call(@form) do
on(:ok) do |participatory_process|
flash[:notice] = I18n.t("participatory_processes.create.success", scope: "decidim.admin")
redirect_to participatory_process_steps_path(participatory_process)
end
on(:invalid) do
flash.now[:alert] = I18n.t("participatory_processes.create.error", scope: "decidim.admin")
render :new
end
end
end
|
#current_participatory_process ⇒ Object
80
81
82
|
# File 'app/controllers/decidim/admin/participatory_processes_controller.rb', line 80
def current_participatory_process
@current_participatory_process ||= collection.find(params[:id]) if params[:id]
end
|
#destroy ⇒ Object
67
68
69
70
71
72
73
74
|
# File 'app/controllers/decidim/admin/participatory_processes_controller.rb', line 67
def destroy
authorize! :destroy, current_participatory_process
current_participatory_process.destroy!
flash[:notice] = I18n.t("participatory_processes.destroy.success", scope: "decidim.admin")
redirect_to participatory_processes_path
end
|
#edit ⇒ Object
40
41
42
43
44
|
# File 'app/controllers/decidim/admin/participatory_processes_controller.rb', line 40
def edit
authorize! :update, current_participatory_process
@form = form(ParticipatoryProcessForm).from_model(current_participatory_process)
render layout: "decidim/admin/participatory_process"
end
|
#index ⇒ Object
13
14
15
16
|
# File 'app/controllers/decidim/admin/participatory_processes_controller.rb', line 13
def index
authorize! :index, Decidim::ParticipatoryProcess
@participatory_processes = collection
end
|
#new ⇒ Object
18
19
20
21
|
# File 'app/controllers/decidim/admin/participatory_processes_controller.rb', line 18
def new
authorize! :new, Decidim::ParticipatoryProcess
@form = form(ParticipatoryProcessForm).instance
end
|
#show ⇒ Object
63
64
65
|
# File 'app/controllers/decidim/admin/participatory_processes_controller.rb', line 63
def show
authorize! :read, current_participatory_process
end
|
#update ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'app/controllers/decidim/admin/participatory_processes_controller.rb', line 46
def update
authorize! :update, current_participatory_process
@form = form(ParticipatoryProcessForm).from_params(participatory_process_params)
UpdateParticipatoryProcess.call(current_participatory_process, @form) do
on(:ok) do |participatory_process|
flash[:notice] = I18n.t("participatory_processes.update.success", scope: "decidim.admin")
redirect_to edit_participatory_process_path(participatory_process)
end
on(:invalid) do
flash.now[:alert] = I18n.t("participatory_processes.update.error", scope: "decidim.admin")
render :edit, layout: "decidim/admin/participatory_process"
end
end
end
|