Move profile-related settings to their own form

Refs #3167
This commit is contained in:
Andy Allan 2021-07-14 17:39:09 +01:00
parent 9b8f2bbcbe
commit caf2e2a242
11 changed files with 205 additions and 130 deletions

View file

@ -0,0 +1,43 @@
class ProfilesController < ApplicationController
layout "site"
before_action :authorize_web
before_action :set_locale
authorize_resource :class => false
before_action :check_database_readable
before_action :check_database_writable, :only => [:update]
def edit; end
def update
if params[:user][:description] != current_user.description
current_user.description = params[:user][:description]
current_user.description_format = "markdown"
end
case params[:avatar_action]
when "new"
current_user.avatar.attach(params[:user][:avatar])
current_user.image_use_gravatar = false
when "delete"
current_user.avatar.purge_later
current_user.image_use_gravatar = false
when "gravatar"
current_user.avatar.purge_later
current_user.image_use_gravatar = true
end
current_user.home_lat = params[:user][:home_lat]
current_user.home_lon = params[:user][:home_lon]
if current_user.save
flash[:notice] = t ".success"
redirect_to user_path(current_user)
else
flash[:error] = t ".failure"
render :edit
end
end
end