Class: Decidim::ActionDelegator::Admin::SettingsController
Instance Method Summary
collapse
#organization_settings, #permission_class_chain
Instance Method Details
#create ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'app/controllers/decidim/action_delegator/admin/settings_controller.rb', line 24
def create
enforce_permission_to :create, :setting
@form = form(SettingForm).from_params(params)
CreateSetting.call(@form, copy_from_setting) do
on(:ok) do
notice = I18n.t("settings.create.success", scope: "decidim.action_delegator.admin")
redirect_to decidim_admin_action_delegator.settings_path, notice: notice
end
on(:invalid) do |_error|
flash.now[:error] = I18n.t("settings.create.error", scope: "decidim.action_delegator.admin")
render :new
end
end
end
|
#destroy ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
|
# File 'app/controllers/decidim/action_delegator/admin/settings_controller.rb', line 66
def destroy
enforce_permission_to :destroy, :setting, resource: current_setting
if current_setting.destroy
flash[:notice] = I18n.t("settings.destroy.success", scope: "decidim.action_delegator.admin")
else
flash[:error] = I18n.t("settings.destroy.error", scope: "decidim.action_delegator.admin")
end
redirect_to settings_path
end
|
#edit ⇒ Object
42
43
44
45
46
|
# File 'app/controllers/decidim/action_delegator/admin/settings_controller.rb', line 42
def edit
enforce_permission_to :update, :setting
@form = form(SettingForm).from_model(current_setting)
end
|
#index ⇒ Object
14
15
16
|
# File 'app/controllers/decidim/action_delegator/admin/settings_controller.rb', line 14
def index
enforce_permission_to :index, :setting
end
|
#new ⇒ Object
18
19
20
21
22
|
# File 'app/controllers/decidim/action_delegator/admin/settings_controller.rb', line 18
def new
enforce_permission_to :create, :setting
@form = form(SettingForm).instance
end
|
#update ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'app/controllers/decidim/action_delegator/admin/settings_controller.rb', line 48
def update
enforce_permission_to :update, :setting
@form = form(SettingForm).from_params(params)
UpdateSetting.call(@form, current_setting, copy_from_setting) do
on(:ok) do
notice = I18n.t("settings.update.success", scope: "decidim.action_delegator.admin")
redirect_to decidim_admin_action_delegator.settings_path, notice: notice
end
on(:invalid) do |_error|
flash.now[:error] = I18n.t("settings.update.error", scope: "decidim.action_delegator.admin")
render :edit
end
end
end
|