Skip to content
Snippets Groups Projects
Commit a0f3b7b8 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

Fix #1441

parent 732e84d2
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,6 @@ class Communication::Block::Template::Person < Communication::Block::Template::B
end
def children
elements
elements.collect(&:person).compact
end
end
......@@ -26,14 +26,25 @@ module Backlinkable
protected
def backlinks(kind, website)
connections
.where(
direct_source_type: kind.to_s,
website_id: website.id
)
.collect(&:direct_source)
.compact
.select { |source| source.published? }
.select { |source| source.language == language }
backlinks_blocks(website).published.map { |block|
# Correct kind
next unless block.about.is_a?(kind)
# Mentioning self
next unless self.in?(block.template.children)
# About published
next unless block.about.published?
block.about
}.compact
end
def backlinks_blocks(website)
case self.class.to_s
when 'University::Organization'
website.blocks.organizations
when 'University::Person'
website.blocks.persons
else
raise "#{self.class} should map to the correct kind of blocks"
end
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment