Skip to content
Snippets Groups Projects
Unverified Commit 4470c99b authored by Arnaud Levy's avatar Arnaud Levy Committed by GitHub
Browse files

Merge pull request #1478 from noesya/fix-backlinks

Finalisation des liens inverses
parents b1d306ce 2f97c9df
No related branches found
No related tags found
No related merge requests found
......@@ -14,8 +14,12 @@ class Communication::Block::Template::Person < Communication::Block::Template::B
end
@elements
end
def people
@people ||= elements.collect(&:person).compact.uniq
end
def children
elements
people
end
end
......@@ -26,14 +26,18 @@ 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|
block.about if backlink_in_block?(block, kind)
}.compact
end
def backlink_in_block?(block, kind)
block.about.is_a?(kind) && # Correct kind
self.in?(block.template.children) && # Mentioning self
block.about.published? # About published
end
def backlinks_blocks(website)
raise NotImplementedError
end
end
\ No newline at end of file
......@@ -130,6 +130,10 @@ class University::Organization < ApplicationRecord
protected
def backlinks_blocks(website)
website.blocks.organizations
end
def explicit_blob_ids
[
logo&.blob_id,
......
......@@ -232,6 +232,10 @@ class University::Person < ApplicationRecord
protected
def backlinks_blocks(website)
website.blocks.persons
end
def explicit_blob_ids
[picture&.blob_id]
end
......
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