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

fix

parent 3ba3d9f9
No related branches found
No related tags found
No related merge requests found
......@@ -16,13 +16,7 @@ class Communication::Block::Template::Post < Communication::Block::Template
end
def selected_posts
if kind == 'all'
@selected_posts ||= all_posts
elsif kind == 'selection'
@selected_posts ||= free_posts
elsif kind == 'category'
@selected_posts ||= category_posts
end
@selected_posts ||= send "selected_posts_#{kind}"
end
protected
......@@ -31,17 +25,17 @@ class Communication::Block::Template::Post < Communication::Block::Template
@kind ||= data['kind'] || 'all'
end
def all_posts
def selected_posts_all
quantity = data['posts_quantity'] || 3
block.about&.website.posts.ordered.limit(quantity)
end
def category_posts
def selected_posts_category
quantity = data['posts_quantity'] || 3
category.posts.ordered.limit(quantity)
end
def free_posts
def selected_posts_free
elements.map { |element| post(element['id']) }
.compact
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