Skip to content

Commit

Permalink
register jalc dois in the handle system. datacite/datacite#977
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Mar 4, 2020
1 parent b3d77bf commit ccccfcb
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/controllers/dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def get_url

authorize! :get_url, @doi

if !@doi.is_registered_or_findable? || %w(europ crossref medra jalc kisti op).include?(@doi.provider_id) || %w(Crossref mEDRA).include?(@doi.agency)
if !@doi.is_registered_or_findable? || %w(europ).include?(@doi.provider_id) || %w(crossref.citations medra.citations jalc.citations kisti.citations op.citations).include?(@doi.client_id)
url = @doi.url
head :no_content && return if url.blank?
else
Expand Down
4 changes: 2 additions & 2 deletions app/jobs/url_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ def perform(doi_id)
response = Doi.get_doi(doi: doi.doi, agency: doi.agency)
url = response.body.dig('data', 'values', 0, 'data', 'value')
if url.present?
if (doi.is_registered_or_findable? || %w(europ crossref medra kisti jalc op).include?(doi.provider_id)) && doi.minted.blank?
if (doi.is_registered_or_findable? || %w(europ).include?(doi.provider_id)) && doi.minted.blank?
doi.update_attributes(url: url, minted: Time.zone.now)
else
doi.update_attributes(url: url)
end

doi.update_attributes(aasm_state: "findable") if %w(europ crossref medra kisti jalc op).include?(doi.provider_id)
doi.update_attributes(aasm_state: "findable") if %w(crossref.citations medra.citations jalc.citations kisti.citations op.citations).include?(doi.client_id)

doi.__elasticsearch__.index_document

Expand Down
4 changes: 2 additions & 2 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def initialize(user)
if user.role_id == "staff_admin"
can :manage, :all
cannot [:new, :create], Doi do |doi|
doi.client.blank? || !(doi.client.prefixes.where(prefix: doi.prefix).first || %w(crossref medra kisti jalc op).include?(doi.client.symbol.downcase.split(".").first))
doi.client.blank? || !(doi.client.prefixes.where(prefix: doi.prefix).first || %w(crossref.citations medra.citations jalc.citations kisti.citations op.citations).include?(doi.client.symbol.downcase))
end
can :export, :contacts
can :export, :organizations
Expand Down Expand Up @@ -96,7 +96,7 @@ def initialize(user)

can [:read, :destroy, :update, :register_url, :validate, :undo, :get_url, :get_urls, :read_landing_page_results], Doi, :client_id => user.client_id
can [:new, :create], Doi do |doi|
doi.client.prefixes.where(prefix: doi.prefix).present? || %w(crossref medra kisti jalc op).include?(doi.client.symbol.downcase.split(".").first)
doi.client.prefixes.where(prefix: doi.prefix).present? || %w(crossref.citations medra.citations jalc.citations kisti.citations op.citations).include?(doi.client.symbol.downcase)
end
can [:read], Doi
can [:read], User
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 @@ -9,7 +9,7 @@ module Indexable
IndexJob.perform_later(self)
if self.class.name == "Doi"
update_column(:indexed, Time.zone.now)
send_import_message(self.to_jsonapi) if aasm_state == "findable" && !Rails.env.test? && !%w(crossref medra kisti jalc op).include?(client.symbol.downcase.split(".").first)
send_import_message(self.to_jsonapi) if aasm_state == "findable" && !Rails.env.test? && !%w(crossref.citations medra.citations jalc.citations kisti.citations op.citations).include?(client.symbol.downcase)
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@ def validatable?
def update_url
return nil if current_user.nil? || !is_registered_or_findable?

if %w(europ crossref medra kisti jalc op).include?(provider_id)
if %w(europ).include?(provider_id) || %w(crossref.citations medra.citations jalc.citations kisti.citations op.citations).include?(client_id)
UrlJob.perform_later(doi)
else
HandleJob.perform_later(doi)
Expand Down

0 comments on commit ccccfcb

Please sign in to comment.