diff --git a/app/models/communication/block/template.rb b/app/models/communication/block/template.rb index b759d8326836f8ecbd05283ddb811c3745c57775..dc9b014366a1984adae6472be8a571c3a0f36649 100644 --- a/app/models/communication/block/template.rb +++ b/app/models/communication/block/template.rb @@ -7,17 +7,12 @@ class Communication::Block::Template def git_dependencies unless @git_dependencies - @git_dependencies = active_storage_blobs build_git_dependencies @git_dependencies.uniq! end @git_dependencies end - def active_storage_blobs - [] - end - protected def build_git_dependencies diff --git a/app/models/communication/block/template/call_to_action.rb b/app/models/communication/block/template/call_to_action.rb index 8123bb6b918f9fa7b0ee7134e65b9ece92f18a9f..c2592194b24a0a3cda6c8d8e8f63886fdb27c2b4 100644 --- a/app/models/communication/block/template/call_to_action.rb +++ b/app/models/communication/block/template/call_to_action.rb @@ -1,6 +1,6 @@ class Communication::Block::Template::CallToAction < Communication::Block::Template def build_git_dependencies - # image à déclarer + add_dependency image&.blob end def text diff --git a/app/models/communication/block/template/gallery.rb b/app/models/communication/block/template/gallery.rb index da9c83d520d0f87f1e10ef11afdd7088ca3a0089..834169a4de18ae5a13948d1a58bfaaea25a188c0 100644 --- a/app/models/communication/block/template/gallery.rb +++ b/app/models/communication/block/template/gallery.rb @@ -1,6 +1,6 @@ class Communication::Block::Template::Gallery < Communication::Block::Template def build_git_dependencies - # Blobs already added in Communication::Block::Template#git_dependencies + add_dependency active_storage_blobs end def images_with_alt diff --git a/app/models/communication/block/template/partner.rb b/app/models/communication/block/template/partner.rb index 2bc364e062b11cb94e01d96ebe761d74eb2052ca..930e858e956f48b73502fcf49a0186adcf221962 100644 --- a/app/models/communication/block/template/partner.rb +++ b/app/models/communication/block/template/partner.rb @@ -1,7 +1,10 @@ class Communication::Block::Template::Partner < Communication::Block::Template def build_git_dependencies - # Blobs already added in Communication::Block::Template#git_dependencies + add_dependency active_storage_blobs add_dependency organizations + organizations.each do |organization| + add_dependency organization.active_storage_blobs + end end def partners diff --git a/app/models/communication/block/template/testimonial.rb b/app/models/communication/block/template/testimonial.rb index b72a81aa67e474fb8aef108ec58917a4833a82e6..85a231cddf44da4c1df77e7be6ae896aecb7abfa 100644 --- a/app/models/communication/block/template/testimonial.rb +++ b/app/models/communication/block/template/testimonial.rb @@ -1,6 +1,6 @@ class Communication::Block::Template::Testimonial < Communication::Block::Template def build_git_dependencies - # Blobs already added in Communication::Block::Template#git_dependencies + add_dependency active_storage_blobs end def testimonials diff --git a/app/models/communication/website.rb b/app/models/communication/website.rb index 266ba4915a11adbe47316297d0f7512e325ffc06..339043d19ea0cb5d8397d0bd9cd54cc4a2ad01d9 100644 --- a/app/models/communication/website.rb +++ b/app/models/communication/website.rb @@ -62,6 +62,7 @@ class Communication::Website < ApplicationRecord dependencies += pages + pages.map(&:active_storage_blobs).flatten dependencies += posts + posts.map(&:active_storage_blobs).flatten if has_communication_posts? dependencies += people_with_facets + people.map(&:active_storage_blobs).flatten if has_persons? + dependencies += organizations_in_blocks + organizations_in_blocks.map(&:active_storage_blobs).flatten if has_organizations_in_blocks? dependencies += [categories] if has_communication_categories? dependencies += about.git_dependencies(website) if about.present? dependencies diff --git a/app/models/communication/website/with_dependencies.rb b/app/models/communication/website/with_dependencies.rb index 2ee6c344a312b7e5a99ec6d68f09eeabbb82bc9e..151b447cd61bb78f56cf799c50330b0f71ea45b3 100644 --- a/app/models/communication/website/with_dependencies.rb +++ b/app/models/communication/website/with_dependencies.rb @@ -61,6 +61,10 @@ module Communication::Website::WithDependencies blocks_dependencies.reject { |dependency| !dependency.is_a? University::Person } end + def organizations_in_blocks + blocks_dependencies.reject { |dependency| !dependency.is_a? University::Organization } + end + def people_with_facets_in_blocks blocks_dependencies.reject { |dependency| !dependency.class.to_s.start_with?('University::Person') } end @@ -122,6 +126,10 @@ module Communication::Website::WithDependencies people_in_blocks.compact.any? end + def has_organizations_in_blocks? + organizations_in_blocks.compact.any? + end + def has_persons? has_authors? || has_administrators? || has_researchers? || has_teachers? || has_people_in_blocks? end diff --git a/app/models/university/organization.rb b/app/models/university/organization.rb index 7dd4201622409c85aed1ef46a1dfea5d035422b2..f29dbcb81adf9ba29c75cc88ae1d6bdece104842 100644 --- a/app/models/university/organization.rb +++ b/app/models/university/organization.rb @@ -54,6 +54,15 @@ class University::Organization < ApplicationRecord government: 30 } + def git_dependencies(website) + dependencies = website.menus.to_a + if for_website?(website) + dependencies << self + dependencies.concat active_storage_blobs + end + dependencies + end + def websites university.communication_websites end