Skip to content

Commit

Permalink
Merge pull request #292 from openstax/fix_mass_updates
Browse files Browse the repository at this point in the history
Fixed Admin::AddCollaborator when sort_positions are not contiguous integers
  • Loading branch information
Dantemss authored Sep 8, 2020
2 parents cf97f3c + 20a16ff commit aa15e20
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/routines/admin/add_collaborator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ def exec(publishables:, user:, collaborator_type:)
authors << Author.new(
user_id: user.id,
publication_id: publication.id,
sort_position: publication.authors.size + 1
sort_position: (publication.authors.map(&:sort_position).max || 0) + 1
) if (collaborator_type == 'Author' || collaborator_type == 'Both') &&
publication.authors.none? { |author| author.user_id == user.id }

copyright_holders << CopyrightHolder.new(
user_id: user.id,
publication_id: publication.id,
sort_position: publication.copyright_holders.size + 1
sort_position: (publication.copyright_holders.map(&:sort_position).max || 0) + 1
) if (collaborator_type == 'Copyright Holder' || collaborator_type == 'Both') &&
publication.copyright_holders.none? { |ch| ch.user_id == user.id }
end
Expand Down

0 comments on commit aa15e20

Please sign in to comment.