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 @@
<%= form_for :circles, :url => {:controller => 'profile', :action => 'follow'}, :html => {:id => "follow-circles-form"} do |f|%> - <%= render partial: "blocks/profile_info_actions/select_circles", :locals => {:circles => circles} %> + <%= render partial: "blocks/profile_info_actions/select_circles", :locals => {:circles => circles, :followed_profile => profile, :follower => current_person } %>
<%= submit_button :ok, _("Follow") %> diff --git a/app/views/blocks/profile_info_actions/_select_circles.html.erb b/app/views/blocks/profile_info_actions/_select_circles.html.erb index 79b43fd..e4524dc 100644 --- a/app/views/blocks/profile_info_actions/_select_circles.html.erb +++ b/app/views/blocks/profile_info_actions/_select_circles.html.erb @@ -1,9 +1,9 @@
-

<%= _("Select the circles for %s") % profile.name %>

+

<%= _("Select the circles for %s") % followed_profile.name %>

<% circles.each do |circle| %>
- <%= labelled_check_box circle.name, "circles[#{circle.name}]", circle.id, profile.in_circle?(circle, current_person) %> + <%= labelled_check_box circle.name, "circles[#{circle.name}]", circle.id, followed_profile.in_circle?(circle, follower) %>
<% end %>
@@ -12,10 +12,10 @@ diff --git a/app/views/followers/_edit_circles_modal.html.erb b/app/views/followers/_edit_circles_modal.html.erb index 0b73eb1..78df952 100644 --- a/app/views/followers/_edit_circles_modal.html.erb +++ b/app/views/followers/_edit_circles_modal.html.erb @@ -1,8 +1,8 @@
<%= form_for :circles, :url => {:controller => 'followers', :action => 'update_category'}, :html => {:id => "follow-circles-form"} do |f|%> - <%= render partial: "blocks/profile_info_actions/select_circles", :locals => {:circles => circles, :profile => profile} %> + <%= render partial: "blocks/profile_info_actions/select_circles", :locals => {:circles => circles, :followed_profile => followed_profile, :follower => profile } %> - <%= hidden_field_tag('followed_profile_id', profile.id) %> + <%= hidden_field_tag('followed_profile_id', followed_profile.id) %>
diff --git a/app/views/followers/_profile_list.html.erb b/app/views/followers/_profile_list.html.erb index 9fb2794..eccd097 100644 --- a/app/views/followers/_profile_list.html.erb +++ b/app/views/followers/_profile_list.html.erb @@ -1,15 +1,16 @@
    - <% profiles.each do |profile| %> + <% profiles.each do |followed_profile| %>
  • - <%= link_to_profile profile_image(profile) + tag('br') + profile.short_name, - profile.identifier, :class => 'profile-link' %> + <%= link_to_profile profile_image(followed_profile) + tag('br') + followed_profile.short_name, + followed_profile.identifier, :class => 'profile-link' %>
    <%= button_without_text :remove, content_tag('span',_('unfollow')), - { :controller => "profile", :profile => profile.identifier , :action => 'unfollow', :redirect_to => url_for({:controller => "followers", :profile => user.identifier}) }, - :title => _('remove') %> + { :controller => "profile", :profile => followed_profile.identifier, :follower_id => profile.id, + :action => 'unfollow', :redirect_to => url_for({:controller => "followers", :profile => profile.identifier}) }, + :title => _('remove') %> <%= modal_icon_button :edit, _('change category'), url_for(:controller => 'followers', :action => 'set_category_modal', - :followed_profile_id => profile.id) %> + :followed_profile_id => followed_profile.id) %>
  • <% end %> -- libgit2 0.21.2