Skip to content

Commit

Permalink
register handle url also when transitioning from draft to findable. 666
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Oct 23, 2020
1 parent 244eb6c commit 0b250f9
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
6 changes: 4 additions & 2 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?, if: Proc.new { |doi| doi.is_registered_or_findable? }
validate :check_url, if: :url?
validate :check_dates, if: :dates?
validate :check_rights_list, if: :rights_list?
validate :check_titles, if: :titles?
Expand Down Expand Up @@ -1774,7 +1774,7 @@ def update_url

if %w(europ).include?(provider_id) || type == "OtherDoi"
UrlJob.perform_later(doi)
elsif url_changed?
elsif url_changed? || changes["aasm_state"] == ["draft", "findable"] || changes["aasm_state"] == ["draft", "registered"]
register_url
end
end
Expand Down Expand Up @@ -1838,6 +1838,8 @@ def event=(value)
end

def check_url
return nil if doi.is_registered_or_findable?

unless match_url_with_domains(url: url, domains: client.domains)
errors.add(:url, "URL is not allowed by repository domain settings.")
end
Expand Down

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

0 comments on commit 0b250f9

Please sign in to comment.