Skip to content

Commit

Permalink
Show the PDC Discovery url on the work show page (#1443)
Browse files Browse the repository at this point in the history
This will let us more easily check whether the work has yet appeared in
PDC Discovery, separate from whether the ARK and DOI redirection have
worked as expected.
  • Loading branch information
bess authored Aug 16, 2023
1 parent 94e378f commit 22d354e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app/models/work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,10 @@ def has_rights?(rights_id)
resource.rights_many.index { |rights| rights.identifier == rights_id } != nil
end

def doi_attribute_url
"https://datacommons.princeton.edu/discovery/doi/#{doi}"
end

protected

# This must be protected, NOT private for ActiveRecord to work properly with this attribute.
Expand Down Expand Up @@ -679,10 +683,6 @@ def publish_doi(user)
retry
end

def doi_attribute_url
"https://datacommons.princeton.edu/discovery/doi/#{doi}"
end

def doi_attribute_resource
PDCMetadata::Resource.new_from_jsonb(metadata)
end
Expand Down
7 changes: 7 additions & 0 deletions app/views/works/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@
<dd><%= link_to(@work.resource.ark, ark_url(@work.resource.ark)) %></dd>
<% end %>

<% if @work.resource.doi %>
<dt>Discovery URL</dt>
<dd>
<%= link_to(@work.doi_attribute_url, @work.doi_attribute_url) %>
</dd>
<% end %>

<% if @work.resource.individual_contributors.count > 0 %>
<dt>Individual Contributors</dt>
<dd>
Expand Down
8 changes: 7 additions & 1 deletion spec/system/work_show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
end
end

it "foo" do
it "uses datatables for easy navigation" do
sign_in user
visit work_path(work)

Expand All @@ -59,6 +59,12 @@
page.driver.go_forward
end

it "shows the PDC Discovery URL" do
sign_in user
visit work_path(work)
expect(page).to have_link("https://datacommons.princeton.edu/discovery/doi/10.34770/r2dz-ys12")
end

it "copies DOI to the clipboard" do
sign_in user
visit work_path(work)
Expand Down

0 comments on commit 22d354e

Please sign in to comment.