diff --git a/app/models/research/publication.rb b/app/models/research/publication.rb index 8035c61da20c87ca2c7dd1f4e2b5bc2ad52dcfad..ce6064e3b42959cf8b0f6927278296c013db1e01 100644 --- a/app/models/research/publication.rb +++ b/app/models/research/publication.rb @@ -55,6 +55,8 @@ class Research::Publication < ApplicationRecord validates_presence_of :title, :publication_date + before_validation :generate_authors_citeproc + def editable? source == 'osuny' end @@ -94,6 +96,16 @@ class Research::Publication < ApplicationRecord } end + def generate_authors_citeproc + return if hal? + self.authors_citeproc = researchers.map do |researcher| + { + "family" => researcher.last_name, + "given" => researcher.first_name + } + end + end + def slug_unavailable?(slug) self.class.unscoped .where(slug: slug)