hydra-core 9.5.0 → 9.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/concerns/hydra/catalog.rb +19 -1
- data/app/controllers/concerns/hydra/controller/search_builder.rb +2 -3
- data/app/search_builders/hydra/search_builder.rb +2 -1
- data/lib/generators/hydra/templates/catalog_controller.rb +46 -45
- data/lib/hydra-head/version.rb +1 -1
- data/spec/controllers/catalog_controller_spec.rb +45 -17
- data/spec/controllers/downloads_controller_spec.rb +2 -0
- data/spec/test_app_templates/Gemfile.extra +3 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7de2e1cf6d7fffb05b9d158a071a5233e757f251
|
4
|
+
data.tar.gz: 190764737d16b04bca3c887f5be91a67699e1ab7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6171dc2226ab963b5221e2a9de0e548307fbebd64881fe2b30947eb8688af55922c2ecb6f5aa9a2ee524fd38f1cc978ff6f300c26bd904899b4192b579e71de
|
7
|
+
data.tar.gz: 45508099ed34d6ff46463feccb5ed7214cbe8bb08a58033982f87febc83cfd46c2485503d9befbd6de279444943481161a17183ba16716350fa1987ff9cc8890
|
@@ -1,5 +1,23 @@
|
|
1
1
|
module Hydra::Catalog
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
include Blacklight::Catalog
|
4
|
-
include
|
4
|
+
include Blacklight::AccessControls::Catalog
|
5
|
+
|
6
|
+
# Action-specific enforcement
|
7
|
+
# Controller "before" filter for enforcing access controls on show actions
|
8
|
+
# @param [Hash] opts (optional, not currently used)
|
9
|
+
def enforce_show_permissions(opts={})
|
10
|
+
# The "super" method comes from blacklight-access_controls.
|
11
|
+
# It will check the read permissions for the record.
|
12
|
+
# By default, it will return a Hydra::PermissionsSolrDocument
|
13
|
+
# that contains the permissions fields for that record
|
14
|
+
# so that you can perform additional permissions checks.
|
15
|
+
permissions_doc = super
|
16
|
+
|
17
|
+
if permissions_doc.under_embargo? && !can?(:edit, permissions_doc)
|
18
|
+
raise Hydra::AccessDenied.new("This item is under embargo. You do not have sufficient access privileges to read this document.", :edit, params[:id])
|
19
|
+
end
|
20
|
+
|
21
|
+
permissions_doc
|
22
|
+
end
|
5
23
|
end
|
@@ -1,9 +1,8 @@
|
|
1
1
|
module Hydra::Controller::SearchBuilder
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
super.tap { |builder| builder.current_ability = current_ability }
|
4
|
+
included do
|
5
|
+
Deprecation.warn Hydra::Controller::SearchBuilder, "Hydra::Controller::SearchBuilder no longer does anything. It will be removed in Hydra version 10. The code that used to be in this module was moved to Blacklight::AccessControls::Catalog in the blacklight-access_controls gem."
|
7
6
|
end
|
8
7
|
|
9
8
|
end
|
@@ -5,16 +5,17 @@ class CatalogController < ApplicationController
|
|
5
5
|
|
6
6
|
include Hydra::Catalog
|
7
7
|
# These before_filters apply the hydra access controls
|
8
|
-
before_filter :enforce_show_permissions, :
|
8
|
+
before_filter :enforce_show_permissions, only: :show
|
9
|
+
|
9
10
|
# This applies appropriate access controls to all solr queries
|
10
|
-
|
11
|
+
Hydra::SearchBuilder.default_processor_chain += [:add_access_controls_to_solr_params]
|
11
12
|
|
12
13
|
|
13
14
|
configure_blacklight do |config|
|
14
15
|
config.search_builder_class = Hydra::SearchBuilder
|
15
16
|
config.default_solr_params = {
|
16
|
-
:
|
17
|
-
:
|
17
|
+
qt: 'search',
|
18
|
+
rows: 10
|
18
19
|
}
|
19
20
|
|
20
21
|
# solr field configuration for search results/index views
|
@@ -41,13 +42,13 @@ class CatalogController < ApplicationController
|
|
41
42
|
#
|
42
43
|
# :show may be set to false if you don't want the facet to be drawn in the
|
43
44
|
# facet bar
|
44
|
-
config.add_facet_field solr_name('object_type', :facetable), :
|
45
|
-
config.add_facet_field solr_name('pub_date', :facetable), :
|
46
|
-
config.add_facet_field solr_name('subject_topic', :facetable), :
|
47
|
-
config.add_facet_field solr_name('language', :facetable), :
|
48
|
-
config.add_facet_field solr_name('lc1_letter', :facetable), :
|
49
|
-
config.add_facet_field solr_name('subject_geo', :facetable), :
|
50
|
-
config.add_facet_field solr_name('subject_era', :facetable), :
|
45
|
+
config.add_facet_field solr_name('object_type', :facetable), label: 'Format'
|
46
|
+
config.add_facet_field solr_name('pub_date', :facetable), label: 'Publication Year'
|
47
|
+
config.add_facet_field solr_name('subject_topic', :facetable), label: 'Topic', limit: 20
|
48
|
+
config.add_facet_field solr_name('language', :facetable), label: 'Language', limit: true
|
49
|
+
config.add_facet_field solr_name('lc1_letter', :facetable), label: 'Call Number'
|
50
|
+
config.add_facet_field solr_name('subject_geo', :facetable), label: 'Region'
|
51
|
+
config.add_facet_field solr_name('subject_era', :facetable), label: 'Era'
|
51
52
|
|
52
53
|
# Have BL send all facet field names to Solr, which has been the default
|
53
54
|
# previously. Simply remove these lines if you'd rather use Solr request
|
@@ -59,32 +60,32 @@ class CatalogController < ApplicationController
|
|
59
60
|
|
60
61
|
# solr fields to be displayed in the index (search results) view
|
61
62
|
# The ordering of the field names is the order of the display
|
62
|
-
config.add_index_field solr_name('title', :stored_searchable, type: :string), :
|
63
|
-
config.add_index_field solr_name('title_vern', :stored_searchable, type: :string), :
|
64
|
-
config.add_index_field solr_name('author', :stored_searchable, type: :string), :
|
65
|
-
config.add_index_field solr_name('author_vern', :stored_searchable, type: :string), :
|
66
|
-
config.add_index_field solr_name('format', :symbol), :
|
67
|
-
config.add_index_field solr_name('language', :stored_searchable, type: :string), :
|
68
|
-
config.add_index_field solr_name('published', :stored_searchable, type: :string), :
|
69
|
-
config.add_index_field solr_name('published_vern', :stored_searchable, type: :string), :
|
70
|
-
config.add_index_field solr_name('lc_callnum', :stored_searchable, type: :string), :
|
63
|
+
config.add_index_field solr_name('title', :stored_searchable, type: :string), label: 'Title:'
|
64
|
+
config.add_index_field solr_name('title_vern', :stored_searchable, type: :string), label: 'Title:'
|
65
|
+
config.add_index_field solr_name('author', :stored_searchable, type: :string), label: 'Author:'
|
66
|
+
config.add_index_field solr_name('author_vern', :stored_searchable, type: :string), label: 'Author:'
|
67
|
+
config.add_index_field solr_name('format', :symbol), label: 'Format:'
|
68
|
+
config.add_index_field solr_name('language', :stored_searchable, type: :string), label: 'Language:'
|
69
|
+
config.add_index_field solr_name('published', :stored_searchable, type: :string), label: 'Published:'
|
70
|
+
config.add_index_field solr_name('published_vern', :stored_searchable, type: :string), label: 'Published:'
|
71
|
+
config.add_index_field solr_name('lc_callnum', :stored_searchable, type: :string), label: 'Call number:'
|
71
72
|
|
72
73
|
# solr fields to be displayed in the show (single result) view
|
73
74
|
# The ordering of the field names is the order of the display
|
74
|
-
config.add_show_field solr_name('title', :stored_searchable, type: :string), :
|
75
|
-
config.add_show_field solr_name('title_vern', :stored_searchable, type: :string), :
|
76
|
-
config.add_show_field solr_name('subtitle', :stored_searchable, type: :string), :
|
77
|
-
config.add_show_field solr_name('subtitle_vern', :stored_searchable, type: :string), :
|
78
|
-
config.add_show_field solr_name('author', :stored_searchable, type: :string), :
|
79
|
-
config.add_show_field solr_name('author_vern', :stored_searchable, type: :string), :
|
80
|
-
config.add_show_field solr_name('format', :symbol), :
|
81
|
-
config.add_show_field solr_name('url_fulltext_tsim', :stored_searchable, type: :string), :
|
82
|
-
config.add_show_field solr_name('url_suppl_tsim', :stored_searchable, type: :string), :
|
83
|
-
config.add_show_field solr_name('language', :stored_searchable, type: :string), :
|
84
|
-
config.add_show_field solr_name('published', :stored_searchable, type: :string), :
|
85
|
-
config.add_show_field solr_name('published_vern', :stored_searchable, type: :string), :
|
86
|
-
config.add_show_field solr_name('lc_callnum', :stored_searchable, type: :string), :
|
87
|
-
config.add_show_field solr_name('isbn', :stored_searchable, type: :string), :
|
75
|
+
config.add_show_field solr_name('title', :stored_searchable, type: :string), label: 'Title:'
|
76
|
+
config.add_show_field solr_name('title_vern', :stored_searchable, type: :string), label: 'Title:'
|
77
|
+
config.add_show_field solr_name('subtitle', :stored_searchable, type: :string), label: 'Subtitle:'
|
78
|
+
config.add_show_field solr_name('subtitle_vern', :stored_searchable, type: :string), label: 'Subtitle:'
|
79
|
+
config.add_show_field solr_name('author', :stored_searchable, type: :string), label: 'Author:'
|
80
|
+
config.add_show_field solr_name('author_vern', :stored_searchable, type: :string), label: 'Author:'
|
81
|
+
config.add_show_field solr_name('format', :symbol), label: 'Format:'
|
82
|
+
config.add_show_field solr_name('url_fulltext_tsim', :stored_searchable, type: :string), label: 'URL:'
|
83
|
+
config.add_show_field solr_name('url_suppl_tsim', :stored_searchable, type: :string), label: 'More Information:'
|
84
|
+
config.add_show_field solr_name('language', :stored_searchable, type: :string), label: 'Language:'
|
85
|
+
config.add_show_field solr_name('published', :stored_searchable, type: :string), label: 'Published:'
|
86
|
+
config.add_show_field solr_name('published_vern', :stored_searchable, type: :string), label: 'Published:'
|
87
|
+
config.add_show_field solr_name('lc_callnum', :stored_searchable, type: :string), label: 'Call number:'
|
88
|
+
config.add_show_field solr_name('isbn', :stored_searchable, type: :string), label: 'ISBN:'
|
88
89
|
|
89
90
|
# "fielded" search configuration. Used by pulldown among other places.
|
90
91
|
# For supported keys in hash, see rdoc for Blacklight::SearchFields
|
@@ -104,7 +105,7 @@ class CatalogController < ApplicationController
|
|
104
105
|
# solr request handler? The one set in config[:default_solr_parameters][:qt],
|
105
106
|
# since we aren't specifying it otherwise.
|
106
107
|
|
107
|
-
config.add_search_field 'all_fields', :
|
108
|
+
config.add_search_field 'all_fields', label: 'All Fields'
|
108
109
|
|
109
110
|
|
110
111
|
# Now we see how to over-ride Solr request handler defaults, in this
|
@@ -117,15 +118,15 @@ class CatalogController < ApplicationController
|
|
117
118
|
# Solr parameter de-referencing like $title_qf.
|
118
119
|
# See: http://wiki.apache.org/solr/LocalParams
|
119
120
|
field.solr_local_parameters = {
|
120
|
-
:
|
121
|
-
:
|
121
|
+
qf: '$title_qf',
|
122
|
+
pf: '$title_pf'
|
122
123
|
}
|
123
124
|
end
|
124
125
|
|
125
126
|
config.add_search_field('author') do |field|
|
126
127
|
field.solr_local_parameters = {
|
127
|
-
:
|
128
|
-
:
|
128
|
+
qf: '$author_qf',
|
129
|
+
pf: '$author_pf'
|
129
130
|
}
|
130
131
|
end
|
131
132
|
|
@@ -135,8 +136,8 @@ class CatalogController < ApplicationController
|
|
135
136
|
config.add_search_field('subject') do |field|
|
136
137
|
field.qt = 'search'
|
137
138
|
field.solr_local_parameters = {
|
138
|
-
:
|
139
|
-
:
|
139
|
+
qf: '$subject_qf',
|
140
|
+
pf: '$subject_pf'
|
140
141
|
}
|
141
142
|
end
|
142
143
|
|
@@ -144,10 +145,10 @@ class CatalogController < ApplicationController
|
|
144
145
|
# label in pulldown is followed by the name of the SOLR field to sort by and
|
145
146
|
# whether the sort is ascending or descending (it must be asc or desc
|
146
147
|
# except in the relevancy case).
|
147
|
-
config.add_sort_field 'score desc, pub_date_dtsi desc, title_tesi asc', :
|
148
|
-
config.add_sort_field 'pub_date_dtsi desc, title_tesi asc', :
|
149
|
-
config.add_sort_field 'author_tesi asc, title_tesi asc', :
|
150
|
-
config.add_sort_field 'title_tesi asc, pub_date_dtsi desc', :
|
148
|
+
config.add_sort_field 'score desc, pub_date_dtsi desc, title_tesi asc', label: 'relevance'
|
149
|
+
config.add_sort_field 'pub_date_dtsi desc, title_tesi asc', label: 'year'
|
150
|
+
config.add_sort_field 'author_tesi asc, title_tesi asc', label: 'author'
|
151
|
+
config.add_sort_field 'title_tesi asc, pub_date_dtsi desc', label: 'title'
|
151
152
|
|
152
153
|
# If there are more than this many search results, no spelling ("did you
|
153
154
|
# mean") suggestion is offered.
|
data/lib/hydra-head/version.rb
CHANGED
@@ -18,27 +18,13 @@ describe CatalogController do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
describe "Paths Generated by Custom Routes:" do
|
22
|
-
# paths generated by custom routes
|
23
|
-
it "should map {:controller=>'catalog', :action=>'index'} to GET /catalog" do
|
24
|
-
expect(get: "/catalog").to route_to(controller: 'catalog', action: 'index')
|
25
|
-
end
|
26
|
-
it "should map {:controller=>'catalog', :action=>'show', :id=>'test:3'} to GET /catalog/test:3" do
|
27
|
-
expect(get: "/catalog/test:3").to route_to(controller: 'catalog', action: 'show', id: 'test:3')
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should map catalog_path" do
|
31
|
-
expect(catalog_path("test:3")).to eq '/catalog/test:3'
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
21
|
describe "index" do
|
36
22
|
describe "access controls" do
|
37
23
|
before(:all) do
|
38
24
|
fq = "read_access_group_ssim:public OR edit_access_group_ssim:public OR discover_access_group_ssim:public"
|
39
25
|
solr_opts = { fq: fq }
|
40
26
|
response = ActiveFedora::SolrService.instance.conn.get('select', params: solr_opts)
|
41
|
-
@public_only_results = Blacklight::
|
27
|
+
@public_only_results = Blacklight::Solr::Response.new(response, solr_opts)
|
42
28
|
end
|
43
29
|
|
44
30
|
it "should only return public documents if role does not have permissions" do
|
@@ -72,9 +58,9 @@ describe CatalogController do
|
|
72
58
|
let(:related_uri) { related.rdf_subject }
|
73
59
|
let(:asset) do
|
74
60
|
ActiveFedora::Base.create do |g|
|
75
|
-
g.resource << [g.rdf_subject, RDF::DC.title, "Test Title"]
|
61
|
+
g.resource << [g.rdf_subject, RDF::Vocab::DC.title, "Test Title"]
|
76
62
|
g.resource << [g.rdf_subject, RDF.type, type]
|
77
|
-
g.resource << [g.rdf_subject, RDF::DC.isReferencedBy, related_uri]
|
63
|
+
g.resource << [g.rdf_subject, RDF::Vocab::DC.isReferencedBy, related_uri]
|
78
64
|
end
|
79
65
|
end
|
80
66
|
let(:related) do
|
@@ -130,4 +116,46 @@ describe CatalogController do
|
|
130
116
|
end
|
131
117
|
end
|
132
118
|
|
119
|
+
describe "enforce_show_permissions" do
|
120
|
+
let(:email_edit_access) { "edit_access@example.com" }
|
121
|
+
let(:email_read_access) { "read_access@example.com" }
|
122
|
+
let(:future_date) { 2.days.from_now.strftime("%Y-%m-%dT%H:%M:%SZ") }
|
123
|
+
|
124
|
+
let(:embargoed_object) {
|
125
|
+
doc = SolrDocument.new(id: '123',
|
126
|
+
"edit_access_person_ssim" => [email_edit_access],
|
127
|
+
"read_access_person_ssim" => [email_read_access],
|
128
|
+
"embargo_release_date_dtsi" => future_date)
|
129
|
+
solr = Blacklight.default_index.connection
|
130
|
+
solr.add(doc)
|
131
|
+
solr.commit
|
132
|
+
doc
|
133
|
+
}
|
134
|
+
|
135
|
+
before do
|
136
|
+
controller.params = { id: embargoed_object.id }
|
137
|
+
allow(controller).to receive(:current_user).and_return(user)
|
138
|
+
end
|
139
|
+
|
140
|
+
context 'a user with edit permissions' do
|
141
|
+
let(:user) { User.new email: email_edit_access }
|
142
|
+
|
143
|
+
it 'allows the user to view an embargoed object' do
|
144
|
+
expect {
|
145
|
+
controller.send(:enforce_show_permissions, {})
|
146
|
+
}.not_to raise_error
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
context 'a user without edit permissions' do
|
151
|
+
let(:user) { User.new email: email_read_access }
|
152
|
+
|
153
|
+
it 'denies access to the embargoed object' do
|
154
|
+
expect {
|
155
|
+
controller.send(:enforce_show_permissions, {})
|
156
|
+
}.to raise_error Hydra::AccessDenied, "This item is under embargo. You do not have sufficient access privileges to read this document."
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
133
161
|
end
|
@@ -39,6 +39,7 @@ describe DownloadsController do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
context "when not logged in" do
|
42
|
+
|
42
43
|
context "when a specific datastream is requested" do
|
43
44
|
it "should redirect to the root path and display an error" do
|
44
45
|
get :show, id: obj, file: "descMetadata"
|
@@ -47,6 +48,7 @@ describe DownloadsController do
|
|
47
48
|
end
|
48
49
|
end
|
49
50
|
end
|
51
|
+
|
50
52
|
context "when logged in, but without read access" do
|
51
53
|
let(:user) { User.create(email: 'email2@example.com', password: 'password') }
|
52
54
|
before do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.
|
4
|
+
version: 9.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Zumwalt, Bess Sadler, Julie Meloni, Naomi Dushay, Jessie Keck, John Scofield,
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-01-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - '='
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 9.
|
34
|
+
version: 9.6.0
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - '='
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 9.
|
41
|
+
version: 9.6.0
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: jettywrapper
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -215,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
215
|
version: '0'
|
216
216
|
requirements: []
|
217
217
|
rubyforge_project:
|
218
|
-
rubygems_version: 2.
|
218
|
+
rubygems_version: 2.5.1
|
219
219
|
signing_key:
|
220
220
|
specification_version: 4
|
221
221
|
summary: Hydra-Head Rails Engine (requires Rails3)
|