Skip to content

Commit

Permalink
Handle self-deposit embargoes correctly
Browse files Browse the repository at this point in the history
Self deposit items can be submitted with an optional embargo.  When
no embargo (value '0') is selected, the :embargo_note attribute should
be left empty; otherwise, the embargo note should contain the embargo
release date

closes #888
  • Loading branch information
mark-dce committed Mar 1, 2018
1 parent 4195710 commit 0802130
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 11 deletions.
6 changes: 3 additions & 3 deletions app/models/forms/contribution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class Contribution

class_attribute :ignore_attributes, :attributes

self.ignore_attributes = [:attachment]
self.ignore_attributes = [:attachment, :embargo]

self.attributes = [:title, :description, :creator, :contributor, :bibliographic_citation, :subject, :attachment, :tufts_license, :embargo_note]
self.attributes = [:title, :description, :creator, :contributor, :bibliographic_citation, :subject, :attachment, :tufts_license, :embargo]

SELFDEP = 'selfdep'.freeze

Expand Down Expand Up @@ -106,7 +106,7 @@ def license_data(contribution)

def insert_embargo_date
return unless @tufts_pdf
@tufts_pdf.embargo_note = (Time.zone.now + embargo_note.to_i.months).iso8601 unless (embargo_note || '0').eql? '0'
@tufts_pdf.embargo_note = (Time.zone.now + embargo.to_i.months).iso8601 unless (embargo || '0').eql? '0'
end

def attachment_has_valid_content_type
Expand Down
2 changes: 1 addition & 1 deletion app/models/forms/gis_poster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class GisPoster < GenericTischDeposit
self.attributes = [:title, :degrees, :schools, :departments, :courses, :methodological_keywords, :geonames,
:term, :year, :topics, :geonames_placeholder,
:degree,
:description, :creator, :contributor, :embargo_note,
:description, :creator, :contributor,
:bibliographic_citation, :subject, :corpname, :attachment, :license]
# def copy_attributes
# super
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
<%= f.select :degree, options_for_select(fletcher_degrees), {prompt: 'Please select a degree', label: 'Degree'}, {required: true} %>
<%= f.select :embargo_note, standard_embargos, label: 'Embargo', help: 'An embargo will restrict all access to your work until the selected time has passed' %>
<%= f.select :embargo, standard_embargos, label: 'Embargo', help: 'An embargo will restrict all access to your work until the selected time has passed' %>
<%= f.text_area :description, label: 'Short Description', rows: 5, class: 'col-sm-8' %>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<%= react_component('ContributeOtherAuthors', {contributor: []}, {camelize_props: true}) %>
<% end %>
<%= f.select :embargo_note, standard_embargos, label: 'Embargo', help: 'An embargo will restrict all access to your work until the selected time has passed' %>
<%= f.select :embargo, standard_embargos, label: 'Embargo', help: 'An embargo will restrict all access to your work until the selected time has passed' %>
<%= f.text_area :description, label: 'Short Description', rows: 5, class: 'col-sm-8' %>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
<%= react_component('ContributeOtherAuthors', {contributor: []}, {camelize_props: true}) %>
<% end %>
<%= f.select :embargo_note, standard_embargos, label: 'Embargo', help: 'An embargo will restrict all access to your work until the selected time has passed' %>
<%= f.select :embargo, standard_embargos, label: 'Embargo', help: 'An embargo will restrict all access to your work until the selected time has passed' %>
<%= f.text_area :description, label: 'Short Description', rows: 5, class: 'col-sm-8', required: true %>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<%= react_component('ContributeOtherAuthors', {contributor: []}, {camelize_props: true}) %>
<% end %>
<%= f.select :embargo_note, standard_embargos, label: 'Embargo', help: 'An embargo will restrict all access to your work until the selected time has passed' %>
<%= f.select :embargo, standard_embargos, label: 'Embargo', help: 'An embargo will restrict all access to your work until the selected time has passed' %>
<%= f.text_area :description, label: 'Short Description', rows: 5, class: 'col-sm-8' %>
2 changes: 1 addition & 1 deletion app/views/contribute/deposit_view/_honors_thesis.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
Tufts.autocomplete()
</script>

<%= f.select :embargo_note, standard_embargos, label: 'Embargo', help: 'An embargo will restrict all access to your work until the selected time has passed' %>
<%= f.select :embargo, standard_embargos, label: 'Embargo', help: 'An embargo will restrict all access to your work until the selected time has passed' %>
<%= f.text_area :description, label: 'Short Description', rows: 5, class: 'col-sm-8', required: true %>
2 changes: 1 addition & 1 deletion app/views/contribute/deposit_view/_public_health.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
<%= f.select :degree, options_for_select(public_health_degrees), {prompt: 'Please select a degree', label: 'Degree'}, {required: true} %>
<%= f.select :embargo_note, standard_embargos, label: 'Embargo', help: 'An embargo will restrict all access to your work until the selected time has passed' %>
<%= f.select :embargo, standard_embargos, label: 'Embargo', help: 'An embargo will restrict all access to your work until the selected time has passed' %>
<%= f.text_area :description, label: 'Short Description', rows: 5, class: 'col-sm-8' %>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<%= react_component('ContributeOtherAuthors', {contributor: []}, {camelize_props: true}) %>
<% end %>
<%= f.select :embargo_note, standard_embargos, label: 'Embargo', help: 'An embargo will restrict all access to your work until the selected time has passed' %>
<%= f.select :embargo, standard_embargos, label: 'Embargo', help: 'An embargo will restrict all access to your work until the selected time has passed' %>
<%= f.text_area :description, label: 'Short Description', rows: 5, class: 'col-sm-8', required: true %>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
let(:abstract) { FFaker::Book.description }
let(:coauthor1) { FFaker::Name.name }
let(:coauthor2) { FFaker::Name.name }

before do
allow(CharacterizeJob).to receive(:perform_later).and_return(true) # Don't run fits
importer = DepositTypeImporter.new('./config/deposit_type_seed.csv')
Expand All @@ -24,6 +25,8 @@
login_as user
user.display_name = " Name with Spaces "
user.save

allow(Time).to receive(:now).and_return( Time.utc(2015, 1, 1, 12, 0, 0) )
end

scenario "a new user contributes faculty scholarship" do
Expand All @@ -38,6 +41,7 @@
page.all(:fillable_field, 'contribution[contributor][]')[0].set(coauthor1)
click_button "Add Another Author"
page.all(:fillable_field, 'contribution[contributor][]')[1].set(coauthor2)
select '6 months', from: 'contribution_embargo'
fill_in "Short Description", with: abstract
click_button "Agree & Deposit"
created_pdf = Pdf.last
Expand All @@ -50,6 +54,7 @@
expect(created_pdf.visibility).to eq Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
expect(created_pdf.description.first).to eq abstract
expect(created_pdf.bibliographic_citation.first).to eq bibliographic_citation
expect(created_pdf.embargo_note).to eq "2015-07-01T12:00:00Z"
logout
login_as(admin)
visit("/concern/pdfs/#{created_pdf.id}")
Expand All @@ -58,6 +63,7 @@
expect(page).to have_content(bibliographic_citation)
expect(page).to have_content("In Collection")
expect(page).to have_content("Tufts Published Scholarship, 1987-2014")
expect(page).to have_content('Embargo Note')
visit("/concern/pdfs/#{created_pdf.id}/edit")
expect(find_by_id("pdf_description").value).to eq abstract
expect(find_by_id("pdf_bibliographic_citation").value).to eq bibliographic_citation
Expand All @@ -77,6 +83,7 @@
expect(created_pdf.creator.first).to eq "Name with Spaces"
expect(created_pdf.description.first).to eq "A short description with wonky spaces"
expect(created_pdf.bibliographic_citation.first).to eq "bibliographic citation with spaces"
expect(created_pdf.embargo_note).to be_nil
end
end
end

0 comments on commit 0802130

Please sign in to comment.