hydra-collections 6.0.0.alpha → 6.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a55e2a03471e0659271fbbbc73f0dd6233119390
4
- data.tar.gz: 872f3f1d0fc426e335b870b1384ebd71d0c8ba78
3
+ metadata.gz: f660059815d3e4687d927cbfebc290aa43b1c029
4
+ data.tar.gz: 3eec16c408c10c7f08d9f4c77a52ec6ea9555619
5
5
  SHA512:
6
- metadata.gz: 4a029879709867b6df79503628696e37bcdb5e68ef69abbae331266ffdc2b604a66c6632c9f53dae9f0b7441b6441228866b868c6551d60c606e3abef51929bc
7
- data.tar.gz: de9b2cbbe3e68940bf208d8ff90db132ddfecd6adc1a8f3f785514b614d63078041125d2b959baa7d1a6dfde7d1b82d1057a4f7e9b0970398aba52248085b383
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::Collections::Collectible` to the models for anything that you want to be able to add to collections (ie. GenericFile, Book, Article, etc.), then add `index_collection_ids` to the solrization logic (ie. put it in to_solr)
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::Collections::Collectible
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::Collections::Collectible` module can look up which collections they belong to via `.collections`. The `index_collection_ids` puts the ids of all associated collections into the `collection` facet.
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
- # add one of the following methods as a before filter on any page that shows the form_for_select_collection
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
- def find_collections_with_edit_access
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
- batch.each do |id|
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
 
@@ -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.1'
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 parent_collections.map(&:id) instead.")
16
- parent_collections.map(&:id)
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 parent_collections instead.")
21
- parent_collections
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
@@ -1,5 +1,5 @@
1
1
  module Hydra
2
2
  module Collections
3
- VERSION = "6.0.0.alpha"
3
+ VERSION = "6.0.0.rc1"
4
4
  end
5
5
  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.parent_collections).to eq [@collection]
205
+ expect(asset1.in_collections).to eq [@collection]
206
206
 
207
207
  delete :destroy, id: @collection
208
- expect(asset1.parent_collections).to eq []
208
+ expect(asset1.in_collections).to eq []
209
209
  end
210
210
  end
211
211
 
@@ -8,7 +8,7 @@ describe OtherCollectionsController, :type => :controller do
8
8
  end
9
9
 
10
10
  class Member < ActiveFedora::Base
11
- include Hydra::Collections::Collectible
11
+ include Hydra::Works::GenericWorkBehavior
12
12
  include Hydra::AccessControls::Permissions
13
13
  end
14
14
  end
@@ -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::Collections::Collectible
65
+ include Hydra::Works::GenericWorkBehavior
66
66
  end
67
67
 
68
68
  @collection = OtherCollection.create
@@ -17,6 +17,7 @@ describe Hydra::Collections::Collectible do
17
17
 
18
18
  describe "collections associations" do
19
19
  before do
20
+ allow(Deprecation).to receive(:warn)
20
21
  collection1.members << collectible
21
22
  collection1.save
22
23
  collection2.members << collectible
@@ -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::Collections::Collectible
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 "parent_collections" to be cached:
97
- expect(gf1.parent_collections).to eq [subject]
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::Collections::Collectible
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.collections).to eq [collection]
165
+ expect(member.in_collections).to eq [collection]
158
166
  end
159
167
  end
160
168
  end
@@ -1 +1,2 @@
1
1
  gem 'kaminari', github: 'jcoyne/kaminari', branch: 'sufia'
2
+ gem 'active-fedora', github: 'projecthydra/active_fedora'
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.alpha
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-08-11 00:00:00.000000000 Z
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.1'
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.1'
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.3
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