Newer
Older
# doi :string
# hal_url :string
# publication_date :date
# ref :string
# title :string
# url :string
# created_at :datetime not null
# updated_at :datetime not null
#
Sébastien Gaya
committed
include Sanitizable
Sébastien Gaya
committed
has_and_belongs_to_many :researchers,
class_name: 'University::Person',
foreign_key: 'university_person_id',
association_foreign_key: 'research_hal_publication_id'
has_and_belongs_to_many :authors,
foreign_key: 'research_hal_author_id',
association_foreign_key: 'research_hal_publication_id'
validates_presence_of :docid
scope :ordered, -> { order(publication_date: :desc)}
def self.import_from_hal_for_author(author)
fields = [
'docid',
'title_s',
'citationRef_s',
'uri_s',
'doiId_s',
'publicationDate_tdate',
'linkExtUrl_s',
# '*',
]
publications = []
response = HalOpenscience::Document.search "authIdFormPerson_s:#{author.docid}", fields: fields, limit: 1000
def self.create_from(doc)
publication = where(docid: doc.docid).first_or_create
publication.title = Osuny::Sanitizer.sanitize doc.title_s.first, 'string'
publication.ref = doc.attributes['citationRef_s']
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.save
publication
end
def template_static
"admin/research/publications/static"
end
protected
def slug_unavailable?(slug)
self.class.unscoped
.where(slug: slug)
.where.not(id: self.id)
.exists?
end