]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/preferences_controller.rb
Merge remote-tracking branch 'upstream/pull/5401'
[rails.git] / app / controllers / preferences_controller.rb
index e098a8acc49a989a58b390e1cfb3a27570e23d95..1d96766ef227b7dbaa86b870f03ca1534c8513c6 100644 (file)
@@ -21,12 +21,25 @@ class PreferencesController < ApplicationController
                                     else
                                       params[:user][:preferred_editor]
                                     end
                                     else
                                       params[:user][:preferred_editor]
                                     end
-    if current_user.save
+
+    success = current_user.save
+
+    if params[:site_color_scheme]
+      site_color_scheme_preference = current_user.preferences.find_or_create_by(:k => "site.color_scheme")
+      success &= site_color_scheme_preference.update(:v => params[:site_color_scheme])
+    end
+
+    if params[:map_color_scheme]
+      map_color_scheme_preference = current_user.preferences.find_or_create_by(:k => "map.color_scheme")
+      success &= map_color_scheme_preference.update(:v => params[:map_color_scheme])
+    end
+
+    if success
       # Use a partial so that it is rendered during the next page load in the correct language.
       flash[:notice] = { :partial => "preferences/update_success_flash" }
       redirect_to preferences_path
     else
       # Use a partial so that it is rendered during the next page load in the correct language.
       flash[:notice] = { :partial => "preferences/update_success_flash" }
       redirect_to preferences_path
     else
-      flash[:error] = t ".failure"
+      flash.now[:error] = t ".failure"
       render :edit
     end
   end
       render :edit
     end
   end