Skip to content
Snippets Groups Projects
Commit f0f018c9 authored by pabois's avatar pabois
Browse files

Merge branch 'master' of github.com:noesya/osuny

parents 0c9668eb c73517ed
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
......
<% if block.template.category %>
category: <%= block.template.category.slug %>
category: "<%= block.template.category.path %>"
<% end %>
posts:
<% block.template.selected_posts.each do |post| %>
......
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