From dc2c5481ef81f9a4793b11c10f62b244bfe4b983 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Wed, 5 Jul 2023 09:49:11 +0200 Subject: [PATCH] publications fields --- app/models/communication/extranet.rb | 57 +++++++++---------- app/models/communication/website.rb | 39 ++++++------- .../communication/website/configs/base.rb | 39 ++++++------- .../website/configs/default_languages.rb | 39 ++++++------- .../website/configs/default_permalinks.rb | 39 ++++++------- .../website/configs/development_config.rb | 39 ++++++------- .../website/configs/production_config.rb | 39 ++++++------- app/models/research/hal/publication.rb | 15 +++++ .../research/hal/publications/show.html.erb | 20 ++++++- .../research/hal/publications/static.html.erb | 7 ++- .../people/researchers/_researcher.html.erb | 10 ++-- ..._add_fields_to_research_hal_publication.rb | 9 +++ db/schema.rb | 7 ++- test/fixtures/communication/extranets.yml | 57 +++++++++---------- test/fixtures/communication/websites.yml | 39 ++++++------- test/fixtures/research/hal/publications.yml | 5 ++ 16 files changed, 261 insertions(+), 199 deletions(-) create mode 100644 db/migrate/20230705073214_add_fields_to_research_hal_publication.rb diff --git a/app/models/communication/extranet.rb b/app/models/communication/extranet.rb index 1a4615b3d..0dc316363 100644 --- a/app/models/communication/extranet.rb +++ b/app/models/communication/extranet.rb @@ -2,35 +2,34 @@ # # Table name: communication_extranets # -# id :uuid not null, primary key -# about_type :string indexed => [about_id] -# allow_experiences_modification :boolean default(TRUE) -# color :string -# cookies_policy :text -# css :text -# feature_alumni :boolean default(FALSE) -# feature_contacts :boolean default(FALSE) -# feature_jobs :boolean default(FALSE) -# feature_library :boolean default(FALSE) -# feature_posts :boolean default(FALSE) -# has_sso :boolean default(FALSE) -# home_sentence :text -# host :string -# name :string -# privacy_policy :text -# registration_contact :string -# sass :text -# sso_button_label :string -# sso_cert :text -# sso_mapping :jsonb -# sso_name_identifier_format :string -# sso_provider :integer default("saml") -# sso_target_url :string -# terms :text -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid indexed => [about_type] -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# color :string +# cookies_policy :text +# css :text +# feature_alumni :boolean default(FALSE) +# feature_contacts :boolean default(FALSE) +# feature_jobs :boolean default(FALSE) +# feature_library :boolean default(FALSE) +# feature_posts :boolean default(FALSE) +# has_sso :boolean default(FALSE) +# home_sentence :text +# host :string +# name :string +# privacy_policy :text +# registration_contact :string +# sass :text +# sso_button_label :string +# sso_cert :text +# sso_mapping :jsonb +# sso_name_identifier_format :string +# sso_provider :integer default("saml") +# sso_target_url :string +# terms :text +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# university_id :uuid not null, indexed # # Indexes # diff --git a/app/models/communication/website.rb b/app/models/communication/website.rb index be1dea930..5762b6d22 100644 --- a/app/models/communication/website.rb +++ b/app/models/communication/website.rb @@ -2,25 +2,26 @@ # # Table name: communication_websites # -# id :uuid not null, primary key -# about_type :string indexed => [about_id] -# access_token :string -# git_branch :string -# git_endpoint :string -# git_provider :integer default("github") -# in_production :boolean default(FALSE) -# name :string -# plausible_url :string -# repository :string -# style :text -# style_updated_at :date -# theme_version :string default("NA") -# url :string -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid indexed => [about_type] -# default_language_id :uuid not null, indexed -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# access_token :string +# deployment_status_badge :text +# git_branch :string +# git_endpoint :string +# git_provider :integer default("github") +# in_production :boolean default(FALSE) +# name :string +# plausible_url :string +# repository :string +# style :text +# style_updated_at :date +# theme_version :string default("NA") +# url :string +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# default_language_id :uuid not null, indexed +# university_id :uuid not null, indexed # # Indexes # diff --git a/app/models/communication/website/configs/base.rb b/app/models/communication/website/configs/base.rb index 2cc59f410..b14fd096b 100644 --- a/app/models/communication/website/configs/base.rb +++ b/app/models/communication/website/configs/base.rb @@ -2,25 +2,26 @@ # # Table name: communication_websites # -# id :uuid not null, primary key -# about_type :string indexed => [about_id] -# access_token :string -# git_branch :string -# git_endpoint :string -# git_provider :integer default("github") -# in_production :boolean default(FALSE) -# name :string -# plausible_url :string -# repository :string -# style :text -# style_updated_at :date -# theme_version :string default("NA") -# url :string -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid indexed => [about_type] -# default_language_id :uuid not null, indexed -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# access_token :string +# deployment_status_badge :text +# git_branch :string +# git_endpoint :string +# git_provider :integer default("github") +# in_production :boolean default(FALSE) +# name :string +# plausible_url :string +# repository :string +# style :text +# style_updated_at :date +# theme_version :string default("NA") +# url :string +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# default_language_id :uuid not null, indexed +# university_id :uuid not null, indexed # # Indexes # diff --git a/app/models/communication/website/configs/default_languages.rb b/app/models/communication/website/configs/default_languages.rb index 53bac0a2b..14a78fdd4 100644 --- a/app/models/communication/website/configs/default_languages.rb +++ b/app/models/communication/website/configs/default_languages.rb @@ -2,25 +2,26 @@ # # Table name: communication_websites # -# id :uuid not null, primary key -# about_type :string indexed => [about_id] -# access_token :string -# git_branch :string -# git_endpoint :string -# git_provider :integer default("github") -# in_production :boolean default(FALSE) -# name :string -# plausible_url :string -# repository :string -# style :text -# style_updated_at :date -# theme_version :string default("NA") -# url :string -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid indexed => [about_type] -# default_language_id :uuid not null, indexed -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# access_token :string +# deployment_status_badge :text +# git_branch :string +# git_endpoint :string +# git_provider :integer default("github") +# in_production :boolean default(FALSE) +# name :string +# plausible_url :string +# repository :string +# style :text +# style_updated_at :date +# theme_version :string default("NA") +# url :string +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# default_language_id :uuid not null, indexed +# university_id :uuid not null, indexed # # Indexes # diff --git a/app/models/communication/website/configs/default_permalinks.rb b/app/models/communication/website/configs/default_permalinks.rb index c0feec9c1..9251792cd 100644 --- a/app/models/communication/website/configs/default_permalinks.rb +++ b/app/models/communication/website/configs/default_permalinks.rb @@ -2,25 +2,26 @@ # # Table name: communication_websites # -# id :uuid not null, primary key -# about_type :string indexed => [about_id] -# access_token :string -# git_branch :string -# git_endpoint :string -# git_provider :integer default("github") -# in_production :boolean default(FALSE) -# name :string -# plausible_url :string -# repository :string -# style :text -# style_updated_at :date -# theme_version :string default("NA") -# url :string -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid indexed => [about_type] -# default_language_id :uuid not null, indexed -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# access_token :string +# deployment_status_badge :text +# git_branch :string +# git_endpoint :string +# git_provider :integer default("github") +# in_production :boolean default(FALSE) +# name :string +# plausible_url :string +# repository :string +# style :text +# style_updated_at :date +# theme_version :string default("NA") +# url :string +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# default_language_id :uuid not null, indexed +# university_id :uuid not null, indexed # # Indexes # diff --git a/app/models/communication/website/configs/development_config.rb b/app/models/communication/website/configs/development_config.rb index e6c253f00..b6f29a235 100644 --- a/app/models/communication/website/configs/development_config.rb +++ b/app/models/communication/website/configs/development_config.rb @@ -2,25 +2,26 @@ # # Table name: communication_websites # -# id :uuid not null, primary key -# about_type :string indexed => [about_id] -# access_token :string -# git_branch :string -# git_endpoint :string -# git_provider :integer default("github") -# in_production :boolean default(FALSE) -# name :string -# plausible_url :string -# repository :string -# style :text -# style_updated_at :date -# theme_version :string default("NA") -# url :string -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid indexed => [about_type] -# default_language_id :uuid not null, indexed -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# access_token :string +# deployment_status_badge :text +# git_branch :string +# git_endpoint :string +# git_provider :integer default("github") +# in_production :boolean default(FALSE) +# name :string +# plausible_url :string +# repository :string +# style :text +# style_updated_at :date +# theme_version :string default("NA") +# url :string +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# default_language_id :uuid not null, indexed +# university_id :uuid not null, indexed # # Indexes # diff --git a/app/models/communication/website/configs/production_config.rb b/app/models/communication/website/configs/production_config.rb index 7a5ca3cd6..0761e6972 100644 --- a/app/models/communication/website/configs/production_config.rb +++ b/app/models/communication/website/configs/production_config.rb @@ -2,25 +2,26 @@ # # Table name: communication_websites # -# id :uuid not null, primary key -# about_type :string indexed => [about_id] -# access_token :string -# git_branch :string -# git_endpoint :string -# git_provider :integer default("github") -# in_production :boolean default(FALSE) -# name :string -# plausible_url :string -# repository :string -# style :text -# style_updated_at :date -# theme_version :string default("NA") -# url :string -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid indexed => [about_type] -# default_language_id :uuid not null, indexed -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# access_token :string +# deployment_status_badge :text +# git_branch :string +# git_endpoint :string +# git_provider :integer default("github") +# in_production :boolean default(FALSE) +# name :string +# plausible_url :string +# repository :string +# style :text +# style_updated_at :date +# theme_version :string default("NA") +# url :string +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# default_language_id :uuid not null, indexed +# university_id :uuid not null, indexed # # Indexes # diff --git a/app/models/research/hal/publication.rb b/app/models/research/hal/publication.rb index 9682b57fb..65c908487 100644 --- a/app/models/research/hal/publication.rb +++ b/app/models/research/hal/publication.rb @@ -3,10 +3,15 @@ # Table name: research_hal_publications # # id :uuid not null, primary key +# abstract :text +# citation_full :text # data :jsonb # docid :string indexed # doi :string +# file :text # hal_url :string +# journal_title :string +# open_access :boolean # publication_date :date # ref :string # slug :string @@ -43,10 +48,15 @@ class Research::Hal::Publication < ApplicationRecord 'docid', 'title_s', 'citationRef_s', + 'citationFull_s', 'uri_s', 'doiId_s', 'publicationDate_tdate', 'linkExtUrl_s', + 'abstract_s', + 'openAccess_bool', + 'journalTitle_s', + 'files_s' # '*', ] publications = [] @@ -63,10 +73,15 @@ class Research::Hal::Publication < ApplicationRecord puts "HAL sync publication #{doc.docid}" publication.title = Osuny::Sanitizer.sanitize doc.title_s.first, 'string' publication.ref = doc.attributes['citationRef_s'] + publication.citation_full = doc.attributes['citationFull_s'] + publication.abstract = doc.attributes['abstract_s']&.first publication.hal_url = doc.attributes['uri_s'] publication.doi = doc.attributes['doiId_s'] publication.publication_date = doc.attributes['publicationDate_tdate'] publication.url = doc.attributes['linkExtUrl_s'] + publication.open_access = doc.attributes['openAccess_bool'] + publication.journal_title = doc.attributes['journalTitle_s'] + publication.file = doc.attributes['files_s']&.first publication.save publication end diff --git a/app/views/admin/research/hal/publications/show.html.erb b/app/views/admin/research/hal/publications/show.html.erb index 5c84a479d..da9578ae6 100644 --- a/app/views/admin/research/hal/publications/show.html.erb +++ b/app/views/admin/research/hal/publications/show.html.erb @@ -2,8 +2,20 @@ <div class="row"> <div class="col-lg-8"> - <p class="lead mb-4"><%= sanitize @publication.ref %></p> + <% 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::Hal::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') %> + <p><%= sanitize @publication.ref %></p> + </div> <div class="col-lg-6"> <%= osuny_label Research::Hal::Publication.human_attribute_name('docid') %> <p><%= @publication.docid %></p> @@ -12,6 +24,10 @@ <%= osuny_label Research::Hal::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') %> + <p><%= t @publication.open_access %></p> + </div> </div> </div> <div class="col-lg-4"> @@ -35,7 +51,7 @@ </div> </div> -<% [:url, :hal_url, :doi_url].each do |key| %> +<% [: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) %> diff --git a/app/views/admin/research/hal/publications/static.html.erb b/app/views/admin/research/hal/publications/static.html.erb index 5910efe14..8a0b146c6 100644 --- a/app/views/admin/research/hal/publications/static.html.erb +++ b/app/views/admin/research/hal/publications/static.html.erb @@ -3,12 +3,17 @@ title: "<%= @about.title %>" date: "<%= @about.publication_date&.iso8601 %>" slug: "<%= @about.slug %>" docid: "<%= @about.docid %>" -ref: > +abstract: >- + <%= prepare_html_for_static @about.abstract, current_university %> +citation_full: >- + <%= prepare_html_for_static @about.citation_full, current_university %> +ref: >- <%= sanitize @about.ref %> url: hal: "<%= @about.hal_url %>" doi: "<%= @about.doi_url %>" raw: "<%= @about.url %>" + file: "<%= @about.file %>" researchers: <% @about.researchers.each do |researcher| %> - <%= researcher.slug %> diff --git a/app/views/admin/university/people/researchers/_researcher.html.erb b/app/views/admin/university/people/researchers/_researcher.html.erb index d79fa151e..cfea76c91 100644 --- a/app/views/admin/university/people/researchers/_researcher.html.erb +++ b/app/views/admin/university/people/researchers/_researcher.html.erb @@ -1,8 +1,10 @@ <article class="mb-4 d-flex align-items-center position-relative"> - <div style="width: 80px"> - <%= kamifusen_tag researcher.best_picture, width: 80, class: 'img-circle' if researcher.best_picture.attached? %> - </div> - <div class="ms-3"> + <% if researcher.best_picture.attached? %> + <div class="me-3" style="width: 80px"> + <%= kamifusen_tag researcher.best_picture, width: 80, class: 'img-circle' %> + </div> + <% end %> + <div> <%= link_to researcher, admin_research_researcher_path(researcher), class: 'stretched-link' %> </div> </article> diff --git a/db/migrate/20230705073214_add_fields_to_research_hal_publication.rb b/db/migrate/20230705073214_add_fields_to_research_hal_publication.rb new file mode 100644 index 000000000..680756b70 --- /dev/null +++ b/db/migrate/20230705073214_add_fields_to_research_hal_publication.rb @@ -0,0 +1,9 @@ +class AddFieldsToResearchHalPublication < ActiveRecord::Migration[7.0] + def change + add_column :research_hal_publications, :citation_full, :text + add_column :research_hal_publications, :open_access, :boolean + add_column :research_hal_publications, :abstract, :text + add_column :research_hal_publications, :journal_title, :string + add_column :research_hal_publications, :file, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 548674c3a..aa152d1d0 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.0].define(version: 2023_07_04_113222) do +ActiveRecord::Schema[7.0].define(version: 2023_07_05_073214) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -738,6 +738,11 @@ ActiveRecord::Schema[7.0].define(version: 2023_07_04_113222) do 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.index ["docid"], name: "index_research_hal_publications_on_docid" end diff --git a/test/fixtures/communication/extranets.yml b/test/fixtures/communication/extranets.yml index 5b00f559b..c4a725645 100644 --- a/test/fixtures/communication/extranets.yml +++ b/test/fixtures/communication/extranets.yml @@ -2,35 +2,34 @@ # # Table name: communication_extranets # -# id :uuid not null, primary key -# about_type :string indexed => [about_id] -# allow_experiences_modification :boolean default(TRUE) -# color :string -# cookies_policy :text -# css :text -# feature_alumni :boolean default(FALSE) -# feature_contacts :boolean default(FALSE) -# feature_jobs :boolean default(FALSE) -# feature_library :boolean default(FALSE) -# feature_posts :boolean default(FALSE) -# has_sso :boolean default(FALSE) -# home_sentence :text -# host :string -# name :string -# privacy_policy :text -# registration_contact :string -# sass :text -# sso_button_label :string -# sso_cert :text -# sso_mapping :jsonb -# sso_name_identifier_format :string -# sso_provider :integer default("saml") -# sso_target_url :string -# terms :text -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid indexed => [about_type] -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# color :string +# cookies_policy :text +# css :text +# feature_alumni :boolean default(FALSE) +# feature_contacts :boolean default(FALSE) +# feature_jobs :boolean default(FALSE) +# feature_library :boolean default(FALSE) +# feature_posts :boolean default(FALSE) +# has_sso :boolean default(FALSE) +# home_sentence :text +# host :string +# name :string +# privacy_policy :text +# registration_contact :string +# sass :text +# sso_button_label :string +# sso_cert :text +# sso_mapping :jsonb +# sso_name_identifier_format :string +# sso_provider :integer default("saml") +# sso_target_url :string +# terms :text +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# university_id :uuid not null, indexed # # Indexes # diff --git a/test/fixtures/communication/websites.yml b/test/fixtures/communication/websites.yml index 8f739d38a..1a331e189 100644 --- a/test/fixtures/communication/websites.yml +++ b/test/fixtures/communication/websites.yml @@ -2,25 +2,26 @@ # # Table name: communication_websites # -# id :uuid not null, primary key -# about_type :string indexed => [about_id] -# access_token :string -# git_branch :string -# git_endpoint :string -# git_provider :integer default("github") -# in_production :boolean default(FALSE) -# name :string -# plausible_url :string -# repository :string -# style :text -# style_updated_at :date -# theme_version :string default("NA") -# url :string -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid indexed => [about_type] -# default_language_id :uuid not null, indexed -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# access_token :string +# deployment_status_badge :text +# git_branch :string +# git_endpoint :string +# git_provider :integer default("github") +# in_production :boolean default(FALSE) +# name :string +# plausible_url :string +# repository :string +# style :text +# style_updated_at :date +# theme_version :string default("NA") +# url :string +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# default_language_id :uuid not null, indexed +# university_id :uuid not null, indexed # # Indexes # diff --git a/test/fixtures/research/hal/publications.yml b/test/fixtures/research/hal/publications.yml index 8580abd33..e94b3c2ea 100644 --- a/test/fixtures/research/hal/publications.yml +++ b/test/fixtures/research/hal/publications.yml @@ -3,10 +3,15 @@ # Table name: research_hal_publications # # id :uuid not null, primary key +# abstract :text +# citation_full :text # data :jsonb # docid :string indexed # doi :string +# file :text # hal_url :string +# journal_title :string +# open_access :boolean # publication_date :date # ref :string # slug :string -- GitLab