Skip to content

Commit

Permalink
Add new deposit type
Browse files Browse the repository at this point in the history
general graduate scholarship despoit item
  • Loading branch information
rawOrlando committed Jul 19, 2024
1 parent c59739f commit 25710bb
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 13 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ jobs:
ruby-version: ${{ matrix.ruby-version }}
bundler: "2.1.4"
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Update rubygems
run: |
gem update --system 3.3.27
gem install bundler:2.1.4
# commenting out untill we move to ruby 3
# - name: Update rubygems
# run: |
# gem update --system 3.3.27
# gem install bundler:2.1.4
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion app/lib/tufts/contribute_collections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def collection_for_work_type(work_type)
title: "Tufts Published Scholarship",
call_number: "PB",
finding_aid: "https://archives.tufts.edu/repositories/2/resources/100",
work_types: [GenericDeposit, GenericTischDeposit, GisPoster, UndergradSummerScholar, FacultyScholarship]
work_types: [GenericDeposit, GenericTischDeposit, GisPoster, UndergradSummerScholar, FacultyScholarship, GradScholarship]
},
{
title: "Fletcher School Records",
Expand Down
32 changes: 32 additions & 0 deletions app/models/forms/grad_scholarship.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# frozen_string_literal: true
class GradScholarship < Contribution
self.attributes += [:department]
self.ignore_attributes += [:department]
attr_accessor :department
validates :department, presence: true

self.attributes += [:advisor]
self.ignore_attributes += [:advisor]
attr_accessor :advisor
validates :advisor, presence: true

protected

def copy_attributes
super
@tufts_pdf.subject = [department]
@tufts_pdf.creator_department = [creator_dept]
end

private

# TODO: copied from Honors Thesis, problally needs work in both places
def creator_dept
terms = Qa::Authorities::Local.subauthority_for('departments').all
if department == terms.find { |t| t[:label] == department }
term[:id]
else
'NEEDS FIXING'
end
end
end
22 changes: 22 additions & 0 deletions app/views/contribute/deposit_view/_grad_scholarship.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<%# NOTE: this form uses bootstrap_form_for and bootstrap_forms helpers - see: https://github.com/sethvargo/bootstrap_forms %>
<%= f.text_field :title, label: 'Title', required: true %>
<%= f.text_field :creator, label: 'Creator', value: @contribution.creator, required: true, readonly: 'readonly' %>
<% if params['contribution'] && params['contribution']['contributor'] %>
<%= react_component('ContributeOtherAuthors', {contributor: params['contribution']['contributor']}, {camelize_props: true}) %>
<% else %>
<%= react_component('ContributeOtherAuthors', {contributor: []}, {camelize_props: true}) %>
<% end %>
<%= f.text_field :department, label: 'Department', 'data-autocomplete': '/authorities/search/local/departments' %>
<script>
Tufts.autocomplete()
</script>

<%= f.text_field :advisor, label: 'Advisor' %>
<%= 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 :abstract, label: 'Short Description', rows: 5, class: 'col-sm-8' %>
4 changes: 2 additions & 2 deletions config/deposit_type_seed.csv
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
display_name,deposit_view,license_name,deposit_agreement
Faculty Scholarship,faculty_scholarship,Tufts Non-Exclusive Deposit License v1.0,"I understand and acknowledge that this submission is governed by the <a href=""/contribute/license"" rel=""nofollow"">Tufts Non-Exclusive Deposit License</a>."
Fletcher School Capstone Project,capstone_project,Tufts Non-Exclusive Deposit License: Fletcher v1.0,"I understand and acknowledge that this submission is governed by the <a href=""/contribute/license"" rel=""nofollow"">Tufts Non-Exclusive Deposit License</a>."
GIS Expo Student Winners,gis_poster,Tufts Non-Exclusive Deposit License v1.0,"I understand and acknowledge that this submission is governed by the <a href=""/contribute/license"" rel=""nofollow"">Tufts Non-Exclusive Deposit License</a>.
"
GIS Expo Student Winners,gis_poster,Tufts Non-Exclusive Deposit License v1.0,"I understand and acknowledge that this submission is governed by the <a href=""/contribute/license"" rel=""nofollow"">Tufts Non-Exclusive Deposit License</a>."
General Undergraduate Scholarship,generic_tisch_deposit,Tufts Non-Exclusive Deposit License v1.0,"I understand and acknowledge that this submission is governed by the <a href=""/contribute/license"" rel=""nofollow"">Tufts Non-Exclusive Deposit License</a>."
Graduate School of Arts and Sciences Education Qualifying Papers,qualifying_paper,Tufts Non-Exclusive Deposit License: Graduate Arts & Science v1.0,"I understand and acknowledge that this submission is governed by the <a href=""/contribute/license"" rel=""nofollow"">Tufts Non-Exclusive Deposit License</a>."
Masters in Animal and Public Policy,cummings_thesis,Tufts Non-Exclusive Deposit License v1.0,"I understand and acknowledge that this submission is governed by the <a href=""/contribute/license"" rel=""nofollow"">Tufts Non-Exclusive Deposit License</a>."
PHPD Field Experience/Capstone,public_health,Tufts Non-Exclusive Deposit License v1.0,"I understand and acknowledge that this submission is governed by the <a href=""/contribute/license"" rel=""nofollow"">Tufts Non-Exclusive Deposit License</a>."
Tisch Library Undergraduate Research Award,generic_deposit,Tufts Non-Exclusive Deposit License v1.0,"I understand and acknowledge that this submission is governed by the <a href=""/contribute/license"" rel=""nofollow"">Tufts Non-Exclusive Deposit License</a>."
Undergraduate Honors Thesis,honors_thesis,Tufts Non-Exclusive Deposit License v1.0,"I understand and acknowledge that this submission is governed by the <a href=""/contribute/license"" rel=""nofollow"">Tufts Non-Exclusive Deposit License</a>."
Undergraduate Summer Scholars,undergrad_summer_scholar, Tufts Non-Exclusive Deposit License v1.0,"I understand and acknowledge that this submission is governed by the <a href=""/contribute/license"" rel=""nofollow"">Tufts Non-Exclusive Deposit License</a>."
General Graduate Scholarship,grad_scholarship,Tufts Non-Exclusive Deposit License v1.0,"I understand and acknowledge that this submission is governed by the <a href=""/contribute/license"" rel=""nofollow"">Tufts Non-Exclusive Deposit License</a>."
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# frozen_string_literal: true
require 'rails_helper'
require 'ffaker'
require 'import_export/deposit_type_importer.rb'
include Warden::Test::Helpers

# NOTE: If you generated more than one work, you have to set "js: true"
RSpec.feature 'General Graduate Scholarship', :clean, js: true do
# TODO: make a csv file
let(:csv_path) { Rails.root.join('config', 'deposit_type_seed.csv').to_s }
let(:importer) { DepositTypeImporter.new(csv_path) }
let(:pdf_path) { Rails.root.join('spec', 'fixtures', 'hello.pdf') }
let(:user) { FactoryBot.create(:user) }
let(:admin) { FactoryBot.create(:admin) }
let(:title) { FFaker::Movie.unique.title }
let(:advisory) { "advisory" }
let(:short_description) { FFaker::Book.description }

before do
allow(CharacterizeJob).to receive(:perform_later).and_return(true) # Don't run fits
login_as user
# loads the deposit_types
importer.import_from_csv
end

scenario do
visit '/contribute'
select 'General Graduate Scholarship', from: 'deposit_type'
click_button 'Begin'
attach_file('PDF to upload', pdf_path)
fill_in 'Title', with: title
fill_in 'Short Description', with: short_description

# Test department autocomplete
fill_in 'Department', with: 'geol'
page.execute_script %{ $('#contribution_department').trigger('focus') }
page.execute_script %{ $('#contribution_department').trigger('keydown') }
expect(page).to have_selector('ul.ui-autocomplete li.ui-menu-item')
page.execute_script %{ $('ul.ui-autocomplete li.ui-menu-item:contains("Dept. of Geology")').trigger('mouseenter').click() }
expect(find_field('Department').value).to eq 'Dept. of Geology'

fill_in 'Advisor', with: advisory

click_button 'Agree & Deposit'
expect(page).to have_content 'Your deposit has been submitted for approval.'
end
end
2 changes: 1 addition & 1 deletion spec/features/contribute/graduate_school_arts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
end
scenario do
visit '/contribute'
find('#deposit_type').find(:xpath, 'option[6]').select_option
find('#deposit_type').find(:xpath, 'option[7]').select_option
click_button 'Begin'
attach_file('PDF to upload', pdf_path)
fill_in 'Title', with: FFaker::Book.title
Expand Down
2 changes: 1 addition & 1 deletion spec/features/contribute/phpd_capstone_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
end
scenario do
visit '/contribute'
find('#deposit_type').find(:xpath, 'option[8]').select_option
find('#deposit_type').find(:xpath, 'option[9]').select_option
click_button 'Begin'
attach_file('PDF to upload', pdf_path)
fill_in 'Capstone Project Title', with: FFaker::Book.title
Expand Down
2 changes: 1 addition & 1 deletion spec/features/contribute/tish_library_reward_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

scenario do
visit '/contribute'
find('#deposit_type').find(:xpath, 'option[9]').select_option
find('#deposit_type').find(:xpath, 'option[10]').select_option
click_button 'Begin'
attach_file('PDF to upload', pdf_path)
fill_in 'Title', with: FFaker::Book.title
Expand Down
2 changes: 1 addition & 1 deletion spec/features/contribute/undergrad_honors_thesis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

scenario do
visit '/contribute'
find('#deposit_type').find(:xpath, 'option[10]').select_option
find('#deposit_type').find(:xpath, 'option[11]').select_option
click_button 'Begin'
attach_file('PDF to upload', pdf_path)
fill_in 'Thesis title', with: FFaker::Book.title
Expand Down
2 changes: 1 addition & 1 deletion spec/features/contribute/undergrad_summer_scholars_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
end
scenario do
visit '/contribute'
find('#deposit_type').find(:xpath, 'option[11]').select_option
find('#deposit_type').find(:xpath, 'option[12]').select_option
click_button 'Begin'
attach_file('PDF to upload', pdf_path)
fill_in 'Title', with: FFaker::Book.title
Expand Down

0 comments on commit 25710bb

Please sign in to comment.