Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion app/javascript/author/invention_disclosure.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/admin_statuses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/models/lionpath/lionpath_export_payload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 5 additions & 1 deletion app/models/solr_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down
15 changes: 11 additions & 4 deletions app/models/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions app/presenters/admin/submission_form_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -79,7 +79,7 @@ def release_date_history
case access_level
when 'restricted'
"<b>Metadata released:</b> #{date_information(released_metadata_at)}<br /><b>Scheduled for full release: </b> #{date_information(released_for_publication_at)}".html_safe
when 'restricted_to_institution'
when 'restricted_to_institution', 'restricted_liberal_arts'
"<b>Released to Penn State Community: </b> #{date_information(released_metadata_at)}<br /><b>Scheduled for full release: </b>#{date_information(released_for_publication_at)}".html_safe
else
metadata_str = ''
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/services/submission_release_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -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?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@
<% end %>
</div>
<br>
<% 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| ["<strong> #{k[:label]} </strong> -- #{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: '<strong>Access level<span class="required-asterisk">*</span></strong>'.html_safe %>
["<strong> #{k[:label]} </strong> -- #{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: '<strong>Access level<span class="required-asterisk">*</span></strong>'.html_safe,
required: true,
collection: access_level_collection,
wrapper: :vertical_radio_and_checkboxes %>
<%= render partial: 'admin_invention_disclosure_information', locals: {f: f} %>

<div class="links cocoon-links">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<% end %>
<div class="author">
<% AccessLevel.display.each do |k| %>
<% next if k[:type] == 'restricted_liberal_arts' && (@submission.academic_program != 'LA' || !current_partner.graduate?) %>
<% value = k[:type] %>
<% id = "submission_access_level_#{value}" %>
<% desc_id = "#{id}-desc" %>
Expand Down
1 change: 1 addition & 0 deletions app/views/author/submissions/_access_level_static.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<%= f.input :access_level, as: :hidden, input_html: { value: "#{@submission.access_level}" } %>
<ul>
<% AccessLevel.display.each do |k| %>
<% next if k[:type] == 'restricted_liberal_arts' %>
<li class="<%= k[:type] %>"><strong><%= k[:label] %></strong> -- <%= k[:description].html_safe %></li>
<%= render partial: 'restricted_note_field', locals: {f: f} if @view.psu_only(k[:label]) %>
<%= render partial: 'invention_disclosure_information', locals: {f: f} if k[:label] == 'Restricted' %>
Expand Down
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 @@ -345,6 +345,10 @@ en:
restricted_to_institution_attr:
description_html: 'Access restricted to individuals having a valid Penn State Access Account, for a period of two years. Allows restricted access of the entire work beginning immediately after degree conferral. At the end of the two-year period, the status will automatically change to Open Access. <i>Intended for use by authors in cases where prior public release of the work may compromise its acceptance for publication.</i>'
scope: final_restricted_institution
restricted_liberal_arts: 'Restricted (Liberal Arts Only)'
restricted_liberal_arts_attr:
description_html: 'Immediately after the conferral of the degree, the abstract becomes accessible worldwide. All other parts of the document are restricted to Penn State only for an embargo period of five (5) years for dissertations/thesis from the College of the Liberal Arts. No extensions will be granted beyond five (5) years.'
scope: final_restricted_institution
restricted: 'Restricted'
restricted_attr:
description_html: 'Restricts the entire work for the purpose of filing a patent. At the end of the two-year period, the status will automatically change to Open Access. Selection of this option requires that an invention disclosure (ID) be filed with the Office of Technology Management (OTM) prior to submission of the final thesis/dissertation, and confirmed by OTM.'
Expand Down
32 changes: 32 additions & 0 deletions spec/integration/admin/submissions/admin_access_level_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,37 @@
click_button('Update Metadata Only')
expect(page).not_to have_content('Invention disclosure number is required for Restricted submissions.')
end

context 'when author is in college of liberal arts' do
before do
submission.update(academic_program: 'LA')
page.refresh
end

if current_partner.graduate?
it 'has a restricted_liberal_arts radio button' do
page.find("input#submission_access_level_restricted_liberal_arts").click
expect(page.find("input#submission_access_level_restricted_liberal_arts")).to be_checked
expect(page).to have_field('submission_invention_disclosures_attributes_0_id_number')
end
end

unless current_partner.graduate?
it 'does not have a restricted_liberal_arts radio button' do
expect(page).not_to have_selector("input#submission_access_level_restricted_liberal_arts")
end
end
end

context 'when author is not in college of liberal arts' do
before do
submission.update(academic_program: 'CA')
page.refresh
end

it 'does not have a restricted_liberal_arts radio button' do
expect(page).not_to have_selector("input#submission_access_level_restricted_liberal_arts")
end
end
end
end
33 changes: 33 additions & 0 deletions spec/integration/author/submission_access_level_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,39 @@
expect(page).not_to have_content('Invention disclosure number is required for Restricted submissions.')
end
end

context 'when author is in college of liberal arts' do
before do
submission.update(academic_program: 'LA')
page.refresh
end

if current_partner.graduate?
it 'has a restricted_liberal_arts radio button' do
page.find("input#submission_access_level_restricted_liberal_arts").click
expect(page.find("input#submission_access_level_restricted_liberal_arts")).to be_checked
expect(page).not_to have_content('Enter justification')
expect(page).not_to have_field('submission_invention_disclosures_attributes_0_id_number')
end
end

unless current_partner.graduate?
it 'does not have a restricted_liberal_arts radio button' do
expect(page).not_to have_selector("input#submission_access_level_restricted_liberal_arts")
end
end
end

context 'when author is not in college of liberal arts' do
before do
submission.update(academic_program: 'CA')
page.refresh
end

it 'does not have a restricted_liberal_arts radio button' do
expect(page).not_to have_selector("input#submission_access_level_restricted_liberal_arts")
end
end
end

context 'milsch authors cannot choose the access level', :milsch do
Expand Down
11 changes: 8 additions & 3 deletions spec/models/access_level_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
let(:open_access_view_struct) { { type: 'open_access', label: 'Open Access', description: EtdaUtilities::AccessLevel.partner_access_levels['access_level']['open_access_attr']['description_html'] } }
let(:restricted_view_struct) { { type: 'restricted', label: 'Restricted', description: EtdaUtilities::AccessLevel.partner_access_levels['access_level']['restricted_attr']['description_html'] } }
let(:restricted_to_institution_view_struct) { { type: 'restricted_to_institution', label: 'Restricted (Penn State Only)', description: EtdaUtilities::AccessLevel.partner_access_levels['access_level']['restricted_to_institution_attr']['description_html'] } }
let(:restricted_liberal_arts_view_struct) { { type: 'restricted_liberal_arts', label: 'Restricted (Liberal Arts Only)', description: EtdaUtilities::AccessLevel.partner_access_levels['access_level']['restricted_liberal_arts_attr']['description_html'] } }

describe '#ACCESS_LEVEL_KEYS' do
it 'constant containing all access levels' do
expect(described_class::ACCESS_LEVEL_KEYS).to contain_exactly('open_access', 'restricted_to_institution', 'restricted', '')
expect(described_class::ACCESS_LEVEL_KEYS).to contain_exactly('open_access', 'restricted_to_institution', 'restricted', 'restricted_liberal_arts', '')
expect(described_class::ACCESS_LEVEL_KEYS).to include('open_access')
expect(described_class::ACCESS_LEVEL_KEYS).to include('restricted')
expect(described_class::ACCESS_LEVEL_KEYS).to include('restricted_to_institution')
expect(described_class::ACCESS_LEVEL_KEYS).to include('restricted_liberal_arts')
expect(described_class::ACCESS_LEVEL_KEYS).to include('')
expect(described_class::ACCESS_LEVEL_KEYS.length).to eq(4)
expect(described_class::ACCESS_LEVEL_KEYS.length).to eq(5)
end
end

Expand Down Expand Up @@ -45,14 +47,17 @@
expect(described_class.paper_access_levels).to include(open_access_view_struct)
expect(described_class.paper_access_levels).to include(restricted_view_struct)
expect(described_class.paper_access_levels).to include(restricted_to_institution_view_struct)
expect(described_class.paper_access_levels).to include(restricted_liberal_arts_view_struct)
end
end

describe 'ordering' do
it "levels should evaluate int he correct order" do
it "levels should evaluate in the correct order" do
expect(described_class.OPEN_ACCESS.to_i < described_class.RESTRICTED.to_i).to be_truthy
expect(described_class.OPEN_ACCESS.to_i < described_class.RESTRICTED_TO_INSTITUTION.to_i).to be_truthy
expect(described_class.OPEN_ACCESS.to_i < described_class.RESTRICTED_LIBERAL_ARTS.to_i).to be_truthy
expect(described_class.RESTRICTED_TO_INSTITUTION.to_i < described_class.RESTRICTED.to_i).to be_truthy
expect(described_class.RESTRICTED_LIBERAL_ARTS.to_i < described_class.RESTRICTED.to_i).to be_truthy
end
end
end
21 changes: 16 additions & 5 deletions spec/models/concerns/admin_statuses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,22 @@
end

context 'when the admin status is final_restricted_institution' do
it 'returns the correct label' do
status = 'final_restricted_institution'
submission = Submission.new(status: 'released for publication!!!',
access_level: 'restricted_to_institution')
expect(submission.admin_status).to eq I18n.t!("#{current_partner.id}.admin_filters.#{status}.title")
context 'when access level is restricted to institution' do
it 'returns the correct label' do
status = 'final_restricted_institution'
submission = Submission.new(status: 'released for publication!!!',
access_level: 'restricted_to_institution')
expect(submission.admin_status).to eq I18n.t!("#{current_partner.id}.admin_filters.#{status}.title")
end
end

context 'when access level is restricted liberal arts' do
it 'returns the correct label' do
status = 'final_restricted_institution'
submission = Submission.new(status: 'released for publication!!!',
access_level: 'restricted_liberal_arts')
expect(submission.admin_status).to eq I18n.t!("#{current_partner.id}.admin_filters.#{status}.title")
end
end
end

Expand Down
Loading