curation_concerns 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/VERSION +1 -1
- data/app/controllers/concerns/curation_concerns/file_sets_controller_behavior.rb +7 -0
- data/app/renderers/curation_concerns/attribute_renderer.rb +4 -2
- data/app/views/collections/_form_to_add_member.html.erb +1 -1
- data/app/views/curation_concerns/base/_show_actions.html.erb +4 -0
- data/lib/curation_concerns/engine.rb +6 -0
- data/lib/curation_concerns/version.rb +1 -1
- data/spec/controllers/curation_concerns/file_sets_controller_spec.rb +1 -0
- data/spec/indexers/collection_indexer_spec.rb +6 -5
- data/spec/jobs/import_url_job_spec.rb +0 -3
- data/spec/models/generic_work_spec.rb +10 -0
- data/spec/renderers/curation_concerns/attribute_renderer_spec.rb +17 -2
- data/spec/services/thumbnail_path_service_spec.rb +3 -3
- data/spec/test_app_templates/Gemfile.extra +5 -0
- data/spec/views/curation_concerns/base/_show_actions.html.erb_spec.rb +18 -0
- metadata +7 -23
- data/app/controllers/concerns/curation_concerns/upload_sets_controller_behavior.rb +0 -50
- data/app/controllers/upload_sets_controller.rb +0 -3
- data/app/forms/curation_concerns/upload_set_form.rb +0 -43
- data/app/views/upload_sets/_base_metadata.html.erb +0 -12
- data/app/views/upload_sets/_edit.js.erb +0 -15
- data/app/views/upload_sets/_metadata.html.erb +0 -40
- data/app/views/upload_sets/_more_metadata.html.erb +0 -7
- data/app/views/upload_sets/edit.html.erb +0 -26
- data/spec/controllers/upload_sets_controller_spec.rb +0 -69
- data/spec/forms/upload_set_form_spec.rb +0 -55
- data/spec/jobs/upload_set_update_job_spec.rb +0 -43
- data/spec/models/upload_set_spec.rb +0 -37
- data/spec/views/upload_sets/_metadata.html.erb_spec.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a85c8841cf6394c4589e461e3b59671377f44678
|
4
|
+
data.tar.gz: 575d68375d4f97744189ac4ab8183648b5483735
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e737b868fcec75f9ed65e2c4361a786b28fdf4516062c04293c47b35c91f954797e5f68a3b0a2fa64ba1ecbf742f7987b3dd1dff3f6fc2e546fb53a4ed7740d
|
7
|
+
data.tar.gz: 29ed236e0bebabe08927012b07c83b960b3522285571fd4e42b06d2151f8de98c3e3ada3e61b58a51b2256e7d36fdf4db19fb7075c3c1e6dc13a0075ac2d06b7
|
data/Gemfile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
@@ -61,6 +61,7 @@ module CurationConcerns
|
|
61
61
|
authorize! :show, @file_set
|
62
62
|
render :show, status: :ok
|
63
63
|
end
|
64
|
+
additional_response_formats(wants)
|
64
65
|
end
|
65
66
|
end
|
66
67
|
|
@@ -140,6 +141,12 @@ module CurationConcerns
|
|
140
141
|
@groups = current_user.groups
|
141
142
|
end
|
142
143
|
|
144
|
+
# Override this method to add additional response
|
145
|
+
# formats to your local app
|
146
|
+
def additional_response_formats(_)
|
147
|
+
# nop
|
148
|
+
end
|
149
|
+
|
143
150
|
def file_set_params
|
144
151
|
params.require(:file_set).permit(
|
145
152
|
:visibility_during_embargo, :embargo_release_date, :visibility_after_embargo, :visibility_during_lease, :lease_expiration_date, :visibility_after_lease, :visibility, title: [])
|
@@ -26,7 +26,7 @@ module CurationConcerns
|
|
26
26
|
markup << %(<tr><th>#{label}</th>\n<td><ul class='tabular'>)
|
27
27
|
attributes = microdata_object_attributes(field).merge(class: "attribute #{field}")
|
28
28
|
Array(values).each do |value|
|
29
|
-
markup << "<li#{html_attributes(attributes)}>#{attribute_value_to_html(value)}</li>"
|
29
|
+
markup << "<li#{html_attributes(attributes)}>#{attribute_value_to_html(value.to_s)}</li>"
|
30
30
|
end
|
31
31
|
markup << %(</ul></td></tr>)
|
32
32
|
markup.html_safe
|
@@ -43,8 +43,10 @@ module CurationConcerns
|
|
43
43
|
def attribute_value_to_html(value)
|
44
44
|
if field == :rights
|
45
45
|
rights_attribute_to_html(value)
|
46
|
-
|
46
|
+
elsif microdata_value_attributes(field).present?
|
47
47
|
"<span#{html_attributes(microdata_value_attributes(field))}>#{li_value(value)}</span>"
|
48
|
+
else
|
49
|
+
li_value(value)
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
@@ -16,6 +16,6 @@
|
|
16
16
|
</fieldset>
|
17
17
|
<div class="form-actions with-side-padding with-footroom">
|
18
18
|
<%= submit_tag "Add to collection", class: 'btn btn-primary' %>
|
19
|
-
<%= link_to 'Cancel', root_path, class: 'btn btn-default', data: { dismiss: 'modal' } %>
|
19
|
+
<%= link_to 'Cancel', main_app.root_path, class: 'btn btn-default', data: { dismiss: 'modal' } %>
|
20
20
|
</div>
|
21
21
|
<% end %>
|
@@ -5,5 +5,9 @@
|
|
5
5
|
<%= link_to "Attach a File", main_app.new_curation_concerns_file_set_path(@presenter), class: 'btn btn-default' %>
|
6
6
|
<%= link_to "Delete This #{@presenter.human_readable_type}", [main_app, @presenter], class: 'btn btn-danger pull-right', data: { confirm: "Delete this #{@presenter.human_readable_type}?" }, method: :delete %>
|
7
7
|
<% end %>
|
8
|
+
<% if collector %>
|
9
|
+
<%= render 'collections/add_to_collection_modal', collectible: @presenter %>
|
10
|
+
<%= link_to_select_collection @presenter, class: 'btn btn-primary' %>
|
11
|
+
<% end %>
|
8
12
|
</div>
|
9
13
|
<% end %>
|
@@ -23,5 +23,11 @@ module CurationConcerns
|
|
23
23
|
initializer 'curation_concerns.initialize' do
|
24
24
|
require 'curation_concerns/rails/routes'
|
25
25
|
end
|
26
|
+
|
27
|
+
initializer 'curation_concerns.assets.precompile' do |app|
|
28
|
+
app.config.assets.paths << config.root.join('app', 'assets', 'images')
|
29
|
+
|
30
|
+
app.config.assets.precompile += %w(*.png *.gif)
|
31
|
+
end
|
26
32
|
end
|
27
33
|
end
|
@@ -222,6 +222,7 @@ describe CurationConcerns::FileSetsController do
|
|
222
222
|
end
|
223
223
|
|
224
224
|
it 'allows access to public files' do
|
225
|
+
expect(controller).to receive(:additional_response_formats).with(ActionController::MimeResponds::Collector)
|
225
226
|
get :show, id: public_file_set
|
226
227
|
expect(response).to be_success
|
227
228
|
end
|
@@ -4,16 +4,17 @@ describe CurationConcerns::CollectionIndexer do
|
|
4
4
|
let(:indexer) { described_class.new(collection) }
|
5
5
|
let(:collection) { build(:collection) }
|
6
6
|
|
7
|
-
before { allow(collection).to receive(:bytes).and_return(1000) }
|
8
7
|
describe "#generate_solr_document" do
|
8
|
+
before do
|
9
|
+
allow(collection).to receive(:bytes).and_return(1000)
|
10
|
+
allow(CurationConcerns::ThumbnailPathService).to receive(:call).and_return("/downloads/1234?file=thumbnail")
|
11
|
+
end
|
9
12
|
subject { indexer.generate_solr_document }
|
10
13
|
|
11
|
-
it "has
|
14
|
+
it "has required fields" do
|
12
15
|
expect(subject.fetch('generic_type_sim')).to eq ["Collection"]
|
13
|
-
end
|
14
|
-
|
15
|
-
it "has bytes" do
|
16
16
|
expect(subject.fetch('bytes_is')).to eq(1000)
|
17
|
+
expect(subject.fetch('thumbnail_path_ss')).to eq "/downloads/1234?file=thumbnail"
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
@@ -41,9 +41,6 @@ describe ImportUrlJob do
|
|
41
41
|
let(:title) { { file_set.id => ['File One'] } }
|
42
42
|
let(:metadata) { {} }
|
43
43
|
let(:visibility) { nil }
|
44
|
-
|
45
|
-
let(:upload_set) { UploadSet.create }
|
46
|
-
let(:upload_set_job) { UploadSetUpdateJob.perform_now(user.user_key, upload_set.id, title, metadata, visibility) }
|
47
44
|
let(:file_set_id) { file_set.id }
|
48
45
|
|
49
46
|
before do
|
@@ -46,4 +46,14 @@ describe GenericWork do
|
|
46
46
|
subject { work.to_partial_path }
|
47
47
|
it { is_expected.to eq 'generic_works/generic_work' }
|
48
48
|
end
|
49
|
+
|
50
|
+
describe "#destroy" do
|
51
|
+
let!(:work) { create(:work_with_files) }
|
52
|
+
it "doesn't save the work after removing each individual file" do
|
53
|
+
expect_any_instance_of(described_class).not_to receive(:save!)
|
54
|
+
expect {
|
55
|
+
work.destroy
|
56
|
+
}.to change { FileSet.count }.by(-2)
|
57
|
+
end
|
58
|
+
end
|
49
59
|
end
|
@@ -12,22 +12,37 @@ describe CurationConcerns::AttributeRenderer do
|
|
12
12
|
I18n.load_path -= Dir[File.join(yml_path)]
|
13
13
|
I18n.reload!
|
14
14
|
end
|
15
|
+
|
15
16
|
describe "#attribute_to_html" do
|
16
17
|
subject { Nokogiri::HTML(renderer.render) }
|
17
18
|
let(:expected) { Nokogiri::HTML(tr_content) }
|
19
|
+
|
18
20
|
context 'without microdata enabled' do
|
19
21
|
before do
|
20
22
|
CurationConcerns.config.display_microdata = false
|
21
23
|
end
|
22
24
|
let(:tr_content) {
|
23
25
|
"<tr><th>Name</th>\n" \
|
24
|
-
"<td><ul class='tabular'><li class=\"attribute name\"
|
25
|
-
"<li class=\"attribute name\"
|
26
|
+
"<td><ul class='tabular'><li class=\"attribute name\">Bob</li>\n" \
|
27
|
+
"<li class=\"attribute name\">Jessica</li>\n" \
|
26
28
|
"</ul></td></tr>"
|
27
29
|
}
|
28
30
|
it { expect(renderer).not_to be_microdata(field) }
|
29
31
|
it { expect(subject).to be_equivalent_to(expected) }
|
30
32
|
end
|
33
|
+
|
34
|
+
context 'with an integer attribute' do
|
35
|
+
let(:field) { :height }
|
36
|
+
let(:renderer) { described_class.new(field, [567]) }
|
37
|
+
let(:tr_content) do
|
38
|
+
"<tr><th>Height</th>\n" \
|
39
|
+
"<td><ul class='tabular'><li class=\"attribute height\">567</li>\n" \
|
40
|
+
"</ul></td></tr>"
|
41
|
+
end
|
42
|
+
|
43
|
+
it { expect(subject).to be_equivalent_to(expected) }
|
44
|
+
end
|
45
|
+
|
31
46
|
context 'with microdata enabled' do
|
32
47
|
before do
|
33
48
|
CurationConcerns.config.display_microdata = true
|
@@ -15,11 +15,11 @@ describe CurationConcerns::ThumbnailPathService do
|
|
15
15
|
|
16
16
|
context "that is an audio" do
|
17
17
|
let(:mime_type) { 'audio/x-wav' }
|
18
|
-
it { is_expected.to
|
18
|
+
it { is_expected.to match %r{/assets/audio-.+.png} }
|
19
19
|
end
|
20
20
|
|
21
21
|
context "that has no thumbnail" do
|
22
|
-
it { is_expected.to
|
22
|
+
it { is_expected.to match %r{/assets/default-.+.png} }
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -37,7 +37,7 @@ describe CurationConcerns::ThumbnailPathService do
|
|
37
37
|
|
38
38
|
context "that doesn't have a representative" do
|
39
39
|
let(:object) { FileSet.new }
|
40
|
-
it { is_expected.to
|
40
|
+
it { is_expected.to match %r{/assets/default-.+.png} }
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -2,3 +2,8 @@
|
|
2
2
|
# gem 'hydra-works', github: 'projecthydra-labs/hydra-works', branch: 'master'
|
3
3
|
# gem 'hydra-pcdm', github: 'projecthydra-labs/hydra-pcdm', branch: 'master'
|
4
4
|
# gem 'activefedora-aggregation', github: 'projecthydra-labs/activefedora-aggregation', branch: 'master'
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
gem 'better_errors'
|
8
|
+
gem 'binding_of_caller'
|
9
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'curation_concerns/base/show_actions' do
|
4
|
+
let(:model) { double('model', persisted?: true, to_param: '123', model_name: GenericWork.model_name) }
|
5
|
+
let(:presenter) { double("presenter", human_readable_type: 'Image', id: '123', to_model: model) }
|
6
|
+
before do
|
7
|
+
assign(:presenter, presenter)
|
8
|
+
render 'curation_concerns/base/show_actions.html.erb', collector: collector, editor: editor
|
9
|
+
end
|
10
|
+
|
11
|
+
context "as a collector" do
|
12
|
+
let(:editor) { true }
|
13
|
+
let(:collector) { true }
|
14
|
+
it "shows the add to collection link" do
|
15
|
+
expect(rendered).to have_link 'Add to a Collection'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
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.
|
4
|
+
version: 0.5.0
|
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:
|
13
|
+
date: 2016-01-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hydra-head
|
@@ -74,14 +74,14 @@ dependencies:
|
|
74
74
|
requirements:
|
75
75
|
- - '='
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: 0.
|
77
|
+
version: 0.5.0
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
82
|
- - '='
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version: 0.
|
84
|
+
version: 0.5.0
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
name: hydra-editor
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
@@ -399,7 +399,6 @@ files:
|
|
399
399
|
- app/controllers/concerns/curation_concerns/single_use_links_controller_behavior.rb
|
400
400
|
- app/controllers/concerns/curation_concerns/single_use_links_viewer_controller_behavior.rb
|
401
401
|
- app/controllers/concerns/curation_concerns/themed_layout_controller.rb
|
402
|
-
- app/controllers/concerns/curation_concerns/upload_sets_controller_behavior.rb
|
403
402
|
- app/controllers/concerns/curation_concerns/welcome_controller_behavior.rb
|
404
403
|
- app/controllers/curation_concerns/application_controller.rb
|
405
404
|
- app/controllers/curation_concerns/classify_concerns_controller.rb
|
@@ -410,12 +409,10 @@ files:
|
|
410
409
|
- app/controllers/downloads_controller.rb
|
411
410
|
- app/controllers/embargoes_controller.rb
|
412
411
|
- app/controllers/leases_controller.rb
|
413
|
-
- app/controllers/upload_sets_controller.rb
|
414
412
|
- app/controllers/welcome_controller.rb
|
415
413
|
- app/forms/curation_concerns/forms/collection_edit_form.rb
|
416
414
|
- app/forms/curation_concerns/forms/file_set_edit_form.rb
|
417
415
|
- app/forms/curation_concerns/forms/work_form.rb
|
418
|
-
- app/forms/curation_concerns/upload_set_form.rb
|
419
416
|
- app/helpers/curation_concerns/ability_helper.rb
|
420
417
|
- app/helpers/curation_concerns/catalog_helper.rb
|
421
418
|
- app/helpers/curation_concerns/collections_helper.rb
|
@@ -584,11 +581,6 @@ files:
|
|
584
581
|
- app/views/shared/_site_actions.html.erb
|
585
582
|
- app/views/shared/_site_search.html.erb
|
586
583
|
- app/views/shared/_title_bar.html.erb
|
587
|
-
- app/views/upload_sets/_base_metadata.html.erb
|
588
|
-
- app/views/upload_sets/_edit.js.erb
|
589
|
-
- app/views/upload_sets/_metadata.html.erb
|
590
|
-
- app/views/upload_sets/_more_metadata.html.erb
|
591
|
-
- app/views/upload_sets/edit.html.erb
|
592
584
|
- app/views/welcome/index.html.erb
|
593
585
|
- config/initializers/simple_form.rb
|
594
586
|
- config/jetty.yml
|
@@ -644,7 +636,6 @@ files:
|
|
644
636
|
- spec/controllers/downloads_controller_spec.rb
|
645
637
|
- spec/controllers/embargoes_controller_spec.rb
|
646
638
|
- spec/controllers/leases_controller_spec.rb
|
647
|
-
- spec/controllers/upload_sets_controller_spec.rb
|
648
639
|
- spec/controllers/welcome_controller_spec.rb
|
649
640
|
- spec/factories/collections.rb
|
650
641
|
- spec/factories/create_curation_concern.rb
|
@@ -661,7 +652,6 @@ files:
|
|
661
652
|
- spec/features/work_generator_spec.rb
|
662
653
|
- spec/forms/collection_edit_form_spec.rb
|
663
654
|
- spec/forms/file_set_edit_form_spec.rb
|
664
|
-
- spec/forms/upload_set_form_spec.rb
|
665
655
|
- spec/forms/work_form_spec.rb
|
666
656
|
- spec/helpers/catalog_helper_spec.rb
|
667
657
|
- spec/helpers/configuration_helper_spec.rb
|
@@ -685,7 +675,6 @@ files:
|
|
685
675
|
- spec/jobs/import_url_job_spec.rb
|
686
676
|
- spec/jobs/ingest_file_job_spec.rb
|
687
677
|
- spec/jobs/ingest_local_file_job_spec.rb
|
688
|
-
- spec/jobs/upload_set_update_job_spec.rb
|
689
678
|
- spec/jobs/visibility_copy_job_spec.rb
|
690
679
|
- spec/lib/curation_concerns/callbacks/registry_spec.rb
|
691
680
|
- spec/lib/curation_concerns/callbacks_spec.rb
|
@@ -706,7 +695,6 @@ files:
|
|
706
695
|
- spec/models/quick_classification_query_spec.rb
|
707
696
|
- spec/models/single_use_link_spec.rb
|
708
697
|
- spec/models/solr_document_spec.rb
|
709
|
-
- spec/models/upload_set_spec.rb
|
710
698
|
- spec/models/user_spec.rb
|
711
699
|
- spec/presenters/curation_concerns/collection_presenter_spec.rb
|
712
700
|
- spec/presenters/curation_concerns/file_set_presenter_spec.rb
|
@@ -754,6 +742,7 @@ files:
|
|
754
742
|
- spec/views/collections/_sort_and_per_page.html.erb_spec.rb
|
755
743
|
- spec/views/curation_concerns/base/_attributes.html.erb_spec.rb
|
756
744
|
- spec/views/curation_concerns/base/_form_permission.html.erb_spec.rb
|
745
|
+
- spec/views/curation_concerns/base/_show_actions.html.erb_spec.rb
|
757
746
|
- spec/views/curation_concerns/base/show.html.erb_spec.rb
|
758
747
|
- spec/views/curation_concerns/base/show.json.jbuilder_spec.rb
|
759
748
|
- spec/views/curation_concerns/file_sets/_file_set.html.erb_spec.rb
|
@@ -767,7 +756,6 @@ files:
|
|
767
756
|
- spec/views/shared/_my_actions.html.erb_spec.rb
|
768
757
|
- spec/views/single_use_links/new_download.html.erb_spec.rb
|
769
758
|
- spec/views/single_use_links_viewer/show.html.erb_spec.rb
|
770
|
-
- spec/views/upload_sets/_metadata.html.erb_spec.rb
|
771
759
|
- tasks/jetty.rake
|
772
760
|
- tasks/release.rake
|
773
761
|
- vendor/assets/images/ui-bg_glass_100_fdf5ce_1x400.png
|
@@ -798,7 +786,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
798
786
|
version: '0'
|
799
787
|
requirements: []
|
800
788
|
rubyforge_project:
|
801
|
-
rubygems_version: 2.5.
|
789
|
+
rubygems_version: 2.4.5.1
|
802
790
|
signing_key:
|
803
791
|
specification_version: 4
|
804
792
|
summary: A Rails Engine that allows an application to CRUD CurationConcern objects
|
@@ -826,7 +814,6 @@ test_files:
|
|
826
814
|
- spec/controllers/downloads_controller_spec.rb
|
827
815
|
- spec/controllers/embargoes_controller_spec.rb
|
828
816
|
- spec/controllers/leases_controller_spec.rb
|
829
|
-
- spec/controllers/upload_sets_controller_spec.rb
|
830
817
|
- spec/controllers/welcome_controller_spec.rb
|
831
818
|
- spec/factories/collections.rb
|
832
819
|
- spec/factories/create_curation_concern.rb
|
@@ -843,7 +830,6 @@ test_files:
|
|
843
830
|
- spec/features/work_generator_spec.rb
|
844
831
|
- spec/forms/collection_edit_form_spec.rb
|
845
832
|
- spec/forms/file_set_edit_form_spec.rb
|
846
|
-
- spec/forms/upload_set_form_spec.rb
|
847
833
|
- spec/forms/work_form_spec.rb
|
848
834
|
- spec/helpers/catalog_helper_spec.rb
|
849
835
|
- spec/helpers/configuration_helper_spec.rb
|
@@ -867,7 +853,6 @@ test_files:
|
|
867
853
|
- spec/jobs/import_url_job_spec.rb
|
868
854
|
- spec/jobs/ingest_file_job_spec.rb
|
869
855
|
- spec/jobs/ingest_local_file_job_spec.rb
|
870
|
-
- spec/jobs/upload_set_update_job_spec.rb
|
871
856
|
- spec/jobs/visibility_copy_job_spec.rb
|
872
857
|
- spec/lib/curation_concerns/callbacks/registry_spec.rb
|
873
858
|
- spec/lib/curation_concerns/callbacks_spec.rb
|
@@ -888,7 +873,6 @@ test_files:
|
|
888
873
|
- spec/models/quick_classification_query_spec.rb
|
889
874
|
- spec/models/single_use_link_spec.rb
|
890
875
|
- spec/models/solr_document_spec.rb
|
891
|
-
- spec/models/upload_set_spec.rb
|
892
876
|
- spec/models/user_spec.rb
|
893
877
|
- spec/presenters/curation_concerns/collection_presenter_spec.rb
|
894
878
|
- spec/presenters/curation_concerns/file_set_presenter_spec.rb
|
@@ -936,6 +920,7 @@ test_files:
|
|
936
920
|
- spec/views/collections/_sort_and_per_page.html.erb_spec.rb
|
937
921
|
- spec/views/curation_concerns/base/_attributes.html.erb_spec.rb
|
938
922
|
- spec/views/curation_concerns/base/_form_permission.html.erb_spec.rb
|
923
|
+
- spec/views/curation_concerns/base/_show_actions.html.erb_spec.rb
|
939
924
|
- spec/views/curation_concerns/base/show.html.erb_spec.rb
|
940
925
|
- spec/views/curation_concerns/base/show.json.jbuilder_spec.rb
|
941
926
|
- spec/views/curation_concerns/file_sets/_file_set.html.erb_spec.rb
|
@@ -949,4 +934,3 @@ test_files:
|
|
949
934
|
- spec/views/shared/_my_actions.html.erb_spec.rb
|
950
935
|
- spec/views/single_use_links/new_download.html.erb_spec.rb
|
951
936
|
- spec/views/single_use_links_viewer/show.html.erb_spec.rb
|
952
|
-
- spec/views/upload_sets/_metadata.html.erb_spec.rb
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module CurationConcerns
|
2
|
-
module UploadSetsControllerBehavior
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
include Hydra::Controller::ControllerBehavior
|
5
|
-
|
6
|
-
included do
|
7
|
-
include CurationConcerns::ThemedLayoutController
|
8
|
-
with_themed_layout '1_column'
|
9
|
-
|
10
|
-
class_attribute :edit_form_class
|
11
|
-
self.edit_form_class = CurationConcerns::UploadSetForm
|
12
|
-
end
|
13
|
-
|
14
|
-
def edit
|
15
|
-
# TODO: redlock this line so that two processes don't attempt to create at the same time.
|
16
|
-
@upload_set = UploadSet.find_or_create(params[:id])
|
17
|
-
@form = edit_form
|
18
|
-
end
|
19
|
-
|
20
|
-
def update
|
21
|
-
authenticate_user!
|
22
|
-
@upload_set = UploadSet.find(params[:id])
|
23
|
-
@upload_set.status = ["processing"]
|
24
|
-
@upload_set.save
|
25
|
-
create_update_job
|
26
|
-
flash[:notice] = 'Your files are being processed by ' + t('curation_concerns.product_name') + ' in the background. The metadata and access controls you specified are being applied. Files will be marked <span class="label label-danger" title="Private">Private</span> until this process is complete (shouldn\'t take too long, hang in there!). You may need to refresh your dashboard to see these updates.'
|
27
|
-
|
28
|
-
redirect_after_update
|
29
|
-
end
|
30
|
-
|
31
|
-
protected
|
32
|
-
|
33
|
-
# Override this method if you want to go elsewhere
|
34
|
-
def redirect_after_update
|
35
|
-
redirect_to main_app.curation_concerns_generic_works_path
|
36
|
-
end
|
37
|
-
|
38
|
-
def edit_form
|
39
|
-
edit_form_class.new(@upload_set, current_ability)
|
40
|
-
end
|
41
|
-
|
42
|
-
def create_update_job
|
43
|
-
UploadSetUpdateJob.perform_later(current_user.user_key,
|
44
|
-
params[:id],
|
45
|
-
params[:title],
|
46
|
-
edit_form_class.model_attributes(params[:upload_set]),
|
47
|
-
params[:visibility])
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module CurationConcerns
|
2
|
-
class UploadSetForm
|
3
|
-
include HydraEditor::Form
|
4
|
-
|
5
|
-
self.terms = CurationConcerns::GenericWorkForm.terms
|
6
|
-
|
7
|
-
delegate :creator, :human_readable_type, :open_access?, :authenticated_only_access?,
|
8
|
-
:open_access_with_embargo_release_date?, :private_access?,
|
9
|
-
:embargo_release_date, :lease_expiration_date, :member_ids, to: :exemplar_work
|
10
|
-
|
11
|
-
def initialize(upload_set, current_ability)
|
12
|
-
@current_ability = current_ability
|
13
|
-
super(upload_set)
|
14
|
-
# TODO: instead of using GenericWorkForm, this should be an UploadSetForm
|
15
|
-
# work = ::GenericWork.new(creator: [creator_display], title: titles)
|
16
|
-
end
|
17
|
-
|
18
|
-
def exemplar_work
|
19
|
-
@exemplar_work ||= GenericWork.new(creator: [creator_display])
|
20
|
-
end
|
21
|
-
|
22
|
-
# @return [Array] a list of the first titles for each of the works.
|
23
|
-
def works
|
24
|
-
@works ||= model.works.sort { |w1, w2| w1.title.first.downcase <=> w2.title.first.downcase }
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.model_attributes(attrs)
|
28
|
-
CurationConcerns::GenericWorkForm.model_attributes(attrs)
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.multiple?(attrs)
|
32
|
-
CurationConcerns::GenericWorkForm.multiple?(attrs)
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
# Override this method if you want the creator to display something other than
|
38
|
-
# the user_key, e.g. "current_user.name"
|
39
|
-
def creator_display
|
40
|
-
@current_ability.current_user.user_key
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
<%#= f.input :resource_type, as: :select_with_help, collection: CurationConcerns.config.resource_types,
|
2
|
-
input_html: { class: 'form-control', multiple: true } %>
|
3
|
-
|
4
|
-
<%= f.input :tag, as: :multi_value_with_help %>
|
5
|
-
|
6
|
-
<%= f.input :creator, as: :multi_value_with_help %>
|
7
|
-
|
8
|
-
<%= f.input :rights, as: :select_with_modal_help, collection: RightsService.select_options,
|
9
|
-
input_html: { class: 'form-control', multiple: true } %>
|
10
|
-
|
11
|
-
<%= render "curation_concerns/file_sets/rights_modal" %>
|
12
|
-
|
@@ -1,15 +0,0 @@
|
|
1
|
-
if (navigator.userAgent.match("MSIE"))
|
2
|
-
$("#new_file_set").validate();
|
3
|
-
|
4
|
-
$('#permissions_display').show();
|
5
|
-
|
6
|
-
confirmation_needed = true;
|
7
|
-
window.onbeforeunload = confirmExit;
|
8
|
-
|
9
|
-
function confirmExit(){
|
10
|
-
if(confirmation_needed){
|
11
|
-
// if you return a string it will be displayed in between "don't navigate away"
|
12
|
-
// and "click Ok to navigate away or cancel to stay put" in the confirm dialog
|
13
|
-
return "Your metadata has not been saved.";
|
14
|
-
}
|
15
|
-
}
|
@@ -1,40 +0,0 @@
|
|
1
|
-
<h2>Individual Titles </h2>
|
2
|
-
<div id="" class="well">
|
3
|
-
<div class="row">
|
4
|
-
<div class="col-sm-8">
|
5
|
-
<h3>Applies to individual files uploaded</h3>
|
6
|
-
<%= content_tag :p, t('curation_concerns.upload_set.help.title'), class: "help-block" %>
|
7
|
-
<% f.object.works.each_with_index do |work, index| %>
|
8
|
-
<div class="form-group">
|
9
|
-
<%= f.input_label :title, as: :multi_value_with_help, label: "Title #{index + 1}" %>
|
10
|
-
<div id="additional_title_clone">
|
11
|
-
<%= f.text_field :title, name: "title[#{work.id}][]", value: work.title, class: 'form-control', required: true %>
|
12
|
-
</div>
|
13
|
-
</div>
|
14
|
-
<% end %>
|
15
|
-
</div>
|
16
|
-
|
17
|
-
<div class="col-sm-4">
|
18
|
-
<!-- put metadata about file being edited here -->
|
19
|
-
</div>
|
20
|
-
</div>
|
21
|
-
</div>
|
22
|
-
|
23
|
-
<%= hidden_field_tag(:extra_description_count, "1") %>
|
24
|
-
<div id="descriptions_display">
|
25
|
-
<h2>Bulk Descriptions</h2>
|
26
|
-
<div class="well">
|
27
|
-
<div class="row">
|
28
|
-
<div class="col-sm-6">
|
29
|
-
<h3>Applies to all files just uploaded</h3>
|
30
|
-
<%= render 'base_metadata', f: f %>
|
31
|
-
|
32
|
-
<button id="show_addl_descriptions" class="btn btn-default" aria-label="reveal additional metadata description fields">Show Additional Fields</button>
|
33
|
-
<!-- hidden on initial load -->
|
34
|
-
|
35
|
-
<%= render 'more_metadata', f: f %>
|
36
|
-
|
37
|
-
</div> <!-- /col-sm-8 -->
|
38
|
-
</div> <!-- /row -->
|
39
|
-
</div><!-- /well -->
|
40
|
-
</div> <!-- /row -->
|
@@ -1,7 +0,0 @@
|
|
1
|
-
<div id="more_descriptions">
|
2
|
-
<button id="hide_addl_descriptions" class="btn btn-default" aria-label="hide additional metadata description fields">Hide Additional Fields</button>
|
3
|
-
<% (f.object.terms - [:title, :creator, :rights, :tag, :resource_type]).each do |term| %>
|
4
|
-
<%# <%= f.input term, as: :multi_value_with_help, input_html: { required: false} %>
|
5
|
-
<%= render_edit_field_partial(term, f: f) %>
|
6
|
-
<% end %>
|
7
|
-
</div> <!-- /more_descriptions -->
|
@@ -1,26 +0,0 @@
|
|
1
|
-
<%= javascript_tag do %>
|
2
|
-
<%= render partial: "edit", formats: [:js] %>
|
3
|
-
<% end %>
|
4
|
-
|
5
|
-
<h1>Apply Metadata</h1>
|
6
|
-
<p>
|
7
|
-
The information you provide for Title will be applied to the corresponding file only; however all other
|
8
|
-
information you provide will be applied <em>to the entire set of files that were uploaded together</em> you have just
|
9
|
-
deposited into <%= t('curation_concerns.product_name') %>. You may edit individual files from
|
10
|
-
<%= link_to "<i class='glyphicon glyphicon-dashboard'></i> #{t('curation_concerns.bread_crumb.works_list')}".html_safe, main_app.curation_concerns_generic_works_path %>
|
11
|
-
once this step is finished. <span class="required"><abbr title="required">*</abbr></span> indicates required fields.
|
12
|
-
</p>
|
13
|
-
<%= simple_form_for [main_app, @form], html: { multipart: true }, builder: CurationConcerns::FormBuilder do |f| %>
|
14
|
-
|
15
|
-
<%= render 'metadata', f: f %>
|
16
|
-
|
17
|
-
<%#= render 'file_sets/permission_form', f: f, upload_set: @upload_set %>
|
18
|
-
|
19
|
-
<div id="permissions_submit">
|
20
|
-
<%= button_tag type: 'submit', class: 'btn btn-primary btn-lg',
|
21
|
-
onclick: "confirmation_needed = false;", id: "upload_submit", name: "update_permission" do %>
|
22
|
-
<i class="glyphicon glyphicon-floppy-disk"></i> Save
|
23
|
-
<% end %>
|
24
|
-
</div>
|
25
|
-
|
26
|
-
<% end %>
|
@@ -1,69 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe UploadSetsController do
|
4
|
-
let(:user) { create(:user) }
|
5
|
-
let(:other_user) { create(:user) }
|
6
|
-
before do
|
7
|
-
sign_in user
|
8
|
-
allow_any_instance_of(User).to receive(:groups).and_return([])
|
9
|
-
end
|
10
|
-
describe "#update" do
|
11
|
-
let(:upload_set_update_message) { double('upload_set update message') }
|
12
|
-
let(:upload_set) { UploadSet.create }
|
13
|
-
context "when successful" do
|
14
|
-
it "enqueues a upload_set job and redirects to generic_works list with a flash message" do
|
15
|
-
expect(UploadSetUpdateJob).to receive(:perform_later).with(user.user_key, upload_set.id, { '1' => 'foo' },
|
16
|
-
{ tag: [] }, 'open').once
|
17
|
-
post :update, id: upload_set.id, title: { '1' => 'foo' }, visibility: 'open', upload_set: { tag: [""] }
|
18
|
-
expect(response).to redirect_to routes.url_helpers.curation_concerns_generic_works_path
|
19
|
-
expect(flash[:notice]).to include("Your files are being processed")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "when user has edit permissions on a file" do
|
24
|
-
# TODO: all these tests could move to upload_set_update_job_spec.rb
|
25
|
-
let!(:work) { create(:generic_work, user: user, upload_set: upload_set) }
|
26
|
-
|
27
|
-
it "they can set public read access" do
|
28
|
-
post :update, id: upload_set, visibility: "open", upload_set: { tag: [""] }
|
29
|
-
expect(work.reload.read_groups).to eq ['public']
|
30
|
-
end
|
31
|
-
|
32
|
-
it "they can set metadata like title" do
|
33
|
-
post :update, id: upload_set, upload_set: { tag: ["footag", "bartag"] }, title: { work.id => ["New Title"] }
|
34
|
-
work.reload
|
35
|
-
expect(work.title).to eq ["New Title"]
|
36
|
-
# TODO: is order important?
|
37
|
-
expect(work.tag).to include("footag", "bartag")
|
38
|
-
end
|
39
|
-
|
40
|
-
it "they cannot set any tags" do
|
41
|
-
post :update, id: upload_set, upload_set: { tag: [""] }
|
42
|
-
expect(work.reload.tag).to be_empty
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "when user does not have edit permissions on a file" do
|
47
|
-
# TODO: all these tests could move to upload_set_update_job_spec.rb
|
48
|
-
let!(:work) { create(:generic_work, title: ['Original Title'], upload_set: upload_set) }
|
49
|
-
|
50
|
-
it "they cannot modify the object" do
|
51
|
-
post :update, id: upload_set, upload_set: { "tag" => [""] },
|
52
|
-
title: { work.id => "Title Won't Change" }
|
53
|
-
work.reload
|
54
|
-
expect(work.title).to eq ["Original Title"]
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "#edit" do
|
60
|
-
let(:us1) { UploadSet.create }
|
61
|
-
|
62
|
-
it "sets up attributes for the form" do
|
63
|
-
get :edit, id: us1
|
64
|
-
expect(assigns[:form]).to be_kind_of CurationConcerns::UploadSetForm
|
65
|
-
expect(assigns[:form].model).to eq us1
|
66
|
-
expect(response).to be_success
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe CurationConcerns::UploadSetForm do
|
4
|
-
let(:form) { described_class.new(upload_set, ability) }
|
5
|
-
let(:user) { build(:user) }
|
6
|
-
let(:ability) { Ability.new(user) }
|
7
|
-
let(:upload_set) { UploadSet.create }
|
8
|
-
let!(:work1) { create(:work, upload_set: upload_set) }
|
9
|
-
let!(:work2) { create(:work, upload_set: upload_set) }
|
10
|
-
|
11
|
-
describe "#to_param" do
|
12
|
-
subject { form.to_param }
|
13
|
-
it { is_expected.to eq upload_set.id }
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "#terms" do
|
17
|
-
subject { form.terms }
|
18
|
-
it { is_expected.to eq [:title,
|
19
|
-
:creator,
|
20
|
-
:contributor,
|
21
|
-
:description,
|
22
|
-
:tag,
|
23
|
-
:rights,
|
24
|
-
:publisher,
|
25
|
-
:date_created,
|
26
|
-
:subject,
|
27
|
-
:language,
|
28
|
-
:identifier,
|
29
|
-
:based_near,
|
30
|
-
:related_url,
|
31
|
-
:representative_id,
|
32
|
-
:thumbnail_id,
|
33
|
-
:files,
|
34
|
-
:visibility_during_embargo,
|
35
|
-
:embargo_release_date,
|
36
|
-
:visibility_after_embargo,
|
37
|
-
:visibility_during_lease,
|
38
|
-
:lease_expiration_date,
|
39
|
-
:visibility_after_lease,
|
40
|
-
:visibility] }
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "works" do
|
44
|
-
let!(:work1) { create(:work_with_one_file, upload_set: upload_set, title: ['B title']) }
|
45
|
-
let!(:work2) { create(:work_with_one_file, upload_set: upload_set, title: ['A title']) }
|
46
|
-
subject { form.works }
|
47
|
-
it { is_expected.to eq [work2, work1] }
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "creator" do
|
51
|
-
let(:user) { build(:user, email: 'bob@example.com') }
|
52
|
-
subject { form.creator }
|
53
|
-
it { is_expected.to eq ['bob@example.com'] }
|
54
|
-
end
|
55
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe UploadSetUpdateJob do
|
4
|
-
let(:user) { create(:user) }
|
5
|
-
let(:upload_set) { UploadSet.create }
|
6
|
-
|
7
|
-
let(:work) { create(:work, user: user, upload_set: upload_set) }
|
8
|
-
let(:work2) { create(:work, user: user, upload_set: upload_set) }
|
9
|
-
|
10
|
-
before do
|
11
|
-
allow(CurationConcerns.config.callback).to receive(:run)
|
12
|
-
allow(CurationConcerns.config.callback).to receive(:set?)
|
13
|
-
.with(:after_upload_set_update_success)
|
14
|
-
.and_return(true)
|
15
|
-
allow(CurationConcerns.config.callback).to receive(:set?)
|
16
|
-
.with(:after_upload_set_update_failure)
|
17
|
-
.and_return(true)
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "#perform" do
|
21
|
-
let(:title) { { work.id => ['File One'], work2.id => ['File Two'] } }
|
22
|
-
let(:metadata) { { tag: [''] } }
|
23
|
-
let(:visibility) { nil }
|
24
|
-
|
25
|
-
subject { described_class.perform_now(user.user_key, upload_set.id, title, metadata, visibility) }
|
26
|
-
|
27
|
-
it "updates work metadata" do
|
28
|
-
expect(CurationConcerns.config.callback).to receive(:run).with(:after_upload_set_update_success, user, upload_set)
|
29
|
-
subject
|
30
|
-
expect(work.reload.title).to eq ['File One']
|
31
|
-
expect(work2.reload.title).to eq ['File Two']
|
32
|
-
end
|
33
|
-
|
34
|
-
context "when user does not have permission to edit all of the works" do
|
35
|
-
it "sends the failure message" do
|
36
|
-
expect_any_instance_of(User).to receive(:can?).with(:edit, work).and_return(true)
|
37
|
-
expect_any_instance_of(User).to receive(:can?).with(:edit, work2).and_return(false)
|
38
|
-
expect(CurationConcerns.config.callback).to receive(:run).with(:after_upload_set_update_failure, user, upload_set)
|
39
|
-
subject
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe UploadSet do
|
4
|
-
let(:user) { create(:user) }
|
5
|
-
let(:upload_set) { described_class.create(title: ["test collection"]) }
|
6
|
-
subject { upload_set }
|
7
|
-
|
8
|
-
it "has dc metadata" do
|
9
|
-
expect(subject.title).to eq ["test collection"]
|
10
|
-
end
|
11
|
-
|
12
|
-
it "responds to #works" do
|
13
|
-
expect(subject).to respond_to(:works)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "supports to_solr" do
|
17
|
-
expect(subject.to_solr).to_not be_nil
|
18
|
-
expect(subject.to_solr["upload_set__title_t"]).to be_nil
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "find_or_create" do
|
22
|
-
describe "when the object exists" do
|
23
|
-
let!(:upload_set) { described_class.create(title: ["test collection"]) }
|
24
|
-
it "finds upload_set instead of creating" do
|
25
|
-
expect(described_class).to_not receive(:create)
|
26
|
-
described_class.find_or_create(subject.id)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
describe "when the object does not exist" do
|
30
|
-
it "creates a new Batch" do
|
31
|
-
expect { described_class.find("upload_set-123") }.to raise_error(ActiveFedora::ObjectNotFoundError)
|
32
|
-
expect(described_class).to receive(:create).once.and_return("the upload_set")
|
33
|
-
expect(described_class.find_or_create("upload_set-123")).to eq "the upload_set"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'upload_sets/_metadata.html.erb' do
|
4
|
-
let(:user) { build(:user) }
|
5
|
-
let(:ability) { Ability.new(user) }
|
6
|
-
let(:upload_set) { UploadSet.create }
|
7
|
-
let(:form) { CurationConcerns::UploadSetForm.new(upload_set, ability) }
|
8
|
-
let(:work1) { build(:work, id: 'work1', title: ['First work']) }
|
9
|
-
let(:work2) { build(:work, id: 'work2', title: ['Second work']) }
|
10
|
-
|
11
|
-
let(:f) do
|
12
|
-
allow(upload_set).to receive(:works).and_return([work1, work2])
|
13
|
-
view.simple_form_for(form, url: '/update', builder: CurationConcerns::FormBuilder) do |fs_form|
|
14
|
-
return fs_form
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
before do
|
19
|
-
allow(view).to receive(:f).and_return(f)
|
20
|
-
render
|
21
|
-
end
|
22
|
-
|
23
|
-
it "draws the form" do
|
24
|
-
expect(rendered).to have_text 'Applies to all files just uploaded'
|
25
|
-
expect(rendered).to have_css 'input[name="title[work1][]"][value="First work"]'
|
26
|
-
expect(rendered).to have_css 'input[name="title[work2][]"][value="Second work"]'
|
27
|
-
end
|
28
|
-
end
|