Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎁 IiifPrint Enhancements to clean up split works as PDF fileset is deleted #288

Merged
merged 15 commits into from
Nov 15, 2023
Merged
3 changes: 3 additions & 0 deletions app/models/iiif_print/pending_relationship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ class PendingRelationship < ApplicationRecord
validates :parent_id, presence: true
validates :child_title, presence: true
validates :child_order, presence: true
validates :parent_model, presence: true
validates :child_model, presence: true
validates :file_id, presence: true
end
laritakr marked this conversation as resolved.
Show resolved Hide resolved
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddModelDetailsToIiifPrintPendingRelationships < ActiveRecord::Migration[5.2]
def change
add_column :iiif_print_pending_relationships, :parent_model, :string
add_column :iiif_print_pending_relationships, :child_model, :string
add_column :iiif_print_pending_relationships, :file_id, :string
end
end
5 changes: 4 additions & 1 deletion lib/iiif_print/jobs/child_works_from_pdf_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ def prepare_import_data(original_pdf_path, image_files, user)
# save child work info to create the member relationships
PendingRelationship.create!(child_title: child_title,
parent_id: @parent_work.id,
child_order: child_title)
child_order: child_title,
parent_model: @parent_work.class,
child_model: @parent_work.iiif_print_config.pdf_split_child_model,
file_id: file_id)

begin
# Clean up the temporary image path.
Expand Down
5 changes: 3 additions & 2 deletions spec/iiif_print/jobs/create_relationships_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ module IiifPrint::Jobs

let(:parent_model) { WorkWithIiifPrintConfig.to_s }
let(:child_model) { WorkWithIiifPrintConfig.to_s }
let(:file) { FileSet.new.tap { |fs| fs.save!(validate: false) } }
let(:parent_record) { WorkWithIiifPrintConfig.new(title: ['required title']) }
let(:child_record1) { WorkWithIiifPrintConfig.new(title: ["Child of #{parent_record.id} page 01"]) }
let(:child_record2) { WorkWithIiifPrintConfig.new(title: ["Child of #{parent_record.id} page 02"]) }
let(:pending_rel1) { IiifPrint::PendingRelationship.new(parent_id: parent_record.id, child_title: "Child of #{parent_record.id} page 01", child_order: "Child of #{parent_record.id} page 01") }
let(:pending_rel2) { IiifPrint::PendingRelationship.new(parent_id: parent_record.id, child_title: "Child of #{parent_record.id} page 02", child_order: "Child of #{parent_record.id} page 02") }
let(:pending_rel1) { IiifPrint::PendingRelationship.new(parent_id: parent_record.id, child_title: "Child of #{parent_record.id} page 01", child_order: "Child of #{parent_record.id} page 01", parent_model: parent_model, child_model: child_model, file_id: file.id) }
let(:pending_rel2) { IiifPrint::PendingRelationship.new(parent_id: parent_record.id, child_title: "Child of #{parent_record.id} page 02", child_order: "Child of #{parent_record.id} page 02", parent_model: parent_model, child_model: child_model, file_id: file.id) }

describe '#perform' do
before do
Expand Down
Loading