Skip to content

Commit

Permalink
Merge pull request #1073 from psu-libraries/996-wrong-version-email
Browse files Browse the repository at this point in the history
adds images and file download link to wrong version email
  • Loading branch information
Smullz622 authored Jan 29, 2025
2 parents d4db89e + 7aecd42 commit afde905
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/final_published_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions app/controllers/open_access_publications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ def update
end
end

def activity_insight_file_download
file = ActivityInsightOAFile.find(publication.activity_insight_oa_files.first.id)
send_file(file.stored_file_path)
end

def scholarsphere_file_version
file_handler = ScholarsphereFileHandler.new(publication, deposit_params)
@jobs ||= []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@
published version.
</p>

<h3>
Examples
</h3>

<h4>
Accepted Manuscript
</h4>
<p>
<%= image_tag "accepted_manuscript_example.png", id: "accepted-manuscript-example", width: "241", height: "311", alt: "A screenshot of a text document with a title and blue section headers" %>
</p>

<h4>
Final Published Version
</h4>
<p>
<%= image_tag "final_published_example.png", id: "final-published-example", width: "221", height: "311", alt: "A screenshot of a journal article with the title and headings in blue, a header containing the journal name and the Routledge logo, and additional complex typesetting" %>
</p>

<p>
One or more of the files you (or an Activity Insight Proxy) uploaded appear to be a version of the article
that the journal's default policy does not allow to be deposited in ScholarSphere. If you have the version of
Expand All @@ -30,20 +48,31 @@
<th>Title</th>
<th>Version we have</th>
<th>Version that can be deposited</th>
<th>Download File</th>
</tr>
</thead>
<tbody class='card-body'>
<% @publications.each do |p| %>
<% file = p.activity_insight_oa_files.first %>
<tr>
<td>
<%= p.title %>
</td>
<td>
<%= p.activity_insight_oa_files.first.version_status_display %>
<%= file.version_status_display %>
</td>
<td>
<%= p.preferred_version_display %>
</td>
<td>
<% if file.stored_file_path.present? %>
<%= link_to "#{file.download_filename}",
activity_insight_file_download_url(p.id),
target: '_blank' %>
<% else %>
Not Found
<% end %>
</td>
</tr>
<% end %>
</tbody>
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ en:
open_access_publications:
update:
success: "Thank you for taking the time to submit your open access URL. It was successfully saved."
activity_insight_file_download:
success: "Download complete"
create_scholarsphere_deposit:
success: "Thank you for taking the time to submit your publication for deposit in ScholarSphere. Your submission has been received, and you should receive an email shortly about the status of your deposit."
fail: "There was an error submitting your publication for deposit in ScholarSphere. Please try again later, and contact support if the problem continues."
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
post 'bio/orcid/employments/:membership_id' => 'orcid_employments#create', as: :orcid_employments
post 'bio/orcid/works' => 'orcid_works#create', as: :orcid_works
get 'publications/:id/open_access/edit' => 'open_access_publications#edit', as: :edit_open_access_publication
get 'publications/:id/open_access/activity_insight_file_download' => 'open_access_publications#activity_insight_file_download', as: :activity_insight_file_download
post 'publications/:id/open_access/scholarsphere_file_version' => 'open_access_publications#scholarsphere_file_version', as: :scholarsphere_file_version
get 'publications/:id/open_access/file_version_result' => 'open_access_publications#file_version_result', as: :file_version_result
post 'publications/:id/open_access/scholarsphere_deposit_form' => 'open_access_publications#scholarsphere_deposit_form', as: :scholarsphere_deposit_form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,29 @@
end
end

describe '#activity_insight_file_download' do
let(:perform_request) { get :activity_insight_file_download, params: { id: blank_oa_pub.id } }
let!(:aif) { create(:activity_insight_oa_file,
publication: blank_oa_pub,
user: user,
file_download_location: fixture_file_open('test_file.pdf')) }

it_behaves_like 'an unauthenticated controller'

context 'when authenticated' do
before do
allow(request.env['warden']).to receive(:authenticate!).and_return(user)
allow(controller).to receive(:current_user).and_return(user)
end

it 'sends the correct file' do
get :activity_insight_file_download, params: { id: blank_oa_pub.id }
expect(response).to be_successful
expect(response.headers['Content-Disposition']).to include('attachment; filename="test_file.pdf"; filename*=UTF-8\'\'test_file.pdf')
end
end
end

describe '#scholarsphere_file_version' do
let(:perform_request) { post :scholarsphere_file_version, params: { id: 1 } }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@
expect(current_email).not_to be_nil
expect(current_email.body).to match(/Version we have/)
expect(current_email.body).to match(/Version that can be deposited/)
expect(current_email.body).to match(/Download File/)
expect(current_email.body).to match(/Title 1/)
expect(current_email.body).to match(/Title 2/)
expect(current_email.body).to have_link(aif1.download_filename)
expect(current_email.body).not_to match(/Title 3/)
expect(pub1.reload.wrong_oa_version_notification_sent_at).not_to be_nil
expect(pub2.reload.wrong_oa_version_notification_sent_at).not_to be_nil
Expand Down

0 comments on commit afde905

Please sign in to comment.