Adding new depositors - OregonDigital/OD2 GitHub Wiki

Setting up new users to be depositors currently requires a developer.
1. once the user has created an account:
  u = User.find_by(email: '[email protected]')
  r = Role.find_by(name: 'depositor')
  u.roles += [r]

2. Add the user to a depositors group (confusingly, this is a role)
  if the group doesn't exist yet:
    r = Role.create(name: 'depositors_in_space')
  else
    r = Role.find_by(name: 'depositors_in_space')
  u.roles += [r]

3. If the group is new, enable the group on an admin set:
  as = AdminSet.find('everything-everywhere')
  as.permission_template.access_grants.create!(agent_type: 'group', access: 'deposit', agent_id: 'depositors_in_space')

4. Enable the group on a collection:
  coll = Collection.find('klingon-embassy-documents-1950s')
  coll.permission_template.access_grants.create!(agent_type: 'group', access: 'deposit', agent_id: 'depositors_in_space')

Notes:
  1. Do not try to add groups to collections in the front end unless the collection is fairly new; doing so seems to load all the objects in the coll; same thing for admin sets.
  2. if the admin set does not appear in the Bulkrax importer form (or disappears) it may need a reindex.