Display tag author only proposal or budget investment author
This commit is contained in:
@@ -18,7 +18,12 @@ module CommunitiesHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def is_author?(community, participant)
|
def is_author?(community, participant)
|
||||||
community.topics.pluck(:author_id).include?(participant.id)
|
if community.from_proposal?
|
||||||
|
community.proposal.author_id == participant.id
|
||||||
|
else
|
||||||
|
investment = Budget::Investment.where(community_id: community.id).first
|
||||||
|
investment.author_id == participant.id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ class Community < ActiveRecord::Base
|
|||||||
has_many :topics
|
has_many :topics
|
||||||
|
|
||||||
def participants
|
def participants
|
||||||
users_participants = users_who_commented_by(self) + users_who_topics_author_by(self)
|
users_participants = users_who_commented_by +
|
||||||
|
users_who_topics_author_by +
|
||||||
|
author_from_community
|
||||||
users_participants.uniq
|
users_participants.uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -14,14 +16,24 @@ class Community < ActiveRecord::Base
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def users_who_commented_by(community)
|
def users_who_commented_by
|
||||||
topics_ids = community.topics.pluck(:id)
|
topics_ids = topics.pluck(:id)
|
||||||
query = "comments.commentable_id IN (?)and comments.commentable_type = 'Topic'"
|
query = "comments.commentable_id IN (?)and comments.commentable_type = 'Topic'"
|
||||||
User.by_comments(query, topics_ids)
|
User.by_comments(query, topics_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
def users_who_topics_author_by(community)
|
def users_who_topics_author_by
|
||||||
author_ids = community.topics.pluck(:author_id)
|
author_ids = topics.pluck(:author_id)
|
||||||
User.by_authors(author_ids)
|
User.by_authors(author_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def author_from_community
|
||||||
|
if from_proposal?
|
||||||
|
User.where(id: proposal.author_id)
|
||||||
|
else
|
||||||
|
investment = Budget::Investment.where(community_id: id).first
|
||||||
|
User.where(id: investment.author_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user