profile photo uploader is now a standard form file element. Upload new image through people#update, which calls current_user.post to do so.

This commit is contained in:
danielvincent 2010-10-29 14:11:20 -07:00
parent 79ec02c6ad
commit 6eb50ea934
6 changed files with 14 additions and 11 deletions

View file

@ -46,6 +46,15 @@ class PeopleController < ApplicationController
params[:person][:profile][:birthday] ||= Date.parse("#{birthday[:year]}-#{birthday[:month]}-#{birthday[:day]}") params[:person][:profile][:birthday] ||= Date.parse("#{birthday[:year]}-#{birthday[:month]}-#{birthday[:day]}")
end end
# upload and set new profile photo
if params[:person][:profile][:image]
raw_image = params[:person][:profile].delete(:image)
params[:profile_image_hash] = { :user_file => raw_image, :to => "all" }
photo = current_user.post(:photo, params[:profile_image_hash])
params[:person][:profile][:image_url] = photo.url(:thumb_medium)
end
prep_image_url(params[:person]) prep_image_url(params[:person])
if current_user.update_profile params[:person][:profile] if current_user.update_profile params[:person][:profile]

View file

@ -51,11 +51,6 @@ class PhotosController < ApplicationController
@photo = current_user.post(:photo, params[:photo]) @photo = current_user.post(:photo, params[:photo])
# set image as profile photo
if params[:set_profile_image] && !params[:set_profile_image].empty?
current_user.update_profile(:image_url=>@photo.url(:thumb_medium))
end
respond_to do |format| respond_to do |format|
format.json{render(:layout => false , :json => {"success" => true, "data" => @photo}.to_json )} format.json{render(:layout => false , :json => {"success" => true, "data" => @photo}.to_json )}
end end

View file

@ -75,7 +75,6 @@ class UsersController < ApplicationController
@user = current_user @user = current_user
@person = @user.person @person = @user.person
@profile = @user.profile @profile = @user.profile
@photos = @user.visible_posts(:person_id => current_user.person.id, :_type => 'Photo').paginate :page => params[:page], :order => 'created_at DESC'
@services = @user.services @services = @user.services
@step = ((params[:step].to_i>0)&&(params[:step].to_i<5)) ? params[:step].to_i : 1 @step = ((params[:step].to_i>0)&&(params[:step].to_i<5)) ? params[:step].to_i : 1

View file

@ -5,7 +5,7 @@
#profile_photo_upload #profile_photo_upload
= owner_image_tag = owner_image_tag
= render 'photos/new_photo', :album_id => nil, :aspect_id => 'all', :set_profile_image => true = form.file_field :image
%p %p
\...or select one from your already existing \...or select one from your already existing

View file

@ -12,7 +12,7 @@
%li=link_to 'Services', services_path %li=link_to 'Services', services_path
.span-19.prepend-5.last .span-19.prepend-5.last
= form_for @person do |person| = form_for @person, :html => { :multipart => true } do |person|
%h3 %h3
Your Profile Your Profile
.description .description
@ -42,7 +42,7 @@
%h4 %h4
Your photo Your photo
= render 'people/profile_photo_upload' = render 'people/profile_photo_upload', :form => profile
.submit_block .submit_block
= link_to t('.cancel'), edit_user_path(current_user) = link_to t('.cancel'), edit_user_path(current_user)

View file

@ -3,7 +3,7 @@
-# the COPYRIGHT file. -# the COPYRIGHT file.
= form_for @person do |person| = form_for @person, :html => { :multipart => true } do |person|
%h3 %h3
Your Profile Your Profile
.description .description
@ -33,7 +33,7 @@
%h4 %h4
Your photo Your photo
= render 'people/profile_photo_upload' = render 'people/profile_photo_upload', :form => profile
= hidden_field_tag :getting_started, @step = hidden_field_tag :getting_started, @step