Skip to content

Commit

Permalink
Merge pull request #793 from psu-libraries/763-admins-upload-corrections
Browse files Browse the repository at this point in the history
763 admins upload corrections
  • Loading branch information
jlandiseigsti authored Jul 10, 2024
2 parents ac880ec + 54a0715 commit c6df868
Show file tree
Hide file tree
Showing 28 changed files with 318 additions and 15 deletions.
6 changes: 6 additions & 0 deletions app/controllers/admin/submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ def dashboard
def edit
@submission = Submission.find(params[:id])
@view = Admin::SubmissionFormView.new(@submission, session)
if @submission.format_review_notes.blank? && !@submission.status_behavior.beyond_waiting_for_format_review_response?
@submission.format_review_notes = current_partner.graduate? ? I18n.t('graduate.default_format_review_note') : ''
end
return unless @submission.final_submission_notes.blank? && !@submission.status_behavior.beyond_collecting_final_submission_files?

@submission.final_submission_notes = current_partner.graduate? ? I18n.t('graduate.default_final_submission_note') : ''
end

def update
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/author/files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ def current_file
# file type
@current_file = if params[:action] == 'download_final_submission'
FinalSubmissionFile.find(params[:id])
elsif params[:action] == 'download_admin_feedback'
AdminFeedbackFile.find(params[:id])
else
FormatReviewFile.find(params[:id])
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def format_review_params
:semester,
:year,
:federal_funding,
format_review_files_attributes: [:asset, :asset_cache, :submission_id, :id, :_destroy])
format_review_files_attributes: [:asset, :asset_cache, :submission_id, :id, :_destroy],
admin_feedback_files_attributes: [:asset, :asset_cache, :submission_id, :feedback_type, :id, :_destroy])
end
end
9 changes: 8 additions & 1 deletion app/controllers/files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@ def download_final_submission
# DownloadFileLog.save_download_details(file, request.remote_ip)
end

def download_admin_feedback
file = AdminFeedbackFile.find(params[:id])
authorize! :read, file, file.submission
send_file file.current_location, disposition: :inline
# DownloadFileLog.save_download_details(file, request.remote_ip)
end

private

def files_params
params.require(:file).permit([:asset, :asset_cache, :id, :_destroy])
params.require(:file).permit([:asset, :asset_cache, :feedback_type, :id, :_destroy])
end
end
33 changes: 33 additions & 0 deletions app/models/admin_feedback_file.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

class AdminFeedbackFile < ApplicationRecord
mount_uploader :asset, SubmissionFileUploader

belongs_to :submission

def self.feedback_types
['format-review', 'final-submission'].freeze
end

validates :submission_id, :asset, presence: true
validates :asset, virus_free: true
validates :feedback_type, inclusion: { in: feedback_types }, presence: true

def class_name
self.class.to_s.underscore.dasherize
end

def link_identifier
self.class.to_s.underscore.split('_file').first.pluralize
end

def full_file_path
# file path only
"#{WORKFLOW_BASE_PATH}admin_feedback_files/#{EtdaFilePaths.new.detailed_file_path(id)}"
end

def current_location
# full file path including file name
full_file_path + asset_identifier
end
end
1 change: 1 addition & 0 deletions app/models/author_ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ def initialize(author, _file, _submission)
can [:read, :edit, :view, :update, :destroy], Submission, author_id: author.id
can [:read, :upload, :edit, :view], FormatReviewFile, submission: { author_id: author.id }
can [:read, :upload, :edit, :view], FinalSubmissionFile, submission: { author_id: author.id }
can [:read, :view], AdminFeedbackFile, submission: { author_id: author.id }
end
end
10 changes: 10 additions & 0 deletions app/models/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Submission < ApplicationRecord
has_many :committee_members, dependent: :destroy
has_many :format_review_files, inverse_of: :submission, dependent: :destroy
has_many :final_submission_files, inverse_of: :submission, dependent: :destroy
has_many :admin_feedback_files, inverse_of: :submission, dependent: :destroy
has_many :keywords, dependent: :destroy, validate: true
has_many :invention_disclosures, dependent: :destroy, validate: true

Expand Down Expand Up @@ -121,6 +122,7 @@ def cache_access_level
allow_destroy: true
accepts_nested_attributes_for :format_review_files, allow_destroy: true
accepts_nested_attributes_for :final_submission_files, allow_destroy: true
accepts_nested_attributes_for :admin_feedback_files, allow_destroy: true
accepts_nested_attributes_for :keywords, allow_destroy: true
accepts_nested_attributes_for :invention_disclosures,
allow_destroy: true,
Expand Down Expand Up @@ -403,6 +405,14 @@ def proquest_agreement=(input)
self[:proquest_agreement_at] = DateTime.now
end

def final_submission_feedback_files?
admin_feedback_files.any? { |file| file.feedback_type == 'final-submission' }
end

def format_review_feedback_files?
admin_feedback_files.any? { |file| file.feedback_type == 'format-review' }
end

private

def file_check
Expand Down
1 change: 1 addition & 0 deletions app/services/final_submission_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def self.call(params)
:is_voting, :federal_funding_used, :_destroy],
format_review_files_attributes: [:asset, :asset_cache, :id, :_destroy],
final_submission_files_attributes: [:asset, :asset_cache, :id, :_destroy],
admin_feedback_files_attributes: [:asset, :asset_cache, :submission_id, :feedback_type, :id, :_destroy],
keywords_attributes: [:word, :id, :_destroy],
invention_disclosures_attributes: [:id, :submission_id, :id_number, :_destroy]
)
Expand Down
3 changes: 2 additions & 1 deletion app/services/format_review_update_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def format_review_params
:lion_path_degree_code,
:federal_funding,
committee_members_attributes: [:id, :committee_role_id, :name, :email, :status, :notes, :is_required, :is_voting, :federal_funding_used, :_destroy],
format_review_files_attributes: [:asset, :asset_cache, :id, :_destroy]
format_review_files_attributes: [:asset, :asset_cache, :id, :_destroy],
admin_feedback_files_attributes: [:asset, :asset_cache, :feedback_type, :id, :_destroy]
)
end
end
2 changes: 2 additions & 0 deletions app/uploaders/submission_file_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def cache_dir
def asset_prefix
if model.class_name == 'final-submission-file'
Rails.root.join(WORKFLOW_BASE_PATH, 'final_submission_files')
elsif model.class_name == 'admin-feedback-file'
Rails.root.join(WORKFLOW_BASE_PATH, 'admin_feedback_files')
else
Rails.root.join(WORKFLOW_BASE_PATH, 'format_review_files')
end
Expand Down
22 changes: 22 additions & 0 deletions app/views/admin/submissions/edit/_admin_feedback_files.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<div id="admin-feedback-files">
<div class="links cocoon-links">
<label> <strong> <%= feedback_type.gsub('_', ' ').titleize %> Notes – Files </strong> </label>
<div id="admin-feedback-file-fields-<%= feedback_type %>">
<p> Any files containing corrections may be uploaded here. They will not be included with the final submission.</p>
<%= f.simple_fields_for :admin_feedback_files do |file| %>
<% if file.object.feedback_type == feedback_type %>
<%= render 'admin/submissions/file_fields', file_fields: file %>
<% end %>
<% end %>
</div>
<%= link_to_add_association f, :admin_feedback_files,
class: 'btn btn-info btn-sm can-toggle-clickability',
data: { association_insertion_node: '#admin-feedback-file-fields-' + feedback_type, association_insertion_method: 'append' },
form_name: 'file_fields',
wrap_object: Proc.new{|file| file.feedback_type = feedback_type; file },
partial: '/admin/submissions/file_fields' do %>
<span class="fa fa-plus"></span> Add File
<% end %>
</div>
</div>

Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@
<%= render partial: 'shared/final_submission_confidential_hold_checkbox', locals: {f: f} if @submission.author.confidential? %>

<%= f.input :final_submission_notes, as: :text, label: "Final Submission Notes to Student", input_html: { class: 'can-toggle-editability' } %>
<%= render partial: 'admin/submissions/edit/admin_feedback_files', locals: {f: f, feedback_type: 'final-submission'} %>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@

<%= render partial: '/shared/federal_funding_checkbox', locals: {f: f} unless @submission.status_behavior.beyond_waiting_for_format_review_response? %>
<%= f.input :format_review_notes, as: :text, label: "Format Review Notes to Student".html_safe, input_html: { class: 'can-toggle-editability' } %>
<%= render partial: 'admin/submissions/edit/admin_feedback_files', locals: {f: f, feedback_type: 'format-review'} %>
</div>
11 changes: 11 additions & 0 deletions app/views/author/submissions/edit_final_submission.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@
</div>
<% end %>

<% if @submission.final_submission_feedback_files? %>
<div id="admin-feedback-files" class="col-sm-12">
<% @submission.admin_feedback_files.each do |file| %>
<% if file.feedback_type == 'final-submission' %>
<div id="admin-feedback-file-<%=file.id%>" class = "pl-2 pb-2">
<%= link_to file.asset_identifier, "/author/files/#{file.link_identifier}/#{file.id}", class: 'file-link', target: '_blank' %>
</div>
<% end %>
<% end %>
<% end %>

<%= render partial: 'title_and_checkbox', locals: {f: f} %>
<%= render partial: 'semester_year', locals: {f: f} %>
<%= render partial: 'defended_at_date', locals: {f: f} if current_partner.graduate? %>
Expand Down
13 changes: 13 additions & 0 deletions app/views/author/submissions/edit_format_review.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
</div>
</div>
<% end %>

<% if @submission.format_review_feedback_files? %>
<div id="admin-feedback-files" class="col-sm-12">
<% @submission.admin_feedback_files.each do |file| %>
<% if file.feedback_type == 'format-review' %>
<div id="admin-feedback-file-<%=file.id%>" class = "pl-2 pb-2">
<%= link_to file.asset_identifier, "/author/files/#{file.link_identifier}/#{file.id}", class: 'file-link', target: '_blank' %>
</div>
<% end %>
<% end %>
</div>
<% end %>

<%= render partial: '/author/submissions/title_and_checkbox', locals: {f: f} %>
<%= render partial: '/author/submissions/semester_year', locals: {f: f} %>
<%= render partial: '/shared/federal_funding_checkbox', locals: {f: f} %>
Expand Down
6 changes: 6 additions & 0 deletions app/views/author/submissions/format_review.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
</div>
<% end %>

<% @submission.admin_feedback_files.each do |file| %>
<div id="admin-feedback-file-<%=file.id%>" class = "pl-2 pb-2">
<%= link_to file.asset_identifier, "/author/files/#{file.link_identifier}/#{file.id}", class: 'file-link', target: '_blank' %>
</div>
<% end %>

<div id="title" class="review-group <%= even_odd(@row_count) %>">
<h2 class="h4">Title</h2>
<p><%= @submission.title %></p>
Expand Down
11 changes: 7 additions & 4 deletions app/views/shared/_file_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<div class="nested-fields col-sm-8">
<% if file_fields.object.asset_identifier %>
<div id="<%= file_fields.object.class_name %>-<%= file_fields.object.id %>" class="form-group uploaded-file-link <%= can_delete ? 'can-delete' : 'cannot-delete' %> ">
<%= link_to_remove_association "[delete]", file_fields, id: 'file_delete_link', class: 'text-danger can-toggle-clickability' %>
<%= link_to "/#{session['user_role']}/files/#{file_fields.object.link_identifier}/#{file_fields.object.id}", class: 'file-link', target: '_blank' do %>
<%= file_fields.object.asset_identifier %>
<% end %>
<%= link_to_remove_association "[delete]", file_fields, id: 'file_delete_link', class: 'text-danger can-toggle-clickability' %>
<%= link_to "/#{session['user_role']}/files/#{file_fields.object.link_identifier}/#{file_fields.object.id}", class: 'file-link', target: '_blank' do %>
<%= file_fields.object.asset_identifier %>
<% end %>
<div class="badge badge-secondary float-right upload-date"><div>Uploaded <%= l file_fields.object.created_at, format: t("#{current_partner.id}.time.formats.medium") %></div></div>
</div>
<% else %>
Expand All @@ -15,5 +15,8 @@
<%= link_to_remove_association "[remove]", file_fields, class: 'text-danger can-toggle-clickability', html: {tabindex: '0'} %>
<%= file_fields.input :asset_cache, :as => :hidden %>
<%= file_fields.object.asset_identifier %>
<% if file_fields.object.respond_to?('feedback_type') %>
<%= file_fields.input :feedback_type, as: :hidden %>
<% end %>
<% end %>
</div>
4 changes: 4 additions & 0 deletions config/locales/partners/en/graduate/graduate.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,10 @@ en:
login_html: 'Login using your Penn State access account to view the paper.'
approval_help:
message: "If you know you need to approve a student's work, but do not see it in your queue or the link is broken, your ability to vote has expired. To resolve this issue, please try clearing your cache and then trying the link again or try the link on a different browser. If that doesn't work, please call OTD at 814-865-5448 or email us at <a href='mailto:[email protected]' target='_blank'>[email protected]</a> so that we may proxy for you."
default_format_review_note:
"The documents below contain your format review corrections, information on supporting materials, and the graduation checklist. Please refer to the Thesis and Dissertation Handbook when making corrections. \n \n The next step is to submit your final dissertation. The final dissertation must be reviewed and approved by all committee members and all changes made before it is uploaded to the eTD site for electronic approval. Formatting changes requested by the Office of Theses and Dissertations will be the only changes permitted after the final is uploaded."
default_final_submission_note:
"Your final submission requires further revisions. To see these revisions, open the PDF below in Adobe Acrobat. Please note this DOES NOT require you to get committee approvals again. Rather, make the requested revisions and then upload the corrected file to the ETDA. The Office of Theses and Dissertations will review your submission again until it is error-free. Please resubmit by the deadline for your intended graduation semester requirements. Not doing so puts you at risk of being removed from the graduation list. \n \n Thank you and do reach out if you have any questions!"
fee_message:
master_thesis:
message: "Before proceeding to your final submission, you must pay the $10 thesis fee. The fee can be paid at the <a href='https://secure.gradsch.psu.edu/paymentportal/' target='_blank'>Payment Section</a> of the Graduate School Thesis and Dissertation Information <a href='https://gradschool.psu.edu/completing-your-degree/thesis-and-dissertation-information/' target='_blank'>webpage</a>."
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@

get '/files/format_reviews/:id', to: 'files#download_format_review', as: :format_review_file
get '/files/final_submissions/:id', to: 'files#download_final_submission', as: :final_submission_file
get '/files/admin_feedbacks/:id', to: 'files#download_admin_feedback', as: :admin_feedback_file

root to: 'submissions#redirect_to_default_dashboard'
end
Expand Down Expand Up @@ -113,6 +114,7 @@

get '/files/format_reviews/:id', to: 'files#download_format_review', as: :format_review_file
get '/files/final_submissions/:id', to: 'files#download_final_submission', as: :final_submission_file
get '/files/admin_feedbacks/:id', to: 'files#download_admin_feedback', as: :admin_feedback_file

root to: 'submissions#index'
get '/tips', to: 'authors#technical_tips', as: :technical_tips
Expand Down
11 changes: 11 additions & 0 deletions db/migrate/20240613195728_create_admin_feedback_files.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CreateAdminFeedbackFiles < ActiveRecord::Migration[6.1]
def change
create_table :admin_feedback_files do |t|
t.bigint :submission_id
t.text :asset
t.string :feedback_type

t.timestamps
end
end
end
10 changes: 9 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2024_06_03_141826) do
ActiveRecord::Schema.define(version: 2024_07_02_191344) do

create_table "admin_feedback_files", charset: "utf8mb4", force: :cascade do |t|
t.bigint "submission_id"
t.text "asset"
t.string "feedback_type"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end

create_table "admins", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.string "access_id", default: "", null: false
Expand Down
8 changes: 8 additions & 0 deletions spec/factories/admin_feedback_files.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# # frozen_string_literal: true

FactoryBot.define do
factory :admin_feedback_file, class: 'AdminFeedbackFile' do |_f|
submission
asset { File.open(fixture('admin_feedback_01.pdf')) }
end
end
Binary file added spec/fixtures/admin_feedback_01.pdf
Binary file not shown.
32 changes: 28 additions & 4 deletions spec/integration/admin/submissions/edit_submission_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,13 @@
end
within('#format-review-files') do
click_link "Additional File"
all('input[type="file"]').first.set(fixture('format_review_file_01.pdf'))
all('input[type="file"]').last.set(fixture('format_review_file_02.pdf'))
end
within('#format-review-file-fields') do
all('input[type="file"]')[0].set(fixture('format_review_file_01.pdf'))
all('input[type="file"]')[1].set(fixture('format_review_file_02.pdf'))
end
within('#admin-feedback-files') do
all('input[type="file"]')[0].set(fixture('admin_feedback_01.pdf'))
end

find('#submission_federal_funding_true').click
Expand Down Expand Up @@ -104,10 +109,14 @@
expect(page).to have_link "format_review_file_02.pdf"
end

within('#admin-feedback-files') do
expect(page).to have_link "admin_feedback_01.pdf"
end

expect(page.find_field("Format Review Notes to Student").value).to eq "New review notes"
expect(page.find_field("Admin notes").value).to eq "Some admin notes"

within('#format-review-files') do
within('#format-review-file-fields') do
delete_link = find_all('a#file_delete_link').first
delete_link.click
end
Expand All @@ -116,6 +125,14 @@
visit admin_edit_submission_path(submission)
expect(page).to have_link "format_review_file_02.pdf"
expect(page).not_to have_link "format_review_file_01.pdf"

within('#admin-feedback-files') do
delete_link = find_all('a#file_delete_link').first
delete_link.click
end
click_button 'Update Metadata'
visit admin_edit_submission_path(submission)
expect(page).not_to have_link "admin_feedback_01.pdf"
end

it 'Allows admin to upload and delete final submission files' do
Expand All @@ -124,18 +141,25 @@
within('#final-submission-information') do
click_link "Additional File"
all('input[type="file"]').first.set(fixture('final_submission_file_01.pdf'))
click_link "Add File"
all('input[type="file"]').last.set(fixture('admin_feedback_01.pdf'))
end
click_button 'Update Metadata'
visit admin_edit_submission_path(final_submission)
expect(page).to have_link('final_submission_file_01.pdf')
expect(page).to have_link('admin_feedback_01.pdf')
within('#final-submission-information') do
delete_link = find_all('a#file_delete_link').first
delete_links = find_all('a#file_delete_link')
delete_link = delete_links.first
delete_link2 = delete_links.last
delete_link.click
delete_link2.click
end
expect(page).to have_content("Marked for deletion [undo]")
click_button 'Update Metadata'
visit admin_edit_submission_path(final_submission)
expect(page).not_to have_link('final_submission_file_01.pdf')
expect(page).not_to have_link('admin_feedback_01.pdf')
end

it 'Allows admin to upload multiple final submission files' do
Expand Down
Loading

0 comments on commit c6df868

Please sign in to comment.