]> git.openstreetmap.org Git - rails.git/blob - app/controllers/profiles_controller.rb
Store selected site color scheme
[rails.git] / app / controllers / profiles_controller.rb
1 class ProfilesController < ApplicationController
2   layout "site"
3
4   before_action :authorize_web
5   before_action :set_locale
6
7   authorize_resource :class => false
8
9   before_action :check_database_readable
10   before_action :check_database_writable, :only => [:update]
11
12   def edit; end
13
14   def update
15     if params[:user][:description] != current_user.description
16       current_user.description = params[:user][:description]
17       current_user.description_format = "markdown"
18     end
19
20     case params[:avatar_action]
21     when "new"
22       current_user.avatar.attach(params[:user][:avatar])
23       current_user.image_use_gravatar = false
24     when "delete"
25       current_user.avatar.purge_later
26       current_user.image_use_gravatar = false
27     when "gravatar"
28       current_user.avatar.purge_later
29       current_user.image_use_gravatar = true
30     end
31
32     current_user.home_lat = params[:user][:home_lat]
33     current_user.home_lon = params[:user][:home_lon]
34
35     if current_user.save
36       flash[:notice] = t ".success"
37       redirect_to user_path(current_user)
38     else
39       flash.now[:error] = t ".failure"
40       render :edit
41     end
42   end
43 end