diff --git a/app/controllers/admin/research/hal/publications_controller.rb b/app/controllers/admin/research/hal/publications_controller.rb index 884b4efab6f4b776266f9f85045213aea7c71f80..1fa195dff532ec2824ff6a57a64dda4c88d4aab2 100644 --- a/app/controllers/admin/research/hal/publications_controller.rb +++ b/app/controllers/admin/research/hal/publications_controller.rb @@ -2,7 +2,7 @@ class Admin::Research::Hal::PublicationsController < Admin::Research::Hal::Appli before_action :load_publication, except: :index def index - @publications = Research::Hal::Publication.ordered.page(params[:page]) + @publications = Research::Publication.hal.ordered.page(params[:page]) breadcrumb end @@ -24,12 +24,12 @@ class Admin::Research::Hal::PublicationsController < Admin::Research::Hal::Appli protected def load_publication - @publication = Research::Hal::Publication.find params[:id] + @publication = Research::Publication.find params[:id] end def breadcrumb super - add_breadcrumb Research::Hal::Publication.model_name.human(count: 2), + add_breadcrumb Research::Publication.model_name.human(count: 2), admin_research_hal_publications_path breadcrumb_for @publication end diff --git a/app/controllers/admin/research/publications_controller.rb b/app/controllers/admin/research/publications_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..637dbf1ee3bd8c2acbc3e2578808697f7482f5ae --- /dev/null +++ b/app/controllers/admin/research/publications_controller.rb @@ -0,0 +1,60 @@ +class Admin::Research::PublicationsController < Admin::Research::ApplicationController + load_and_authorize_resource class: Research::Publication + + has_scope :for_search_term + + def index + @publications = apply_scopes(@publications).ordered.page(params[:page]) + breadcrumb + end + + def show + breadcrumb + end + + def new + breadcrumb + end + + def edit + breadcrumb + add_breadcrumb t('edit') + end + + def create + if @publication.save + redirect_to [:admin, @publication], notice: t('admin.successfully_created_html', model: @publication.to_s) + else + breadcrumb + render :new, status: :unprocessable_entity + end + end + + def update + if @publication.update(publication_params) + redirect_to [:admin, @publication], notice: t('admin.successfully_updated_html', model: @publication.to_s) + else + breadcrumb + add_breadcrumb t('edit') + render :edit, status: :unprocessable_entity + end + end + + def destroy + @publication.destroy + redirect_to admin_research_publications_url, notice: t('admin.successfully_destroyed_html', model: @publication.to_s) + end + + protected + + def breadcrumb + super + add_breadcrumb Research::Publication.model_name.human(count: 2), admin_research_publications_path + breadcrumb_for @publication + end + + def publication_params + params.require(:research_publication) + .permit(:title) + end +end diff --git a/app/models/research.rb b/app/models/research.rb index 633d16d2a16491cdedca12166d8213be2f894dd7..0c9050ee5598f8415c07587e3041291f8958a9fe 100644 --- a/app/models/research.rb +++ b/app/models/research.rb @@ -12,7 +12,7 @@ module Research [Research::Laboratory, :admin_research_laboratories_path], [Research::Thesis, :admin_research_theses_path], [Research::Journal, :admin_research_journals_path], - [Research::Hal, :admin_research_hal_root_path], + [Research::Publication, :admin_research_publications_path], ] end end diff --git a/app/models/research/hal.rb b/app/models/research/hal.rb index 21695429ce29bf132b47c2268119e4645460a73e..9151d3e536ff39d8161c45f7ae23b393c0bfdc60 100644 --- a/app/models/research/hal.rb +++ b/app/models/research/hal.rb @@ -39,7 +39,7 @@ module Research::Hal def self.parts [ - [Research::Hal::Publication, :admin_research_hal_publications_path], + [Research::Publication, :admin_research_hal_publications_path], [Research::Hal::Author, :admin_research_hal_authors_path], ] end diff --git a/app/models/research/hal/author.rb b/app/models/research/hal/author.rb index 916467e972a7300aa983ba714581974cacca797c..8843d31effb08074cfdabad4f4e549564594dd01 100644 --- a/app/models/research/hal/author.rb +++ b/app/models/research/hal/author.rb @@ -20,7 +20,7 @@ class Research::Hal::Author < ApplicationRecord include Sanitizable has_and_belongs_to_many :publications, - foreign_key: 'research_hal_publication_id', + foreign_key: 'research_publication_id', association_foreign_key: :research_hal_author_id has_and_belongs_to_many :university_person_researchers, class_name: 'University::Person', @@ -47,7 +47,7 @@ class Research::Hal::Author < ApplicationRecord end def self.create_from(doc) - author = where(docid: doc.docid).first_or_create + author = where(docid: doc.hal_docid).first_or_create author.form_identifier = doc.form_i author.person_identifier = doc&.person_i if doc.attributes.has_key?(:person_i) author.first_name = doc.firstName_s diff --git a/app/models/research/hal/publication.rb b/app/models/research/publication.rb similarity index 84% rename from app/models/research/hal/publication.rb rename to app/models/research/publication.rb index 62e543fe86d77005396687a7ba4e68d88327d619..615a27f8e8ae2d2e1a2de9a8684099da790f609b 100644 --- a/app/models/research/hal/publication.rb +++ b/app/models/research/publication.rb @@ -1,6 +1,6 @@ # == Schema Information # -# Table name: research_hal_publications +# Table name: research_publications # # id :uuid not null, primary key # abstract :text @@ -8,15 +8,16 @@ # authors_list :text # citation_full :text # data :jsonb -# docid :string indexed # doi :string # file :text +# hal_docid :string indexed # hal_url :string # journal_title :string # open_access :boolean # publication_date :date # ref :string # slug :string indexed +# source :integer default("osuny") # title :string # url :string # created_at :datetime not null @@ -24,10 +25,10 @@ # # Indexes # -# index_research_hal_publications_on_docid (docid) -# index_research_hal_publications_on_slug (slug) +# index_research_publications_on_hal_docid (hal_docid) +# index_research_publications_on_slug (slug) # -class Research::Hal::Publication < ApplicationRecord +class Research::Publication < ApplicationRecord include AsIndirectObject include Sanitizable include Sluggable @@ -38,16 +39,26 @@ class Research::Hal::Publication < ApplicationRecord has_and_belongs_to_many :researchers, class_name: 'University::Person', foreign_key: :university_person_id, - association_foreign_key: :research_hal_publication_id + association_foreign_key: :research_publication_id has_and_belongs_to_many :authors, + class_name: 'Research::Hal::Author', foreign_key: :research_hal_author_id, - association_foreign_key: :research_hal_publication_id + association_foreign_key: :research_publication_id validates_presence_of :docid scope :ordered, -> { order(publication_date: :desc)} + enum source: { + osuny: 0, + hal: 1 + } + + def editable? + source == :osuny + end + # https://api.archives-ouvertes.fr/search/?q=03713859&fl=* def self.import_from_hal_for_author(author) fields = [ @@ -78,7 +89,7 @@ class Research::Hal::Publication < ApplicationRecord end def self.create_from(doc) - publication = where(docid: doc.docid).first_or_create + publication = where(hal_docid: doc.docid).first_or_create puts "HAL sync publication #{doc.docid}" publication.title = Osuny::Sanitizer.sanitize doc.title_s.first, 'string' publication.ref = doc.attributes['citationRef_s'] @@ -104,7 +115,7 @@ class Research::Hal::Publication < ApplicationRecord end def template_static - "admin/research/hal/publications/static" + "admin/research/publications/static" end def git_path(website) diff --git a/app/models/university/person/with_research.rb b/app/models/university/person/with_research.rb index e501d5543fb78670d65d24506b7fda0fb70d1fe6..29c0812a6630f0075865fc2b9d4588a743cd7f9a 100644 --- a/app/models/university/person/with_research.rb +++ b/app/models/university/person/with_research.rb @@ -6,14 +6,7 @@ module University::Person::WithResearch class_name: 'Research::Hal::Author', foreign_key: :research_hal_author_id, association_foreign_key: :university_person_id - alias :hal_authors :research_hal_authors - - has_and_belongs_to_many :research_hal_publications, - class_name: 'Research::Hal::Publication', - foreign_key: :research_hal_publication_id, - association_foreign_key: :university_person_id - alias :hal_publications :research_hal_publications - alias :publications :research_hal_publications + alias :hal_authors :research_hal_authors has_many :authored_research_theses, class_name: 'Research::Thesis', @@ -25,11 +18,17 @@ module University::Person::WithResearch foreign_key: :director_id, dependent: :nullify + has_and_belongs_to_many :research_publications, + class_name: 'Research::Publication', + foreign_key: :research_publication_id, + association_foreign_key: :university_person_id + alias :publications :research_publications + has_and_belongs_to_many :research_laboratories, class_name: 'Research::Laboratory', foreign_key: :research_laboratory_id, association_foreign_key: :university_person_id - alias :laboratories :research_laboratories + alias :laboratories :research_laboratories scope :with_hal_identifier, -> { where.not(hal_form_identifier: [nil,'']) } end diff --git a/app/models/university/with_research.rb b/app/models/university/with_research.rb index 7169a92242738687ef2d4ceb79eeda5846355ca2..dc721e5bd9dd348a7eb8e227340ed0d8d0d4591c 100644 --- a/app/models/university/with_research.rb +++ b/app/models/university/with_research.rb @@ -4,6 +4,7 @@ module University::WithResearch included do has_many :research_journals, class_name: 'Research::Journal', dependent: :destroy has_many :research_laboratories, class_name: 'Research::Laboratory', dependent: :destroy + has_many :research_publications, class_name: 'Research::Publication', dependent: :destroy has_many :research_theses, class_name: 'Research::Thesis', dependent: :destroy end end diff --git a/app/views/admin/research/hal/authors/show.html.erb b/app/views/admin/research/hal/authors/show.html.erb index f3b2e937108f883f95d4236f55b2bcb67443e024..243de83b6141410d7a5c31aa59744e6a707aeece 100644 --- a/app/views/admin/research/hal/authors/show.html.erb +++ b/app/views/admin/research/hal/authors/show.html.erb @@ -14,7 +14,7 @@ </div> </div> -<%= osuny_panel Research::Hal::Publication.model_name.human(count: 2), subtitle: @author.publications.count do %> +<%= osuny_panel Research::Publication.model_name.human(count: 2), subtitle: @author.publications.count do %> <%= render 'admin/research/hal/publications/list', publications: @author.publications.ordered %> <% end %> diff --git a/app/views/admin/research/hal/publications/_list.html.erb b/app/views/admin/research/hal/publications/_list.html.erb index 62de27ec44b9d0e21a83de09d625017c3afeaaf1..27745c378e856235b8a35e97e3d18e67bd0389a5 100644 --- a/app/views/admin/research/hal/publications/_list.html.erb +++ b/app/views/admin/research/hal/publications/_list.html.erb @@ -2,8 +2,8 @@ <table class="<%= table_classes %>"> <thead> <tr> - <th><%= Research::Hal::Publication.human_attribute_name('title') %></th> - <th width="150"><%= Research::Hal::Publication.human_attribute_name('publication_date') %></th> + <th><%= Research::Publication.human_attribute_name('title') %></th> + <th width="150"><%= Research::Publication.human_attribute_name('publication_date') %></th> <th width="200"><%= University::Person::Researcher.model_name.human(count: 2) %></th> </tr> </thead> diff --git a/app/views/admin/research/hal/publications/index.html.erb b/app/views/admin/research/hal/publications/index.html.erb index 5b34326d71b5e6bdbc298b1c628d9a104dde9881..bf53ad41ce2a6c8dd206c8919bebaa929fd31630 100644 --- a/app/views/admin/research/hal/publications/index.html.erb +++ b/app/views/admin/research/hal/publications/index.html.erb @@ -1,4 +1,4 @@ -<% content_for :title, Research::Hal::Publication.model_name.human(count: 2) %> +<% content_for :title, Research::Publication.model_name.human(count: 2) %> <% content_for :title_right, "#{ @publications.total_count }" %> <%= render 'admin/research/hal/publications/list', publications: @publications %> <%= paginate @publications, theme: 'bootstrap-5' %> diff --git a/app/views/admin/research/hal/publications/show.html.erb b/app/views/admin/research/hal/publications/show.html.erb index 4f0a02251bae44db524964b7b9fa041462674f3f..3b8b3871050477c839b7065d4bef135a3026c849 100644 --- a/app/views/admin/research/hal/publications/show.html.erb +++ b/app/views/admin/research/hal/publications/show.html.erb @@ -9,29 +9,29 @@ <% end %> <div class="row"> <div class="col-lg-6"> - <%= osuny_label Research::Hal::Publication.human_attribute_name('citation_full') %> + <%= osuny_label Research::Publication.human_attribute_name('citation_full') %> <p><%= sanitize @publication.citation_full %></p> </div> <div class="col-lg-6"> - <%= osuny_label Research::Hal::Publication.human_attribute_name('ref') %> + <%= osuny_label Research::Publication.human_attribute_name('ref') %> <p><%= sanitize @publication.ref %></p> </div> <div class="col-lg-6"> - <%= osuny_label Research::Hal::Publication.human_attribute_name('docid') %> - <p><%= @publication.docid %></p> + <%= osuny_label Research::Publication.human_attribute_name('docid') %> + <p><%= @publication.hal_docid %></p> </div> <div class="col-lg-6"> - <%= osuny_label Research::Hal::Publication.human_attribute_name('publication_date') %> + <%= osuny_label Research::Publication.human_attribute_name('publication_date') %> <p><%= l @publication.publication_date %></p> </div> <div class="col-lg-6"> - <%= osuny_label Research::Hal::Publication.human_attribute_name('open_access') %> + <%= osuny_label Research::Publication.human_attribute_name('open_access') %> <p><%= t @publication.open_access %></p> </div> </div> </div> <div class="col-lg-4"> - <%= osuny_panel Research::Hal::Publication.human_attribute_name('authors_list') do %> + <%= osuny_panel Research::Publication.human_attribute_name('authors_list') do %> <p><%= @publication.authors_list %></p> <% end %> <%= osuny_panel University::Person::Researcher.model_name.human(count: 2) do %> @@ -57,7 +57,7 @@ <% [:url, :hal_url, :doi_url, :file].each do |key| %> <% value = @publication.send key %> <% next if value.blank? %> - <%= osuny_label Research::Hal::Publication.human_attribute_name(key) %> + <%= osuny_label Research::Publication.human_attribute_name(key) %> <p><%= link_to value, value, target: :_blank %></p> <% end %> diff --git a/app/views/admin/research/hal/publications/static.html.erb b/app/views/admin/research/hal/publications/static.html.erb index 75fbeacb368554157da234689a31ef581e11d3ad..438b84b5a4d11a427d58cb4d56d91f871049a4f7 100644 --- a/app/views/admin/research/hal/publications/static.html.erb +++ b/app/views/admin/research/hal/publications/static.html.erb @@ -6,7 +6,9 @@ date: "<%= @about.publication_date&.iso8601 %>" pages: @website.special_page(Communication::Website::Page::ResearchHalPublication).ancestors_and_self, current_title: @about.to_s %> <%= render 'admin/application/static/permalink' %> -docid: "<%= @about.docid %>" +hal: + docid: "<%= @about.hal_docid %>" + url: "<%= @about.hal_url %>" abstract: >- <%= prepare_html_for_static @about.abstract, @website.university %> citation_full: >- diff --git a/app/views/admin/research/publications/_form.html.erb b/app/views/admin/research/publications/_form.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..ca7c538952057d3661a21a90342b6a00277309d1 --- /dev/null +++ b/app/views/admin/research/publications/_form.html.erb @@ -0,0 +1,13 @@ +<%= simple_form_for [:admin, publication] do |f| %> + <%= f.error_notification %> + <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %> + + <div class="row"> + <div class="col-md-6"> + <%= f.input :title %> + </div> + </div> + <% content_for :action_bar_right do %> + <%= submit f %> + <% end %> +<% end %> diff --git a/app/views/admin/research/publications/_list.html.erb b/app/views/admin/research/publications/_list.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..347ceff6660f3a73ea16d3286f1a0c1669041d10 --- /dev/null +++ b/app/views/admin/research/publications/_list.html.erb @@ -0,0 +1,30 @@ +<div class="table-responsive"> + <table class="<%= table_classes %>"> + <thead> + <tr> + <th><%= Research::Publication.human_attribute_name('title') %></th> + <th><%= Research::Publication.human_attribute_name('publication_date') %></th> + <th></th> + </tr> + </thead> + <tbody> + <% @publications.each do |publication| %> + <tr> + <td> + <%= link_to publication, [:admin, publication] %><br> + <small><%= publication.authors_list %></small> + </td> + <td><%= l publication.publication_date %></td> + <td class="text-end"> + <% if publication.editable? %> + <div class="btn-group" role="group"> + <%= edit_link publication %> + <%= destroy_link publication %> + </div> + <% end %> + </td> + </tr> + <% end %> + </tbody> + </table> +</div> \ No newline at end of file diff --git a/app/views/admin/research/publications/edit.html.erb b/app/views/admin/research/publications/edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..02d475a3c5f707a68c16282e0405f0fd60fb3824 --- /dev/null +++ b/app/views/admin/research/publications/edit.html.erb @@ -0,0 +1,3 @@ +<% content_for :title, @publication %> + +<%= render 'form', publication: @publication %> diff --git a/app/views/admin/research/publications/index.html.erb b/app/views/admin/research/publications/index.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..9791ccb5a32ca9318a9af78a21ce06f8fc8d9755 --- /dev/null +++ b/app/views/admin/research/publications/index.html.erb @@ -0,0 +1,8 @@ +<% content_for :title, Research::Publication.model_name.human(count: 2) %> +<%= render 'filters', current_path: admin_research_publications_path, filters: @filters if @filters.any? %> +<%= render 'admin/research/publications/list', publications: @publications %> +<%= paginate @publications, theme: 'bootstrap-5' %> + +<% content_for :action_bar_right do %> + <%= create_link Research::Publication %> +<% end %> diff --git a/app/views/admin/research/publications/new.html.erb b/app/views/admin/research/publications/new.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..0ef29607a47153f3d0f1f508037f90dc66ef975d --- /dev/null +++ b/app/views/admin/research/publications/new.html.erb @@ -0,0 +1,3 @@ +<% content_for :title, Research::Publication.model_name.human %> + +<%= render 'form', publication: @publication %> diff --git a/app/views/admin/research/publications/show.html.erb b/app/views/admin/research/publications/show.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..8c1428cba7d5c0ae6dc957c04812bc16fb9c878f --- /dev/null +++ b/app/views/admin/research/publications/show.html.erb @@ -0,0 +1,72 @@ +<% content_for :title, @publication %> + + +<div class="row"> + <div class="col-lg-8"> + <% if @publication.abstract.present? %> + <p class="lead mb-5"> + <%= sanitize @publication.abstract %> + </p> + <% end %> + <div class="row"> + <div class="col-lg-6"> + <%= osuny_label Research::Publication.human_attribute_name('citation_full') %> + <p><%= sanitize @publication.citation_full %></p> + </div> + <div class="col-lg-6"> + <%= osuny_label Research::Publication.human_attribute_name('ref') %> + <p><%= sanitize @publication.ref %></p> + </div> + <div class="col-lg-6"> + <%= osuny_label Research::Publication.human_attribute_name('docid') %> + <p><%= @publication.hal_docid %></p> + </div> + <div class="col-lg-6"> + <%= osuny_label Research::Publication.human_attribute_name('publication_date') %> + <p><%= l @publication.publication_date %></p> + </div> + <div class="col-lg-6"> + <%= osuny_label Research::Publication.human_attribute_name('open_access') %> + <p><%= t @publication.open_access %></p> + </div> + </div> + </div> + <div class="col-lg-4"> + <%= osuny_panel Research::Publication.human_attribute_name('authors_list') do %> + <p><%= @publication.authors_list %></p> + <% end %> + <%= osuny_panel University::Person::Researcher.model_name.human(count: 2) do %> + <% @publication.researchers.in_university(current_university).each do |researcher| %> + <%= render 'admin/university/people/researchers/researcher', researcher: researcher %> + <% end %> + <% end %> + <%= osuny_panel Research::Hal::Author.model_name.human(count: 2) do %> + <ul class="list-unstyled"> + <% @publication.authors.each do |author| %> + <li> + <%= link_to [:admin, author] do %> + <%= author %> + (<%= author.docid %>) + <% end %> + </li> + <% end %> + </ul> + <% end %> + </div> +</div> + +<% [:url, :hal_url, :doi_url, :file].each do |key| %> + <% value = @publication.send key %> + <% next if value.blank? %> + <%= osuny_label Research::Publication.human_attribute_name(key) %> + <p><%= link_to value, value, target: :_blank %></p> +<% end %> + + +<% content_for :action_bar_left do %> + <%= destroy_link @publication if @publication.editable? %> +<% end %> + +<% content_for :action_bar_right do %> + <%= edit_link @publication if @publication.editable? %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/research/publications/static.html.erb b/app/views/admin/research/publications/static.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..438b84b5a4d11a427d58cb4d56d91f871049a4f7 --- /dev/null +++ b/app/views/admin/research/publications/static.html.erb @@ -0,0 +1,51 @@ +--- +title: >- + <%= @about.title %> +date: "<%= @about.publication_date&.iso8601 %>" +<%= render 'admin/application/static/breadcrumbs', + pages: @website.special_page(Communication::Website::Page::ResearchHalPublication).ancestors_and_self, + current_title: @about.to_s %> +<%= render 'admin/application/static/permalink' %> +hal: + docid: "<%= @about.hal_docid %>" + url: "<%= @about.hal_url %>" +abstract: >- + <%= prepare_html_for_static @about.abstract, @website.university %> +citation_full: >- + <%= prepare_html_for_static @about.citation_full, @website.university %> +authors_list: >- + <%= @about.authors_list %> +ref: >- + <%= sanitize @about.ref %> +links: + - label: "HAL" + url: "<%= @about.hal_url %>" + - label: "DOI" + url: "<%= @about.doi_url %>" + - label: "URL" + url: "<%= @about.url %>" + - label: "PDF" + url: "<%= @about.file %>" +researchers: +<% @about.researchers.in_university(@website.university).each do |researcher| %> + - <%= researcher.slug %> +<% end %> +citations: + - label: "APA" + content: >- + <%= prepare_html_for_static @about.citation_apa, @website.university %> + - label: "MLA" + content: >- + <%= prepare_html_for_static @about.citation_mla, @website.university %> + - label: "Chicago" + content: >- + <%= prepare_html_for_static @about.citation_chicago, @website.university %> + - label: "Harvard" + content: >- + <%= prepare_html_for_static @about.citation_harvard, @website.university %> + <% if @website.default_language.iso_code == "fr" %> + - label: "ISO 690" + content: >- + <%= prepare_html_for_static @about.citation_iso690, @website.university %> + <% end %> +--- \ No newline at end of file diff --git a/app/views/admin/research/researchers/show.html.erb b/app/views/admin/research/researchers/show.html.erb index d1f930ea00068f34008a080e9e4753ae6085d25a..d67e6524aac89316ec7eb118edef9f5516ad592d 100644 --- a/app/views/admin/research/researchers/show.html.erb +++ b/app/views/admin/research/researchers/show.html.erb @@ -44,13 +44,13 @@ </div> <% end %> -<%= osuny_panel Research::Hal::Publication.model_name.human(count: 2) do %> +<%= osuny_panel Research::Publication.model_name.human(count: 2) do %> <p> - <%= "#{@researcher.hal_publications.count} #{Research::Hal::Publication.model_name.human(count: @researcher.hal_publications.count).downcase}" %>. + <%= "#{@researcher.hal_publications.count} #{Research::Publication.model_name.human(count: @researcher.hal_publications.count).downcase}" %>. Les publications sont mises à jour automatiquement, chaque nuit. </p> <div class="table-responsive"> - <%= render 'admin/research/hal/publications/list', publications: @researcher.hal_publications.ordered %> + <%= render 'admin/research/publications/list', publications: @researcher.hal_publications.ordered %> </div> <% end %> diff --git a/config/locales/research/en.yml b/config/locales/research/en.yml index da5bce56385159fd5c8140d435eaac430cca089c..874e2fe7fa877e7536869e2face7111597ae2b51 100644 --- a/config/locales/research/en.yml +++ b/config/locales/research/en.yml @@ -11,9 +11,6 @@ en: research/hal/author: one: HAL author other: HAL authors - research/hal/publication: - one: Publication - other: Publications research/journal: one: Journal other: Journals @@ -32,6 +29,9 @@ en: research/laboratory/axis: one: Axis other: Axes + research/publication: + one: Publication + other: Publications research/thesis: one: Thesis other: Theses @@ -41,14 +41,6 @@ en: first_name: First name full_name: Full name last_name: Last name - research/hal/publication: - authors_list: Authors list - docid: Identifier - doi_url: URL DOI - publication_date: Publication date - title: Title - url: URL - hal_url: URL HAL research/journal: issn: ISSN title: Title @@ -88,6 +80,14 @@ en: name: Name short_name: Short name text: Text + research/publication: + authors_list: Authors list + docid: Identifier + doi_url: URL DOI + publication_date: Publication date + title: Title + url: URL + hal_url: URL HAL research/thesis: abstract: Abstract author: Author @@ -112,6 +112,8 @@ en: description: Open access journals allowing researchers to contribute to research laboratory: description: Research structure hosting the work of researchers + publication: + description: Scientific publications produced by researchers researcher: description: Individual linked to a university, department, laboratory, etc. thesis: diff --git a/config/locales/research/fr.yml b/config/locales/research/fr.yml index bb29775ad7aafef35ced5a073a6f1ac5ab72139f..796dc026b74cccab60e75e0840f354250b923e55 100644 --- a/config/locales/research/fr.yml +++ b/config/locales/research/fr.yml @@ -11,9 +11,6 @@ fr: research/hal/author: one: Auteur·e HAL other: Auteur·e·s HAL - research/hal/publication: - one: Publication - other: Publications research/journal: one: Revue scientifique other: Revues scientifiques @@ -32,6 +29,9 @@ fr: research/laboratory/axis: one: Axe other: Axes + research/publication: + one: Publication + other: Publications research/thesis: one: Thèse other: Thèses @@ -41,14 +41,6 @@ fr: first_name: Prénom full_name: Nom complet last_name: Nom - research/hal/publication: - authors_list: Liste des auteur·e·s - docid: Identifiant - doi_url: URL DOI - publication_date: Date de publication - title: Titre - url: URL - hal_url: URL HAL research/journal: issn: ISSN title: Titre @@ -88,6 +80,14 @@ fr: name: Nom short_name: Nom court text: Texte + research/publication: + authors_list: Liste des auteur·e·s + docid: Identifiant + doi_url: URL DOI + publication_date: Date de publication + title: Titre + url: URL + hal_url: URL HAL research/thesis: abstract: Résumé author: Auteur·e @@ -112,6 +112,8 @@ fr: description: Journaux en accès ouvert (open access) permettant aux chercheur·e·s de contribuer à la recherche laboratory: description: Structure de recherche hébergeant le travail des chercheur·e·s + publication: + description: Publications scientifiques produites par les chercheur·e·s researcher: description: Personne physique liée à une université, une composante, un laboratoire, etc. thesis: diff --git a/config/routes/admin/research.rb b/config/routes/admin/research.rb index 329a657052c1ca6fa5339608281f91679346030d..00428c433f058c1242808f564cbd411c31d527d1 100644 --- a/config/routes/admin/research.rb +++ b/config/routes/admin/research.rb @@ -4,6 +4,11 @@ namespace :research do post 'sync-with-hal' => 'researchers#sync_with_hal', as: :sync_with_hal end end + resources :publications do + member do + get :static + end + end namespace :hal do resources :authors, only: [:index, :show, :destroy] do member do diff --git a/db/migrate/20240131081040_rename_hal_publications.rb b/db/migrate/20240131081040_rename_hal_publications.rb new file mode 100644 index 0000000000000000000000000000000000000000..93e5f2fb3a21eab2b8272a533195c1f41b30617c --- /dev/null +++ b/db/migrate/20240131081040_rename_hal_publications.rb @@ -0,0 +1,17 @@ +class RenameHalPublications < ActiveRecord::Migration[7.1] + def change + rename_column :research_hal_authors_publications, :research_hal_publication_id, :research_publication_id + + rename_table :research_hal_publications_university_people, :research_publications_university_people + rename_column :research_publications_university_people, :research_hal_publication_id, :research_publication_id + + # Vieil index problématique + # https://stackoverflow.com/questions/32395126/rename-table-relation-table-pkey-does-not-exist + execute "ALTER INDEX research_documents_pkey RENAME TO research_hal_publications_pkey;" + rename_table :research_hal_publications, :research_publications + rename_column :research_publications, :docid, :hal_docid + add_column :research_publications, :source, :integer, default: 0 + # All existing publications are from HAL at this moment + Research::Publication.update_all source: 1 + end +end diff --git a/db/schema.rb b/db/schema.rb index 941f26db705addac4f9a7690c82b955534b9813c..840cf18f37ce393411362b8c082bb413bab08a60 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_01_30_111440) do +ActiveRecord::Schema[7.1].define(version: 2024_01_31_081040) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -771,9 +771,9 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_30_111440) do create_table "research_hal_authors_publications", id: false, force: :cascade do |t| t.uuid "research_hal_author_id", null: false - t.uuid "research_hal_publication_id", null: false - t.index ["research_hal_author_id", "research_hal_publication_id"], name: "hal_author_publication" - t.index ["research_hal_publication_id", "research_hal_author_id"], name: "hal_publication_author" + t.uuid "research_publication_id", null: false + t.index ["research_hal_author_id", "research_publication_id"], name: "hal_author_publication" + t.index ["research_publication_id", "research_hal_author_id"], name: "hal_publication_author" end create_table "research_hal_authors_university_people", id: false, force: :cascade do |t| @@ -783,36 +783,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_30_111440) do t.index ["university_person_id", "research_hal_author_id"], name: "hal_person_author" end - create_table "research_hal_publications", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.string "docid" - t.jsonb "data" - t.string "title" - t.string "url" - t.string "ref" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "hal_url" - t.date "publication_date" - t.string "doi" - t.string "slug" - t.text "citation_full" - t.boolean "open_access" - t.text "abstract" - t.string "journal_title" - t.text "file" - t.text "authors_list" - t.json "authors_citeproc" - t.index ["docid"], name: "index_research_hal_publications_on_docid" - t.index ["slug"], name: "index_research_hal_publications_on_slug" - end - - create_table "research_hal_publications_university_people", id: false, force: :cascade do |t| - t.uuid "research_hal_publication_id", null: false - t.uuid "university_person_id", null: false - t.index ["research_hal_publication_id", "university_person_id"], name: "index_publication_person" - t.index ["university_person_id", "research_hal_publication_id"], name: "index_person_publication" - end - create_table "research_journal_paper_kinds", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "journal_id", null: false @@ -928,6 +898,37 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_30_111440) do t.index ["university_id"], name: "index_research_laboratory_axes_on_university_id" end + create_table "research_publications", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.string "hal_docid" + t.jsonb "data" + t.string "title" + t.string "url" + t.string "ref" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "hal_url" + t.date "publication_date" + t.string "doi" + t.string "slug" + t.text "citation_full" + t.boolean "open_access" + t.text "abstract" + t.string "journal_title" + t.text "file" + t.text "authors_list" + t.json "authors_citeproc" + t.integer "source", default: 0 + t.index ["hal_docid"], name: "index_research_publications_on_hal_docid" + t.index ["slug"], name: "index_research_publications_on_slug" + end + + create_table "research_publications_university_people", id: false, force: :cascade do |t| + t.uuid "research_publication_id", null: false + t.uuid "university_person_id", null: false + t.index ["research_publication_id", "university_person_id"], name: "index_publication_person" + t.index ["university_person_id", "research_publication_id"], name: "index_person_publication" + end + create_table "research_theses", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "research_laboratory_id", null: false