Skip to content

Commit

Permalink
HYC-1351 Switch CC licenses from 3.0 to 4.0 (#1071)
Browse files Browse the repository at this point in the history
* updating license definitions

* added filter to hide archived licenses from non-admin users to cdrservice

* sight change to license definitions

* adding 4.0 licenses to existing tests, including CC BY 4.0 in dataset license options

* tests added for non admins

* updating archive to archived

* changing ordering

* rubocop updates

* refactoring tests

* rubocop changes

* changing https to http in license definitions

* modifying expected values in tests

* switching https to http in license definition test fixture
  • Loading branch information
davidcam-src authored Jan 17, 2024
1 parent c2e10f8 commit d386e82
Show file tree
Hide file tree
Showing 16 changed files with 186 additions and 97 deletions.
14 changes: 6 additions & 8 deletions app/services/cdr_license_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ module CdrLicenseService
mattr_accessor :authority
self.authority = Qa::Authorities::Local.subauthority_for('licenses')

def self.select(work_type)
license_type = if work_type.match?('data_sets')
'all'
else
''
end

authority.all.reject { |item| item['active'] == license_type }.map do |element|
def self.select(work_type, admin_check)
is_data_set = work_type.match?('data_sets')
filtered_elements = authority.all
.reject { |item| is_data_set && item['active'] != 'data' } # hide non-data licenses from data sets
.reject { |item| !admin_check && item['archived'] } # hide archived licenses from non-admins
filtered_elements.map do |element|
[element[:label], element[:id]]
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/views/records/edit_fields/_license.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<%# [hyc-override] Overriding partial in hyrax gem in order to make license single-valued and add custom service %>
<% if params[:action] == 'edit' %>
<%= f.input :license, as: :select,
collection: CdrLicenseService.select(params[:controller]),
collection: CdrLicenseService.select(params[:controller],current_user&.admin?),
include_blank: true,
item_helper: CdrLicenseService.method(:include_current_value),
input_html: { class: 'form-control' } %>
<% else %>
<%= f.input :license, as: :select,
collection: CdrLicenseService.select(params[:controller]),
collection: CdrLicenseService.select(params[:controller], current_user&.admin?),
include_blank: true,
item_helper: CdrLicenseService.method(:include_current_value),
selected: CdrLicenseService.default_license(params[:controller]),
Expand Down
60 changes: 42 additions & 18 deletions config/authorities/licenses.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,61 @@
terms:
- id: http://creativecommons.org/licenses/by/3.0/us/
term: Attribution 3.0 United States
active: data
- id: http://creativecommons.org/licenses/by/4.0/
term: Attribution 4.0 International
active: data
archived: false
- id: http://creativecommons.org/licenses/by-nc/4.0/
term: Attribution-NonCommercial 4.0 International
active: all
- id: http://creativecommons.org/licenses/by-sa/3.0/us/
term: Attribution-ShareAlike 3.0 United States
archived: false
- id: http://creativecommons.org/licenses/by-nc-nd/4.0/
term: Attribution-NonCommercial-NoDerivs 4.0 International
active: all
- id: http://creativecommons.org/licenses/by-nc/3.0/us/
term: Attribution-NonCommercial 3.0 United States
archived: false
- id: http://creativecommons.org/licenses/by-nc-sa/4.0/
term: Attribution-NonCommercial-ShareAlike 4.0 International
active: all
- id: http://creativecommons.org/licenses/by-nc/4.0/
term: Attribution-NonCommercial 4.0 International
archived: false
- id: http://creativecommons.org/licenses/by-nd/4.0/
term: Attribution-NoDerivs 4.0 International
active: all
- id: http://creativecommons.org/licenses/by-nd/3.0/us/
term: Attribution-NoDerivs 3.0 United States
archived: false
- id: http://creativecommons.org/licenses/by-sa/4.0/
term: Attribution-ShareAlike 4.0 International
active: all
archived: false
- id: http://creativecommons.org/licenses/by/3.0/us/
term: Attribution 3.0 United States
active: data
archived: true
- id: http://creativecommons.org/licenses/by-nc/3.0/us/
term: Attribution-NonCommercial 3.0 United States
active: all
archived: true
- id: http://creativecommons.org/licenses/by-nc-nd/3.0/us/
term: Attribution-NonCommercial-NoDerivs 3.0 United States
active: all
- id: http://creativecommons.org/licenses/by-nc-nd/4.0/
term: Attribution-NonCommercial-NoDerivatives 4.0 International
active: all
archived: true
- id: http://creativecommons.org/licenses/by-nc-sa/3.0/us/
term: Attribution-NonCommercial-ShareAlike 3.0 United States
active: all
- id: http://creativecommons.org/publicdomain/mark/1.0/
term: Public Domain Mark 1.0
archived: true
- id: http://creativecommons.org/licenses/by-nd/3.0/us/
term: Attribution-NoDerivs 3.0 United States
active: all
archived: true
- id: http://creativecommons.org/licenses/by-sa/3.0/us/
term: Attribution-ShareAlike 3.0 United States
active: all
archived: true
- id: http://www.europeana.eu/portal/rights/rr-r.html
term: All rights reserved
active: all
archived: false
- id: http://creativecommons.org/publicdomain/zero/1.0/
term: CC0 1.0 Universal
active: data
- id: http://www.europeana.eu/portal/rights/rr-r.html
term: All rights reserved
archived: false
- id: http://creativecommons.org/publicdomain/mark/1.0/
term: Public Domain Mark 1.0
active: all
archived: false
6 changes: 3 additions & 3 deletions spec/features/create_article_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

# extra fields
fill_in 'Keyword', with: 'Test Default Keyword'
select 'Attribution 3.0 United States', from: 'article_license'
select 'Attribution 4.0 International', from: 'article_license'
select 'In Copyright', from: 'article_rights_statement'
fill_in 'Publisher', with: 'UNC Press'
fill_in 'Subject', with: 'test'
Expand Down Expand Up @@ -140,7 +140,7 @@
expect(page).to have_content 'Abstract some abstract'
expect(page).to have_content 'Alternate title my other title'
expect(page).to have_content 'Date of publication October 3, 2018'
expect(page).to have_content 'License Attribution 3.0 United States'
expect(page).to have_content 'License Attribution 4.0 International'
expect(page).to have_content 'Rights statement In Copyright'
expect(page).to have_content 'Publisher UNC Press'
expect(page).to have_content 'Subject test'
Expand All @@ -160,7 +160,7 @@
expect(page).to have_content 'Is the article or chapter peer-reviewed? Yes'
expect(page).to have_content 'Place of publication UNC'
expect(page).to_not have_content 'Language http://id.loc.gov/vocabulary/iso639-2/eng'
expect(page).to_not have_content 'License http://creativecommons.org/licenses/by/3.0/us/'
expect(page).to_not have_content 'License http://creativecommons.org/licenses/by/4.0/'
expect(page).to_not have_content 'Rights statement http://rightsstatements.org/vocab/InC/1.0/'

expect(page).to_not have_content 'In Administrative Set: article admin set'
Expand Down
6 changes: 3 additions & 3 deletions spec/features/create_artwork_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
# extra fields

fill_in 'Note', with: 'my note'
select 'Attribution 3.0 United States', from: 'artwork_license'
select 'Attribution 4.0 International', from: 'artwork_license'
select 'In Copyright', from: 'artwork_rights_statement'

expect(page).to have_selector('#artwork_license_label', visible: false)
Expand Down Expand Up @@ -110,12 +110,12 @@
expect(page).to have_content 'Other Affiliation: UNC'
expect(page).to have_content 'Abstract a description'
expect(page).to have_content 'Extent some extent'
expect(page).to have_content 'License Attribution 3.0 United States'
expect(page).to have_content 'License Attribution 4.0 International'
expect(page).to have_content 'Medium a medium'
expect(page).to have_content 'Note my note'
expect(page).to have_content 'Resource type Art'
expect(page).to have_content 'Rights statement In Copyright'
expect(page).to_not have_content 'License http://creativecommons.org/licenses/by/3.0/us/'
expect(page).to_not have_content 'License http://creativecommons.org/licenses/by/4.0/'
expect(page).to_not have_content 'Rights statement http://rightsstatements.org/vocab/InC/1.0/'

expect(page).to_not have_content 'In Administrative Set: artwork admin set'
Expand Down
6 changes: 3 additions & 3 deletions spec/features/create_data_set_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
find('#data_set_based_near_attributes_0_id', visible: false).set('http://sws.geonames.org/4460162/')
fill_in 'Keyword', with: 'Test Default Keyword'
fill_in 'Last modified date', with: '2018-10-03'
select 'Attribution 3.0 United States', from: 'data_set_license'
select 'Attribution 4.0 International', from: 'data_set_license'
fill_in 'Project Director', { with: 'project director', id: 'data_set_project_directors_attributes_0_name' }
fill_in 'ORCID', { with: 'project director orcid', id: 'data_set_project_directors_attributes_0_orcid' }
select 'Department of Biology', from: 'data_set_project_directors_attributes_0_affiliation'
Expand Down Expand Up @@ -139,7 +139,7 @@
expect(page).to have_content 'Abstract some abstract'
expect(page).to have_content 'Date of publication October 3, 2018'
expect(page).to have_content 'Kind of data Text'
expect(page).to have_content 'License Attribution 3.0 United States'
expect(page).to have_content 'License Attribution 4.0 International'
expect(page).to have_content 'Language English'
expect(page).to have_content 'Related resource URL something.com'
expect(page).to have_content 'Resource type Dataset'
Expand All @@ -153,7 +153,7 @@
expect(page).to have_content 'Sponsor a sponsor'
expect(page).to have_content 'Subject test'
expect(page).to_not have_content 'Language http://id.loc.gov/vocabulary/iso639-2/eng'
expect(page).to_not have_content 'License http://creativecommons.org/licenses/by/3.0/us/'
expect(page).to_not have_content 'License http://creativecommons.org/licenses/by/4.0/'

expect(page).to_not have_content 'In Administrative Set: data set admin set'
expect(page).to_not have_content 'Type http://purl.org/dc/dcmitype/Dataset'
Expand Down
6 changes: 3 additions & 3 deletions spec/features/create_honors_thesis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
# extra fields
find('#honors_thesis_based_near_attributes_0_id', visible: false).set('http://sws.geonames.org/4460162/')
fill_in 'Keyword', with: 'Test Default Keyword'
select 'Attribution 3.0 United States', from: 'honors_thesis_license'
select 'Attribution 4.0 International', from: 'honors_thesis_license'
fill_in 'Note', with: 'a note'
select 'Honors Thesis', from: 'honors_thesis_resource_type'
fill_in 'Related resource URL', with: 'something.com'
Expand Down Expand Up @@ -135,14 +135,14 @@
expect(page).to have_content 'Graduation year 2018'
expect(page).to have_content 'Keyword Test Default Keyword'
expect(page).to have_content 'Language English'
expect(page).to have_content 'License Attribution 3.0 United States'
expect(page).to have_content 'License Attribution 4.0 International'
expect(page).to have_content 'Note a note'
expect(page).to have_content 'Resource type Honors Thesis'
expect(page).to have_content 'Related resource URL something.com'
expect(page).to have_content 'Rights statement In Copyright'
expect(page).to have_content 'Subject test'
expect(page).to_not have_content 'Language http://id.loc.gov/vocabulary/iso639-2/eng'
expect(page).to_not have_content 'License http://creativecommons.org/licenses/by/3.0/us/'
expect(page).to_not have_content 'License http://creativecommons.org/licenses/by/4.0/'
expect(page).to_not have_content 'Rights statement http://rightsstatements.org/vocab/InC/1.0/'

expect(page).to_not have_content 'In Administrative Set: honors thesis admin set'
Expand Down
6 changes: 3 additions & 3 deletions spec/features/create_journal_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
select 'Preprint', from: 'Version'
fill_in 'Related resource URL', with: 'a url'
fill_in 'Keyword', with: 'Test Default Keyword'
select 'Attribution 3.0 United States', from: 'journal_license'
select 'Attribution 4.0 International', from: 'journal_license'
fill_in 'Note', with: 'a note'
fill_in 'Place of publication', with: 'UNC'
select 'Journal', from: 'journal_resource_type'
Expand Down Expand Up @@ -131,7 +131,7 @@
expect(page).to have_content 'Related resource URL a url'
expect(page).to have_content 'Keyword Test Default Keyword'
expect(page).to have_content 'Language English'
expect(page).to have_content 'License Attribution 3.0 United States'
expect(page).to have_content 'License Attribution 4.0 International'
expect(page).to have_content 'Note a note'
expect(page).to have_content 'Place of publication UNC'
expect(page).to have_content 'Publisher UNC Press'
Expand All @@ -140,7 +140,7 @@
expect(page).to have_content 'Series series1'
expect(page).to have_content 'Subject test'
expect(page).to_not have_content 'Language http://id.loc.gov/vocabulary/iso639-2/eng'
expect(page).to_not have_content 'License http://creativecommons.org/licenses/by/3.0/us/'
expect(page).to_not have_content 'License http://creativecommons.org/licenses/by/4.0/'
expect(page).to_not have_content 'Rights statement http://rightsstatements.org/vocab/InC/1.0/'

expect(page).to_not have_content 'In Administrative Set: journal admin set'
Expand Down
6 changes: 3 additions & 3 deletions spec/features/create_masters_paper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
select 'Clinical Nutrition', from: 'Academic Concentration'
find('#masters_paper_based_near_attributes_0_id', visible: false).set('http://sws.geonames.org/4460162/')
fill_in 'Keyword', with: 'Test Default Keyword'
select 'Attribution 3.0 United States', from: 'masters_paper_license'
select 'Attribution 4.0 International', from: 'masters_paper_license'
fill_in 'Note', with: 'a note'
fill_in 'Reviewer', { with: 'reviewer', id: 'masters_paper_reviewers_attributes_0_name' }
fill_in 'ORCID', { with: 'reviewer orcid', id: 'masters_paper_reviewers_attributes_0_orcid' }
Expand Down Expand Up @@ -166,14 +166,14 @@
expect(page).to have_content 'Graduation year 2018'
expect(page).to have_content 'Keyword Test Default Keyword'
expect(page).to have_content 'Language English'
expect(page).to have_content 'License Attribution 3.0 United States'
expect(page).to have_content 'License Attribution 4.0 International'
expect(page).to have_content 'Note a note'
expect(page).to have_content 'Resource type Masters Paper'
expect(page).to have_content 'Reviewer reviewer ORCID: reviewer orcid'
expect(page).to have_content 'Rights statement In Copyright'
expect(page).to have_content 'Subject test'
expect(page).to_not have_content 'Language http://id.loc.gov/vocabulary/iso639-2/eng'
expect(page).to_not have_content 'License http://creativecommons.org/licenses/by/3.0/us/'
expect(page).to_not have_content 'License http://creativecommons.org/licenses/by/4.0/'
expect(page).to_not have_content 'Rights statement http://rightsstatements.org/vocab/InC/1.0/'

expect(page).to_not have_content 'In Administrative Set: dept admin set'
Expand Down
6 changes: 3 additions & 3 deletions spec/features/create_multimed_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
fill_in 'Extent', with: 'some extent'
find('#multimed_based_near_attributes_0_id', visible: false).set('http://sws.geonames.org/4460162/')
fill_in 'Keyword', with: 'Test Default Keyword'
select 'Attribution 3.0 United States', from: 'multimed_license'
select 'Attribution 4.0 International', from: 'multimed_license'
fill_in 'Note', with: 'a note'
select 'In Copyright', from: 'multimed_rights_statement'
fill_in 'Subject', with: 'test'
Expand Down Expand Up @@ -122,13 +122,13 @@
expect(page).to have_content 'Location Chapel Hill, North Carolina, United States'
expect(page).to have_content 'Keyword Test Default Keyword'
expect(page).to have_content 'Language English'
expect(page).to have_content 'License Attribution 3.0 United States'
expect(page).to have_content 'License Attribution 4.0 International'
expect(page).to have_content 'Note a note'
expect(page).to have_content 'Resource type Video'
expect(page).to have_content 'Rights statement In Copyright'
expect(page).to have_content 'Subject test'
expect(page).to_not have_content 'Language http://id.loc.gov/vocabulary/iso639-2/eng'
expect(page).to_not have_content 'License http://creativecommons.org/licenses/by/3.0/us/'
expect(page).to_not have_content 'License http://creativecommons.org/licenses/by/4.0/'
expect(page).to_not have_content 'Rights statement http://rightsstatements.org/vocab/InC/1.0/'
expect(page).to_not have_content 'In Administrative Set: multimed admin set'
expect(page).to_not have_content 'Type http://purl.org/dc/dcmitype/InteractiveResource'
Expand Down
6 changes: 3 additions & 3 deletions spec/features/create_scholarly_work_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
fill_in 'Conference name', with: 'a conference'
find('#scholarly_work_based_near_attributes_0_id', visible: false).set('http://sws.geonames.org/4460162/')
fill_in 'Keyword', with: 'Test Default Keyword'
select 'Attribution 3.0 United States', from: 'scholarly_work_license'
select 'Attribution 4.0 International', from: 'scholarly_work_license'
select 'Other', from: 'scholarly_work_resource_type'
select 'In Copyright', from: 'scholarly_work_rights_statement'
fill_in 'Subject', with: 'test'
Expand Down Expand Up @@ -129,12 +129,12 @@
expect(page).to have_content 'Location Chapel Hill, North Carolina, United States'
expect(page).to have_content 'Keyword Test Default Keyword'
expect(page).to have_content 'Language English'
expect(page).to have_content 'License Attribution 3.0 United States'
expect(page).to have_content 'License Attribution 4.0 International'
expect(page).to have_content 'Resource type Other'
expect(page).to have_content 'Rights statement In Copyright'
expect(page).to have_content 'Subject test'
expect(page).to_not have_content 'Language http://id.loc.gov/vocabulary/iso639-2/eng'
expect(page).to_not have_content 'License http://creativecommons.org/licenses/by/3.0/us/'
expect(page).to_not have_content 'License http://creativecommons.org/licenses/by/4.0/'
expect(page).to_not have_content 'Rights statement http://rightsstatements.org/vocab/InC/1.0/'

expect(page).to_not have_content 'In Administrative Set: scholarly work admin set'
Expand Down
2 changes: 1 addition & 1 deletion spec/features/edit_sage_ingested_works_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
keywords = keyword_fields.map(&:value)
expect(keyword_fields.count).to eq 8
expect(keywords).to include('Propionibacterium acnes')
expect(page).to have_select('License', with_selected: 'Attribution-NonCommercial-NoDerivatives 4.0 International')
expect(page).to have_select('License', with_selected: 'Attribution-NonCommercial-NoDerivs 4.0 International')
expect(page).to have_field('Page end', with: '20')
expect(page).to have_field('Page start', with: '13')
end
Expand Down
Loading

0 comments on commit d386e82

Please sign in to comment.