sufia 4.3.1 → 5.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +8 -1
  3. data/Gemfile +10 -1
  4. data/History.md +14 -0
  5. data/LICENSE +15 -0
  6. data/README.md +7 -3
  7. data/SUFIA_VERSION +1 -1
  8. data/app/assets/javascripts/sufia.js +17 -1
  9. data/app/assets/javascripts/sufia/batch_edit.js +28 -43
  10. data/app/assets/javascripts/sufia/edit_metadata.js +14 -9
  11. data/app/assets/javascripts/sufia/manage_repeating_fields.js +74 -0
  12. data/app/assets/stylesheets/sufia.css.scss +1 -1
  13. data/app/assets/stylesheets/sufia/_batch-edit.scss +8 -0
  14. data/app/assets/stylesheets/sufia/_file-listing.scss +1 -1
  15. data/app/assets/stylesheets/sufia/_multi_value_fields.css.scss +67 -0
  16. data/app/controllers/concerns/sufia/breadcrumbs.rb +8 -3
  17. data/app/controllers/concerns/sufia/users_controller_behavior.rb +5 -1
  18. data/app/helpers/generic_file_helper.rb +0 -9
  19. data/app/helpers/sufia/records_helper_behavior.rb +0 -14
  20. data/app/inputs/multi_value_input.rb +84 -0
  21. data/app/views/batch/_metadata.html.erb +4 -16
  22. data/app/views/batch/edit.html.erb +1 -1
  23. data/app/views/batch_edits/edit.html.erb +6 -10
  24. data/app/views/collections/_edit_descriptions.html.erb +1 -1
  25. data/app/views/collections/_form.html.erb +3 -3
  26. data/app/views/generic_files/_descriptions.html.erb +9 -7
  27. data/app/views/generic_files/_field_form.html.erb +23 -8
  28. data/app/views/generic_files/edit.html.erb +0 -1
  29. data/app/views/records/_edit_field.html.erb +19 -17
  30. data/app/views/records/_rights_modal.html.erb +1 -0
  31. data/app/views/records/edit_fields/_default.html.erb +12 -6
  32. data/app/views/records/edit_fields/_description.html.erb +3 -6
  33. data/app/views/records/edit_fields/_resource_type.html.erb +5 -4
  34. data/app/views/records/edit_fields/_rights.html.erb +2 -5
  35. data/app/views/records/edit_fields/_suffix.html.erb +0 -11
  36. data/app/views/records/edit_fields/_type.html.erb +2 -8
  37. data/config/initializers/simple_form.rb +167 -0
  38. data/config/initializers/simple_form_bootstrap.rb +137 -0
  39. data/config/locales/simple_form.en.yml +31 -0
  40. data/config/locales/sufia.en.yml +2 -0
  41. data/lib/sufia/version.rb +1 -1
  42. data/spec/controllers/batch_edits_controller_spec.rb +1 -0
  43. data/spec/controllers/generic_files_controller_spec.rb +26 -0
  44. data/spec/controllers/users_controller_spec.rb +4 -3
  45. data/spec/features/collection_spec.rb +7 -0
  46. data/spec/helpers/records_helper_spec.rb +0 -13
  47. data/spec/lib/sufia/breadcrumbs_spec.rb +46 -8
  48. data/spec/views/collections/_form.html.erb_spec.rb +0 -2
  49. data/sufia-models/app/models/concerns/sufia/user.rb +5 -0
  50. data/sufia-models/lib/sufia/models/stats/user_stat_importer.rb +9 -5
  51. data/sufia-models/lib/sufia/models/version.rb +1 -1
  52. data/sufia.gemspec +1 -0
  53. metadata +29 -9
  54. data/LICENSE.md +0 -14
  55. data/app/assets/javascripts/sufia/multiForm.js +0 -67
@@ -5,6 +5,13 @@ describe 'collection', :type => :feature do
5
5
  visit '/dashboard'
6
6
  first('#hydra-collection-add').click
7
7
  expect(page).to have_content 'Create New Collection'
8
+
9
+ # Creator is a multi-value field, so it should have button to add more fields
10
+ expect(page).to have_selector "div.collection_creator .input-append button.add"
11
+
12
+ # Title is a single-value field, so it should not have the adder button
13
+ expect(page).to_not have_selector "div.collection_title .input-append button.add"
14
+
8
15
  fill_in('Title', with: title)
9
16
  fill_in('Abstract or Summary', with: description)
10
17
  click_button("Create Collection")
@@ -1,19 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe RecordsHelper, :type => :helper do
4
- let(:adder) {
5
- "<button class=\"adder btn\" id=\"additional_test_submit\" name=\"additional_test\"><span aria-hidden=\"true\"><i class=\"glyphicon glyphicon-plus\"></i></span><span class=\"sr-only\">add another test</span></button>"
6
- }
7
- let(:remover) {
8
- "<button class=\"remover btn\" id=\"additional_test_submit\" name=\"additional_test\"><span aria-hidden=\"true\"><i class=\"glyphicon glyphicon-remove\"></i></span><span class=\"sr-only\">add another test</span></button>"
9
- }
10
- it "draws add button" do
11
- expect(helper.add_field(:test)).to eql(adder)
12
- end
13
-
14
- it "draws subtract button" do
15
- expect(helper.subtract_field(:test)).to eql(remover)
16
- end
17
4
 
18
5
  it "draws help_icon" do
19
6
  str = String.new(helper.help_icon(:tag))
@@ -54,25 +54,63 @@ describe Sufia::Breadcrumbs do
54
54
  expect(crumbs.trail_from_referer).to eql([[I18n.t('sufia.bread_crumb.search_results'), referer]])
55
55
  end
56
56
  end
57
- context "when coming from the dashboard" do
57
+ context "when coming places other than the catalog" do
58
58
  before do
59
- allow(crumbs.request).to receive(:referer).and_return("http://...dashboard/")
59
+ allow(crumbs.request).to receive(:referer).and_return("http://...blargh/")
60
60
  allow(crumbs).to receive(:user_signed_in?) { true }
61
+ allow(crumbs).to receive(:action_name).and_return("view")
61
62
  end
62
63
  specify "the trail goes back to the user's files" do
63
64
  allow(crumbs).to receive(:controller_name).and_return("my/files")
64
- expect(crumbs.trail_from_referer.first).to eql([I18n.t('sufia.dashboard.title'), sufia.dashboard_index_path])
65
- expect(crumbs.trail_from_referer.last).to eql([I18n.t('sufia.dashboard.my.files'), sufia.dashboard_files_path])
65
+ crumbs.trail_from_referer
66
+ expect(crumbs.trail.first).to eql([I18n.t('sufia.dashboard.title'), sufia.dashboard_index_path])
67
+ expect(crumbs.trail.last).to eql([I18n.t('sufia.dashboard.my.files'), sufia.dashboard_files_path])
66
68
  end
67
69
  specify "the trail goes back to the user's collections" do
68
70
  allow(crumbs).to receive(:controller_name).and_return("my/collections")
69
- expect(crumbs.trail_from_referer.first).to eql([I18n.t('sufia.dashboard.title'), sufia.dashboard_index_path])
70
- expect(crumbs.trail_from_referer.last).to eql([I18n.t('sufia.dashboard.my.collections'), sufia.dashboard_collections_path])
71
+ crumbs.trail_from_referer
72
+ expect(crumbs.trail.first).to eql([I18n.t('sufia.dashboard.title'), sufia.dashboard_index_path])
73
+ expect(crumbs.trail.last).to eql([I18n.t('sufia.dashboard.my.collections'), sufia.dashboard_collections_path])
71
74
  end
72
75
  specify "the trail goes back to the user's files when on the batch edit page" do
73
76
  allow(crumbs).to receive(:controller_name).and_return("batch_edit")
74
- expect(crumbs.trail_from_referer.first).to eql([I18n.t('sufia.dashboard.title'), sufia.dashboard_index_path])
75
- expect(crumbs.trail_from_referer.last).to eql([I18n.t('sufia.dashboard.my.files'), sufia.dashboard_files_path])
77
+ crumbs.trail_from_referer
78
+ expect(crumbs.trail.first).to eql([I18n.t('sufia.dashboard.title'), sufia.dashboard_index_path])
79
+ expect(crumbs.trail.last).to eql([I18n.t('sufia.dashboard.my.files'), sufia.dashboard_files_path])
80
+ end
81
+ end
82
+
83
+ context "when editing a file" do
84
+ before do
85
+ allow(crumbs.request).to receive(:referer).and_return("http://...blargh/")
86
+ allow(crumbs).to receive(:user_signed_in?) { true }
87
+ allow(crumbs).to receive(:action_name).and_return("edit")
88
+ allow(crumbs).to receive(:params).and_return({"id" => "abc123"})
89
+ allow(crumbs).to receive(:controller_name).and_return("generic_files")
90
+ end
91
+
92
+ specify "the trail goes back to the user's files and the browse view" do
93
+ crumbs.trail_from_referer
94
+ expect(crumbs.trail.first).to eql([I18n.t('sufia.dashboard.title'), sufia.dashboard_index_path])
95
+ expect(crumbs.trail[1]).to eql([I18n.t('sufia.dashboard.my.files'), sufia.dashboard_files_path])
96
+ expect(crumbs.trail.last).to eql([I18n.t('sufia.generic_file.browse_view'), sufia.generic_file_path("abc123")])
97
+ end
98
+ end
99
+
100
+ context "when viewing file statistics" do
101
+ before do
102
+ allow(crumbs.request).to receive(:referer).and_return("http://...blargh/")
103
+ allow(crumbs).to receive(:user_signed_in?) { true }
104
+ allow(crumbs).to receive(:action_name).and_return("stats")
105
+ allow(crumbs).to receive(:params).and_return({"id" => "abc123"})
106
+ allow(crumbs).to receive(:controller_name).and_return("generic_files")
107
+ end
108
+
109
+ specify "the trail goes back to the user's files and the browse view" do
110
+ crumbs.trail_from_referer
111
+ expect(crumbs.trail.first).to eql([I18n.t('sufia.dashboard.title'), sufia.dashboard_index_path])
112
+ expect(crumbs.trail[1]).to eql([I18n.t('sufia.dashboard.my.files'), sufia.dashboard_files_path])
113
+ expect(crumbs.trail.last).to eql([I18n.t('sufia.generic_file.browse_view'), sufia.generic_file_path("abc123")])
76
114
  end
77
115
  end
78
116
  end
@@ -14,9 +14,7 @@ describe 'collections/_form.html.erb', :type => :view do
14
14
  it "should draw the metadata fields for collection" do
15
15
  render
16
16
  expect(rendered).to have_selector("input#collection_title", count: 1)
17
- expect(rendered).to_not have_selector("div#additional_title_clone button.adder")
18
17
  expect(rendered).to have_selector("input#collection_creator", count: 1)
19
- expect(rendered).to have_selector("div#additional_creator_clone button.adder")
20
18
  expect(rendered).to have_selector("textarea#collection_description", count: 1)
21
19
  expect(rendered).to have_selector("input#collection_contributor", count: 1)
22
20
  expect(rendered).to have_selector("input#collection_tag", count: 1)
@@ -54,6 +54,11 @@ module Sufia::User
54
54
  { id: user_key, text: display_name ? "#{display_name} (#{user_key})" : user_key }
55
55
  end
56
56
 
57
+ # Populate user instance with attributes from remote system (e.g., LDAP)
58
+ # There is no default implementation -- override this in your application
59
+ def populate_attributes
60
+ end
61
+
57
62
  def email_address
58
63
  self.email
59
64
  end
@@ -12,11 +12,11 @@ module Sufia
12
12
  start_date = date_since_last_cache(user)
13
13
 
14
14
  stats = {}
15
- files_for_user(user).each do |file|
16
- view_stats = FileViewStat.statistics(file.id, start_date, user.id)
15
+ file_ids_for_user(user).each do |file_id|
16
+ view_stats = FileViewStat.statistics(file_id, start_date, user.id)
17
17
  stats = tally_results(view_stats, :views, stats)
18
18
 
19
- dl_stats = FileDownloadStat.statistics(file.id, start_date, user.id)
19
+ dl_stats = FileDownloadStat.statistics(file_id, start_date, user.id)
20
20
  stats = tally_results(dl_stats, :downloads, stats)
21
21
  end
22
22
 
@@ -38,8 +38,12 @@ private
38
38
  end
39
39
  end
40
40
 
41
- def files_for_user(user)
42
- ::GenericFile.where(Solrizer.solr_name('depositor', :symbol) => user.user_key)
41
+ def file_ids_for_user(user)
42
+ ids = []
43
+ ::GenericFile.find_in_batches("#{Solrizer.solr_name('depositor', :symbol)}:\"#{user.user_key}\"", fl:"id") do |group|
44
+ ids.concat group.map { |doc| doc["id"] }
45
+ end
46
+ ids
43
47
  end
44
48
 
45
49
  # For each date, add the view and download counts for this
@@ -1,5 +1,5 @@
1
1
  module Sufia
2
2
  module Models
3
- VERSION = "4.3.1"
3
+ VERSION = "5.0.0.rc1"
4
4
  end
5
5
  end
@@ -38,6 +38,7 @@ Gem::Specification.new do |gem|
38
38
  gem.add_dependency 'font-awesome-rails'
39
39
  gem.add_dependency 'hydra-editor', '~> 0.3'
40
40
  gem.add_dependency 'hydra-collections', '~> 2.0'
41
+ gem.add_dependency 'simple_form', '~> 3.1.0'
41
42
  gem.add_dependency 'bootstrap_form', '~> 2.1'
42
43
  gem.add_dependency 'blacklight-gallery'
43
44
  gem.add_dependency 'breadcrumbs_on_rails', '~>2.3.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sufia
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.1
4
+ version: 5.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-17 00:00:00.000000000 Z
12
+ date: 2015-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sufia-models
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 4.3.1
20
+ version: 5.0.0.rc1
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: 4.3.1
27
+ version: 5.0.0.rc1
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: blacklight_advanced_search
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -227,6 +227,20 @@ dependencies:
227
227
  - - "~>"
228
228
  - !ruby/object:Gem::Version
229
229
  version: '2.0'
230
+ - !ruby/object:Gem::Dependency
231
+ name: simple_form
232
+ requirement: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - "~>"
235
+ - !ruby/object:Gem::Version
236
+ version: 3.1.0
237
+ type: :runtime
238
+ prerelease: false
239
+ version_requirements: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: 3.1.0
230
244
  - !ruby/object:Gem::Dependency
231
245
  name: bootstrap_form
232
246
  requirement: !ruby/object:Gem::Requirement
@@ -424,7 +438,7 @@ files:
424
438
  - CONTRIBUTING.md
425
439
  - Gemfile
426
440
  - History.md
427
- - LICENSE.md
441
+ - LICENSE
428
442
  - README.md
429
443
  - RELEASING.md
430
444
  - Rakefile
@@ -502,7 +516,7 @@ files:
502
516
  - app/assets/javascripts/sufia/featured_works.js
503
517
  - app/assets/javascripts/sufia/fileupload.js
504
518
  - app/assets/javascripts/sufia/ga_events.js
505
- - app/assets/javascripts/sufia/multiForm.js
519
+ - app/assets/javascripts/sufia/manage_repeating_fields.js
506
520
  - app/assets/javascripts/sufia/permissions.js
507
521
  - app/assets/javascripts/sufia/proxy_rights.js
508
522
  - app/assets/javascripts/sufia/search.js
@@ -533,6 +547,7 @@ files:
533
547
  - app/assets/stylesheets/sufia/_file-listing.scss
534
548
  - app/assets/stylesheets/sufia/_header.scss
535
549
  - app/assets/stylesheets/sufia/_home-page.scss
550
+ - app/assets/stylesheets/sufia/_multi_value_fields.css.scss
536
551
  - app/assets/stylesheets/sufia/_proxy-rights.scss
537
552
  - app/assets/stylesheets/sufia/_settings.scss
538
553
  - app/assets/stylesheets/sufia/_styles.scss
@@ -594,6 +609,7 @@ files:
594
609
  - app/helpers/sufia/records_helper_behavior.rb
595
610
  - app/helpers/sufia/sufia_helper_behavior.rb
596
611
  - app/helpers/trophy_helper.rb
612
+ - app/inputs/multi_value_input.rb
597
613
  - app/jobs/content_delete_event_job.rb
598
614
  - app/jobs/content_deposit_event_job.rb
599
615
  - app/jobs/content_depositor_change_event_job.rb
@@ -774,6 +790,7 @@ files:
774
790
  - app/views/my/index.html.erb
775
791
  - app/views/pages/show.html.erb
776
792
  - app/views/records/_edit_field.html.erb
793
+ - app/views/records/_rights_modal.html.erb
777
794
  - app/views/records/edit_fields/_default.html.erb
778
795
  - app/views/records/edit_fields/_description.html.erb
779
796
  - app/views/records/edit_fields/_resource_type.html.erb
@@ -831,8 +848,11 @@ files:
831
848
  - app/views/users/notifications_number.js.erb
832
849
  - app/views/users/show.html.erb
833
850
  - bin/audit_repository
851
+ - config/initializers/simple_form.rb
852
+ - config/initializers/simple_form_bootstrap.rb
834
853
  - config/initializers/sufia_events.rb
835
854
  - config/jetty.yml
855
+ - config/locales/simple_form.en.yml
836
856
  - config/locales/sufia.en.yml
837
857
  - config/routes.rb
838
858
  - db/data.yml
@@ -1210,12 +1230,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
1210
1230
  version: '0'
1211
1231
  required_rubygems_version: !ruby/object:Gem::Requirement
1212
1232
  requirements:
1213
- - - ">="
1233
+ - - ">"
1214
1234
  - !ruby/object:Gem::Version
1215
- version: '0'
1235
+ version: 1.3.1
1216
1236
  requirements: []
1217
1237
  rubyforge_project:
1218
- rubygems_version: 2.4.3
1238
+ rubygems_version: 2.2.2
1219
1239
  signing_key:
1220
1240
  specification_version: 4
1221
1241
  summary: Sufia was extracted from ScholarSphere developed by Penn State University
data/LICENSE.md DELETED
@@ -1,14 +0,0 @@
1
- Copyright 2012 Penn State University
2
- Additional copyright may be held by others, as reflected in the commit history.
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
@@ -1,67 +0,0 @@
1
- (function( $ ){
2
-
3
- $.fn.multiForm = function( options ) {
4
-
5
- // Create some defaults, extending them with any options that were provided
6
- var settings = $.extend( { }, options);
7
-
8
- function addField() {
9
- count = $(this).closest('.form-group').find('input').size();
10
- var cloneId = this.id.replace("submit", "clone");
11
- var newId = this.id.replace("submit", "elements");
12
- var cloneElem = $('#'+cloneId).clone();
13
- // change the add button to a remove button
14
- var plusbttn = cloneElem.find('#'+this.id);
15
- var sr_hidden = '<span aria-hidden="true"><i class="glyphicon glyphicon-remove"></i></span>';
16
- var sr_only = '<span class="sr-only">remove this ' + this.name.replace("_", " ") + '</span>';
17
- var remove_button = sr_hidden + sr_only;
18
- plusbttn.html(remove_button);
19
- plusbttn.on('click',removeField);
20
-
21
-
22
- // remove the help tag on subsequent added fields
23
- cloneElem.find('.formHelp').remove();
24
- cloneElem.find('.modal-div').remove();
25
-
26
- //clear out the value for the element being appended
27
- //so the new element has a blank value
28
- // Note: there may be more than one input field. Example:
29
- // creator_name
30
- // creator_role
31
- textFields = cloneElem.find('input[type=text]')
32
- $.each(textFields, function(n, tf) {
33
- newName = $(tf).attr('name').replace('[0]', '['+count+']');
34
- $(tf).attr('name', newName).val('').attr("required", false)
35
- })
36
-
37
- if (settings.afterAdd) {
38
- settings.afterAdd(this, cloneElem)
39
- }
40
-
41
- $('#'+newId).append(cloneElem);
42
- cloneElem.find('input[type=text]').focus();
43
- return false;
44
- }
45
-
46
- function removeField () {
47
- // get parent and remove it
48
- $(this).parent().remove();
49
- return false;
50
- }
51
-
52
- return this.each(function() {
53
-
54
- // Tooltip plugin code here
55
- /*
56
- * adds additional metadata elements
57
- */
58
- $('.adder', this).click(addField);
59
-
60
- $('.remover', this).click(removeField);
61
-
62
-
63
- });
64
-
65
- };
66
- })( jQuery );
67
-