Skip to content

Commit

Permalink
Post upgrade minor fixes (#271)
Browse files Browse the repository at this point in the history
* update config template values; rename solr core

* use videojs for streaming media

* enable fluid mode for videojs

* center the play button for videos

* fix layout issue with embed popup header

* modify videojs settings to fix issue with videos autoplaying in safari

* add videoReady function for videojs

* fix ACHYDRA-905 /api/v1/search endpoint searching not working

* add styling for video player branding element

* add link to logo

* add pointer cursor to AC branding link

* ACHYDRA-908 require current student radio button selection

* ACHYDRA-909 remove unnecessary int to date conversion

* ACHYDRA-908 change academic advisor to thesis advisor

* revert field name

* make modal code use title variable

* fix ACHYDRA-905 /api/v1/search endpoint searching not working

* ACHYDRA-908 require current student radio button selection

* ACHYDRA-909 remove unnecessary int to date conversion

* ACHYDRA-908 change academic advisor to thesis advisor

* revert field name

* rebases onto ACHYDRA-907; removes mediaelement.js

---------

Co-authored-by: Ed Madrid <edmadrid@gmail.com>
  • Loading branch information
JackBlackLight and edmadrid authored May 25, 2023
1 parent 76adfea commit e03acc5
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 66 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ gem 'fancybox2-rails' # Used in helper classes. TODO: Confirm that this is neede
gem 'gaffe'
gem 'grape'
gem 'grape-entity'
gem 'grape-swagger', '0.31.0'
# pinning swagger to commit that supports braces in array params; functionality is broken in next version - 0.31.0
gem 'grape-swagger', git: 'https://github.com/ruby-grape/grape-swagger', ref: 'da351d0f99228f31329210d21b975a64500e73ab'
gem 'http'
gem 'jbuilder'
gem 'jquery-rails'
Expand Down
12 changes: 9 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ GIT
blacklight_range_limit (8.2.4)
blacklight (>= 7.25.2, < 9)

GIT
remote: https://github.com/ruby-grape/grape-swagger
revision: da351d0f99228f31329210d21b975a64500e73ab
ref: da351d0f99228f31329210d21b975a64500e73ab
specs:
grape-swagger (0.30.1)
grape (>= 0.16.2)

GIT
remote: https://github.com/samvera-deprecated/jettywrapper.git
revision: 6b03c21726a83dcecf09d9b20683bfcd63f106d1
Expand Down Expand Up @@ -247,8 +255,6 @@ GEM
grape-entity (0.10.1)
activesupport (>= 3.0.0)
multi_json (>= 1.3.2)
grape-swagger (0.31.0)
grape (>= 0.16.2)
haml (5.2.2)
temple (>= 0.8.0)
tilt
Expand Down Expand Up @@ -651,7 +657,7 @@ DEPENDENCIES
gaffe
grape
grape-entity
grape-swagger (= 0.31.0)
grape-swagger!
http
jbuilder
jettywrapper (>= 1.4.0)!
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/uploads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def create

def upload_params
params.require(:deposit)
.permit(:title, :abstract, :year, :doi, :license, :rights, :notes, :degree_program, :academic_advisor,
.permit(:title, :abstract, :year, :doi, :license, :rights, :notes, :degree_program, :academic_advisor, :current_student,
:thesis_or_dissertation, :degree_earned, :embargo_date, :previously_published, :article_version, :keywords,
:current_student, files: [], creators: %i[first_name last_name uni])
end
Expand Down
27 changes: 0 additions & 27 deletions app/javascript/src/mediaelement.js

This file was deleted.

24 changes: 18 additions & 6 deletions app/javascript/src/upload/current-student.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
$(document).ready(function () {
// onChange only fires when radio button is selected
$("form#upload input#deposit_current_student_true")
.change(function () {
document.getElementsByClassName("student-section")[0].style.display =
"block";
})
.change();

$('form#upload input#deposit_current_student').change(function () {
document.getElementsByClassName('student-section')[0].style.display = "none";
if (document.getElementById('deposit_current_student').checked == true) {
document.getElementsByClassName('student-section')[0].style.display = "block";
}
}).change();
$("form#upload input#deposit_current_student_false")
.change(function () {
document.getElementsByClassName("student-section")[0].style.display =
"none";
})
.change();

//check if button is already selected on page render, ie after validation failure
if ($("form#upload input#deposit_current_student_true").is(":checked")) {
document.getElementsByClassName("student-section")[0].style.display =
"block";
}
});
17 changes: 4 additions & 13 deletions app/models/deposit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Deposit < ApplicationRecord
}.freeze

before_validation :clean_up_creators
before_save :convert_embargo_value_to_date_string, :finalize_notes_contents
before_save :finalize_notes_contents

# validates_presence_of :agreement_version
# validates_presence_of :name
Expand All @@ -41,7 +41,7 @@ class Deposit < ApplicationRecord
validate :one_creator_must_be_present, on: :create
validate :cco_must_be_selected, if: proc { |a| a.rights == RIGHTS_OPTIONS['No Copyright'] }
validates :title, :abstract, :year, :rights, :files, presence: true, on: :create
validates :previously_published, inclusion: { in: [true, false] }, on: :create
validates :previously_published, :current_student, inclusion: { in: [true, false] }, on: :create
validates :rights, inclusion: { in: RIGHTS_OPTIONS.values }, on: :create
validates :license, inclusion: { in: LICENSE_OPTIONS }, on: :create, if: proc { |a| a.license.present? }
validates :degree_program, :academic_advisor, :thesis_or_dissertation,
Expand Down Expand Up @@ -180,21 +180,12 @@ def finalize_notes_contents
#{self.notes}
Degree Program: #{self.degree_program}
Advisor Name: #{self.academic_advisor}
Academic Advisor: #{self.academic_advisor}
Thesis or Dissertation: #{self.thesis_or_dissertation}
Degree Earned: #{self.degree_earned}
Embargo Date: #{self.embargo_date}
Embargo Year(s): #{self.embargo_date}
Previously Published: #{self.previously_published}
Article Version: #{self.article_version}
Keywords: #{self.keywords}
TEXT
end

def convert_embargo_value_to_date_string
return self.embargo_date = '' unless embargo_date&.present?

embargo_date_int = Integer(self.embargo_date)
return self.embargo_date = '' unless embargo_date_int.positive?

self.embargo_date = embargo_date_int.year.from_now.strftime('%-Y-%-m-%-y')
end
14 changes: 9 additions & 5 deletions app/views/uploads/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,13 @@
</div>


<div class="form-group checkbox">
<h3>Current student?</h3>
<%= form.check_box :current_student %>
<%= form.label :current_student, 'Check here if you are a current student at Columbia or one of its affiliate institutions.' %>
<div class="form-group">
<h3>Current student*</h3>
<p>Are you a current student at Columbia or one of its affiliate institutions?</p>
<%= form.radio_button(:current_student, true) %>
<%= form.label(:current_student, 'Yes') %></br>
<%= form.radio_button(:current_student, false) %>
<%= form.label(:current_student, 'No') %></br>
</div>

<div class="student-section" >
Expand All @@ -86,7 +89,8 @@


<div class="form-group">
<%= form.label(:academic_advisor, 'Academic Advisor*', class: 'control-label') %>
<h3>Academic Advisor*</h3>
<p>(If you are uploading a thesis, please give us the name of your thesis advisor.)</p>
<%= form.text_field(:academic_advisor) %>
</div>

Expand Down
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2022_12_08_202313) do
ActiveRecord::Schema.define(version: 2023_05_18_134528) do

create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
Expand Down
3 changes: 2 additions & 1 deletion spec/controllers/uploads_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
rights: 'http://rightsstatements.org/vocab/InC/1.0/',
previously_published: true,
creators: [{ first_name: 'Jane', last_name: 'Doe', uni: 'abc123' }],
files: [file]
files: [file],
current_student: false
}
}
end
Expand Down
1 change: 1 addition & 0 deletions spec/factories/deposit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
rights { 'http://rightsstatements.org/vocab/InC/1.0/' }
license { 'https://creativecommons.org/licenses/by/4.0/' }
previously_published { true }
current_student { false }

after(:build) do |deposit|
deposit.files.attach(
Expand Down
20 changes: 12 additions & 8 deletions spec/features/upload_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
expect(page).to have_field 'Notes'
end

it 'renders student checkbox' do
expect(page).to have_unchecked_field('Check here if you are a current student at Columbia or one of its affiliate institutions.')
it 'renders student radio buttons' do
expect(page).to have_unchecked_field 'deposit[current_student]'
end

it 'contains creator field with user\'s information' do
Expand All @@ -89,29 +89,33 @@
expect(page).to have_css 'input[type="file"]', visible: false
end

context 'when user selects current student' do
context 'when user is a current student' do
before do
check 'Check here if you are a current student at Columbia or one of its affiliate institutions.'
choose('deposit[current_student]', option: true)
end

it 'contains degree program input' do
expect(page).to have_css 'input[name="deposit[degree_program]"]'
end
end

context 'when user does not select current student' do
context 'when user is not a current student' do
before do
choose('deposit[current_student]', option: false)
end

it 'does not contain academic advisor input' do
expect(page).not_to have_css 'input[name="deposit[academic_advisor]"]', visible: true
end
end

context 'when student submits form with all required data' do
before do
check 'Check here if you are a current student at Columbia or one of its affiliate institutions.'
choose('deposit[current_student]', option: true)
fill_in 'Title*', with: 'Test Deposit'
fill_in 'Abstract*', with: 'Blah Blah Blah'
fill_in 'Year Created*', with: '2017'
fill_in 'Academic Advisor*', with: 'Advisor Name'
fill_in 'deposit[academic_advisor]', with: 'Advisor Name'
fill_in 'Degree Program*', with: 'Economics'
choose 'deposit[thesis_or_dissertation]', option: 'dissertation'
choose 'deposit[license]', option: 'https://creativecommons.org/publicdomain/zero/1.0/'
Expand Down Expand Up @@ -140,7 +144,7 @@

context 'when student submits form with missing required data' do
before do
check 'Check here if you are a current student at Columbia or one of its affiliate institutions.'
choose('deposit[current_student]', option: true)
fill_in 'Title*', with: 'Test Deposit'
fill_in 'Abstract*', with: 'Blah Blah Blah'
fill_in 'Year Created*', with: '2017'
Expand Down

0 comments on commit e03acc5

Please sign in to comment.