Skip to content

Commit

Permalink
fix url registration in handle system. #666
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Oct 23, 2020
1 parent 3c4382e commit c52c1f9
Show file tree
Hide file tree
Showing 51 changed files with 518 additions and 217 deletions.
10 changes: 5 additions & 5 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Doi < ActiveRecord::Base
validates_inclusion_of :agency, :in => %w(datacite crossref kisti medra istic jalc airiti cnki op), allow_blank: true
validates :last_landing_page_status, numericality: { only_integer: true }, if: :last_landing_page_status?
validates :xml, presence: true, xml_schema: true, if: Proc.new { |doi| doi.validatable? }
validate :check_url, if: :url?
validate :check_url, if: Proc.new { |doi| doi.is_registered_or_findable? }
validate :check_dates, if: :dates?
validate :check_rights_list, if: :rights_list?
validate :check_titles, if: :titles?
Expand Down Expand Up @@ -1774,7 +1774,9 @@ def update_url

if %w(europ).include?(provider_id) || type == "OtherDoi"
UrlJob.perform_later(doi)
elsif url_changed? || changes["aasm_state"] == ["draft", "findable"] || changes["aasm_state"] == ["draft", "registered"]
# TODO better define conditions for updating handle system
# elsif url_changed? || changes["aasm_state"] == ["draft", "findable"] || changes["aasm_state"] == ["draft", "registered"]
else
register_url
end
end
Expand Down Expand Up @@ -1838,9 +1840,7 @@ def event=(value)
end

def check_url
return nil if is_registered_or_findable?

unless match_url_with_domains(url: url, domains: client.domains)
unless url.blank? || match_url_with_domains(url: url, domains: client.domains)
errors.add(:url, "URL is not allowed by repository domain settings.")
end
end
Expand Down
6 changes: 4 additions & 2 deletions spec/fixtures/files/datacite-user-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
"resourceTypeGeneral": "Text"
},
"identifiers": [{
"identifier":"https://doi.org/10.17918/9zwb-rb91",
"identifier": "https://doi.org/10.17918/9zwb-rb91",
"identifier_type": "DOI"
}],
"creators": [{
"nameType": "Personal",
"givenName": "Julia M.",
"familyName": "Rovera",
"affiliation": ["Drexel University"],
"affiliation": [{
"name": "Drexel University"
}],
"nameIdentifiers": [{
"schemeUri": "https://orcid.org",
"nameIdentifier": "",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c52c1f9

Please sign in to comment.