diff options
-rw-r--r-- | app/controllers/subparticipants_controller.rb | 2 | ||||
-rw-r--r-- | app/models/community.rb | 5 | ||||
-rw-r--r-- | app/models/membership.rb | 10 |
3 files changed, 14 insertions, 3 deletions
diff --git a/app/controllers/subparticipants_controller.rb b/app/controllers/subparticipants_controller.rb index daf1b72..6284536 100644 --- a/app/controllers/subparticipants_controller.rb +++ b/app/controllers/subparticipants_controller.rb @@ -98,7 +98,7 @@ private :email => participant.email, :community_selfrouting => participant.community_selfrouting, :events => participant.events_, - :communities => participant.communities.map{|c| c.name}, + :memberships => Membership.memberships(participant,true), :realm => subparticipant.realm, } data diff --git a/app/models/community.rb b/app/models/community.rb index 9faa3d1..cf0d258 100644 --- a/app/models/community.rb +++ b/app/models/community.rb @@ -24,6 +24,11 @@ class Community < ActiveRecord::Base :conditions => ["participants.anonymous = ?", false], :order => "participants.id ASC" end + def with_reduced_attributes_and_only_itsyou_and_without_anonymous(pid) + find :all, :select => "participants.id, name, description, email, dns, organization_id", + :conditions => ["participants.anonymous = ? and participants.id = ?", false, pid], + :order => "participants.id ASC" + end end has_many :community_messages, :dependent => :destroy has_many :messages, :through => :community_messages diff --git a/app/models/membership.rb b/app/models/membership.rb index 7e7aebf..895d7e6 100644 --- a/app/models/membership.rb +++ b/app/models/membership.rb @@ -59,7 +59,7 @@ class Membership < ActiveRecord::Base end end - def self.memberships(participant) + def self.memberships(participant,itsyou=false) memberships = [] Membership.for_participant_id(participant.id).each do |membership| community= lambda { |memb| @@ -68,7 +68,13 @@ class Membership < ActiveRecord::Base attribs }.call(membership) logger.debug "**** Membership::memberships: community: #{community.inspect}" - participants= membership.community.participants.with_reduced_attributes_and_without_anonymous.map do |p| + if itsyou + participants_with_reduced_attribs= membership.community.participants.with_reduced_attributes_and_only_itsyou_and_without_anonymous(participant.id) + logger.debug "**** Membership::memberships: participants_with_reduced_attribs: #{participants_with_reduced_attribs.inspect}" + else + participants_with_reduced_attribs= membership.community.participants.with_reduced_attributes_and_without_anonymous + end + participants= participants_with_reduced_attribs.map do |p| attribs = p.attributes attribs["mid"] = Membership.for_participant_id_and_community_id(p.id, membership.community.id).first.id attribs["org"] = {"name" => p.organization.name, "abbr" => p.organization.abrev} |