Class: Decidim::Results::Admin::ResultsController
Overview
This controller allows an admin to manage results from a Participatory Process
Instance Method Summary
collapse
#current_feature, #current_participatory_space, #parent_path
#current_ability_klass, #user_not_authorized_path
enhance_controller, extended, included
Instance Method Details
#create ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'decidim-results/app/controllers/decidim/results/admin/results_controller.rb', line 14
def create
@form = form(ResultForm).from_params(params)
CreateResult.call(@form) do
on(:ok) do
flash[:notice] = I18n.t("results.create.success", scope: "decidim.results.admin")
redirect_to results_path
end
on(:invalid) do
flash.now[:alert] = I18n.t("results.create.invalid", scope: "decidim.results.admin")
render action: "new"
end
end
end
|
#destroy ⇒ Object
50
51
52
53
54
55
56
|
# File 'decidim-results/app/controllers/decidim/results/admin/results_controller.rb', line 50
def destroy
result.destroy!
flash[:notice] = I18n.t("results.destroy.success", scope: "decidim.results.admin")
redirect_to results_path
end
|
#edit ⇒ Object
30
31
32
|
# File 'decidim-results/app/controllers/decidim/results/admin/results_controller.rb', line 30
def edit
@form = form(ResultForm).from_model(result)
end
|
#new ⇒ Object
10
11
12
|
# File 'decidim-results/app/controllers/decidim/results/admin/results_controller.rb', line 10
def new
@form = form(ResultForm).instance
end
|
#update ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'decidim-results/app/controllers/decidim/results/admin/results_controller.rb', line 34
def update
@form = form(ResultForm).from_params(params)
UpdateResult.call(@form, result) do
on(:ok) do
flash[:notice] = I18n.t("results.update.success", scope: "decidim.results.admin")
redirect_to results_path
end
on(:invalid) do
flash.now[:alert] = I18n.t("results.update.invalid", scope: "decidim.results.admin")
render action: "edit"
end
end
end
|