curation_concerns 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +9 -1
  3. data/Gemfile +1 -0
  4. data/VERSION +1 -1
  5. data/app/controllers/concerns/curation_concerns/application_controller_behavior.rb +9 -5
  6. data/app/controllers/concerns/curation_concerns/catalog_controller.rb +0 -20
  7. data/app/controllers/concerns/curation_concerns/collections_controller_behavior.rb +27 -5
  8. data/app/controllers/concerns/curation_concerns/curation_concern_controller.rb +7 -3
  9. data/app/controllers/concerns/curation_concerns/download_behavior.rb +5 -5
  10. data/app/controllers/concerns/curation_concerns/file_sets_controller_behavior.rb +17 -9
  11. data/app/controllers/concerns/curation_concerns/parent_container.rb +4 -9
  12. data/app/controllers/concerns/curation_concerns/single_use_links_viewer_controller_behavior.rb +6 -2
  13. data/app/helpers/curation_concerns/catalog_helper.rb +2 -4
  14. data/app/helpers/curation_concerns/collections_helper.rb +1 -1
  15. data/app/helpers/curation_concerns/permissions_helper.rb +4 -3
  16. data/app/helpers/curation_concerns/search_paths_helper.rb +2 -2
  17. data/app/inputs/multifile_input.rb +1 -1
  18. data/app/inputs/select_with_modal_help_input.rb +1 -1
  19. data/app/inputs/with_help_icon.rb +3 -3
  20. data/app/presenters/curation_concerns/presenter_factory.rb +2 -1
  21. data/app/presenters/curation_concerns/version_list_presenter.rb +3 -3
  22. data/app/presenters/curation_concerns/version_presenter.rb +1 -1
  23. data/app/presenters/curation_concerns/work_show_presenter.rb +1 -1
  24. data/app/renderers/curation_concerns/attribute_renderer.rb +10 -7
  25. data/app/search_builders/curation_concerns/collection_member_search_builder.rb +5 -0
  26. data/app/search_builders/curation_concerns/embargo_search_builder.rb +0 -3
  27. data/app/search_builders/curation_concerns/file_set_search_builder.rb +10 -0
  28. data/app/search_builders/curation_concerns/filter_by_type.rb +29 -0
  29. data/app/search_builders/curation_concerns/lease_search_builder.rb +0 -3
  30. data/app/search_builders/curation_concerns/search_builder.rb +1 -27
  31. data/app/search_builders/curation_concerns/single_result.rb +13 -0
  32. data/app/search_builders/curation_concerns/single_use_link_search_builder.rb +6 -0
  33. data/app/search_builders/curation_concerns/work_search_builder.rb +5 -0
  34. data/app/services/curation_concerns/parent_service.rb +1 -1
  35. data/app/views/catalog/index.json.jbuilder +9 -0
  36. data/app/views/collections/_form.html.erb +3 -3
  37. data/app/views/collections/_search_collection_dashboard_form.html.erb +1 -1
  38. data/app/views/collections/_search_form.html.erb +1 -1
  39. data/app/views/collections/_sort_and_per_page.html.erb +1 -1
  40. data/app/views/shared/_site_search.html.erb +2 -2
  41. data/curation_concerns.gemspec +3 -5
  42. data/lib/curation_concerns/rails/routes.rb +1 -1
  43. data/lib/curation_concerns/version.rb +1 -1
  44. data/lib/generators/curation_concerns/install_generator.rb +2 -3
  45. data/lib/generators/curation_concerns/templates/catalog_controller.rb +1 -1
  46. data/spec/actors/curation_concerns/work_actor_spec.rb +2 -1
  47. data/spec/controllers/catalog_controller_spec.rb +1 -0
  48. data/spec/controllers/curation_concerns/generic_works_controller_spec.rb +2 -3
  49. data/spec/controllers/downloads_controller_spec.rb +4 -4
  50. data/spec/features/catalog_search_spec.rb +1 -1
  51. data/spec/features/collection_spec.rb +17 -1
  52. data/spec/helpers/catalog_helper_spec.rb +10 -1
  53. data/spec/helpers/render_constraints_helper_spec.rb +1 -1
  54. data/spec/helpers/url_helper_spec.rb +1 -1
  55. data/spec/models/curation_concerns/collection_behavior_spec.rb +0 -42
  56. data/spec/models/curation_concerns/file_set/derivatives_spec.rb +14 -0
  57. data/spec/search_builders/curation_concerns/file_set_search_builder_spec.rb +29 -0
  58. data/spec/search_builders/curation_concerns/search_builder_spec.rb +0 -19
  59. data/spec/services/derivative_path_spec.rb +24 -0
  60. data/spec/spec_helper.rb +5 -5
  61. data/spec/test_app_templates/Gemfile.extra +1 -0
  62. data/spec/views/catalog/index.html.erb_spec.rb +9 -3
  63. data/spec/views/collections/_sort_and_per_page.html.erb_spec.rb +2 -0
  64. data/spec/views/curation_concerns/base/_attributes.html.erb_spec.rb +3 -3
  65. data/spec/views/curation_concerns/file_sets/_file_set.html.erb_spec.rb +4 -0
  66. data/tasks/release.rake +1 -1
  67. metadata +31 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a85c8841cf6394c4589e461e3b59671377f44678
4
- data.tar.gz: 575d68375d4f97744189ac4ab8183648b5483735
3
+ metadata.gz: 9e77165da47c309d90805ddb6981da218c262545
4
+ data.tar.gz: 5b4967ede0c3c0a0eafc7bb60d4db47950519044
5
5
  SHA512:
6
- metadata.gz: 0e737b868fcec75f9ed65e2c4361a786b28fdf4516062c04293c47b35c91f954797e5f68a3b0a2fa64ba1ecbf742f7987b3dd1dff3f6fc2e546fb53a4ed7740d
7
- data.tar.gz: 29ed236e0bebabe08927012b07c83b960b3522285571fd4e42b06d2151f8de98c3e3ada3e61b58a51b2256e7d36fdf4db19fb7075c3c1e6dc13a0075ac2d06b7
6
+ metadata.gz: 295594240997309f48717675eca0bd6e4104e2e13c468fb9f9cdb67496853a6b2380456281e913a453e0d341fa86407d4769eb6366462ee7795b52f7cbbef048
7
+ data.tar.gz: 0a874acf3320fca7cac2ebd597baa353ff0fbfdc5211b32afa24eab97662297713bad2ef749253426f959a16170865292c4b4e59f7fe04771388e99b93710fe2
data/.rubocop.yml CHANGED
@@ -1,7 +1,6 @@
1
1
  require: rubocop-rspec
2
2
 
3
3
  AllCops:
4
- RunRailsCops: true
5
4
  DisplayCopNames: true
6
5
  Include:
7
6
  - '**/Rakefile'
@@ -13,6 +12,15 @@ AllCops:
13
12
  - '.internal_test_app/**/*'
14
13
  - 'curation_concerns-models/app/models/concerns/curation_concerns/file_set/export.rb'
15
14
 
15
+ Rails:
16
+ Enabled: true
17
+
18
+ Performance/RedundantBlockCall:
19
+ # We can remove this exclusion when this commit is released:
20
+ # https://github.com/bbatsov/rubocop/commit/7df382531db4f66cd9872a4f478bd486d6ce6712
21
+ Exclude:
22
+ - 'curation_concerns-models/lib/curation_concerns/null_logger.rb'
23
+
16
24
  Lint/AssignmentInCondition:
17
25
  Exclude:
18
26
  - 'curation_concerns-models/app/services/curation_concerns/persist_derivatives.rb'
data/Gemfile CHANGED
@@ -31,6 +31,7 @@ if File.exists?(file)
31
31
  else
32
32
  Bundler.ui.warn "[EngineCart] Unable to find test application dependencies in #{file}, using placeholder dependencies"
33
33
  gem 'rails', ENV['RAILS_VERSION'] if ENV['RAILS_VERSION']
34
+
34
35
  if ENV['RAILS_VERSION'].nil? || ENV['RAILS_VERSION'] =~ /^4.2/
35
36
  gem 'responders', "~> 2.0"
36
37
  gem 'sass-rails', ">= 5.0"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.6.0
@@ -14,16 +14,20 @@ module CurationConcerns
14
14
  # neccesarily know about, seems to be consistent with what Rails4 does
15
15
  # by default with uncaught ActiveRecord::RecordNotFound in production
16
16
  wants.any do
17
- # use standard, possibly locally overridden, 404.html file. Even for
18
- # possibly non-html formats, this is consistent with what Rails does
19
- # on raising an ActiveRecord::RecordNotFound. Rails.root IS needed
20
- # for it to work under testing, without worrying about CWD.
21
- render file: "#{Rails.root}/public/404.html", status: :not_found, layout: false
17
+ render_404
22
18
  end
23
19
  end
24
20
  end
25
21
  end
26
22
 
23
+ def render_404
24
+ # use standard, possibly locally overridden, 404.html file. Even for
25
+ # possibly non-html formats, this is consistent with what Rails does
26
+ # on raising an ActiveRecord::RecordNotFound. Rails.root IS needed
27
+ # for it to work under testing, without worrying about CWD.
28
+ render file: "#{Rails.root}/public/404.html", status: :not_found, layout: false
29
+ end
30
+
27
31
  # Called by Hydra::Controller::ControllerBehavior when CanCan::AccessDenied is caught
28
32
  # @param [CanCan::AccessDenied] exception error to handle
29
33
  def deny_access(exception)
@@ -11,9 +11,6 @@ module CurationConcerns::CatalogController
11
11
  helper CurationConcerns::CatalogHelper
12
12
  # These before_filters apply the hydra access controls
13
13
  before_action :enforce_show_permissions, only: :show
14
- # This applies appropriate access controls to all solr queries
15
- CatalogController.search_params_logic += [:add_access_controls_to_solr_params]
16
- self.search_params_logic += [:filter_models]
17
14
  end
18
15
 
19
16
  module ClassMethods
@@ -34,21 +31,4 @@ module CurationConcerns::CatalogController
34
31
  { 'qf' => %w(title_tesim name_tesim), 'qt' => 'search', 'rows' => 10 }
35
32
  end
36
33
  end
37
-
38
- protected
39
-
40
- # Overriding Blacklight so that the search results can be displayed in a way compatible with
41
- # tokenInput javascript library. This is used for suggesting "Related Works" to attach.
42
- def render_search_results_as_json
43
- { 'docs' => @response['response']['docs'].map { |solr_doc| serialize_work_from_solr(solr_doc) } }
44
- end
45
-
46
- def serialize_work_from_solr(solr_doc)
47
- title = solr_doc['title_tesim'].first
48
- title << " (#{solr_doc['human_readable_type_tesim'].first})" if solr_doc['human_readable_type_tesim'].present?
49
- {
50
- pid: solr_doc['id'],
51
- title: title
52
- }
53
- end
54
34
  end
@@ -2,11 +2,10 @@ module CurationConcerns
2
2
  module CollectionsControllerBehavior
3
3
  extend ActiveSupport::Concern
4
4
  include Hydra::CollectionsControllerBehavior
5
- include Hydra::Controller::SearchBuilder
5
+ include Blacklight::AccessControls::Catalog
6
6
 
7
7
  included do
8
8
  before_action :filter_docs_with_read_access!, except: :show
9
- self.search_params_logic += [:add_access_controls_to_solr_params, :add_advanced_parse_q_to_solr]
10
9
  layout 'curation_concerns/1_column'
11
10
  skip_load_and_authorize_resource only: :show
12
11
  end
@@ -26,6 +25,17 @@ module CurationConcerns
26
25
  super
27
26
  end
28
27
 
28
+ def after_create_error
29
+ form
30
+ super
31
+ end
32
+
33
+ def after_update_error
34
+ form
35
+ query_collection_members
36
+ super
37
+ end
38
+
29
39
  # overriding the method in Hydra::Collections so the search builder can find the collection
30
40
  def collection
31
41
  action_name == 'show' ? @presenter : @collection
@@ -40,19 +50,31 @@ module CurationConcerns
40
50
 
41
51
  def presenter
42
52
  @presenter ||= begin
43
- _, document_list = search_results(params, self.class.search_params_logic + [:find_one])
44
- curation_concern = document_list.first
53
+ # Query Solr for the collection.
54
+ # run the solr query to find the collection members
55
+ response = repository.search(collection_search_builder.query)
56
+ curation_concern = response.documents.first
45
57
  raise CanCan::AccessDenied unless curation_concern
46
58
  presenter_class.new(curation_concern, current_ability)
47
59
  end
48
60
  end
49
61
 
62
+ def collection_search_builder
63
+ collection_search_builder_class.new(self).with(params).tap do |builder|
64
+ builder.current_ability = current_ability
65
+ end
66
+ end
67
+
50
68
  def presenter_class
51
69
  CurationConcerns::CollectionPresenter
52
70
  end
53
71
 
72
+ def collection_search_builder_class
73
+ CurationConcerns::WorkSearchBuilder
74
+ end
75
+
54
76
  def collection_member_search_builder_class
55
- CurationConcerns::SearchBuilder
77
+ CurationConcerns::CollectionMemberSearchBuilder
56
78
  end
57
79
 
58
80
  def collection_params
@@ -1,7 +1,7 @@
1
1
  module CurationConcerns::CurationConcernController
2
2
  extend ActiveSupport::Concern
3
3
  include Blacklight::Base
4
- include Hydra::Controller::SearchBuilder
4
+ include Blacklight::AccessControls::Catalog
5
5
 
6
6
  included do
7
7
  copy_blacklight_config_from(CatalogController)
@@ -145,7 +145,7 @@ module CurationConcerns::CurationConcernController
145
145
  def after_destroy_response(title)
146
146
  flash[:notice] = "Deleted #{title}"
147
147
  respond_to do |wants|
148
- wants.html { redirect_to main_app.catalog_index_path }
148
+ wants.html { redirect_to main_app.search_catalog_path }
149
149
  wants.json { render_json_response(response_type: :deleted, message: "Deleted #{curation_concern.id}") }
150
150
  end
151
151
  end
@@ -164,10 +164,14 @@ module CurationConcerns::CurationConcernController
164
164
  # nop
165
165
  end
166
166
 
167
+ def search_builder_class
168
+ CurationConcerns::WorkSearchBuilder
169
+ end
170
+
167
171
  private
168
172
 
169
173
  def curation_concern_from_search_results
170
- _, document_list = search_results(params, CatalogController.search_params_logic + [:find_one])
174
+ _, document_list = search_results(params)
171
175
  raise CanCan::AccessDenied.new(nil, :show) if document_list.empty?
172
176
  document_list.first
173
177
  end
@@ -50,11 +50,11 @@ module CurationConcerns
50
50
  end
51
51
 
52
52
  def default_file
53
- if asset.class.respond_to?(:default_file_path)
54
- default_file_reference = asset.class.default_file_path
55
- else
56
- default_file_reference = DownloadsController.default_content_path
57
- end
53
+ default_file_reference = if asset.class.respond_to?(:default_file_path)
54
+ asset.class.default_file_path
55
+ else
56
+ DownloadsController.default_content_path
57
+ end
58
58
  association = dereference_file(default_file_reference)
59
59
  association.reader if association
60
60
  end
@@ -1,6 +1,8 @@
1
1
  module CurationConcerns
2
2
  module FileSetsControllerBehavior
3
3
  extend ActiveSupport::Concern
4
+ include Blacklight::Base
5
+ include Blacklight::AccessControls::Catalog
4
6
 
5
7
  included do
6
8
  include CurationConcerns::ThemedLayoutController
@@ -8,8 +10,6 @@ module CurationConcerns
8
10
  load_and_authorize_resource class: ::FileSet, except: :show
9
11
  helper_method :curation_concern
10
12
  include CurationConcerns::ParentContainer
11
- include Blacklight::Base
12
- include Hydra::Controller::SearchBuilder
13
13
  copy_blacklight_config_from(::CatalogController)
14
14
  end
15
15
 
@@ -95,12 +95,7 @@ module CurationConcerns
95
95
  end
96
96
  end
97
97
  if success
98
- respond_to do |wants|
99
- wants.html do
100
- redirect_to [main_app, @file_set], notice: "The file #{view_context.link_to(@file_set, [main_app, @file_set])} has been updated."
101
- end
102
- wants.json { render :show, status: :ok, location: polymorphic_path([main_app, @file_set]) }
103
- end
98
+ after_update_response
104
99
  else
105
100
  respond_to do |wants|
106
101
  wants.html do
@@ -116,6 +111,15 @@ module CurationConcerns
116
111
  render action: 'edit'
117
112
  end
118
113
 
114
+ def after_update_response
115
+ respond_to do |wants|
116
+ wants.html do
117
+ redirect_to [main_app, @file_set], notice: "The file #{view_context.link_to(@file_set, [main_app, @file_set])} has been updated."
118
+ end
119
+ wants.json { render :show, status: :ok, location: polymorphic_path([main_app, @file_set]) }
120
+ end
121
+ end
122
+
119
123
  def versions
120
124
  @version_list = version_list
121
125
  end
@@ -130,13 +134,17 @@ module CurationConcerns
130
134
 
131
135
  def presenter
132
136
  @presenter ||= begin
133
- _, document_list = search_results(params, [:add_access_controls_to_solr_params, :find_one, :only_file_sets])
137
+ _, document_list = search_results(params)
134
138
  curation_concern = document_list.first
135
139
  raise CanCan::AccessDenied unless curation_concern
136
140
  show_presenter.new(curation_concern, current_ability)
137
141
  end
138
142
  end
139
143
 
144
+ def search_builder_class
145
+ CurationConcerns::FileSetSearchBuilder
146
+ end
147
+
140
148
  def initialize_edit_form
141
149
  @groups = current_user.groups
142
150
  end
@@ -15,15 +15,10 @@ module CurationConcerns::ParentContainer
15
15
  end
16
16
 
17
17
  def lookup_parent_from_child
18
- if curation_concern
19
- # in_objects method is inherited from Hydra::PCDM::ObjectBehavior
20
- curation_concern.in_objects.first
21
- elsif @presenter
22
-
23
- CurationConcerns::ParentService.parent_for(@presenter.id)
24
- else
25
- raise "no child"
26
- end
18
+ # in_objects method is inherited from Hydra::PCDM::ObjectBehavior
19
+ return curation_concern.in_objects.first if curation_concern
20
+ return CurationConcerns::ParentService.parent_for(@presenter.id) if @presenter
21
+ raise "no child"
27
22
  end
28
23
 
29
24
  def parent_id
@@ -3,7 +3,7 @@ module CurationConcerns
3
3
  extend ActiveSupport::Concern
4
4
  include CurationConcerns::DownloadBehavior
5
5
  include Blacklight::Base
6
- include Hydra::Controller::SearchBuilder
6
+ include Blacklight::AccessControls::Catalog
7
7
 
8
8
  included do
9
9
  include ActionDispatch::Routing::PolymorphicRoutes
@@ -23,7 +23,7 @@ module CurationConcerns
23
23
  end
24
24
 
25
25
  def show
26
- _, document_list = search_results({ id: single_use_link.itemId }, [:find_one])
26
+ _, document_list = search_results(id: single_use_link.itemId)
27
27
  curation_concern = document_list.first
28
28
 
29
29
  # Authorize using SingleUseLinksViewerController::Ability
@@ -41,6 +41,10 @@ module CurationConcerns
41
41
 
42
42
  protected
43
43
 
44
+ def search_builder_class
45
+ CurationConcerns::SingleUseLinkSearchBuilder
46
+ end
47
+
44
48
  def content_options
45
49
  super.tap do |options|
46
50
  options[:disposition] = 'attachment' if action_name == 'download'
@@ -5,7 +5,7 @@ module CurationConcerns::CatalogHelper
5
5
  else
6
6
  # TODO: Unused variable. Not sure why this is here.
7
7
  # facet_solr_field = facet_configuration_for_field(type_field)
8
- path = search_action_path(add_facet_params_and_redirect(type_field, key))
8
+ path = search_action_path(search_state.add_facet_params_and_redirect(type_field, key))
9
9
  # local_params = params.dup
10
10
  # local_facet_params = local_params[:f] || {}.with_indifferent_access
11
11
  # local_params[:f] = local_facet_params.select{|k,_| k != type_field }
@@ -17,9 +17,7 @@ module CurationConcerns::CatalogHelper
17
17
 
18
18
  def all_type_tab(label = t('curation_concerns.catalog.index.type_tabs.all'))
19
19
  if params[:f] && params[:f][type_field]
20
- # TODO: Unused variable. Not sure why this is here.
21
- # facet_solr_field = facet_configuration_for_field(type_field)
22
- new_params = remove_facet_params(type_field, params[:f][type_field].first)
20
+ new_params = search_state.remove_facet_params(type_field, params[:f][type_field].first)
23
21
 
24
22
  # Delete any request params from facet-specific action, needed
25
23
  # to redir to index action properly.
@@ -4,7 +4,7 @@ module CurationConcerns::CollectionsHelper
4
4
  end
5
5
 
6
6
  def collection_modal_id(collectible)
7
- "#{collectible.to_param.gsub(/:/, '-')}-modal"
7
+ "#{collectible.to_param.tr(':', '-')}-modal"
8
8
  end
9
9
 
10
10
  def link_to_select_collection(collectible, opts = {})
@@ -1,8 +1,9 @@
1
1
  module CurationConcerns
2
2
  module PermissionsHelper
3
3
  def help_link(file, title, aria_label)
4
- link_to help_icon, '#', 'data-toggle': 'popover', 'data-content': capture_content(file),
5
- 'data-original-title': title, 'aria-label': aria_label
4
+ link_to help_icon, '#',
5
+ data: { toggle: 'popover', content: capture_content(file), 'original-title' => title },
6
+ 'aria-label' => aria_label
6
7
  end
7
8
 
8
9
  private
@@ -14,7 +15,7 @@ module CurationConcerns
14
15
  end
15
16
 
16
17
  def help_icon
17
- content_tag 'i', '', 'aria-hidden': true, class: 'help-icon'
18
+ content_tag 'i', '', 'aria-hidden' => true, class: 'help-icon'
18
19
  end
19
20
  end
20
21
  end
@@ -1,11 +1,11 @@
1
1
  module CurationConcerns::SearchPathsHelper
2
2
  def search_path_for_my_works(opts = {})
3
3
  params_for_my_works = { 'f[generic_type_sim][]' => 'Work', works: 'mine' }
4
- main_app.catalog_index_path(params_for_my_works.merge(opts))
4
+ main_app.search_catalog_path(params_for_my_works.merge(opts))
5
5
  end
6
6
 
7
7
  def search_path_for_my_collections(opts = {})
8
8
  params_for_my_collections = { 'f[generic_type_sim][]' => 'Collection', works: 'mine' }
9
- main_app.catalog_index_path(params_for_my_collections.merge(opts))
9
+ main_app.search_catalog_path(params_for_my_collections.merge(opts))
10
10
  end
11
11
  end
@@ -2,7 +2,7 @@ class MultifileInput < SimpleForm::Inputs::CollectionInput
2
2
  def input(wrapper_options = nil)
3
3
  merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
4
4
 
5
- merged_input_options.merge!(name: "#{@builder.object_name}[#{attribute_name}][]")
5
+ merged_input_options[:name] = "#{@builder.object_name}[#{attribute_name}][]"
6
6
  @builder.file_field(attribute_name, merged_input_options)
7
7
  end
8
8
  end
@@ -1,7 +1,7 @@
1
1
  class SelectWithModalHelpInput < MultiValueWithHelpInput
2
2
  def link_to_help
3
3
  template.link_to "##{attribute_name}Modal", id: "#{input_class}_help_modal", rel: 'button',
4
- data: { toggle: 'modal' }, 'aria-label': aria_label do
4
+ data: { toggle: 'modal' }, 'aria-label' => aria_label do
5
5
  help_icon
6
6
  end
7
7
  end
@@ -9,14 +9,14 @@ module WithHelpIcon
9
9
  template.link_to '#', id: "#{input_class}_help",
10
10
  data: { toggle: 'popover'.freeze,
11
11
  content: metadata_help,
12
- 'original-title': raw_label_text },
13
- 'aria-label': aria_label do
12
+ 'original-title' => raw_label_text },
13
+ 'aria-label' => aria_label do
14
14
  help_icon
15
15
  end
16
16
  end
17
17
 
18
18
  def help_icon
19
- template.content_tag 'i', nil, "aria-hidden": true, class: "help-icon"
19
+ template.content_tag 'i', nil, 'aria-hidden' => true, class: "help-icon"
20
20
  end
21
21
 
22
22
  def metadata_help
@@ -36,7 +36,8 @@ module CurationConcerns
36
36
 
37
37
  # Query solr using POST so that the query doesn't get too large for a URI
38
38
  def query(query, args = {})
39
- args.merge!(q: query, qt: 'standard')
39
+ args[:q] = query
40
+ args[:qt] = 'standard'
40
41
  conn = ActiveFedora::SolrService.instance.conn
41
42
  result = conn.post('select', data: args)
42
43
  result.fetch('response').fetch('docs')
@@ -10,9 +10,9 @@ module CurationConcerns
10
10
 
11
11
  def wrapped_list
12
12
  @wrapped_list ||=
13
- @raw_list.map { |v| CurationConcerns::VersionPresenter.new(v) } # wrap each item in a presenter
14
- .sort { |a, b| b.version.created <=> a.version.created } # sort list of versions based on creation date
15
- .tap { |l| l.first.try(:current!) } # set the first version to the current version
13
+ @raw_list.map { |v| CurationConcerns::VersionPresenter.new(v) } # wrap each item in a presenter
14
+ .sort { |a, b| b.version.created <=> a.version.created } # sort list of versions based on creation date
15
+ .tap { |l| l.first.try(:current!) } # set the first version to the current version
16
16
  end
17
17
  end
18
18
  end
@@ -8,7 +8,7 @@ module CurationConcerns
8
8
  end
9
9
 
10
10
  delegate :label, :uri, to: :version
11
- alias_method :current?, :current
11
+ alias current? current
12
12
 
13
13
  def current!
14
14
  @current = true
@@ -35,7 +35,7 @@ module CurationConcerns
35
35
  # TODO: Extract this to ActiveFedora::Aggregations::ListSource
36
36
  def ordered_ids
37
37
  ActiveFedora::SolrService.query("proxy_in_ssi:#{id}", fl: "ordered_targets_ssim")
38
- .flat_map { |x| x.fetch("ordered_targets_ssim", []) }
38
+ .flat_map { |x| x.fetch("ordered_targets_ssim", []) }
39
39
  end
40
40
 
41
41
  # Override this method if you want to use an alternate presenter class for the files
@@ -32,13 +32,16 @@ module CurationConcerns
32
32
  markup.html_safe
33
33
  end
34
34
 
35
- private
35
+ # @return The human-readable label for this field.
36
+ # @note This is a central location for determining the label of a field
37
+ # name. Can be overridden if more complicated logic is needed.
38
+ def label
39
+ translate(
40
+ :"blacklight.search.fields.show.#{field}",
41
+ default: [:"blacklight.search.fields.#{field}", options.fetch(:label, field.to_s.humanize)])
42
+ end
36
43
 
37
- def label
38
- translate(
39
- :"blacklight.search.fields.show.#{field}",
40
- default: [:"blacklight.search.fields.#{field}", options.fetch(:label, field.to_s.humanize)])
41
- end
44
+ private
42
45
 
43
46
  def attribute_value_to_html(value)
44
47
  if field == :rights
@@ -72,7 +75,7 @@ module CurationConcerns
72
75
  end
73
76
 
74
77
  def search_path(value)
75
- Rails.application.routes.url_helpers.catalog_index_path(
78
+ Rails.application.routes.url_helpers.search_catalog_path(
76
79
  search_field: search_field, q: ERB::Util.h(value))
77
80
  end
78
81
 
@@ -0,0 +1,5 @@
1
+ module CurationConcerns
2
+ class CollectionMemberSearchBuilder < Hydra::Collections::MemberSearchBuilder
3
+ include CurationConcerns::FilterByType
4
+ end
5
+ end
@@ -2,9 +2,6 @@ module CurationConcerns
2
2
  # Finds embargoed objects
3
3
  class EmbargoSearchBuilder < Blacklight::SearchBuilder
4
4
  self.default_processor_chain = [:with_pagination, :with_sorting, :only_active_embargoes]
5
- def initialize(scope)
6
- super(true, scope)
7
- end
8
5
 
9
6
  # TODO: add more complex pagination
10
7
  def with_pagination(solr_params)
@@ -0,0 +1,10 @@
1
+ module CurationConcerns
2
+ class FileSetSearchBuilder < Hydra::SearchBuilder
3
+ include CurationConcerns::SingleResult
4
+ self.default_processor_chain += [:only_file_sets]
5
+
6
+ def only_file_sets(solr_parameters)
7
+ solr_parameters[:fq] << ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: ::FileSet.to_class_uri)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,29 @@
1
+ module CurationConcerns
2
+ module FilterByType
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ self.default_processor_chain += [:filter_models]
7
+ end
8
+
9
+ # Add queries that excludes everything except for works and collections
10
+ def filter_models(solr_parameters)
11
+ solr_parameters[:fq] ||= []
12
+ solr_parameters[:fq] << '(' + (work_clauses + collection_clauses).join(' OR ') + ')'
13
+ end
14
+
15
+ private
16
+
17
+ def work_clauses
18
+ return [] if blacklight_params.key?(:f) && Array(blacklight_params[:f][:generic_type_sim]).include?('Collection')
19
+ CurationConcerns.config.registered_curation_concern_types.map(&:constantize).map do |klass|
20
+ ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: klass.to_class_uri)
21
+ end
22
+ end
23
+
24
+ def collection_clauses
25
+ return [] if blacklight_params.key?(:f) && Array(blacklight_params[:f][:generic_type_sim]).include?('Work')
26
+ [ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: ::Collection.to_class_uri)]
27
+ end
28
+ end
29
+ end
@@ -2,9 +2,6 @@ module CurationConcerns
2
2
  # Finds objects under lease
3
3
  class LeaseSearchBuilder < Blacklight::SearchBuilder
4
4
  self.default_processor_chain = [:with_pagination, :with_sorting, :only_active_leases]
5
- def initialize(scope)
6
- super(true, scope)
7
- end
8
5
 
9
6
  # TODO: add more complex pagination
10
7
  def with_pagination(solr_params)
@@ -1,14 +1,6 @@
1
1
  class CurationConcerns::SearchBuilder < Hydra::SearchBuilder
2
2
  include BlacklightAdvancedSearch::AdvancedSearchBuilder
3
- include Hydra::Collections::SearchBehaviors
4
-
5
- def only_file_sets(solr_parameters)
6
- solr_parameters[:fq] << ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: FileSet.to_class_uri)
7
- end
8
-
9
- def find_one(solr_parameters)
10
- solr_parameters[:fq] << "_query_:\"{!raw f=id}#{blacklight_params.fetch(:id)}\""
11
- end
3
+ include CurationConcerns::FilterByType
12
4
 
13
5
  # Override Hydra::AccessControlsEnforcement (or Hydra::PolicyAwareAccessControlsEnforcement)
14
6
  # Allows admin users to see everything (don't apply any gated_discovery_filters for those users)
@@ -22,22 +14,4 @@ class CurationConcerns::SearchBuilder < Hydra::SearchBuilder
22
14
  return ['edit'] if blacklight_params[:works] == 'mine'
23
15
  super
24
16
  end
25
-
26
- # This is included as part of blacklight search solr params logic
27
- def filter_models(solr_parameters)
28
- solr_parameters[:fq] ||= []
29
- solr_parameters[:fq] << '(' + (work_clauses + collection_clauses).join(' OR ') + ')'
30
- end
31
-
32
- def work_clauses
33
- return [] if blacklight_params.key?(:f) && Array(blacklight_params[:f][:generic_type_sim]).include?('Collection')
34
- CurationConcerns.config.registered_curation_concern_types.map(&:constantize).map do |klass|
35
- ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: klass.to_class_uri)
36
- end
37
- end
38
-
39
- def collection_clauses
40
- return [] if blacklight_params.key?(:f) && Array(blacklight_params[:f][:generic_type_sim]).include?('Work')
41
- [ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: ::Collection.to_class_uri)]
42
- end
43
17
  end
@@ -0,0 +1,13 @@
1
+ module CurationConcerns
2
+ module SingleResult
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ self.default_processor_chain += [:find_one]
7
+ end
8
+
9
+ def find_one(solr_parameters)
10
+ solr_parameters[:fq] << "_query_:\"{!raw f=id}#{blacklight_params.fetch(:id)}\""
11
+ end
12
+ end
13
+ end