From ccccfcbe998ede9efce7721c51e33635fd4f16c0 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Wed, 4 Mar 2020 08:43:27 +0100 Subject: [PATCH] register jalc dois in the handle system. datacite/datacite#977 --- app/controllers/dois_controller.rb | 2 +- app/jobs/url_job.rb | 4 ++-- app/models/ability.rb | 4 ++-- app/models/concerns/indexable.rb | 2 +- app/models/doi.rb | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/dois_controller.rb b/app/controllers/dois_controller.rb index 94989722a..578f5dffd 100644 --- a/app/controllers/dois_controller.rb +++ b/app/controllers/dois_controller.rb @@ -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 diff --git a/app/jobs/url_job.rb b/app/jobs/url_job.rb index 1971d1be3..9885ecc90 100644 --- a/app/jobs/url_job.rb +++ b/app/jobs/url_job.rb @@ -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 diff --git a/app/models/ability.rb b/app/models/ability.rb index 786b2a8cc..828b90f12 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -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 @@ -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 diff --git a/app/models/concerns/indexable.rb b/app/models/concerns/indexable.rb index 12bb897a3..8b34f9910 100644 --- a/app/models/concerns/indexable.rb +++ b/app/models/concerns/indexable.rb @@ -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 diff --git a/app/models/doi.rb b/app/models/doi.rb index 74e01fdb2..77e863229 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -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)