hydra-collections 6.0.0.alpha → 6.0.0.rc1
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/Changelog.md +18 -0
- data/README.md +5 -24
- data/app/controllers/concerns/hydra/collections/selects_collections.rb +22 -3
- data/app/controllers/concerns/hydra/collections_controller_behavior.rb +1 -4
- data/app/models/concerns/hydra/collection.rb +7 -0
- data/app/views/collections/_index_default.html.erb +1 -1
- data/hydra-collections.gemspec +1 -1
- data/lib/hydra/collections/collectible.rb +4 -4
- data/lib/hydra/collections/version.rb +1 -1
- data/spec/controllers/collections_controller_spec.rb +2 -2
- data/spec/controllers/other_collections_controller_spec.rb +1 -1
- data/spec/controllers/selects_collections_spec.rb +5 -0
- data/spec/helpers/collections_helper_spec.rb +1 -1
- data/spec/lib/collectible_spec.rb +1 -0
- data/spec/models/collection_spec.rb +13 -5
- data/spec/test_app_templates/Gemfile.extra +1 -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: f660059815d3e4687d927cbfebc290aa43b1c029
|
|
4
|
+
data.tar.gz: 3eec16c408c10c7f08d9f4c77a52ec6ea9555619
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 61d400608b2fb3b865dfbee6c14d73d39f5aa70172bd5d88c9ab379207798f36065bf22d9d1a08fc2ec85ff61a3ed92ca7793b26cbf7b5b112e9c355162e75c6
|
|
7
|
+
data.tar.gz: e4f3c3ef0120f0734ab46fc6d76f67767f6b2965235cca7f3008635ef2b73043fb8dd961e17dadf72002db15dd6b5d47018a153dedca079158608bb3231bb5cf
|
data/Changelog.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
# 6.0.0.rc1
|
|
2
|
+
Hydra::Collections 6.0.0 is the first release that sits atop the Portland Common Data Model. It includes the following changes:
|
|
3
|
+
|
|
4
|
+
* Update for hydra-works 0.2.0 [Justin Coyne]
|
|
5
|
+
* add instructions to list of editable collections; add_members to
|
|
6
|
+
collection [E. Lynette Rayle]
|
|
7
|
+
* Pass the document_counter to index_default [Justin Coyne]
|
|
8
|
+
* Update changelog with v6.0.0.alpha entry [Michael J. Giarlo]
|
|
9
|
+
|
|
10
|
+
# 6.0.0.alpha
|
|
11
|
+
|
|
12
|
+
* Depend upon hydra-works 0.1.0, which brings PCDM-related dependencies. Collections defined by Hydra::Collections are now PCDM collections.
|
|
13
|
+
* Add ParentCollectionAssociation#count_records to calculate the number of a collection's members.
|
|
14
|
+
* Change the default join column for querying members of a collection (was `hasCollectionMember_ssim`, is now `member_ids_ssim`)
|
|
15
|
+
* Deprecate the Hydra::Collections::Collectible module (in favor of Hydra::Works::GenericWorkBehavior).
|
|
16
|
+
* Update rails to 4.2.1, blacklight to 5.14.0, and kaminari to the latest in Justin Coyne's fork
|
|
17
|
+
* Pull latest hydra-jetty (was pinned to 8.1.0)
|
|
18
|
+
|
|
1
19
|
# 5.0.2
|
|
2
20
|
|
|
3
21
|
* Using new Hydra::Catalog module and Hydra::Collections::SearchBehaviors
|
data/README.md
CHANGED
|
@@ -24,46 +24,27 @@ Or install it yourself as:
|
|
|
24
24
|
|
|
25
25
|
### Call button_create_collection view helper in your search result page template.
|
|
26
26
|
First add `helper :collections` to your `catalog_controller.rb`
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
Next, we recommend putting the view helper in catalog/[_sort_and_per_page.html.erb](https://github.com/projectblacklight/blacklight/blob/master/app/views/catalog/_sort_and_per_page.html.erb) which you will manually override in you app.
|
|
29
29
|
```erb
|
|
30
30
|
<%= button_for_create_collection %>
|
|
31
|
-
```
|
|
31
|
+
```
|
|
32
32
|
|
|
33
33
|
### Any time you want to refer to the routes from hydra-collections use collections.
|
|
34
34
|
collections.new_collections_path
|
|
35
35
|
|
|
36
36
|
### Make your Models Collectible
|
|
37
37
|
|
|
38
|
-
Add `include Hydra::
|
|
38
|
+
Add `include Hydra::Works::GenericWorkBehavior` to the models for anything that you want to be able to add to collections (ie. GenericFile, Book, Article, etc.).
|
|
39
39
|
|
|
40
40
|
Example:
|
|
41
41
|
```ruby
|
|
42
42
|
class GenericFile < ActiveFedora::Base
|
|
43
|
-
include Hydra::
|
|
44
|
-
...
|
|
45
|
-
def to_solr(solr_doc={}, opts={})
|
|
46
|
-
super(solr_doc, opts)
|
|
47
|
-
index_collection_ids(solr_doc)
|
|
48
|
-
return solr_doc
|
|
49
|
-
end
|
|
43
|
+
include Hydra::Works::GenericWorkBehavior
|
|
50
44
|
end
|
|
51
45
|
```
|
|
52
46
|
|
|
53
|
-
Any items that include the `Hydra::
|
|
54
|
-
|
|
55
|
-
### Make the Collection show as a facet in your CatalogController
|
|
56
|
-
|
|
57
|
-
```ruby
|
|
58
|
-
class CatalogController < ApplicationController
|
|
59
|
-
include Blacklight::Catalog
|
|
60
|
-
...
|
|
61
|
-
configure_blacklight do |config|
|
|
62
|
-
...
|
|
63
|
-
config.add_facet_field solr_name("collection", :facetable), label: "Collection", helper_method: :collection_name
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
```
|
|
47
|
+
Any items that include the `Hydra::Works::GenericWorkBehavior` module can look up which collections they belong to via `.in_collections`.
|
|
67
48
|
|
|
68
49
|
### Make your Controller Accept a Batch
|
|
69
50
|
|
|
@@ -11,16 +11,35 @@ module Hydra::Collections::SelectsCollections
|
|
|
11
11
|
{ read: [:read, :edit], edit: [:edit] }
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
##
|
|
15
|
+
# Return list of collections for which the current user has read access.
|
|
16
|
+
# Add this or find_collections_with_edit_access as a before filter on any page that shows the form_for_select_collection
|
|
17
|
+
#
|
|
18
|
+
# @return [Array<SolrDocument>] Solr documents for each collection the user has read access
|
|
15
19
|
def find_collections_with_read_access
|
|
16
20
|
find_collections(:read)
|
|
17
21
|
end
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
##
|
|
24
|
+
# Return list of collections for which the current user has edit access. Optionally prepend with default
|
|
25
|
+
# that can be used in a select menu to instruct user to select a collection.
|
|
26
|
+
# Add this or find_collections_with_read_access as a before filter on any page that shows the form_for_select_collection
|
|
27
|
+
#
|
|
28
|
+
# @param [TrueClass|FalseClass] :include_default if true, prepends the default_option; otherwise, if false, returns only collections
|
|
29
|
+
# @param [Fixnum] :default_id for select menus, this is the id of the first selection representing the instructions
|
|
30
|
+
# @param [String] :default_title for select menus, this is the text displayed as the first item serving as instructions
|
|
31
|
+
#
|
|
32
|
+
# @return [Array<SolrDocument>] Solr documents for each collection the user has edit access, plus optional instructions
|
|
33
|
+
def find_collections_with_edit_access(include_default=false, default_id=-1, default_title="Select collection...")
|
|
20
34
|
find_collections(:edit)
|
|
35
|
+
default_option = SolrDocument.new(id: default_id, title_tesim: default_title)
|
|
36
|
+
@user_collections.unshift(default_option) if include_default
|
|
21
37
|
end
|
|
22
38
|
|
|
23
|
-
|
|
39
|
+
##
|
|
40
|
+
# Return list of collections matching the passed in access_level for the current user.
|
|
41
|
+
# @param [Symbol] :access_level one of :read or :edit
|
|
42
|
+
# @return [Array<SolrDocument>] Solr documents for each collection the user has the appropriate access level
|
|
24
43
|
def find_collections (access_level = nil)
|
|
25
44
|
# need to know the user if there is an access level applied otherwise we are just doing public collections
|
|
26
45
|
authenticate_user! unless access_level.blank?
|
|
@@ -172,10 +172,7 @@ module Hydra
|
|
|
172
172
|
|
|
173
173
|
def add_members_to_collection collection = nil
|
|
174
174
|
collection ||= @collection
|
|
175
|
-
|
|
176
|
-
collection.child_generic_works << ActiveFedora::Base.find(id)
|
|
177
|
-
end
|
|
178
|
-
#TODO this old way was more efficient #collection.member_ids = batch.concat(collection.member_ids)
|
|
175
|
+
collection.add_members batch
|
|
179
176
|
end
|
|
180
177
|
|
|
181
178
|
def remove_members_from_collection
|
|
@@ -7,5 +7,12 @@ module Hydra
|
|
|
7
7
|
include Hydra::AccessControls::Permissions
|
|
8
8
|
include Hydra::Collections::Metadata
|
|
9
9
|
include Hydra::Works::CollectionBehavior
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def add_members new_member_ids
|
|
13
|
+
return if new_member_ids.nil? || new_member_ids.size < 1
|
|
14
|
+
self.members << ActiveFedora::Base.find(new_member_ids)
|
|
15
|
+
end
|
|
16
|
+
|
|
10
17
|
end
|
|
11
18
|
end
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
<%= render 'catalog/index_default', document: document %>
|
|
1
|
+
<%= render 'catalog/index_default', document: document, document_counter: document_counter %>
|
|
2
2
|
|
data/hydra-collections.gemspec
CHANGED
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
|
21
21
|
spec.add_dependency 'hydra-head', '~> 9.1'
|
|
22
22
|
spec.add_dependency 'deprecation', '~> 0.1'
|
|
23
23
|
spec.add_dependency 'blacklight', '~> 5.10'
|
|
24
|
-
spec.add_dependency 'hydra-works', '~> 0.
|
|
24
|
+
spec.add_dependency 'hydra-works', '~> 0.2'
|
|
25
25
|
|
|
26
26
|
spec.add_development_dependency 'engine_cart', '~> 0.5'
|
|
27
27
|
spec.add_development_dependency 'rspec-rails', '~> 3.1'
|
|
@@ -12,13 +12,13 @@ module Hydra::Collections
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def collection_ids
|
|
15
|
-
Deprecation.warn(Collectible, "collection_ids is deprecated and will be removed in Hydra::Collections 7.0. Use
|
|
16
|
-
|
|
15
|
+
Deprecation.warn(Collectible, "collection_ids is deprecated and will be removed in Hydra::Collections 7.0. Use in_collections.map(&:id) instead.")
|
|
16
|
+
in_collections.map(&:id)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def collections
|
|
20
|
-
Deprecation.warn(Collectible, "collections is deprecated and will be removed in Hydra::Collections 7.0. Use
|
|
21
|
-
|
|
20
|
+
Deprecation.warn(Collectible, "collections is deprecated and will be removed in Hydra::Collections 7.0. Use in_collections instead.")
|
|
21
|
+
in_collections
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
end
|
|
@@ -202,10 +202,10 @@ describe CollectionsController, :type => :controller do
|
|
|
202
202
|
asset1 = GenericWork.create!
|
|
203
203
|
@collection.members << asset1
|
|
204
204
|
@collection.save!
|
|
205
|
-
expect(asset1.
|
|
205
|
+
expect(asset1.in_collections).to eq [@collection]
|
|
206
206
|
|
|
207
207
|
delete :destroy, id: @collection
|
|
208
|
-
expect(asset1.
|
|
208
|
+
expect(asset1.in_collections).to eq []
|
|
209
209
|
end
|
|
210
210
|
end
|
|
211
211
|
|
|
@@ -90,6 +90,11 @@ describe SelectsCollectionsController, :type => :controller do
|
|
|
90
90
|
subject.find_collections_with_edit_access
|
|
91
91
|
expect(assigns[:user_collections].map(&:id)).to match_array [@collection.id, @collection3.id]
|
|
92
92
|
end
|
|
93
|
+
|
|
94
|
+
it "should return only public or editable collections & instructions" do
|
|
95
|
+
subject.find_collections_with_edit_access(true)
|
|
96
|
+
expect(assigns[:user_collections].map(&:id)).to match_array [-1, @collection.id, @collection3.id]
|
|
97
|
+
end
|
|
93
98
|
end
|
|
94
99
|
end
|
|
95
100
|
end
|
|
@@ -62,7 +62,7 @@ describe CollectionsHelper, :type => :helper do
|
|
|
62
62
|
before(:all) do
|
|
63
63
|
class OtherCollection < ActiveFedora::Base
|
|
64
64
|
include Hydra::Collection
|
|
65
|
-
include Hydra::
|
|
65
|
+
include Hydra::Works::GenericWorkBehavior
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
@collection = OtherCollection.create
|
|
@@ -4,7 +4,7 @@ describe Collection, :type => :model do
|
|
|
4
4
|
before(:all) do
|
|
5
5
|
@user = FactoryGirl.find_or_create(:user)
|
|
6
6
|
class GenericFile < ActiveFedora::Base
|
|
7
|
-
include Hydra::
|
|
7
|
+
include Hydra::Works::GenericWorkBehavior
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
after(:all) do
|
|
@@ -14,6 +14,7 @@ describe Collection, :type => :model do
|
|
|
14
14
|
|
|
15
15
|
let(:gf1) { GenericFile.create }
|
|
16
16
|
let(:gf2) { GenericFile.create }
|
|
17
|
+
let(:gf3) { GenericFile.create }
|
|
17
18
|
|
|
18
19
|
let(:user) { @user }
|
|
19
20
|
|
|
@@ -82,6 +83,13 @@ describe Collection, :type => :model do
|
|
|
82
83
|
subject.save
|
|
83
84
|
expect(subject.reload.members).to eq [gf1, gf2]
|
|
84
85
|
end
|
|
86
|
+
|
|
87
|
+
it "should allow multiple files to be added" do
|
|
88
|
+
subject.reload
|
|
89
|
+
subject.add_members [gf2.id, gf3.id]
|
|
90
|
+
subject.save
|
|
91
|
+
expect(subject.reload.members).to eq [gf1, gf2, gf3]
|
|
92
|
+
end
|
|
85
93
|
end
|
|
86
94
|
end
|
|
87
95
|
|
|
@@ -93,8 +101,8 @@ describe Collection, :type => :model do
|
|
|
93
101
|
end
|
|
94
102
|
|
|
95
103
|
it "allows files to be removed" do
|
|
96
|
-
# force the "
|
|
97
|
-
expect(gf1.
|
|
104
|
+
# force the "in_collections" to be cached:
|
|
105
|
+
expect(gf1.in_collections).to eq [subject]
|
|
98
106
|
|
|
99
107
|
# We need to ensure that deleting causes the collection to be flushed.
|
|
100
108
|
subject.reload.members.delete(gf1)
|
|
@@ -136,7 +144,7 @@ describe Collection, :type => :model do
|
|
|
136
144
|
end
|
|
137
145
|
|
|
138
146
|
class Member < ActiveFedora::Base
|
|
139
|
-
include Hydra::
|
|
147
|
+
include Hydra::Works::GenericWorkBehavior
|
|
140
148
|
end
|
|
141
149
|
end
|
|
142
150
|
after do
|
|
@@ -154,7 +162,7 @@ describe Collection, :type => :model do
|
|
|
154
162
|
|
|
155
163
|
it "have members that know about the collection" do
|
|
156
164
|
member.reload
|
|
157
|
-
expect(member.
|
|
165
|
+
expect(member.in_collections).to eq [collection]
|
|
158
166
|
end
|
|
159
167
|
end
|
|
160
168
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hydra-collections
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.0.0.
|
|
4
|
+
version: 6.0.0.rc1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Carolyn Cole
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-09-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: hydra-head
|
|
@@ -58,14 +58,14 @@ dependencies:
|
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '0.
|
|
61
|
+
version: '0.2'
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '0.
|
|
68
|
+
version: '0.2'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: engine_cart
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -218,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
218
218
|
version: 1.3.1
|
|
219
219
|
requirements: []
|
|
220
220
|
rubyforge_project:
|
|
221
|
-
rubygems_version: 2.4.
|
|
221
|
+
rubygems_version: 2.4.5.1
|
|
222
222
|
signing_key:
|
|
223
223
|
specification_version: 4
|
|
224
224
|
summary: A rails engine for managing Hydra Collections
|