Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a rake task to grant a person the right to manage all publications of a project #2074

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions lib/tasks/seek_dev.rake
Original file line number Diff line number Diff line change
Expand Up @@ -401,4 +401,20 @@ namespace :seek_dev do
task rebuild_csl_style_list: :environment do
File.write(Seek::Citations.style_dictionary_path, Seek::Citations.generate_style_pairs.to_yaml)
end

#bundle exec rake seek_dev:grant_a_person_the_right_to_manage_all_publications_of_a_project[project_id,person_id]
task :grant_a_person_the_right_to_manage_all_publications_of_a_project, [:project_id, :person_id] => [:environment] do |t, args|

project_id = args.project_id
person_id = args.person_id
puts "project_id:"+project_id.to_s
puts "person_id:"+person_id.to_s

pub_ids = Project.find(project_id).publications.map(&:id)
pub_ids.each do |id|
permission = Publication.find(id).policy.permissions.where(contributor_type: "Person", contributor_id: person_id).first_or_initialize
permission.update_attributes(access_type: Policy::MANAGING)
end

end
end