From bf3dacbe95d3b0bc7e830729f682947f0de458d9 Mon Sep 17 00:00:00 2001 From: Xiaoming Hu Date: Tue, 14 Jan 2025 23:50:42 +0100 Subject: [PATCH] enable to save ror_id when creating an institution along with a project --- app/controllers/projects_controller.rb | 13 ++++++------- .../administer_create_project_request.html.erb | 3 +++ lib/seek/project_message_log_details.rb | 3 +-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 8ce42d74e7..50be687f54 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -129,7 +129,7 @@ def respond_join_request validation_error_msg=nil; if params[:accept_request]=='1' - inst_params = params.require(:institution).permit([:id, :title, :web_page, :city, :country]) + inst_params = params.require(:institution).permit([:id, :title, :web_page, :city, :country, :ror_id]) @institution = Institution.new(inst_params) if @institution.id @@ -184,7 +184,7 @@ def request_join raise 'no projects defined' if @projects.empty? @institution = Institution.find_by_id(params[:institution][:id]) if @institution.nil? - inst_params = params.require(:institution).permit([:id, :title, :web_page, :city, :country]) + inst_params = params.require(:institution).permit([:id, :title, :web_page, :city, :country, :ror_id]) @institution = Institution.new(inst_params) end @@ -230,7 +230,7 @@ def request_create @institution = Institution.find_by_id(params[:institution][:id]) if @institution.nil? - inst_params = params.require(:institution).permit([:title, :web_page, :city, :country]) + inst_params = params.require(:institution).permit([:title, :web_page, :city, :country, :ror_id]) @institution = Institution.new(inst_params) end @@ -341,7 +341,7 @@ def request_import # Create institution @institution = Institution.find_by_id(params[:institution][:id]) if @institution.nil? - inst_params = params.require(:institution).permit([:id, :title, :web_page, :city, :country]) + inst_params = params.require(:institution).permit([:id, :title, :web_page, :city, :country, :ror_id]) @institution = Institution.new(inst_params) end @@ -718,12 +718,11 @@ def administer_import_project_request def respond_create_project_request requester = @message_log.sender - if params['accept_request']=='1' if params['institution']['id'] @institution = Institution.find(params['institution']['id']) else - @institution = Institution.new(params.require(:institution).permit([:title, :web_page, :city, :country])) + @institution = Institution.new(params.require(:institution).permit([:title, :web_page, :city, :country, :ror_id])) end @project = Project.new(params.require(:project).permit([:title, :web_page, :description])) @@ -784,7 +783,7 @@ def respond_import_project_request if params['institution']['id'] @institution = Institution.find(params['institution']['id']) else - @institution = Institution.new(params.require(:institution).permit([:title, :web_page, :city, :country])) + @institution = Institution.new(params.require(:institution).permit([:title, :web_page, :city, :country, :ror_id])) end @project = Project.new(params.require(:project).permit([:title, :web_page, :description])) diff --git a/app/views/projects/administer_create_project_request.html.erb b/app/views/projects/administer_create_project_request.html.erb index 1bd5081588..d7f84bfb88 100644 --- a/app/views/projects/administer_create_project_request.html.erb +++ b/app/views/projects/administer_create_project_request.html.erb @@ -68,6 +68,9 @@ <%= label_tag 'Title' %>* <%= text_field_tag 'institution[title]',@institution.title, class:'form-control' %> + <%= label_tag 'ROR ID','ROR ID' %> + <%= text_field_tag 'institution[ror_id]',@institution.ror_id, class:'form-control' %> + <%= label_tag 'Website' %> <%= text_field_tag 'institution[web_page]',@institution.web_page, class:'form-control' %> diff --git a/lib/seek/project_message_log_details.rb b/lib/seek/project_message_log_details.rb index ce4d8f8d26..20358fcec9 100644 --- a/lib/seek/project_message_log_details.rb +++ b/lib/seek/project_message_log_details.rb @@ -26,7 +26,7 @@ def parsed_details REQUIRED_ATTRIBUTES = { Project => %w[id title description web_page programme_id], - Institution => %w[id title city country web_page], + Institution => %w[id title city country web_page ror_id], Person => %w[id first_name last_name email], Programme => %w[id title description] }.freeze @@ -65,7 +65,6 @@ def details_json(programme: nil, project: nil, institution: nil, people: nil, co details[:programme] = programme.attributes.slice(*REQUIRED_ATTRIBUTES[Programme]) if programme details[:people] = people.map { |person| person.attributes.slice(*REQUIRED_ATTRIBUTES[Person]) } if people details[:comments] = comments if comments - details.to_json end end