diff --git a/app/controllers/my_profile/circles_controller.rb b/app/controllers/my_profile/circles_controller.rb index ff03259..7b74b15 100644 --- a/app/controllers/my_profile/circles_controller.rb +++ b/app/controllers/my_profile/circles_controller.rb @@ -3,7 +3,7 @@ class CirclesController < MyProfileController before_action :accept_only_post, :only => [:create, :update, :destroy] def index - @circles = current_person.circles + @circles = profile.circles end def new @@ -11,7 +11,7 @@ class CirclesController < MyProfileController end def create - @circle = Circle.new(params[:circle].merge({ :person => current_person })) + @circle = Circle.new(params[:circle].merge({ :person => profile })) if @circle.save redirect_to :action => 'index' else @@ -21,7 +21,7 @@ class CirclesController < MyProfileController def xhr_create if request.xhr? - circle = Circle.new(params[:circle].merge({:person => current_person })) + circle = Circle.new(params[:circle].merge({:person => profile })) if circle.save render :partial => "circle_checkbox", :locals => { :circle => circle }, :status => 201 diff --git a/app/controllers/my_profile/followers_controller.rb b/app/controllers/my_profile/followers_controller.rb index f2d663d..7288583 100644 --- a/app/controllers/my_profile/followers_controller.rb +++ b/app/controllers/my_profile/followers_controller.rb @@ -4,7 +4,7 @@ class FollowersController < MyProfileController before_action :accept_only_post, :only => [:update_category] def index - @followed_people = current_person.followed_profiles.order(:type) + @followed_people = profile.followed_profiles.order(:type) @profile_types = {_('All profiles') => nil}.merge(Circle.profile_types).to_a if params['filter'].present? @@ -16,9 +16,9 @@ class FollowersController < MyProfileController end def set_category_modal - profile = Profile.find(params[:followed_profile_id]) - circles = Circle.where(:person => current_person, :profile_type => profile.class.name) - render :partial => 'followers/edit_circles_modal', :locals => { :circles => circles, :profile => profile } + followed_profile = Profile.find(params[:followed_profile_id]) + circles = Circle.where(:person => profile, :profile_type => followed_profile.class.name) + render :partial => 'followers/edit_circles_modal', :locals => { :circles => circles, :followed_profile => followed_profile } end def update_category @@ -27,7 +27,7 @@ class FollowersController < MyProfileController selected_circles = params[:circles].map{ |circle_name, circle_id| Circle.find_by(:id => circle_id) }.select{ |c| c.present? } if followed_profile - current_person.update_profile_circles(followed_profile, selected_circles) + profile.update_profile_circles(followed_profile, selected_circles) render :text => _("Circles of %s updated successfully") % followed_profile.name, :status => 200 else render :text => _("Error: No profile to follow."), :status => 400 diff --git a/app/controllers/public/profile_controller.rb b/app/controllers/public/profile_controller.rb index c7237fa..da8784a 100644 --- a/app/controllers/public/profile_controller.rb +++ b/app/controllers/public/profile_controller.rb @@ -184,8 +184,10 @@ class ProfileController < PublicController end def unfollow - if current_person.follows?(profile) - current_person.unfollow(profile) + follower = params[:follower_id].present? ? Person.find_by(id: params[:follower_id]) : current_person + + if follower && follower.follows?(profile) + follower.unfollow(profile) end redirect_url = params["redirect_to"] ? params["redirect_to"] : profile.url redirect_to redirect_url diff --git a/app/views/blocks/profile_info_actions/_circles.html.erb b/app/views/blocks/profile_info_actions/_circles.html.erb index 6f66c7a..ecf4e85 100644 --- a/app/views/blocks/profile_info_actions/_circles.html.erb +++ b/app/views/blocks/profile_info_actions/_circles.html.erb @@ -1,7 +1,7 @@
<%= _("Select the circles for %s") % profile.name %>
+<%= _("Select the circles for %s") % followed_profile.name %>