diff --git a/app/models/concerns/follower.rb b/app/models/concerns/follower.rb new file mode 100644 index 0000000..ed8860e --- /dev/null +++ b/app/models/concerns/follower.rb @@ -0,0 +1,16 @@ +module Follower + extend ActiveSupport::Concern + + def follow(profile, circles) + circles = [circles] unless circles.is_a?(Array) + circles.each do |new_circle| + ProfileFollower.create(profile: profile, circle: new_circle) + end + end + + def follows?(profile) + return false if profile.nil? + profile.followed_by?(self) + end + +end diff --git a/app/models/external_person.rb b/app/models/external_person.rb index abab490..8a0ad1c 100644 --- a/app/models/external_person.rb +++ b/app/models/external_person.rb @@ -3,6 +3,7 @@ class ExternalPerson < ActiveRecord::Base include Human include ProfileEntity + include Follower has_many :circles, as: :person validates_uniqueness_of :identifier, scope: :source @@ -196,7 +197,7 @@ class ExternalPerson < ActiveRecord::Base build_contact: nil, is_a_friend?: false, ask_to_join?: false, refuse_join: nil, blocks_to_expire_cache: [], cache_keys: [], communities_cache_key: '', friends_cache_key: '', manage_friends_cache_key: '', - relationships_cache_key: '', is_member_of?: false, follows?: false, + relationships_cache_key: '', is_member_of?: false, each_friend: nil, is_last_admin?: false, is_last_admin_leaving?: false, leave: nil, last_notification: nil, notification_time: 0, notifier: nil, remove_suggestion: nil, allow_invitation_from?: false @@ -255,7 +256,7 @@ class ExternalPerson < ActiveRecord::Base may_display_field_to?: true, may_display_location_to?: true, public_fields: {}, followed_by?: false, display_private_info_to?: true, can_view_field?: true, remove_from_suggestion_list: nil, layout_template: 'default', - is_admin?: false, add_friend: false, follows?: false, is_a_friend?: false, + is_admin?: false, add_friend: false, is_a_friend?: false, already_request_friendship?: false } @@ -278,13 +279,6 @@ class ExternalPerson < ActiveRecord::Base super end - def follow(profile, circles) - circles = [circles] unless circles.is_a?(Array) - circles.each do |new_circle| - ProfileFollower.create(profile: profile, circle: new_circle) - end - end - private def generate_derivated_methods(methods) diff --git a/app/models/person.rb b/app/models/person.rb index 62a1100..355b627 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -2,6 +2,7 @@ class Person < Profile include Human + include Follower attr_accessible :organization, :contact_information, :sex, :birth_date, :cell_phone, :comercial_phone, :jabber_id, :personal_website, :nationality, :address_reference, :district, :schooling, :schooling_status, :formation, :custom_formation, :area_of_study, :custom_area_of_study, :professional_activity, :organization_website, :following_articles @@ -181,13 +182,6 @@ class Person < Profile end end - def follow(profile, circles) - circles = [circles] unless circles.is_a?(Array) - circles.each do |new_circle| - ProfileFollower.create(profile: profile, circle: new_circle) - end - end - def update_profile_circles(profile, new_circles) profile_circles = ProfileFollower.with_profile(profile).with_follower(self).map(&:circle) circles_to_add = new_circles - profile_circles @@ -492,11 +486,6 @@ class Person < Profile profile.members.include?(self) end - def follows?(profile) - return false if profile.nil? - profile.followed_by?(self) - end - def each_friend(offset=0) while friend = self.friends.order(:id).offset(offset).first yield friend diff --git a/app/views/blocks/profile_info_actions/_common.html.erb b/app/views/blocks/profile_info_actions/_common.html.erb index ed83824..a59ef79 100644 --- a/app/views/blocks/profile_info_actions/_common.html.erb +++ b/app/views/blocks/profile_info_actions/_common.html.erb @@ -1,7 +1,7 @@