diff --git a/README.md b/README.md index 43722ab1..47f4f333 100644 --- a/README.md +++ b/README.md @@ -123,13 +123,10 @@ irb(main):016:0> user.add_role(:group_admin, Group.research_data) ``` ## PPPL submitters -To allow a non-admin user to submit only to the PPPL group and its communities and subcommunities, that user's default Group must be set to the Princeton Plasma Physics Lab and their roles must be updated. To do this, use the Rails console: +To allow a non-admin user to submit only to the PPPL group and its communities and subcommunities, that user's default Group must be set to the Princeton Plasma Physics Lab and their roles must be updated. To do this, use the Rake task `users:make_pppl_user` and pass the `netid` of the user to update: + ``` -irb(main):011:0> user = User.find_by(uid: 'hb0344') -irb(main):012:0> user.default_group_id = Group.plasma_laboratory.id -irb(main):013:0> user.add_role(:submitter, Group.plasma_laboratory) -irb(main):014:0> user.remove_role(:submitter, Group.research_data) -irb(main):015:0> user.save! +bundle exec rake users:make_pppl_user[xx123] ``` ## Viewing the Application outside of the load balancer diff --git a/lib/tasks/users.rake b/lib/tasks/users.rake index b148e50a..dc991a0a 100644 --- a/lib/tasks/users.rake +++ b/lib/tasks/users.rake @@ -17,6 +17,17 @@ namespace :users do User.create_default_users end + desc "Set a user to be a PPPL user." + task :make_pppl_user, [:netid] => :environment do |_, args| + netid = args[:netid] + user = User.find_by(uid: netid) + user.default_group_id = Group.plasma_laboratory.id + user.add_role(:submitter, Group.plasma_laboratory) + user.remove_role(:submitter, Group.research_data) + user.save! + puts "Switched user #{netid} to PPPL group" + end + # Use this task to regenerate the group_defaults.yml file with the data currently # in the database. This is useful to seed the data from one environment to another. desc "Outputs to the console the user/group admin rights in YAML format"