1 class PreferencesController < ApplicationController
4 before_action :authorize_web
5 before_action :set_locale
7 authorize_resource :class => false
9 before_action :check_database_readable
10 before_action :check_database_writable, :only => [:update]
15 current_user.languages = params[:user][:languages].split(",")
17 current_user.preferred_editor = if params[:user][:preferred_editor] == "default"
20 params[:user][:preferred_editor]
23 success = current_user.save
25 if params[:site_color_scheme]
26 site_color_scheme_preference = current_user.preferences.find_or_create_by(:k => "site.color_scheme")
27 success &= site_color_scheme_preference.update(:v => params[:site_color_scheme])
30 if params[:map_color_scheme]
31 map_color_scheme_preference = current_user.preferences.find_or_create_by(:k => "map.color_scheme")
32 success &= map_color_scheme_preference.update(:v => params[:map_color_scheme])
36 # Use a partial so that it is rendered during the next page load in the correct language.
37 flash[:notice] = { :partial => "preferences/update_success_flash" }
38 redirect_to preferences_path
40 flash.now[:error] = t ".failure"