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

deletes

parent df53cce9
No related branches found
No related tags found
No related merge requests found
......@@ -79,7 +79,11 @@ class Communication::Website::Category < ApplicationRecord
end
def git_dependencies_static
posts
descendents + posts
end
def git_destroy_dependencies_static
descendents
end
def update_children_paths
......
......@@ -42,4 +42,7 @@ class Communication::Website::Home < ApplicationRecord
active_storage_blobs
end
def git_destroy_dependencies_static
active_storage_blobs
end
end
......@@ -76,7 +76,11 @@ class Communication::Website::Page < ApplicationRecord
end
def git_dependencies_static
descendents + siblings + active_storage_blobs
descendents + active_storage_blobs + siblings
end
def git_destroy_dependencies_static
descendents + active_storage_blobs
end
def to_s
......
......@@ -75,6 +75,10 @@ class Communication::Website::Post < ApplicationRecord
[author] + categories + active_storage_blobs
end
def git_destroy_dependencies_static
explicit_active_storage_blobs
end
def to_s
"#{title}"
end
......
......@@ -41,6 +41,10 @@ module WithGit
websites_with_fallback.each do |website|
identifiers.each do |identifier|
Communication::Website::GitFile.sync website, self, identifier, destroy: true
dependencies = send "git_destroy_dependencies_#{identifier}"
dependencies.each do |object|
Communication::Website::GitFile.sync website, object, identifier, destroy: true
end
end
website.git_repository.sync!
end
......@@ -82,4 +86,8 @@ module WithGit
def git_dependencies_static
[]
end
def git_destroy_dependencies_static
[]
end
end
......@@ -2,8 +2,15 @@ module WithMedia
extend ActiveSupport::Concern
def active_storage_blobs
blob_ids = [best_featured_image&.blob_id, rich_text_blob_ids].flatten.compact
university.active_storage_blobs.where(id: blob_ids)
explicit_active_storage_blobs.or inherited_active_storage_blobs
end
def explicit_active_storage_blobs
blobs_with_ids [featured_image&.blob_id, rich_text_blob_ids]
end
def inherited_active_storage_blobs
blobs_with_ids [best_featured_image]
end
def rich_text_reflection_names
......@@ -20,4 +27,10 @@ module WithMedia
def best_featured_image(fallback: true)
featured_image
end
protected
def blobs_with_ids(ids)
university.active_storage_blobs.where(id: ids.flatten.compact)
end
end
......@@ -25,8 +25,8 @@ class Research::Journal < ApplicationRecord
belongs_to :university
has_many :websites, class_name: 'Communication::Website', as: :about
has_many :volumes, foreign_key: :research_journal_id
has_many :articles, foreign_key: :research_journal_id
has_many :volumes, foreign_key: :research_journal_id, dependent: :destroy
has_many :articles, foreign_key: :research_journal_id, dependent: :destroy
has_many :researchers, through: :articles
scope :ordered, -> { order(:title) }
......@@ -42,4 +42,8 @@ class Research::Journal < ApplicationRecord
def git_dependencies_static
articles + volumes + researchers
end
def git_destroy_dependencies_static
articles + volumes
end
end
......@@ -32,7 +32,7 @@ class Research::Journal::Volume < ApplicationRecord
belongs_to :university
belongs_to :journal, foreign_key: :research_journal_id
has_many :articles, foreign_key: :research_journal_volume_id
has_many :articles, foreign_key: :research_journal_volume_id, dependent: :nullify
has_many :websites, -> { distinct }, through: :journal
has_many :researchers, through: :articles
......
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