diff --git a/.rubocop.yml b/.rubocop.yml index ef75d6df9..b211470ed 100755 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -71,6 +71,7 @@ Metrics/ClassLength: - app/controllers/author/submissions_controller.rb - app/models/committee_member.rb - app/models/export_report.rb + - app/models/solr_submission.rb Metrics/CyclomaticComplexity: Exclude: diff --git a/Gemfile.lock b/Gemfile.lock index aeec422f1..de13f2fe9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -168,7 +168,7 @@ GEM rubocop (>= 1) smart_properties erubi (1.13.1) - etda_utilities (0.21.0) + etda_utilities (0.21.2) factory_bot (6.5.1) activesupport (>= 6.1.0) factory_bot_rails (6.4.4) diff --git a/app/javascript/author/invention_disclosure.js b/app/javascript/author/invention_disclosure.js index f673d1925..3bd69d0b0 100644 --- a/app/javascript/author/invention_disclosure.js +++ b/app/javascript/author/invention_disclosure.js @@ -18,7 +18,8 @@ const bind_to_access_level = () => e.preventDefault; } - if ($('div.author #submission_access_level_restricted_to_institution').prop('checked')) { + if ($('div.author #submission_access_level_restricted_to_institution').prop('checked') || + $('div.author #submission_access_level_restricted_liberal_arts').prop('checked')) { $('div#restricted_note').removeClass('d-none'); return $('#submission_restricted_notes').focus(); } else { diff --git a/app/models/concerns/admin_statuses.rb b/app/models/concerns/admin_statuses.rb index 255460eaa..9822a126e 100644 --- a/app/models/concerns/admin_statuses.rb +++ b/app/models/concerns/admin_statuses.rb @@ -84,7 +84,7 @@ def final_submission_on_hold end def final_restricted_institution - access_level == 'restricted_to_institution' && status.start_with?('released for publication') + access_level.in?(['restricted_to_institution', 'restricted_liberal_arts']) && status.start_with?('released for publication') end def final_withheld diff --git a/app/models/lionpath/lionpath_export_payload.rb b/app/models/lionpath/lionpath_export_payload.rb index 764fed2b2..1c2cfe283 100644 --- a/app/models/lionpath/lionpath_export_payload.rb +++ b/app/models/lionpath/lionpath_export_payload.rb @@ -48,6 +48,7 @@ def embargo_type access_level_map = { 'open_access' => 'OPEN', 'restricted_to_institution' => 'RPSU', + 'restricted_liberal_arts' => 'RLA', 'restricted' => 'RSTR' } access_level_map[submission.access_level] diff --git a/app/models/solr_submission.rb b/app/models/solr_submission.rb index 71634f936..85affda8d 100644 --- a/app/models/solr_submission.rb +++ b/app/models/solr_submission.rb @@ -39,7 +39,7 @@ def field_semantics keyword_list: ['keyword_ssim', 'keyword_tesim'], title: ['title_ssi', 'title_tesi'], id: ['db_id'], - access_level: 'access_level_ss', + adjusted_access_level: 'access_level_ss', semester: 'semester_ssi', abstract: 'abstract_tesi', defended_at_dtsi: 'defended_at_dtsi', @@ -92,6 +92,10 @@ def committee_member_names names end + def adjusted_access_level + access_level == 'restricted_liberal_arts' ? 'restricted_to_institution' : access_level + end + def author_name_tesi "#{author.last_name}, #{author.first_name} #{author.middle_name}" end diff --git a/app/models/submission.rb b/app/models/submission.rb index db43f0e05..08eebdeba 100755 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -140,18 +140,21 @@ def program_head scope :final_submission_is_approved, -> { where(status: 'waiting for publication release') } scope :final_submission_is_on_hold, -> { where(status: 'waiting in final submission on hold') } scope :released_for_publication, -> { where('status LIKE "released for publication%"') } - scope :final_is_restricted_institution, -> { where('status LIKE "released for publication%"').where(access_level: 'restricted_to_institution') } + scope :final_is_restricted_institution, -> { where('status LIKE "released for publication%"').where(access_level: ['restricted_to_institution', 'restricted_liberal_arts']) } scope :final_is_withheld, -> { where('status LIKE "released for publication%"').where(access_level: 'restricted') } scope :ok_to_release, -> { where('released_for_publication_at <= ?', Time.zone.today.end_of_day) } scope :ok_to_autorelease, -> { - ok_to_release.where(access_level: 'restricted_to_institution') + ok_to_release.where(access_level: ['restricted_to_institution', 'restricted_liberal_arts']) .where(status: 'released for publication metadata only') } scope :release_warning_needed?, -> { - where('released_metadata_at >= ?', Time.zone.today.years_ago(2).end_of_day) + where( + '(released_metadata_at >= ? AND access_level = ?) OR (released_metadata_at >= ? AND access_level = ?)', + Time.zone.today.years_ago(2).end_of_day, 'restricted_to_institution', + Time.zone.today.years_ago(5).end_of_day, 'restricted_liberal_arts' + ) .where('released_for_publication_at <= ?', Time.zone.today.next_month) .where(author_release_warning_sent_at: nil) - .where(access_level: 'restricted_to_institution') } def advisor @@ -334,6 +337,8 @@ def final_submission_rejected? delegate :restricted_to_institution?, to: :access_level + delegate :restricted_liberal_arts?, to: :access_level + def publication_release_access_level return 'open_access' if status_behavior.released_for_publication? # full release of submission that was held for 2 years @@ -349,6 +354,8 @@ def publication_release_date(date_to_release) # released_fo_publication_at = date_to_release return date_to_release if open_access? + return date_to_release.to_date + 5.years if restricted_liberal_arts? + date_to_release.to_date + 2.years end diff --git a/app/presenters/admin/submission_form_view.rb b/app/presenters/admin/submission_form_view.rb index f31c1fb41..46bdb0cbb 100644 --- a/app/presenters/admin/submission_form_view.rb +++ b/app/presenters/admin/submission_form_view.rb @@ -29,7 +29,7 @@ def title return 'Edit Final Submission On Hold' if status_behavior.waiting_in_final_submission_on_hold? return 'Edit Released Submission' if status_behavior.released_for_publication? && open_access? return 'Edit Restricted Submission' if status_behavior.released_for_publication_metadata_only? && restricted? - return 'Edit Final Submission is Restricted to Penn State' if status_behavior.released_for_publication? && access_level == 'restricted_to_institution' + return 'Edit Final Submission is Restricted to Penn State' if status_behavior.released_for_publication? && (access_level == 'restricted_to_institution' || access_level == 'restricted_liberal_arts') 'Edit Incomplete Format Review' end @@ -79,7 +79,7 @@ def release_date_history case access_level when 'restricted' "Metadata released: #{date_information(released_metadata_at)}
Scheduled for full release: #{date_information(released_for_publication_at)}".html_safe - when 'restricted_to_institution' + when 'restricted_to_institution', 'restricted_liberal_arts' "Released to Penn State Community: #{date_information(released_metadata_at)}
Scheduled for full release: #{date_information(released_for_publication_at)}".html_safe else metadata_str = '' @@ -139,7 +139,7 @@ def cancel_url # return "/admin/#{degree_type}/released_for_publication" if status_behavior.released_for_publication? && open_access? TOO SLOW; RETURN TO DASHBOARD return "/admin/#{degree_type.slug}" if status_behavior.released_for_publication? && open_access? return "/admin/#{degree_type.slug}/final_withheld" if status_behavior.released_for_publication_metadata_only? && restricted? - return "/admin/#{degree_type.slug}/final_restricted_institution" if status_behavior.released_for_publication? && access_level == 'restricted_to_institution' + return "/admin/#{degree_type.slug}/final_restricted_institution" if status_behavior.released_for_publication? && (access_level == 'restricted_to_institution' || access_level == 'restricted_liberal_arts') "/admin/#{degree_type.slug}/format_review_incomplete" end diff --git a/app/services/submission_release_service.rb b/app/services/submission_release_service.rb index 48174f671..f8f634cfd 100644 --- a/app/services/submission_release_service.rb +++ b/app/services/submission_release_service.rb @@ -73,7 +73,7 @@ def publish_a_submission(submission, date_to_release, original_final_files) status_giver = SubmissionStatusGiver.new(submission) status_giver.can_release_for_publication? - if submission.restricted? || submission.restricted_to_institution? + if submission.restricted? || submission.restricted_to_institution? || submission.restricted_liberal_arts? status_giver.released_for_publication_metadata_only! else status_giver.released_for_publication! @@ -97,7 +97,7 @@ def update_restricted_submission_to_open_access(submission, date_to_release, ori new_public_id = submission.public_id.presence || PublicIdMinter.new(submission).id return unless public_id_ok(new_public_id) - return if new_access_level == 'restricted' || new_access_level == 'restricted to institution' + return if new_access_level == 'restricted' || new_access_level == 'restricted to institution' || new_access_level == 'restricted liberal arts' status_giver = SubmissionStatusGiver.new(submission) status_giver.can_release_for_publication? diff --git a/app/views/admin/submissions/edit/_final_submission_fields.html.erb b/app/views/admin/submissions/edit/_final_submission_fields.html.erb index f0e659278..52a87f497 100644 --- a/app/views/admin/submissions/edit/_final_submission_fields.html.erb +++ b/app/views/admin/submissions/edit/_final_submission_fields.html.erb @@ -26,11 +26,16 @@ <% end %>
+ <% access_level_collection = AccessLevel.display.filter_map do |k| + next if k[:type] == 'restricted_liberal_arts' && (@submission.academic_program != 'LA' || !current_partner.graduate?) - <%= f.input :access_level, as: :radio_buttons, - collection: AccessLevel.display.map { |k| [" #{k[:label]} -- #{k[:description]} #{render partial: 'restricted_notes', locals: {f: f} if @view.psu_only(k[:label])}".html_safe, k[:type], { class: "#{k[:type]}" }] }, - wrapper: :vertical_radio_and_checkboxes, - label: 'Access level*'.html_safe %> + [" #{k[:label]} -- #{k[:description]} #{render partial: 'restricted_notes', locals: {f: f} if @view.psu_only(k[:label])}".html_safe, k[:type], { class: "#{k[:type]}" }] + end %> + <%= f.input :access_level, as: :radio_buttons, + label: 'Access level*'.html_safe, + required: true, + collection: access_level_collection, + wrapper: :vertical_radio_and_checkboxes %> <%= render partial: 'admin_invention_disclosure_information', locals: {f: f} %>