From 3e74ced2e888414227b5387d8aff90a1a5238a5c Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Wed, 21 Aug 2019 11:27:36 +0200 Subject: [PATCH] show dois by researcher-id. datacite/bracco#214 --- app/models/ability.rb | 6 ++++++ app/models/concerns/indexable.rb | 2 +- config/routes.rb | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index ac59b48dd..43fab2603 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -35,6 +35,7 @@ def initialize(user) end can [:read], User can [:read], Phrase + can [:read], Researcher can [:read], Activity do |activity| activity.doi.findable? || activity.doi.provider_id == user.provider_id end @@ -50,6 +51,7 @@ def initialize(user) end can [:read], User can [:read], Phrase + can [:read], Researcher can [:read], Activity do |activity| activity.doi.findable? || activity.doi.provider_id == user.provider_id end @@ -72,6 +74,7 @@ def initialize(user) end can [:read], User can [:read], Phrase + can [:read], Researcher can [:read], Activity do |activity| activity.doi.findable? || activity.doi.client_id == user.client_id end @@ -84,6 +87,7 @@ def initialize(user) end can [:read], User can [:read], Phrase + can [:read], Researcher can [:read], Activity do |activity| activity.doi.findable? || activity.doi.client_id == user.client_id end @@ -96,6 +100,7 @@ def initialize(user) end can [:read], User, :id => user.id can [:read], Phrase + can [:read], Researcher can [:read], Activity do |activity| activity.doi.findable? end @@ -104,6 +109,7 @@ def initialize(user) doi.findable? end can [:read], Provider + can [:read], Researcher can [:read], Activity do |activity| activity.doi.findable? end diff --git a/app/models/concerns/indexable.rb b/app/models/concerns/indexable.rb index c83a1a925..009972aa7 100644 --- a/app/models/concerns/indexable.rb +++ b/app/models/concerns/indexable.rb @@ -157,7 +157,6 @@ def query(query, options={}) must << { terms: { client_id: options[:client_id].to_s.split(",") }} if options[:client_id].present? must << { terms: { prefix: options[:prefix].to_s.split(",") }} if options[:prefix].present? must << { term: { uid: options[:uid] }} if options[:uid].present? - must << { term: { "creators.nameIdentifiers.nameIdentifier" => "*#{options[:researcher_id]}" }} if options[:researcher_id].present? must << { range: { created: { gte: "#{options[:created].split(",").min}||/y", lte: "#{options[:created].split(",").max}||/y", format: "yyyy" }}} if options[:created].present? must << { term: { schema_version: "http://datacite.org/schema/kernel-#{options[:schema_version]}" }} if options[:schema_version].present? must << { terms: { "subjects.subject": options[:subject].split(",") }} if options[:subject].present? @@ -203,6 +202,7 @@ def query(query, options={}) elsif self.name == "Doi" must << { terms: { aasm_state: options[:state].to_s.split(",") }} if options[:state].present? must << { range: { registered: { gte: "#{options[:registered].split(",").min}||/y", lte: "#{options[:registered].split(",").max}||/y", format: "yyyy" }}} if options[:registered].present? + must << { term: { "creators.nameIdentifiers.nameIdentifier" => "https://orcid.org/#{options[:researcher_id]}" }} if options[:researcher_id].present? must << { term: { consortium_id: options[:consortium_id] }} if options[:consortium_id].present? must << { term: { "client.re3data_id" => options[:re3data_id].upcase.gsub("/", '\/') }} if options[:re3data_id].present? must << { term: { "client.opendoar_id" => options[:opendoar_id] }} if options[:opendoar_id].present? diff --git a/config/routes.rb b/config/routes.rb index a2682febb..bceef1448 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -96,7 +96,9 @@ resources :prefixes, constraints: { :id => /.+/ } end resources :providers, constraints: { :id => /.+/ } - resources :researchers + resources :researchers, constraints: { id: /.+/ } do + resources :dois, constraints: { id: /.+/ } + end resources :resource_types, path: 'resource-types', only: [:show, :index] # custom routes for maintenance tasks