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