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

Close #431

parent fc89c0ed
No related branches found
No related tags found
No related merge requests found
......@@ -78,6 +78,10 @@ class Communication::Block < ApplicationRecord
@template ||= "Communication::Block::Template::#{template_kind.classify}".constantize.new self
end
def template_reset!
@template = nil
end
def to_s
title.blank? ? "Block #{position}"
: "#{title}"
......
......@@ -22,6 +22,10 @@ class Communication::Block::Template
[]
end
def excluded_for?(about)
about.class.in? exclude_for
end
protected
def build_git_dependencies
......@@ -64,6 +68,10 @@ class Communication::Block::Template
: []
end
def exclude_for
[]
end
def university
block.university
end
......
......@@ -41,6 +41,10 @@ class Communication::Block::Template::Page < Communication::Block::Template
protected
def exclude_for
[Education::Program]
end
def kind
@kind ||= data['kind'] || 'selection'
end
......
......@@ -24,6 +24,10 @@ class Communication::Block::Template::Post < Communication::Block::Template
protected
def exclude_for
[Education::Program]
end
def kind
@kind ||= data['kind'] || 'all'
end
......
......@@ -14,7 +14,13 @@
<hr>
<div class="row">
<% kinds.each do |kind| %>
<% @block.template_kind = kind %>
<%
@block.template_reset!
@block.template_kind = kind
about = @block.about
template = @block.template
%>
<% next if template.excluded_for?(about) %>
<div class="col-xxl-2 col-lg-3 col-md-4 d-flex">
<div class="card flex-fill">
<%= image_tag "communication/blocks/templates/#{kind}.jpg", alt: '', class:"card-img-top" %>
......
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