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

fix

parent fa58cdac
No related branches found
No related tags found
No related merge requests found
class Admin::Research::DocumentsController < Admin::Research::ApplicationController
def index
@documents = Research::Document.all.page(params[:page])
@documents = current_university.research_documents.page(params[:page])
breadcrumb
end
......
......@@ -2,10 +2,11 @@ module University::Person::WithResearch
extend ActiveSupport::Concern
included do
has_many :research_documents
has_many :research_documents, class_name: 'Research::Document', foreign_key: :university_person_id
end
def load_research_documents!
return unless hal_person_identifier.present?
url = "https://api.archives-ouvertes.fr/search/?q=authIdPerson_i:#{hal_person_identifier}&fl=docid,title_s,citationRef_s,uri_s&rows=1000"
uri = URI(url)
response = Net::HTTP.get(uri)
......
......@@ -2,6 +2,7 @@ module University::WithResearch
extend ActiveSupport::Concern
included do
has_many :research_documents, class_name: 'Research::Document', dependent: :destroy
has_many :research_journals, class_name: 'Research::Journal', dependent: :destroy
has_many :research_laboratories, class_name: 'Research::Laboratory', dependent: :destroy
has_many :research_theses, class_name: 'Research::Thesis', dependent: :destroy
......
......@@ -5,7 +5,6 @@
<thead>
<tr>
<th><%= Research::Document.human_attribute_name('title') %></th>
<th width="400"><%= Research::Document.human_attribute_name('ref') %></th>
<th><%= Research::Document.human_attribute_name('url') %></th>
</tr>
</thead>
......@@ -14,8 +13,7 @@
<% @documents.each do |document| %>
<tr>
<td><%= link_to document, admin_research_document_path(document) %></td>
<td><%= sanitize document.ref %></td>
<td><%= link_to t('show'), document.url, class: button_classes, target: :_blank %></td>
<td><%= link_to t('open'), document.url, class: button_classes, target: :_blank %></td>
</tr>
<% end %>
</tbody>
......
<% content_for :title, @document %>
<%= link_to @document.person, admin_research_researcher_path(@document.person) %>
<p><%= @document.docid %></p>
<div><%= sanitize @document.ref %></div>
......
......@@ -16,35 +16,27 @@
</div>
<% end %>
<% content_for :action_bar_right do %>
<%= edit_link @researcher %>
<% end %>
<% if @researcher.hal_person_identifier.present? %>
<h2 class="h4 mt-5">Publications</h2>
<%
url = "https://api.archives-ouvertes.fr/search/?q=authIdPerson_i:#{@researcher.hal_person_identifier}&fl=title_s,citationRef_s,uri_s&rows=1000"
uri = URI(url)
response = Net::HTTP.get(uri)
data = JSON.parse(response)
%>
<table class="table">
<h2 class="h4 mt-5">Publications</h2>
<div class="table-responsive">
<table class="<%= table_classes %>">
<thead>
<tr>
<th>Titre</th>
<th>Source</th>
<th>URL</th>
<th><%= Research::Document.human_attribute_name('title') %></th>
<th><%= Research::Document.human_attribute_name('url') %></th>
</tr>
</thead>
<tbody>
<% data['response']['docs'].each do |doc| %>
<% @researcher.research_documents.each do |document| %>
<tr>
<td><%= sanitize doc['title_s'][0] %></td>
<td><%= sanitize doc['citationRef_s'] %></td>
<td><%= link_to t('show'), doc['uri_s'], target: :_blank %></td>
<td><%= link_to document, admin_research_document_path(document) %></td>
<td><%= link_to t('open'), document.url, class: button_classes, target: :_blank %></td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
\ No newline at end of file
</div>
<% content_for :action_bar_right do %>
<%= edit_link @researcher %>
<% end %>
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