curation_concerns 0.14.0.pre3 → 0.14.0.pre4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/actors/curation_concerns/file_set_actor.rb +5 -5
- data/app/controllers/concerns/curation_concerns/curation_concern_controller.rb +0 -1
- data/app/controllers/concerns/curation_concerns/file_sets_controller_behavior.rb +3 -3
- data/app/forms/curation_concerns/forms/collection_edit_form.rb +1 -1
- data/app/helpers/curation_concerns/url_helper.rb +1 -1
- data/app/indexers/curation_concerns/file_set_indexer.rb +0 -1
- data/app/indexers/curation_concerns/work_indexer.rb +0 -4
- data/app/jobs/import_url_job.rb +2 -2
- data/app/models/concerns/curation_concerns/file_set/belongs_to_works.rb +18 -16
- data/app/presenters/curation_concerns/presenter_factory.rb +1 -1
- data/app/services/curation_concerns/lock_manager.rb +1 -1
- data/curation_concerns.gemspec +0 -2
- data/lib/curation_concerns/name.rb +3 -3
- data/lib/curation_concerns/rails/routes.rb +2 -2
- data/lib/curation_concerns/version.rb +1 -1
- data/lib/generators/curation_concerns/models_generator.rb +0 -2
- data/lib/generators/curation_concerns/templates/config/redis_config.rb +0 -3
- data/lib/generators/curation_concerns/work/USAGE +1 -2
- data/lib/generators/curation_concerns/work/templates/README +3 -3
- data/spec/actors/curation_concerns/file_set_actor_spec.rb +3 -3
- data/spec/controllers/curation_concerns/file_sets_controller_spec.rb +1 -1
- data/spec/factories/generic_works.rb +1 -1
- data/spec/features/collection_spec.rb +0 -6
- data/spec/features/update_file_spec.rb +1 -1
- data/spec/models/file_set_spec.rb +1 -1
- metadata +2 -33
- data/lib/generators/curation_concerns/templates/config/resque-pool.yml +0 -1
- data/lib/generators/curation_concerns/templates/config/resque_config.rb +0 -6
- data/lib/tasks/resque.rake +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f26ce391fb38ff166cbb42ab25a0672e00c4afb
|
4
|
+
data.tar.gz: 147ccb6fca4723a76d739f63209605c6fc60dab1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6e502b77d4b2dceb8516c696bc0a79325eab35f666b642d279a329109cce3924973ccd489c214a084449130aad4f391f781c0f153f73b785c8dd94901821fb1
|
7
|
+
data.tar.gz: 34ecae91255788a87ff51aff846b1ecdaba2c68eb9456bec585a08315a8a6256e9ef9aa1d1424766ec79b262f5301831bb6be222791e9d63de91511103340cfa
|
@@ -143,12 +143,12 @@ module CurationConcerns
|
|
143
143
|
end
|
144
144
|
|
145
145
|
def unlink_from_work
|
146
|
-
work = file_set.
|
146
|
+
work = file_set.parent
|
147
147
|
return unless work && (work.thumbnail_id == file_set.id || work.representative_id == file_set.id)
|
148
|
-
# This is required to clear the thumbnail_id and representative_id
|
149
|
-
# and force it to be re-solrized. Although
|
150
|
-
# children nodes it leaves the
|
151
|
-
# fields in Solr populated.
|
148
|
+
# This is required to clear the thumbnail_id and representative_id
|
149
|
+
# fields on the work and force it to be re-solrized. Although
|
150
|
+
# ActiveFedora clears the children nodes it leaves the work's
|
151
|
+
# thumbnail_id and representative_id fields in Solr populated.
|
152
152
|
work.thumbnail = nil if work.thumbnail_id == file_set.id
|
153
153
|
work.representative = nil if work.representative_id == file_set.id
|
154
154
|
work.save!
|
@@ -70,7 +70,7 @@ module CurationConcerns
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def destroy
|
73
|
-
parent = @file_set.
|
73
|
+
parent = @file_set.parent
|
74
74
|
actor.destroy
|
75
75
|
redirect_to [main_app, parent], notice: 'The file has been deleted.'
|
76
76
|
end
|
@@ -194,7 +194,7 @@ module CurationConcerns
|
|
194
194
|
if request.xhr?
|
195
195
|
render 'jq_upload', formats: 'json', content_type: 'text/html'
|
196
196
|
else
|
197
|
-
redirect_to [main_app, @file_set.
|
197
|
+
redirect_to [main_app, @file_set.parent]
|
198
198
|
end
|
199
199
|
end
|
200
200
|
format.json do
|
@@ -204,7 +204,7 @@ module CurationConcerns
|
|
204
204
|
else
|
205
205
|
msg = @file_set.errors.full_messages.join(', ')
|
206
206
|
flash[:error] = msg
|
207
|
-
json_error "Error creating
|
207
|
+
json_error "Error creating file #{file.original_filename}: #{msg}"
|
208
208
|
end
|
209
209
|
end
|
210
210
|
|
@@ -18,7 +18,7 @@ module CurationConcerns
|
|
18
18
|
model_class.validators_on(key).any? { |v| v.is_a? ActiveModel::Validations::PresenceValidator }
|
19
19
|
end
|
20
20
|
|
21
|
-
# @return [Hash] All
|
21
|
+
# @return [Hash] All FileSets in the collection, file.to_s is the key, file.id is the value
|
22
22
|
def select_files
|
23
23
|
Hash[all_files]
|
24
24
|
end
|
@@ -10,7 +10,7 @@ module CurationConcerns
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
# generated
|
13
|
+
# generated models get registered as curation concerns and need a
|
14
14
|
# track_model_path to render Blacklight-related views
|
15
15
|
(['FileSet', 'Collection'] + CurationConcerns.config.registered_curation_concern_types).each do |concern|
|
16
16
|
define_method("track_#{concern.constantize.model_name.singular_route_key}_path") { |*args| main_app.track_solr_document_path(*args) }
|
@@ -14,7 +14,6 @@ module CurationConcerns
|
|
14
14
|
solr_doc[Solrizer.solr_name('file_format', :facetable)] = file_format
|
15
15
|
solr_doc[Solrizer.solr_name(:file_size, STORED_INTEGER)] = object.file_size[0]
|
16
16
|
solr_doc['all_text_timv'] = object.full_text.content
|
17
|
-
solr_doc[Solrizer.solr_name('generic_work_ids', :symbol)] = object.generic_work_ids unless object.generic_work_ids.empty?
|
18
17
|
solr_doc['height_is'] = Integer(object.height.first) if object.height.present?
|
19
18
|
solr_doc['width_is'] = Integer(object.width.first) if object.width.present?
|
20
19
|
solr_doc[Solrizer.solr_name('mime_type', :stored_sortable)] = object.mime_type
|
@@ -3,10 +3,6 @@ module CurationConcerns
|
|
3
3
|
include IndexesThumbnails
|
4
4
|
def generate_solr_document
|
5
5
|
super.tap do |solr_doc|
|
6
|
-
# We know that all the members of GenericWorks are FileSets so we can use
|
7
|
-
# member_ids which requires fewer Fedora API calls than file_set_ids.
|
8
|
-
# file_set_ids requires loading all the members from Fedora but member_ids
|
9
|
-
# looks just at solr
|
10
6
|
solr_doc[Solrizer.solr_name('member_ids', :symbol)] = object.member_ids
|
11
7
|
Solrizer.set_field(solr_doc, 'generic_type', 'Work', :facetable)
|
12
8
|
end
|
data/app/jobs/import_url_job.rb
CHANGED
@@ -17,10 +17,10 @@ class ImportUrlJob < ActiveJob::Base
|
|
17
17
|
Tempfile.open(file_set.id.tr('/', '_')) do |f|
|
18
18
|
copy_remote_file(file_set, f)
|
19
19
|
|
20
|
-
# reload the
|
20
|
+
# reload the FileSet once the data is copied since this is a long running task
|
21
21
|
file_set.reload
|
22
22
|
|
23
|
-
# attach downloaded file to
|
23
|
+
# attach downloaded file to FileSet stubbed out
|
24
24
|
if CurationConcerns::FileSetActor.new(file_set, user).create_content(f)
|
25
25
|
# send message to user on download success
|
26
26
|
CurationConcerns.config.callback.run(:after_import_url_success, file_set, user)
|
@@ -7,19 +7,14 @@ module CurationConcerns
|
|
7
7
|
before_destroy :remove_representative_relationship
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
# OPTIMIZE: We can load this from Solr much faster than loading the objects
|
15
|
-
def generic_work_ids
|
16
|
-
generic_works.map(&:id)
|
10
|
+
def parents
|
11
|
+
in_works
|
17
12
|
end
|
18
13
|
|
19
14
|
# Returns the first parent object
|
20
15
|
# This is a hack to handle things like FileSets inheriting access controls from their parent. (see CurationConcerns::ParentContainer in app/controllers/concerns/curation_concers/parent_container.rb)
|
21
16
|
def parent
|
22
|
-
|
17
|
+
parents.first
|
23
18
|
end
|
24
19
|
|
25
20
|
# Returns the id of first parent object
|
@@ -27,21 +22,28 @@ module CurationConcerns
|
|
27
22
|
delegate :id, to: :parent, prefix: true
|
28
23
|
|
29
24
|
# Files with sibling relationships
|
30
|
-
# Returns all FileSets aggregated by any of the
|
25
|
+
# Returns all FileSets aggregated by any of the parent objects that
|
26
|
+
# aggregate the current object
|
31
27
|
def related_files
|
32
|
-
|
33
|
-
return [] if
|
34
|
-
|
28
|
+
parent_objects = parents
|
29
|
+
return [] if parent_objects.empty?
|
30
|
+
parent_objects.flat_map do |work|
|
31
|
+
work.file_sets.select do |file_set|
|
32
|
+
file_set.id != id
|
33
|
+
end
|
34
|
+
end
|
35
35
|
end
|
36
36
|
|
37
|
-
# If any parent
|
37
|
+
# If any parent objects are pointing at this object as their
|
38
|
+
# representative, remove that pointer.
|
38
39
|
def remove_representative_relationship
|
39
|
-
|
40
|
-
return if
|
41
|
-
|
40
|
+
parent_objects = parents
|
41
|
+
return if parent_objects.empty?
|
42
|
+
parent_objects.each do |work|
|
42
43
|
work.update(representative_id: nil) if work.representative_id == id
|
43
44
|
end
|
44
45
|
end
|
45
46
|
end
|
46
47
|
end
|
47
48
|
end
|
49
|
+
\
|
@@ -3,7 +3,7 @@ module CurationConcerns
|
|
3
3
|
class << self
|
4
4
|
# @param [Array] ids the list of ids to load
|
5
5
|
# @param [Class] klass the class of presenter to make
|
6
|
-
# @return [Array] presenters for the
|
6
|
+
# @return [Array] presenters for the documents in order of the ids
|
7
7
|
def build_presenters(ids, klass, ability)
|
8
8
|
new(ids, klass, ability).build
|
9
9
|
end
|
data/curation_concerns.gemspec
CHANGED
@@ -31,8 +31,6 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_dependency 'active_attr'
|
32
32
|
spec.add_dependency 'hydra-works', '~> 0.8', '>= 0.8.1'
|
33
33
|
spec.add_dependency 'active_fedora-noid', '~> 1.0'
|
34
|
-
spec.add_dependency 'resque', '~> 1.23'
|
35
|
-
spec.add_dependency 'resque-pool', '~> 0.3'
|
36
34
|
spec.add_dependency 'qa', '~> 0.5'
|
37
35
|
spec.add_dependency 'redlock', '~> 0.1.2'
|
38
36
|
spec.add_dependency 'solrizer', '~> 3.4'
|
@@ -3,11 +3,11 @@ module CurationConcerns
|
|
3
3
|
# without changing the param key.
|
4
4
|
#
|
5
5
|
# Example:
|
6
|
-
# name = CurationConcerns::Name.new(
|
6
|
+
# name = CurationConcerns::Name.new(MyWork)
|
7
7
|
# name.param_key
|
8
|
-
# # => '
|
8
|
+
# # => 'my_work'
|
9
9
|
# name.route_key
|
10
|
-
# # => '
|
10
|
+
# # => 'curation_concerns_my_works'
|
11
11
|
#
|
12
12
|
class Name < ActiveModel::Name
|
13
13
|
def initialize(klass, namespace = nil, name = nil)
|
@@ -71,9 +71,9 @@ module ActionDispatch::Routing
|
|
71
71
|
ROUTE_OPTIONS = { 'curation_concerns' => { path: :concern } }.freeze
|
72
72
|
|
73
73
|
# Namespaces routes appropriately
|
74
|
-
# @example namespaced_resources("curation_concerns/
|
74
|
+
# @example namespaced_resources("curation_concerns/my_work") is equivalent to
|
75
75
|
# namespace "curation_concerns", path: :concern do
|
76
|
-
# resources "
|
76
|
+
# resources "my_work", except: [:index]
|
77
77
|
# end
|
78
78
|
def namespaced_resources(target, opts = {}, &block)
|
79
79
|
if target.include?('/')
|
@@ -43,9 +43,7 @@ This generator makes the following changes to your application:
|
|
43
43
|
"\nMime::Type.register 'application/x-endnote-refer', :endnote", verbose: false
|
44
44
|
copy_file 'config/curation_concerns.rb', 'config/initializers/curation_concerns.rb'
|
45
45
|
copy_file 'config/redis.yml', 'config/redis.yml'
|
46
|
-
copy_file 'config/resque-pool.yml', 'config/resque-pool.yml'
|
47
46
|
copy_file 'config/redis_config.rb', 'config/initializers/redis_config.rb'
|
48
|
-
copy_file 'config/resque_config.rb', 'config/initializers/resque_config.rb'
|
49
47
|
end
|
50
48
|
|
51
49
|
def create_collection
|
@@ -4,9 +4,9 @@ After creating your work you may wish to:
|
|
4
4
|
|
5
5
|
1. Add custom views:
|
6
6
|
|
7
|
-
|
8
|
-
CurationConcerns::
|
9
|
-
|
7
|
+
By default, the views found in
|
8
|
+
CurationConcerns::Engine.root/app/views/curation_concerns/base
|
9
|
+
will be used.
|
10
10
|
|
11
11
|
2. Modify the model, actor, form or presenter.
|
12
12
|
|
@@ -30,15 +30,15 @@ describe CurationConcerns::FileSetActor do
|
|
30
30
|
|
31
31
|
context 'when a work is not provided' do
|
32
32
|
it "leaves the association blank" do
|
33
|
-
expect(subject.
|
33
|
+
expect(subject.parents).to be_empty
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
context 'when a work is provided' do
|
38
38
|
let(:work) { create(:generic_work) }
|
39
39
|
|
40
|
-
it 'adds the
|
41
|
-
expect(subject.
|
40
|
+
it 'adds the FileSet to the parent work' do
|
41
|
+
expect(subject.parents).to eq [work]
|
42
42
|
expect(work.reload.file_sets).to include(subject)
|
43
43
|
|
44
44
|
# Confirming that date_uploaded and date_modified were set
|
@@ -81,7 +81,7 @@ describe CurationConcerns::FileSetsController do
|
|
81
81
|
it 'errors out of create after on continuous rsolr error' do
|
82
82
|
xhr :post, :create, parent_id: parent, file_set: { files: [file] },
|
83
83
|
permission: { group: { 'public' => 'read' } }, terms_of_service: '1'
|
84
|
-
expect(response.body).to include('Error creating
|
84
|
+
expect(response.body).to include('Error creating file image.png')
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
@@ -19,7 +19,7 @@ FactoryGirl.define do
|
|
19
19
|
|
20
20
|
factory :work_with_one_file do
|
21
21
|
before(:create) do |work, evaluator|
|
22
|
-
work.ordered_members << FactoryGirl.create(:file_set, user: evaluator.user, title: ['A Contained
|
22
|
+
work.ordered_members << FactoryGirl.create(:file_set, user: evaluator.user, title: ['A Contained FileSet'], filename: 'filename.pdf')
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -12,13 +12,7 @@ feature 'collection' do
|
|
12
12
|
let(:gw1) { create(:generic_work, user: user, title: ['First test work']) }
|
13
13
|
let(:gw2) { create(:generic_work, user: user, title: ['Second test work']) }
|
14
14
|
|
15
|
-
before(:all) do
|
16
|
-
@old_resque_inline_value = Resque.inline
|
17
|
-
Resque.inline = true
|
18
|
-
end
|
19
|
-
|
20
15
|
after(:all) do
|
21
|
-
Resque.inline = @old_resque_inline_value
|
22
16
|
GenericWork.destroy_all
|
23
17
|
Collection.destroy_all
|
24
18
|
end
|
@@ -20,7 +20,7 @@ feature 'Editing attached files' do
|
|
20
20
|
attach_file('Upload a file', fixture_file_path('files/image.png'))
|
21
21
|
click_button 'Update Attached File'
|
22
22
|
|
23
|
-
expect(page).to have_content 'The file A Contained
|
23
|
+
expect(page).to have_content 'The file A Contained FileSet has been updated.'
|
24
24
|
|
25
25
|
# TODO: this stuff belongs in an Actor or Controller test:
|
26
26
|
file_set.reload
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: curation_concerns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.14.0.
|
4
|
+
version: 0.14.0.pre4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Zumwalt
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-05-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hydra-head
|
@@ -200,34 +200,6 @@ dependencies:
|
|
200
200
|
- - "~>"
|
201
201
|
- !ruby/object:Gem::Version
|
202
202
|
version: '1.0'
|
203
|
-
- !ruby/object:Gem::Dependency
|
204
|
-
name: resque
|
205
|
-
requirement: !ruby/object:Gem::Requirement
|
206
|
-
requirements:
|
207
|
-
- - "~>"
|
208
|
-
- !ruby/object:Gem::Version
|
209
|
-
version: '1.23'
|
210
|
-
type: :runtime
|
211
|
-
prerelease: false
|
212
|
-
version_requirements: !ruby/object:Gem::Requirement
|
213
|
-
requirements:
|
214
|
-
- - "~>"
|
215
|
-
- !ruby/object:Gem::Version
|
216
|
-
version: '1.23'
|
217
|
-
- !ruby/object:Gem::Dependency
|
218
|
-
name: resque-pool
|
219
|
-
requirement: !ruby/object:Gem::Requirement
|
220
|
-
requirements:
|
221
|
-
- - "~>"
|
222
|
-
- !ruby/object:Gem::Version
|
223
|
-
version: '0.3'
|
224
|
-
type: :runtime
|
225
|
-
prerelease: false
|
226
|
-
version_requirements: !ruby/object:Gem::Requirement
|
227
|
-
requirements:
|
228
|
-
- - "~>"
|
229
|
-
- !ruby/object:Gem::Version
|
230
|
-
version: '0.3'
|
231
203
|
- !ruby/object:Gem::Dependency
|
232
204
|
name: qa
|
233
205
|
requirement: !ruby/object:Gem::Requirement
|
@@ -1010,8 +982,6 @@ files:
|
|
1010
982
|
- lib/generators/curation_concerns/templates/config/mime_types.rb
|
1011
983
|
- lib/generators/curation_concerns/templates/config/redis.yml
|
1012
984
|
- lib/generators/curation_concerns/templates/config/redis_config.rb
|
1013
|
-
- lib/generators/curation_concerns/templates/config/resque-pool.yml
|
1014
|
-
- lib/generators/curation_concerns/templates/config/resque_config.rb
|
1015
985
|
- lib/generators/curation_concerns/templates/curation_concerns.js
|
1016
986
|
- lib/generators/curation_concerns/templates/curation_concerns.scss
|
1017
987
|
- lib/generators/curation_concerns/templates/curation_concerns_helper.rb
|
@@ -1033,7 +1003,6 @@ files:
|
|
1033
1003
|
- lib/generators/curation_concerns/work/work_generator.rb
|
1034
1004
|
- lib/tasks/curation_concerns.rake
|
1035
1005
|
- lib/tasks/migrate.rake
|
1036
|
-
- lib/tasks/resque.rake
|
1037
1006
|
- lib/tasks/solr_reindex.rake
|
1038
1007
|
- solr/config/_rest_managed.json
|
1039
1008
|
- solr/config/admin-extra.html
|
@@ -1 +0,0 @@
|
|
1
|
-
"*": 1
|
@@ -1,6 +0,0 @@
|
|
1
|
-
require 'resque'
|
2
|
-
config = YAML.load(ERB.new(IO.read(File.join(Rails.root, 'config', 'redis.yml'))).result)[Rails.env].with_indifferent_access
|
3
|
-
Resque.redis = Redis.new(host: config[:host], port: config[:port], thread_safe: true)
|
4
|
-
|
5
|
-
Resque.inline = Rails.env.test?
|
6
|
-
Resque.redis.namespace = "#{CurationConcerns.config.redis_namespace}:#{Rails.env}"
|
data/lib/tasks/resque.rake
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'resque/pool/tasks'
|
2
|
-
|
3
|
-
# This provides access to the Rails env within all Resque workers
|
4
|
-
task 'resque:setup' => :environment
|
5
|
-
|
6
|
-
# Set up resque-pool
|
7
|
-
task 'resque:pool:setup' do
|
8
|
-
ActiveRecord::Base.connection.disconnect!
|
9
|
-
require 'resque/pool'
|
10
|
-
Resque::Pool.after_prefork do |job|
|
11
|
-
ActiveRecord::Base.establish_connection
|
12
|
-
Resque.redis.client.reconnect
|
13
|
-
end
|
14
|
-
end
|