Skip to content

Commit

Permalink
Merge pull request #607 from IU-Libraries-Joint-Development/essi-1949…
Browse files Browse the repository at this point in the history
…_add_members_single_save

[ESSI-1949] add members via a single save
  • Loading branch information
aploshay authored May 14, 2024
2 parents d45ebba + 267198e commit a2c349b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/extensions/extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def attribute_will_change!(attr)
Hyrax::CurationConcern.actor_factory.swap Hyrax::Actors::CreateWithFilesActor, Hyrax::Actors::CreateWithFilesOrderedMembersActor
Hyrax::Actors::BaseActor.prepend Extensions::Hyrax::Actors::BaseActor::UndoAttributeArrayWrap
Hyrax::Actors::FileSetActor.prepend Extensions::Hyrax::Actors::FileSetActor::CreateContent

Hyrax::Actors::ApplyOrderActor.prepend Extensions::Hyrax::Actors::ApplyOrderActor::AddMembersSingleSave

# .jp2 conversion settings
Hydra::Derivatives.kdu_compress_path = ESSI.config.dig(:essi, :kdu_compress_path)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# modified from hyrax: #save! call moved outside of loop
module Extensions
module Hyrax
module Actors
module ApplyOrderActor
module AddMembersSingleSave
def add_new_work_ids_not_already_in_curation_concern(env, ordered_member_ids)
(ordered_member_ids - env.curation_concern.ordered_member_ids).each do |work_id|
work = ::ActiveFedora::Base.find(work_id)
if can_edit_both_works?(env, work)
env.curation_concern.ordered_members << work
else
env.curation_concern.errors[:ordered_member_ids] << "Works can only be related to each other if user has ability to edit both."
end
end
env.curation_concern.save!
end
end
end
end
end
end

0 comments on commit a2c349b

Please sign in to comment.