From a986b1f2b5676624f02373cb54eb3b81b18f3f79 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Thu, 20 Aug 2026 19:39:39 +0200 Subject: Add banner render logic --- app/models/node.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/models/node.rb') diff --git a/app/models/node.rb b/app/models/node.rb index ef981a97..8f59de43 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -632,6 +632,17 @@ class Node < ApplicationRecord .distinct end + def self.current_banners + parent = Node.find_by(:unique_name => CccConventions::BANNER_PARENT_NAME) + return Node.none unless parent + + parent.children + .joins(:head) + .where("pages.published_at IS NULL OR pages.published_at <= ?", Time.now) + .order("pages.published_at DESC") + .includes(:head => { :related_assets => :asset }) + end + # This one is for admin-only views, where finding a draft is the point. # Substring match on whichever of head/draft is present. def self.editor_search(term) -- cgit v1.3