curation_concerns 0.12.0.pre5 → 0.12.0.pre6
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/actors/curation_concerns/file_actor.rb +1 -1
- data/app/jobs/ingest_file_job.rb +2 -3
- data/app/jobs/ingest_local_file_job.rb +7 -8
- data/app/models/concerns/curation_concerns/ability.rb +2 -0
- data/app/presenters/curation_concerns/work_show_presenter.rb +22 -5
- data/app/search_builders/curation_concerns/search_filters.rb +1 -1
- data/lib/curation_concerns/version.rb +1 -1
- data/spec/actors/curation_concerns/file_actor_spec.rb +1 -1
- data/spec/actors/curation_concerns/file_set_actor_spec.rb +3 -3
- data/spec/jobs/ingest_file_job_spec.rb +1 -1
- data/spec/jobs/ingest_local_file_job_spec.rb +1 -3
- data/spec/presenters/curation_concerns/work_show_presenter_spec.rb +16 -0
- data/spec/search_builders/curation_concerns/search_builder_spec.rb +1 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f36dfe3aa91727d022c395d9ecf77afab2d5843
|
4
|
+
data.tar.gz: 3d33f42c2909c683f78f23557b70a121649fdc59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f89a1474a4e438832ce73090e9ca5bdc1d88a705305b6a276d87685e21392ee8bb079034da146f9f8e7b0854d738b314a51d2cce43c433095653bf153676205
|
7
|
+
data.tar.gz: 9f726193ec1c8ac22c741a8ce7ecb4a272c1491781c5d83f2e53c129aca5b33d9618f95d0b2876dc98559a6c36b0e1c289734b6c6c0e9e9399a012486404a1f5
|
@@ -21,7 +21,7 @@ module CurationConcerns
|
|
21
21
|
def ingest_file(file)
|
22
22
|
working_file = copy_file_to_working_directory(file, file_set.id)
|
23
23
|
mime_type = file.respond_to?(:content_type) ? file.content_type : nil
|
24
|
-
IngestFileJob.perform_later(file_set, working_file, mime_type, user
|
24
|
+
IngestFileJob.perform_later(file_set, working_file, mime_type, user, relation)
|
25
25
|
make_derivative(file_set, working_file)
|
26
26
|
true
|
27
27
|
end
|
data/app/jobs/ingest_file_job.rb
CHANGED
@@ -4,9 +4,9 @@ class IngestFileJob < ActiveJob::Base
|
|
4
4
|
# @param [FileSet] file_set
|
5
5
|
# @param [String] filename
|
6
6
|
# @param [String,NilClass] mime_type
|
7
|
-
# @param [
|
7
|
+
# @param [User] user
|
8
8
|
# @param [String] relation ('original_file')
|
9
|
-
def perform(file_set, filename, mime_type,
|
9
|
+
def perform(file_set, filename, mime_type, user, relation = 'original_file')
|
10
10
|
file = File.open(filename, "rb")
|
11
11
|
# If mime-type is known, wrap in an IO decorator
|
12
12
|
# Otherwise allow Hydra::Works service to determine mime_type
|
@@ -23,7 +23,6 @@ class IngestFileJob < ActiveJob::Base
|
|
23
23
|
file_set.save!
|
24
24
|
|
25
25
|
# Do post file ingest actions
|
26
|
-
user = User.find_by_user_key(user_key)
|
27
26
|
CurationConcerns::VersioningService.create(file_set.send(relation.to_sym), user)
|
28
27
|
CurationConcerns.config.callback.run(:after_create_content, file_set, user)
|
29
28
|
end
|
@@ -1,20 +1,19 @@
|
|
1
1
|
class IngestLocalFileJob < ActiveJob::Base
|
2
2
|
queue_as :ingest_local
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
file_set.label ||=
|
9
|
-
path = File.join(directory, filename)
|
4
|
+
# @param [FileSet] file_set
|
5
|
+
# @param [String] path
|
6
|
+
# @param [User] user
|
7
|
+
def perform(file_set, path, user)
|
8
|
+
file_set.label ||= File.basename(path)
|
10
9
|
|
11
10
|
actor = CurationConcerns::FileSetActor.new(file_set, user)
|
12
11
|
|
13
12
|
if actor.create_content(File.open(path))
|
14
13
|
FileUtils.rm(path)
|
15
|
-
CurationConcerns.config.callback.run(:after_import_local_file_success, file_set, user,
|
14
|
+
CurationConcerns.config.callback.run(:after_import_local_file_success, file_set, user, path)
|
16
15
|
else
|
17
|
-
CurationConcerns.config.callback.run(:after_import_local_file_failure, file_set, user,
|
16
|
+
CurationConcerns.config.callback.run(:after_import_local_file_failure, file_set, user, path)
|
18
17
|
end
|
19
18
|
end
|
20
19
|
end
|
@@ -4,6 +4,14 @@ module CurationConcerns
|
|
4
4
|
include PresentsAttributes
|
5
5
|
attr_accessor :solr_document, :current_ability
|
6
6
|
|
7
|
+
class_attribute :collection_presenter_class, :file_presenter_class
|
8
|
+
|
9
|
+
# modify this attribute to use an alternate presenter class for the collections
|
10
|
+
self.collection_presenter_class = CollectionPresenter
|
11
|
+
|
12
|
+
# modify this attribute to use an alternate presenter class for the files
|
13
|
+
self.file_presenter_class = FileSetPresenter
|
14
|
+
|
7
15
|
# @param [SolrDocument] solr_document
|
8
16
|
# @param [Ability] current_ability
|
9
17
|
def initialize(solr_document, current_ability)
|
@@ -43,8 +51,22 @@ module CurationConcerns
|
|
43
51
|
current_ability)
|
44
52
|
end
|
45
53
|
|
54
|
+
# @return [Array<CollectionPresenter>] presenters for the collections that this work is a member of
|
55
|
+
def collection_presenters
|
56
|
+
PresenterFactory.build_presenters(in_collection_ids,
|
57
|
+
collection_presenter_class,
|
58
|
+
current_ability)
|
59
|
+
end
|
60
|
+
|
46
61
|
private
|
47
62
|
|
63
|
+
# @return [Array<String>] ids of the collections that this work is a member of
|
64
|
+
def in_collection_ids
|
65
|
+
ActiveFedora::SolrService.query("{!field f=ordered_targets_ssim}#{id}",
|
66
|
+
fl: 'proxy_in_ssi')
|
67
|
+
.map { |x| x.fetch('proxy_in_ssi') }
|
68
|
+
end
|
69
|
+
|
48
70
|
# TODO: Extract this to ActiveFedora::Aggregations::ListSource
|
49
71
|
def ordered_ids
|
50
72
|
ActiveFedora::SolrService.query("proxy_in_ssi:#{id}",
|
@@ -60,10 +82,5 @@ module CurationConcerns
|
|
60
82
|
fq: "{!join from=ordered_targets_ssim to=id}id:\"#{id}/list_source\"")
|
61
83
|
.flat_map { |x| x.fetch("id", []) }
|
62
84
|
end
|
63
|
-
|
64
|
-
# Override this method if you want to use an alternate presenter class for the files
|
65
|
-
def file_presenter_class
|
66
|
-
FileSetPresenter
|
67
|
-
end
|
68
85
|
end
|
69
86
|
end
|
@@ -6,7 +6,7 @@ module CurationConcerns::SearchFilters
|
|
6
6
|
# Override Hydra::AccessControlsEnforcement (or Hydra::PolicyAwareAccessControlsEnforcement)
|
7
7
|
# Allows admin users to see everything (don't apply any gated_discovery_filters for those users)
|
8
8
|
def gated_discovery_filters(permission_types = discovery_permissions, ability = current_ability)
|
9
|
-
return [] if ability.
|
9
|
+
return [] if ability.admin?
|
10
10
|
super
|
11
11
|
end
|
12
12
|
|
@@ -11,7 +11,7 @@ describe CurationConcerns::FileActor do
|
|
11
11
|
describe '#ingest_file' do
|
12
12
|
it 'calls ingest file job' do
|
13
13
|
expect(CharacterizeJob).to receive(:perform_later)
|
14
|
-
expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png$/, 'image/png', user
|
14
|
+
expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png$/, 'image/png', user, 'remastered')
|
15
15
|
actor.ingest_file(uploaded_file)
|
16
16
|
end
|
17
17
|
end
|
@@ -22,7 +22,7 @@ describe CurationConcerns::FileSetActor do
|
|
22
22
|
|
23
23
|
before do
|
24
24
|
expect(CharacterizeJob).to receive(:perform_later)
|
25
|
-
expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png$/, 'image/png', user
|
25
|
+
expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png$/, 'image/png', user, 'original_file')
|
26
26
|
allow(actor).to receive(:acquire_lock_for).and_yield
|
27
27
|
actor.create_metadata(work)
|
28
28
|
actor.create_content(uploaded_file)
|
@@ -68,14 +68,14 @@ describe CurationConcerns::FileSetActor do
|
|
68
68
|
describe '#create_content' do
|
69
69
|
it 'calls ingest file job' do
|
70
70
|
expect(CharacterizeJob).to receive(:perform_later)
|
71
|
-
expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png$/, 'image/png', user
|
71
|
+
expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png$/, 'image/png', user, 'original_file')
|
72
72
|
actor.create_content(uploaded_file)
|
73
73
|
end
|
74
74
|
|
75
75
|
context 'when an alternative relationship is specified' do
|
76
76
|
it 'calls ingest file job' do
|
77
77
|
expect(CharacterizeJob).to receive(:perform_later)
|
78
|
-
expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png$/, 'image/png', user
|
78
|
+
expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png$/, 'image/png', user, 'remastered')
|
79
79
|
actor.create_content(uploaded_file, 'remastered')
|
80
80
|
end
|
81
81
|
end
|
@@ -72,7 +72,7 @@ describe IngestFileJob do
|
|
72
72
|
subject { CurationConcerns.config.callback }
|
73
73
|
it 'runs with file_set and user arguments' do
|
74
74
|
expect(subject).to receive(:run).with(:after_create_content, file_set, user)
|
75
|
-
described_class.perform_now(file_set, filename, 'image/png', user
|
75
|
+
described_class.perform_now(file_set, filename, 'image/png', user)
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -4,7 +4,6 @@ describe IngestLocalFileJob do
|
|
4
4
|
let(:user) { create(:user) }
|
5
5
|
|
6
6
|
let(:file_set) { FileSet.new }
|
7
|
-
let(:file_set_id) { 'abc123' }
|
8
7
|
let(:actor) { double }
|
9
8
|
|
10
9
|
let(:mock_upload_directory) { 'spec/mock_upload_directory' }
|
@@ -12,12 +11,11 @@ describe IngestLocalFileJob do
|
|
12
11
|
before do
|
13
12
|
Dir.mkdir mock_upload_directory unless File.exist? mock_upload_directory
|
14
13
|
FileUtils.copy(File.expand_path('../../fixtures/world.png', __FILE__), mock_upload_directory)
|
15
|
-
allow(FileSet).to receive(:find).with(file_set_id).and_return(file_set)
|
16
14
|
allow(CurationConcerns::FileSetActor).to receive(:new).with(file_set, user).and_return(actor)
|
17
15
|
end
|
18
16
|
|
19
17
|
it 'has attached a file' do
|
20
18
|
expect(actor).to receive(:create_content).and_return(true)
|
21
|
-
described_class.perform_now(
|
19
|
+
described_class.perform_now(file_set, File.join(mock_upload_directory, 'world.png'), user)
|
22
20
|
end
|
23
21
|
end
|
@@ -99,6 +99,22 @@ describe CurationConcerns::WorkShowPresenter do
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
+
describe "#collection_presenters" do
|
103
|
+
let(:collection) { create(:collection) }
|
104
|
+
let(:obj) { create(:work) }
|
105
|
+
let(:attributes) { obj.to_solr }
|
106
|
+
|
107
|
+
before do
|
108
|
+
collection.ordered_members << obj
|
109
|
+
collection.save!
|
110
|
+
obj.save!
|
111
|
+
end
|
112
|
+
|
113
|
+
it "filters out members that are not file sets" do
|
114
|
+
expect(presenter.collection_presenters.map(&:id)).to eq [collection.id]
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
102
118
|
describe "#attribute_to_html" do
|
103
119
|
let(:presenter) { described_class.new(solr_document, ability) }
|
104
120
|
let(:renderer) { double('renderer') }
|
@@ -12,8 +12,7 @@ describe CurationConcerns::SearchBuilder do
|
|
12
12
|
describe '#gated_discovery_filters' do
|
13
13
|
before do
|
14
14
|
allow(subject).to receive(:current_ability).and_return(ability)
|
15
|
-
allow(ability).to receive(:
|
16
|
-
allow(user).to receive(:groups).and_return(['admin'])
|
15
|
+
allow(ability).to receive(:admin?).and_return(true)
|
17
16
|
end
|
18
17
|
|
19
18
|
it 'does not filter results for admin users' do
|
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.12.0.
|
4
|
+
version: 0.12.0.pre6
|
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-04-
|
13
|
+
date: 2016-04-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hydra-head
|