make profile button on photo show page. (removed clean hash on usercontroller)
This commit is contained in:
parent
98a8fbcfb6
commit
61122b83d0
5 changed files with 45 additions and 18 deletions
|
|
@ -36,10 +36,8 @@ class UsersController < ApplicationController
|
||||||
flash[:error] = "Password Change Failed"
|
flash[:error] = "Password Change Failed"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
data = clean_hash params[:user]
|
prep_image_url(params[:user])
|
||||||
prep_image_url(data)
|
if @user.update_profile params[:user][:profile]
|
||||||
|
|
||||||
if @user.update_profile data
|
|
||||||
flash[:notice] = "Profile updated"
|
flash[:notice] = "Profile updated"
|
||||||
else
|
else
|
||||||
flash[:error] = "Failed to update profile"
|
flash[:error] = "Failed to update profile"
|
||||||
|
|
@ -120,15 +118,4 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
|
||||||
|
|
@ -281,7 +281,7 @@ class User
|
||||||
|
|
||||||
########### Profile ######################
|
########### Profile ######################
|
||||||
def update_profile(params)
|
def update_profile(params)
|
||||||
if self.person.update_attributes(params)
|
if self.person.profile.update_attributes(params)
|
||||||
push_to_aspects profile, :all
|
push_to_aspects profile, :all
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,10 @@
|
||||||
|
|
||||||
%div{:id => @photo.id}
|
%div{:id => @photo.id}
|
||||||
#show_photo
|
#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
|
.caption
|
||||||
-if current_user.owns? @photo
|
-if current_user.owns? @photo
|
||||||
-if @photo.caption and @photo.caption != ""
|
-if @photo.caption and @photo.caption != ""
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,6 @@ $(document).ready(function(){
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
});//end document ready
|
});//end document ready
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -105,3 +104,15 @@ function openVideo(type, videoid, link) {
|
||||||
$(container).slideDown('fast', function() { });
|
$(container).slideDown('fast', function() { });
|
||||||
link.onclick = function() { $(container).slideToggle('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()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -1089,3 +1089,29 @@ header
|
||||||
img
|
img
|
||||||
:height 27px
|
:height 27px
|
||||||
:width 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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue