Skip to content
Snippets Groups Projects
Commit ff3755bd authored by Arnaud Levy's avatar Arnaud Levy
Browse files

update working

parent 29a29eef
No related branches found
No related tags found
No related merge requests found
......@@ -9,11 +9,7 @@ class Admin::Research::ResearchersController < Admin::Research::ApplicationContr
def show
load
if @researcher.hal_identity?
@researcher.load_research_publications!
else
@possible_hal_authors = @researcher.possible_hal_authors
end
@possible_hal_authors = @researcher.possible_hal_authors unless @researcher.hal_identity?
@papers = @researcher.research_journal_papers.ordered.page(params[:page])
breadcrumb
end
......@@ -23,7 +19,7 @@ class Admin::Research::ResearchersController < Admin::Research::ApplicationContr
@researcher.update_column :hal_doc_identifier, params[:hal_doc_identifier] if params.has_key?(:hal_doc_identifier)
@researcher.update_column :hal_form_identifier, params[:hal_form_identifier] if params.has_key?(:hal_form_identifier)
@researcher.update_column :hal_person_identifier, params[:hal_person_identifier] if params.has_key?(:hal_person_identifier)
@researcher.load_research_publications!
@researcher.load_research_publications
redirect_to admin_research_researcher_path(@researcher)
end
......
......@@ -44,6 +44,13 @@ class Research::Publication < ApplicationRecord
publication
end
def self.update_from_hal
University::Person::Researcher.with_hal_identifier.find_each do |researcher|
puts "Loading publications for #{researcher} (#{researcher.university})"
researcher.load_research_publications
end
end
def template_static
"admin/research/publications/static"
end
......
......@@ -7,13 +7,15 @@ module University::Person::WithResearch
foreign_key: 'research_publication_id',
association_foreign_key: 'university_person_id'
alias :publications :research_publications
scope :with_hal_identifier, -> { where.not(hal_form_identifier: [nil,'']) }
end
def hal_identity?
hal_form_identifier.present?
end
def load_research_publications!
def load_research_publications
return unless hal_identity?
response = HalOpenscience::Document.search "authIdForm_i:#{hal_form_identifier}",
fields: ["docid", "title_s", "citationRef_s", "uri_s", "*"],
......@@ -23,6 +25,7 @@ module University::Person::WithResearch
research_publications << publication unless publication.in?(research_publications)
end
end
handle_asynchronously :load_research_publications
def possible_hal_authors
HalOpenscience::Author.search(to_s, fields: ['*']).results
......
......@@ -16,35 +16,27 @@
</div>
<% end %>
<div class="card flex-fill w-100">
<div class="card-header">
<h2 class="card-title mb-0 h5">
<%= Research::Publication.model_name.human(count: @researcher.research_publications.count) %>
(<%= @researcher.research_publications.count %>)
</h2>
</div>
<%= osuny_panel Research::Publication.model_name.human(count: 2), action: @researcher.research_publications.count do %>
<% if @researcher.hal_identity? %>
<div class="table-responsive">
<%= render 'admin/research/publications/list', publications: @researcher.research_publications.ordered %>
</div>
<% else %>
<div class="card-body">
<p>Vous n'avez pas d'identifiant HAL. Est-ce l'une des possibilités suivantes ?<p>
<ul class="list-unstyled">
<% @possible_hal_authors.each do |author| %>
<li>
<%= link_to admin_research_researcher_path( @researcher,
hal_doc_identifier: author.docid,
hal_form_identifier: author.attributes['form_i'],
hal_person_identifier: author.attributes['person_i']), method: :put do %>
<%= author.fullName_s %> (<%= author.docid %>)
<% end %>
</li>
<% end %>
</ul>
</div>
<p>Vous n'avez pas d'identifiant HAL. Est-ce l'une des possibilités suivantes ?<p>
<ul class="list-unstyled">
<% @possible_hal_authors.each do |author| %>
<li>
<%= link_to admin_research_researcher_path( @researcher,
hal_doc_identifier: author.docid,
hal_form_identifier: author.attributes['form_i'],
hal_person_identifier: author.attributes['person_i']), method: :put do %>
<%= author.fullName_s %> (<%= author.docid %>)
<% end %>
</li>
<% end %>
</ul>
<% end %>
</div>
<% end %>
<% content_for :action_bar_right do %>
<%= edit_link @researcher %>
......
namespace :auto do
desc 'Update publications from HAL for all researchers'
task update_publications_from_hal: :environment do
Research::Publication.update_from_hal
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment