Skip to content

Commit

Permalink
show dois by researcher-id. datacite/bracco#214
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Aug 21, 2019
1 parent af2b15d commit 3e74ced
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/indexable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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?
Expand Down
4 changes: 3 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3e74ced

Please sign in to comment.