New admin setting: open/close registrations, with custom message, from the admin UI
This commit is contained in:
parent
405c495c23
commit
5f54981846
8 changed files with 70 additions and 21 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue