Skip to content
Snippets Groups Projects
Unverified Commit c57ee2e6 authored by Sébastien Gaya's avatar Sébastien Gaya
Browse files

#342

parent fb8307ec
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,12 @@ class Communication::Block::Template::Post < Communication::Block::Template
def selected_posts_category
quantity = data['posts_quantity'] || 3
category.posts.ordered.limit(quantity)
category_ids = [category.id, category.descendants.map(&:id)].flatten
university.communication_website_posts.joins(:categories)
.where(categories: { id: category_ids })
.distinct
.ordered
.limit(quantity)
end
def selected_posts_selection
......
......@@ -12,6 +12,10 @@ module University::WithCommunication
dependent: :destroy
alias_attribute :websites, :communication_websites
has_many :communication_website_posts,
class_name: 'Communication::Website::Post',
dependent: :destroy
has_many :communication_blocks,
class_name: 'Communication::Block',
dependent: :destroy
......
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