about summary refs log tree commit diff
path: root/app/controllers/admin
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-04-04 15:26:57 +0200
committerEugen Rochko <eugen@zeonfederated.com>2017-04-04 15:28:12 +0200
commit5f54981846508daf9558f66ffd70d42d8213bea9 (patch)
tree0ccd822d4e04a3082bb4bf9adc6cdb981f05425e /app/controllers/admin
parent405c495c234d80a036a37052841850be29000d0b (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.rb14
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