diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-04-04 15:26:57 +0200 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-04-04 15:28:12 +0200 |
commit | 5f54981846508daf9558f66ffd70d42d8213bea9 (patch) | |
tree | 0ccd822d4e04a3082bb4bf9adc6cdb981f05425e /app/controllers/admin | |
parent | 405c495c234d80a036a37052841850be29000d0b (diff) |
New admin setting: open/close registrations, with custom message, from the admin UI
Diffstat (limited to 'app/controllers/admin')
-rw-r--r-- | app/controllers/admin/settings_controller.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb index af0be8823..7615c781d 100644 --- a/app/controllers/admin/settings_controller.rb +++ b/app/controllers/admin/settings_controller.rb @@ -11,9 +11,13 @@ class Admin::SettingsController < ApplicationController def update @setting = Setting.where(var: params[:id]).first_or_initialize(var: params[:id]) + value = settings_params[:value] - if @setting.value != params[:setting][:value] - @setting.value = params[:setting][:value] + # Special cases + value = value == 'true' if @setting.var == 'open_registrations' + + if @setting.value != value + @setting.value = value @setting.save end @@ -22,4 +26,10 @@ class Admin::SettingsController < ApplicationController format.json { respond_with_bip(@setting) } end end + + private + + def settings_params + params.require(:setting).permit(:value) + end end |