Skip to content

Commit

Permalink
unauthenticated users should only see findable dois. #284
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jun 1, 2019
1 parent 32c7c4d commit 8b5257c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/controllers/dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def index
source: params[:source],
page: page,
sort: sort,
random: params[:random])
random: params[:random],
current_user: current_user)
end

begin
Expand Down
7 changes: 6 additions & 1 deletion app/models/concerns/indexable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ def query(query, options={})

must = []
must << { query_string: { query: query, fields: query_fields }} if query.present?
must << { terms: { aasm_state: options[:state].to_s.split(",") }} if options[:state].present?
must << { term: { "types.resourceTypeGeneral": options[:resource_type_id].underscore.camelize }} if options[:resource_type_id].present?
must << { terms: { provider_id: options[:provider_id].split(",") }} if options[:provider_id].present?
must << { terms: { client_id: options[:client_id].to_s.split(",") }} if options[:client_id].present?
Expand Down Expand Up @@ -172,6 +171,12 @@ def query(query, options={})
must << { terms: { "software.raw" => options[:software].split(",") }} if options[:software].present?
must_not << { exists: { field: "deleted_at" }} unless options[:include_deleted]
elsif self.name == "Doi"
# anonymous users should only see findable DOIs
if options[:current_user]
must << { terms: { aasm_state: options[:state].to_s.split(",") }} if options[:state].present?
else
must << { terms: { aasm_state: ["findable"] }}
end
must << { range: { registered: { gte: "#{options[:registered].split(",").min}||/y", lte: "#{options[:registered].split(",").max}||/y", format: "yyyy" }}} if options[:registered].present?
end

Expand Down

0 comments on commit 8b5257c

Please sign in to comment.