From 87d3266d74ebfebbbb7a706b32d42381a5546e90 Mon Sep 17 00:00:00 2001 From: Rob Kaufman Date: Tue, 21 Aug 2018 21:55:19 -0700 Subject: [PATCH 1/2] update to hyrax 2.2 --- Gemfile | 2 +- Gemfile.lock | 29 ++++++++++++----------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Gemfile b/Gemfile index cc3dfa4a3..7d0470df7 100644 --- a/Gemfile +++ b/Gemfile @@ -77,7 +77,7 @@ end gem 'blacklight', '~> 6.7' -gem 'hyrax', '2.1.0' +gem 'hyrax', '2.2.0' gem 'rsolr', '~> 2.0' gem 'devise' diff --git a/Gemfile.lock b/Gemfile.lock index 50b1762d4..e96004d1e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -54,7 +54,7 @@ GEM activemodel (= 5.1.6) activesupport (= 5.1.6) arel (~> 8.0) - activerecord-import (0.24.0) + activerecord-import (0.25.0) activerecord (>= 3.2) activesupport (5.1.6) concurrent-ruby (~> 1.0, >= 1.0.2) @@ -107,7 +107,7 @@ GEM blacklight (~> 6.0) cancancan (~> 1.8) deprecation (~> 1.0) - blacklight-gallery (0.10.0) + blacklight-gallery (0.11.0) blacklight (~> 6.3) bootstrap-sass (~> 3.0) openseadragon (>= 0.2.0) @@ -213,7 +213,7 @@ GEM dry-container (~> 0.2, >= 0.2.6) dry-core (~> 0.2) dry-equalizer (~> 0.2) - dry-struct (0.5.0) + dry-struct (0.5.1) dry-core (~> 0.4, >= 0.4.3) dry-equalizer (~> 0.2) dry-types (~> 0.13) @@ -266,7 +266,7 @@ GEM railties (>= 3.2, < 6.0) globalid (0.4.1) activesupport (>= 4.2.0) - google-api-client (0.23.0) + google-api-client (0.23.4) addressable (~> 2.5, >= 2.5.1) googleauth (>= 0.5, < 0.7.0) httpclient (>= 2.8.1, < 3.0) @@ -277,13 +277,12 @@ GEM google-api-client (>= 0.11.0, < 1.0.0) googleauth (>= 0.5.0, < 1.0.0) nokogiri (>= 1.5.3, < 2.0.0) - googleauth (0.6.2) + googleauth (0.6.5) faraday (~> 0.12) jwt (>= 1.4, < 3.0) - logging (~> 2.0) memoist (~> 0.12) multi_json (~> 1.11) - os (~> 0.9) + os (>= 0.9, < 2.0) signet (~> 0.7) haml (5.0.4) temple (>= 0.8.0) @@ -342,14 +341,14 @@ GEM hydra-file_characterization (~> 0.3, >= 0.3.3) hydra-pcdm (>= 0.9) om (~> 3.1) - hyrax (2.1.0) + hyrax (2.2.0) active-fedora (~> 11.5, >= 11.5.2) almond-rails (~> 0.1) awesome_nested_set (~> 3.1) blacklight (~> 6.14) blacklight-gallery (~> 0.7) breadcrumbs_on_rails (~> 3.0) - browse-everything (>= 0.10.5) + browse-everything (< 0.16) carrierwave (~> 1.0) clipboard-rails (~> 1.5) dry-equalizer (~> 0.2) @@ -501,10 +500,6 @@ GEM rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) ruby_dep (~> 1.2) - little-plugger (1.1.4) - logging (2.2.2) - little-plugger (~> 1.1) - multi_json (~> 1.10) lograge (0.5.1) actionpack (>= 4, < 5.2) activesupport (>= 4, < 5.2) @@ -564,7 +559,7 @@ GEM openseadragon (0.5.0) rails (> 3.2.0) orm_adapter (0.5.0) - os (0.9.6) + os (1.0.0) parallel (1.12.1) parser (2.4.0.2) ast (~> 2.3) @@ -793,7 +788,7 @@ GEM connection_pool (~> 2.2, >= 2.2.0) rack-protection (>= 1.5.0) redis (~> 3.3, >= 3.3.3) - signet (0.8.1) + signet (0.9.0) addressable (~> 2.3) faraday (~> 0.9) jwt (>= 1.5, < 3.0) @@ -862,7 +857,7 @@ GEM thread_safe (0.3.6) tilt (2.0.8) tins (1.14.0) - tinymce-rails (4.7.13) + tinymce-rails (4.8.2) railties (>= 3.1.1) turbolinks (5.0.1) turbolinks-source (~> 5) @@ -923,7 +918,7 @@ DEPENDENCIES fcrepo_wrapper (~> 0.4) flipflop (~> 2.3) honeybadger (~> 3.0) - hyrax (= 2.1.0) + hyrax (= 2.2.0) i18n-debug i18n-tasks iiif_manifest (~> 0.3.0) From 6579a09a6946fa08a48fd7bda80dc8ea3a8b0cb9 Mon Sep 17 00:00:00 2001 From: cldambrosio Date: Thu, 4 Oct 2018 10:09:17 +0100 Subject: [PATCH 2/2] Creative Commons License in main fields when adding a new work (#1525) * add 'license' to primary_terms * Test --- app/forms/hyrax/form_terms.rb | 11 +++++++++++ app/forms/hyrax/generic_work_form.rb | 1 + app/forms/hyrax/image_form.rb | 1 + lib/importer/factory/object_factory.rb | 6 +++++- spec/forms/hyrax/generic_work_form_spec.rb | 2 ++ spec/forms/hyrax/image_form_spec.rb | 2 ++ spec/forms/hyrax/shared_examples_spec.rb | 0 spec/support/shared_examples_spec.rb | 7 +++++++ 8 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 app/forms/hyrax/form_terms.rb create mode 100644 spec/forms/hyrax/shared_examples_spec.rb create mode 100644 spec/support/shared_examples_spec.rb diff --git a/app/forms/hyrax/form_terms.rb b/app/forms/hyrax/form_terms.rb new file mode 100644 index 000000000..3f9f8ef23 --- /dev/null +++ b/app/forms/hyrax/form_terms.rb @@ -0,0 +1,11 @@ +module Hyrax + module FormTerms + include Hyrax::Forms + # overrides Hyrax::Forms::WorkForm + # to display 'license' in the 'base-terms' div on the user dashboard "Add New Work" description + # by getting iterated over in hyrax/app/views/hyrax/base/_form_metadata.html.erb + def primary_terms + super + [:license] + end + end +end diff --git a/app/forms/hyrax/generic_work_form.rb b/app/forms/hyrax/generic_work_form.rb index 543604ad1..8eae3dc3d 100644 --- a/app/forms/hyrax/generic_work_form.rb +++ b/app/forms/hyrax/generic_work_form.rb @@ -2,6 +2,7 @@ # `rails generate curation_concerns:work GenericWork` module Hyrax class GenericWorkForm < Hyrax::Forms::WorkForm + include Hyrax::FormTerms self.model_class = ::GenericWork include HydraEditor::Form::Permissions self.terms += %i[resource_type rendering_ids] diff --git a/app/forms/hyrax/image_form.rb b/app/forms/hyrax/image_form.rb index 5dbbee466..0ae85cad1 100644 --- a/app/forms/hyrax/image_form.rb +++ b/app/forms/hyrax/image_form.rb @@ -2,6 +2,7 @@ # `rails generate hyrax:work Image` module Hyrax class ImageForm < Hyrax::Forms::WorkForm + include Hyrax::FormTerms self.model_class = ::Image self.terms += %i[resource_type extent rendering_ids] diff --git a/lib/importer/factory/object_factory.rb b/lib/importer/factory/object_factory.rb index 451fc04dd..ff59001b7 100644 --- a/lib/importer/factory/object_factory.rb +++ b/lib/importer/factory/object_factory.rb @@ -34,7 +34,11 @@ def update end def create_attributes - { collection_type: collection_type }.merge(transform_attributes) + if klass == Collection + { collection_type: collection_type }.merge(transform_attributes) + else + transform_attributes + end end def update_attributes diff --git a/spec/forms/hyrax/generic_work_form_spec.rb b/spec/forms/hyrax/generic_work_form_spec.rb index db700f3e7..949a9be74 100644 --- a/spec/forms/hyrax/generic_work_form_spec.rb +++ b/spec/forms/hyrax/generic_work_form_spec.rb @@ -20,4 +20,6 @@ expect(subject['rendering_ids']).to eq [file_set.id] end end + + include_examples("work_form") end diff --git a/spec/forms/hyrax/image_form_spec.rb b/spec/forms/hyrax/image_form_spec.rb index 819df32f9..700bbcca6 100644 --- a/spec/forms/hyrax/image_form_spec.rb +++ b/spec/forms/hyrax/image_form_spec.rb @@ -23,4 +23,6 @@ expect(subject['extent']).to eq ['extent'] end end + + include_examples("work_form") end diff --git a/spec/forms/hyrax/shared_examples_spec.rb b/spec/forms/hyrax/shared_examples_spec.rb new file mode 100644 index 000000000..e69de29bb diff --git a/spec/support/shared_examples_spec.rb b/spec/support/shared_examples_spec.rb new file mode 100644 index 000000000..3c2790984 --- /dev/null +++ b/spec/support/shared_examples_spec.rb @@ -0,0 +1,7 @@ +RSpec.shared_examples "work_form" do + describe ".primary_terms" do + it 'includes the license field' do + expect(form.primary_terms).to include(:license) + end + end +end