From 25710bb005b051ab3a0b784d41f8e517cee047c1 Mon Sep 17 00:00:00 2001 From: Ryan Orlando Date: Thu, 11 Jul 2024 12:00:01 -0400 Subject: [PATCH] Add new deposit type general graduate scholarship despoit item --- .github/workflows/ci.yml | 10 ++-- app/lib/tufts/contribute_collections.rb | 2 +- app/models/forms/grad_scholarship.rb | 32 +++++++++++++ .../deposit_view/_grad_scholarship.html.erb | 22 +++++++++ config/deposit_type_seed.csv | 4 +- ...eneral_grad_scholarship_contribute_spec.rb | 47 +++++++++++++++++++ .../contribute/graduate_school_arts_spec.rb | 2 +- .../features/contribute/phpd_capstone_spec.rb | 2 +- .../contribute/tish_library_reward_spec.rb | 2 +- .../undergrad_honors_thesis_spec.rb | 2 +- .../undergrad_summer_scholars_spec.rb | 2 +- 11 files changed, 114 insertions(+), 13 deletions(-) create mode 100644 app/models/forms/grad_scholarship.rb create mode 100644 app/views/contribute/deposit_view/_grad_scholarship.html.erb create mode 100644 spec/features/contribute/general_grad_scholarship_contribute_spec.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a569761..1a2092ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/app/lib/tufts/contribute_collections.rb b/app/lib/tufts/contribute_collections.rb index bf73f1c3..37f44bce 100644 --- a/app/lib/tufts/contribute_collections.rb +++ b/app/lib/tufts/contribute_collections.rb @@ -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", diff --git a/app/models/forms/grad_scholarship.rb b/app/models/forms/grad_scholarship.rb new file mode 100644 index 00000000..2ad194b1 --- /dev/null +++ b/app/models/forms/grad_scholarship.rb @@ -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 diff --git a/app/views/contribute/deposit_view/_grad_scholarship.html.erb b/app/views/contribute/deposit_view/_grad_scholarship.html.erb new file mode 100644 index 00000000..6260b03a --- /dev/null +++ b/app/views/contribute/deposit_view/_grad_scholarship.html.erb @@ -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' %> + + +<%= 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' %> diff --git a/config/deposit_type_seed.csv b/config/deposit_type_seed.csv index 66112b93..c9a41504 100644 --- a/config/deposit_type_seed.csv +++ b/config/deposit_type_seed.csv @@ -1,8 +1,7 @@ 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 Tufts Non-Exclusive Deposit License." 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 Tufts Non-Exclusive Deposit License." -GIS Expo Student Winners,gis_poster,Tufts Non-Exclusive Deposit License v1.0,"I understand and acknowledge that this submission is governed by the Tufts Non-Exclusive Deposit License. -" +GIS Expo Student Winners,gis_poster,Tufts Non-Exclusive Deposit License v1.0,"I understand and acknowledge that this submission is governed by the Tufts Non-Exclusive Deposit License." General Undergraduate Scholarship,generic_tisch_deposit,Tufts Non-Exclusive Deposit License v1.0,"I understand and acknowledge that this submission is governed by the Tufts Non-Exclusive Deposit License." 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 Tufts Non-Exclusive Deposit License." 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 Tufts Non-Exclusive Deposit License." @@ -10,3 +9,4 @@ PHPD Field Experience/Capstone,public_health,Tufts Non-Exclusive Deposit License 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 Tufts Non-Exclusive Deposit License." Undergraduate Honors Thesis,honors_thesis,Tufts Non-Exclusive Deposit License v1.0,"I understand and acknowledge that this submission is governed by the Tufts Non-Exclusive Deposit License." Undergraduate Summer Scholars,undergrad_summer_scholar, Tufts Non-Exclusive Deposit License v1.0,"I understand and acknowledge that this submission is governed by the Tufts Non-Exclusive Deposit License." +General Graduate Scholarship,grad_scholarship,Tufts Non-Exclusive Deposit License v1.0,"I understand and acknowledge that this submission is governed by the Tufts Non-Exclusive Deposit License." diff --git a/spec/features/contribute/general_grad_scholarship_contribute_spec.rb b/spec/features/contribute/general_grad_scholarship_contribute_spec.rb new file mode 100644 index 00000000..d9c98129 --- /dev/null +++ b/spec/features/contribute/general_grad_scholarship_contribute_spec.rb @@ -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 diff --git a/spec/features/contribute/graduate_school_arts_spec.rb b/spec/features/contribute/graduate_school_arts_spec.rb index 290e647d..c659318c 100644 --- a/spec/features/contribute/graduate_school_arts_spec.rb +++ b/spec/features/contribute/graduate_school_arts_spec.rb @@ -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 diff --git a/spec/features/contribute/phpd_capstone_spec.rb b/spec/features/contribute/phpd_capstone_spec.rb index 6033fe5a..ac91b4de 100644 --- a/spec/features/contribute/phpd_capstone_spec.rb +++ b/spec/features/contribute/phpd_capstone_spec.rb @@ -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 diff --git a/spec/features/contribute/tish_library_reward_spec.rb b/spec/features/contribute/tish_library_reward_spec.rb index dd9ba14e..1c7af113 100644 --- a/spec/features/contribute/tish_library_reward_spec.rb +++ b/spec/features/contribute/tish_library_reward_spec.rb @@ -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 diff --git a/spec/features/contribute/undergrad_honors_thesis_spec.rb b/spec/features/contribute/undergrad_honors_thesis_spec.rb index c7eb1fb9..257eba35 100644 --- a/spec/features/contribute/undergrad_honors_thesis_spec.rb +++ b/spec/features/contribute/undergrad_honors_thesis_spec.rb @@ -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 diff --git a/spec/features/contribute/undergrad_summer_scholars_spec.rb b/spec/features/contribute/undergrad_summer_scholars_spec.rb index ec76f4a4..b6556394 100644 --- a/spec/features/contribute/undergrad_summer_scholars_spec.rb +++ b/spec/features/contribute/undergrad_summer_scholars_spec.rb @@ -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