diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a0f03877dcedc7cbd4ee8edcb28f9b197e5d7d68..aacff850431a9f2c7c1113c2d1b1b0125b6d69dd 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -36,10 +36,8 @@ class UsersController < ApplicationController flash[:error] = "Password Change Failed" end else - data = clean_hash params[:user] - prep_image_url(data) - - if @user.update_profile data + prep_image_url(params[:user]) + if @user.update_profile params[:user][:profile] flash[:notice] = "Profile updated" else flash[:error] = "Failed to update profile" @@ -120,15 +118,4 @@ class UsersController < ApplicationController end end - def clean_hash(params) - return { - :profile => - { - :first_name => params[:profile][:first_name], - :last_name => params[:profile][:last_name], - :image_url => params[:profile][:image_url] - } - } - end - end diff --git a/app/models/user.rb b/app/models/user.rb index cc9531c8c871aa6e58e514fd7a014af6ce2bf703..0e28357f2e585583a8bebba733cca0d415f223ba 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -281,7 +281,7 @@ class User ########### Profile ###################### def update_profile(params) - if self.person.update_attributes(params) + if self.person.profile.update_attributes(params) push_to_aspects profile, :all true else diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 8fe22cc9bc0770bc5c45bb75f57958d6bbdd936f..12b6a1af178b821e42c083d123f469e792a0b960 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -76,7 +76,10 @@ %div{:id => @photo.id} #show_photo - = linked_scaled_photo @photo, @album + .edit_pane + .controls{:data=>{:actor=>"#{@photo.person.owner.id}",:image_url=>"#{@photo.url(:thumb_medium)}"}} + = link_to 'make profile photo', '#', :class => "make_profile_photo" + = linked_scaled_photo @photo, @album .caption -if current_user.owns? @photo -if @photo.caption and @photo.caption != "" diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 1096b532cdd85ba682cc8a032484ab8d9050c6dd..575007819da6a2573a303bad87234b49c49df554 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -67,7 +67,6 @@ $(document).ready(function(){ }; }); - });//end document ready @@ -105,3 +104,15 @@ function openVideo(type, videoid, link) { $(container).slideDown('fast', function() { }); link.onclick = function() { $(container).slideToggle('fast', function() { } ); } } + +$(".make_profile_photo").live("click", function(){ + var user_id = $(this).closest(".controls").attr('data-actor'); + photo_url = $(this).closest(".controls").attr('data-image_url'); + + $.ajax({ + type: "PUT", + url: '/users/'+user_id, + data: {"user":{"profile":{ "image_url": photo_url }}}, + success: window.location.reload() + }); +}); diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 56a781be529051c5bf96a8077433827aca7be332..716c4e23860b986e3568a9e344536618a2ec4412 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -1089,3 +1089,29 @@ header img :height 27px :width 27px + + +.edit_pane + :display inline + :position relative + + .controls + :display none + :background + :color rgba(51,51,51,0.9) + :padding 10px + :position absolute + :right 0 + + a + :font + :weight bold + :color #eee + :text-shadow 0 1px #000 + + &:hover + :color #fff + + &:hover + .controls + :display inline