Skip to content

Commit

Permalink
enable to save ror_id when creating an institution along with a project
Browse files Browse the repository at this point in the history
  • Loading branch information
whomingbird committed Jan 14, 2025
1 parent 81dba73 commit bf3dacb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
13 changes: 6 additions & 7 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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]))
Expand Down Expand Up @@ -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]))
Expand Down
3 changes: 3 additions & 0 deletions app/views/projects/administer_create_project_request.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
<%= label_tag 'Title' %><span class="required">*</span>
<%= 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' %>

Expand Down
3 changes: 1 addition & 2 deletions lib/seek/project_message_log_details.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bf3dacb

Please sign in to comment.