aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/user_controller.rb
diff options
context:
space:
mode:
authorFrancis Irving <francis@mysociety.org>2010-07-15 16:02:48 +0100
committerFrancis Irving <francis@mysociety.org>2010-07-15 16:02:48 +0100
commit160645b6f067ff0a8bb43118aafe5bd0a4370a91 (patch)
treeb4b9b19f8bbbd2619a8697c99d87906bb7d783d0 /app/controllers/user_controller.rb
parent90b3637c20f5b02a9844148ed2fa30faef5d9f70 (diff)
Make cropping work
Diffstat (limited to 'app/controllers/user_controller.rb')
-rw-r--r--app/controllers/user_controller.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index a07701208..e2998333c 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -375,8 +375,12 @@ class UserController < ApplicationController
render :template => 'user/set_crop_profile_photo.rhtml'
return
elsif !params[:submitted_crop_profile_photo].nil?
- # change user's photo
+ # crop the draft photo according to jquery parameters and set it as the users photo
+ draft_profile_photo = ProfilePhoto.find(params[:draft_profile_photo_id])
+ @profile_photo = ProfilePhoto.new(:data => draft_profile_photo.data, :draft => false,
+ :x => params[:x], :y => params[:y], :w => params[:w], :h => params[:h])
@user.set_profile_photo(@profile_photo)
+ draft_profile_photo.destroy
flash[:notice] = "Thank you for updating your profile photo"
redirect_to user_url(@user)
else