Skip to content

AdminSets, users and permissions

Ryan Wick edited this page Sep 7, 2018 · 1 revision

In a given AdminSet with existing works, changes to the participating `users' or permissions are not saved to existing works, only new works going forward. More info: http://samvera.github.io/admin-set-participants.html

This can be mitigated some by using groups instead of users, so the group is used for permissions, and people can join or be removed from a group as needed.

But there may be a need to assign a specific user (or even a group) to either all existing items in an AdminSet, or a subset of items. This can be done via the Rails console on Production, an example below for Dataset works, but needing user# replacement:

# Find items in Admin Set, iterate over them
# Check if user is already 'edit user', if not add as part of all users
results = ActiveFedora::SolrService.query("admin_set_tesim:#{RSolr.escape("Dataset")}", :fl => "id", :rows => 100000)
results.count

count = 0
results.map{|x| x["id"]}.each do |pid|
w = ActiveFedora::Base.find(pid)

puts pid + " " + w.edit_users.to_s
next if w.edit_users.include?('user3')

w.edit_users = ["user1", "user2", "user3", "user4"]
w.save

count += 1
end

puts count.to_s + " changed"

Note: this will assign the username values listed in the array and overwrite any existing values. It may be worthwhile to check all existing values, especially if users aren't very uniform across the items. Can just comment out the lines after puts to print them. Or look at adding the new user3 to existing values with +=. w.edit_users << "user3" wasn't working when I tried it.