diff options
author | Francis Irving <francis@mysociety.org> | 2010-07-18 05:29:26 +0100 |
---|---|---|
committer | Francis Irving <francis@mysociety.org> | 2010-07-18 05:29:26 +0100 |
commit | 3981460a8b2e5924e9b833ea214bc6ce0c3dfe33 (patch) | |
tree | 271457f63f61e97d6e906478300ec89e017c027f /app/controllers/user_controller.rb | |
parent | 57aa8cc12e47efd6f79acd7349d4805cd4c986b9 (diff) |
Editable about me text
Diffstat (limited to 'app/controllers/user_controller.rb')
-rw-r--r-- | app/controllers/user_controller.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 85d09abc7..fd9eb9fbf 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -419,6 +419,34 @@ class UserController < ApplicationController render_for_text(@display_user.profile_photo.data) end + # Change about me text on your profile page + def set_profile_about_me + if authenticated_user.nil? + flash[:error] = "You need to be logged in to change the text about you on your profile." + redirect_to frontpage_url + return + end + + if !params[:submitted_about_me] + params[:about_me] = {} + params[:about_me][:about_me] = @user.about_me + @about_me = AboutMeValidator.new(params[:about_me]) + render :action => 'set_profile_about_me' + return + end + + @about_me = AboutMeValidator.new(params[:about_me]) + if !@about_me.valid? + render :action => 'set_profile_about_me' + return + end + + @user.about_me = @about_me.about_me + @user.save! + flash[:notice] = "You have now changed the text about you on your profile." + redirect_to user_url(@user) + end + private # Decide where we are going to redirect back to after signin/signup, and record that |