-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #607 from IU-Libraries-Joint-Development/essi-1949…
…_add_members_single_save [ESSI-1949] add members via a single save
- Loading branch information
Showing
2 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
lib/extensions/hyrax/actors/apply_order_actor/add_members_single_save.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |