2017-01-12 21:46:24 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-10 22:27:03 +03:00
|
|
|
module Admin
|
|
|
|
class SettingsController < BaseController
|
2017-05-04 19:12:44 +03:00
|
|
|
def edit
|
2017-11-11 21:23:33 +02:00
|
|
|
authorize :settings, :show?
|
2019-03-23 15:07:04 +02:00
|
|
|
|
2017-07-12 04:24:04 +03:00
|
|
|
@admin_settings = Form::AdminSettings.new
|
2017-04-10 22:27:03 +03:00
|
|
|
end
|
2017-01-12 21:46:24 +02:00
|
|
|
|
2017-04-10 22:27:03 +03:00
|
|
|
def update
|
2017-11-11 21:23:33 +02:00
|
|
|
authorize :settings, :update?
|
|
|
|
|
2019-03-23 15:07:04 +02:00
|
|
|
@admin_settings = Form::AdminSettings.new(settings_params)
|
2017-05-04 19:12:44 +03:00
|
|
|
|
2019-03-23 15:07:04 +02:00
|
|
|
if @admin_settings.save
|
|
|
|
flash[:notice] = I18n.t('generic.changes_saved_msg')
|
|
|
|
redirect_to edit_admin_settings_path
|
|
|
|
else
|
|
|
|
render :edit
|
|
|
|
end
|
2017-01-12 21:46:24 +02:00
|
|
|
end
|
|
|
|
|
2017-04-10 22:27:03 +03:00
|
|
|
private
|
2017-04-04 16:26:57 +03:00
|
|
|
|
2017-04-10 22:27:03 +03:00
|
|
|
def settings_params
|
2019-03-23 15:07:04 +02:00
|
|
|
params.require(:form_admin_settings).permit(*Form::AdminSettings::KEYS)
|
2017-04-20 18:18:09 +03:00
|
|
|
end
|
2017-04-04 16:26:57 +03:00
|
|
|
end
|
2017-01-12 21:46:24 +02:00
|
|
|
end
|