curation_concerns 0.10.0 → 0.11.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +0 -3
  3. data/CONTRIBUTING.md +111 -0
  4. data/Gemfile +1 -1
  5. data/README.md +16 -0
  6. data/VERSION +1 -1
  7. data/app/assets/javascripts/curation_concerns/file_manager/save_manager.es6 +1 -1
  8. data/app/assets/stylesheets/curation_concerns/_positioning.scss +0 -4
  9. data/app/controllers/concerns/curation_concerns/catalog_controller.rb +1 -4
  10. data/app/controllers/concerns/curation_concerns/collections_controller_behavior.rb +4 -8
  11. data/app/controllers/concerns/curation_concerns/curation_concern_controller.rb +15 -11
  12. data/app/controllers/concerns/curation_concerns/file_sets_controller_behavior.rb +5 -13
  13. data/app/controllers/curation_concerns/permissions_controller.rb +3 -3
  14. data/app/forms/curation_concerns/forms/collection_edit_form.rb +1 -1
  15. data/app/forms/curation_concerns/forms/work_form.rb +2 -0
  16. data/app/helpers/curation_concerns/collections_helper.rb +21 -4
  17. data/app/jobs/visibility_copy_job.rb +2 -4
  18. data/app/presenters/curation_concerns/collection_presenter.rb +1 -1
  19. data/app/presenters/curation_concerns/work_show_presenter.rb +27 -4
  20. data/app/search_builders/curation_concerns/filter_by_type.rb +8 -1
  21. data/app/search_builders/curation_concerns/search_builder.rb +7 -14
  22. data/app/search_builders/curation_concerns/search_filters.rb +18 -0
  23. data/app/search_builders/curation_concerns/single_result.rb +1 -1
  24. data/app/search_builders/curation_concerns/single_use_link_search_builder.rb +1 -1
  25. data/app/search_builders/curation_concerns/work_search_builder.rb +1 -1
  26. data/app/views/curation_concerns/base/{_form_descriptive_fields.erb → _form_descriptive_fields.html.erb} +0 -0
  27. data/app/views/curation_concerns/base/_member.html.erb +12 -0
  28. data/app/views/curation_concerns/base/_related_files.html.erb +2 -2
  29. data/curation_concerns.gemspec +2 -1
  30. data/lib/curation_concerns/version.rb +1 -1
  31. data/lib/curation_concerns.rb +1 -0
  32. data/lib/generators/curation_concerns/assets_generator.rb +16 -0
  33. data/lib/generators/curation_concerns/install_generator.rb +7 -14
  34. data/lib/generators/curation_concerns/templates/catalog_controller.rb +4 -4
  35. data/lib/generators/curation_concerns/work/templates/controller.rb.erb +1 -1
  36. data/lib/generators/curation_concerns/work/templates/feature_spec.rb.erb +26 -0
  37. data/lib/generators/curation_concerns/work/work_generator.rb +5 -0
  38. data/spec/actors/curation_concerns/file_actor_spec.rb +1 -1
  39. data/spec/actors/curation_concerns/file_set_actor_spec.rb +4 -3
  40. data/spec/controllers/curation_concerns/file_sets_controller_spec.rb +14 -1
  41. data/spec/controllers/curation_concerns/permissions_controller_spec.rb +1 -1
  42. data/spec/features/add_file_spec.rb +1 -1
  43. data/spec/features/collection_spec.rb +1 -11
  44. data/spec/features/create_work_spec.rb +1 -1
  45. data/spec/features/embargo_spec.rb +1 -1
  46. data/spec/features/lease_spec.rb +1 -1
  47. data/spec/features/update_file_spec.rb +1 -1
  48. data/spec/features/work_generator_spec.rb +1 -1
  49. data/spec/forms/work_form_spec.rb +5 -0
  50. data/spec/helpers/curation_concerns/collections_helper_spec.rb +19 -5
  51. data/spec/indexers/collection_indexer_spec.rb +1 -1
  52. data/spec/javascripts/save_manager_spec.coffee +1 -0
  53. data/spec/jobs/audit_job_spec.rb +3 -7
  54. data/spec/jobs/characterize_job_spec.rb +4 -4
  55. data/spec/jobs/create_derivatives_job_spec.rb +4 -4
  56. data/spec/jobs/import_url_job_spec.rb +6 -6
  57. data/spec/jobs/ingest_file_job_spec.rb +6 -6
  58. data/spec/jobs/visibility_copy_job_spec.rb +3 -3
  59. data/spec/models/file_set_spec.rb +6 -0
  60. data/spec/models/generic_work_spec.rb +6 -0
  61. data/spec/presenters/curation_concerns/work_show_presenter_spec.rb +25 -1
  62. data/spec/search_builders/curation_concerns/file_set_search_builder_spec.rb +2 -2
  63. data/spec/search_builders/curation_concerns/search_builder_spec.rb +16 -3
  64. data/spec/spec_helper.rb +2 -2
  65. data/spec/test_app_templates/Gemfile.extra +0 -1
  66. data/spec/views/curation_concerns/{file_sets/_file_set.html.erb_spec.rb → base/_member.html.erb_spec.rb} +2 -2
  67. data/vendor/assets/{javascrips → javascripts}/fileupload/jquery.fileupload-process.js +0 -0
  68. data/vendor/assets/{javascrips → javascripts}/fileupload/jquery.fileupload-ui.js +0 -0
  69. data/vendor/assets/{javascrips → javascripts}/fileupload/jquery.fileupload-validate.js +0 -0
  70. data/vendor/assets/{javascrips → javascripts}/fileupload/jquery.fileupload.js +0 -0
  71. data/vendor/assets/{javascrips → javascripts}/fileupload/locale.js +0 -0
  72. data/vendor/assets/{javascrips → javascripts}/fileupload/tmpl.js +0 -0
  73. metadata +36 -21
  74. data/app/views/curation_concerns/file_sets/_file_set.html.erb +0 -12
  75. data/lib/curation_concerns/form_builder.rb +0 -16
  76. data/spec/jobs/active_fedora_id_based_job_spec.rb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 942802ebcf7c7e14d4ee9470a4a3a215af0bca4d
4
- data.tar.gz: 468ff214bd88dcc7ec4d226d51974e16061fccde
3
+ metadata.gz: 4c78f15b06d8b5d61d52a99b9498950819fffdc9
4
+ data.tar.gz: 79effc2f8a6b6ecec62815cbe91e5a5f0987f239
5
5
  SHA512:
6
- metadata.gz: 031509db45e6bd7c1bedb70cc4be63c0cf42ef0d5516178c8462534a51c45fc0c82259ce95ab4724d0216cd7fe529f2e256dc074367096074a680b539bc810ba
7
- data.tar.gz: be8bd2e85ac10c0c98b3ad0194e9f1db681028b5999ad754b97026ac15fa3fe958065115711bdd12ab57e2f77d67d4faa7ba3c9c66e3af90e8a789a34b3bb8c6
6
+ metadata.gz: ad7c5e7f4605f50a235bd79d2fce714e59fb3febd3f26f17e20fe3d21bf2aafa378dd3d44a8ce9dcb480f74e62d01640cbb0e0cebd5c5a6819848f0cab06a7eb
7
+ data.tar.gz: 4f736f41c13de86dd6ed2004c35407024efbac2e8b3a6114dac7674e20fa61d04ea2811b1fa0fc89b325dc6fec9dff6c6f7c0ffa7b487abe789f94cc50c908ed
data/.rubocop.yml CHANGED
@@ -1,5 +1,4 @@
1
1
  require: rubocop-rspec
2
-
3
2
  AllCops:
4
3
  DisplayCopNames: true
5
4
  Include:
@@ -178,9 +177,7 @@ RSpec/DescribeClass:
178
177
  Exclude:
179
178
  - 'spec/javascripts/jasmine_spec.rb'
180
179
  - 'spec/tasks/rake_spec.rb'
181
- - 'spec/jobs/event_jobs_spec.rb'
182
180
  - 'spec/abilities/**/*'
183
- - 'spec/features/**/*'
184
181
  - 'spec/views/**/*'
185
182
  - 'spec/routing/**/*'
186
183
  - 'spec/inputs/**/*'
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,111 @@
1
+ # How to Contribute
2
+
3
+ We want your help to make Project Hydra great.
4
+ There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
5
+
6
+ ## Hydra Project Intellectual Property Licensing and Ownership
7
+
8
+ All code contributors must have an Individual Contributor License Agreement (iCLA) on file with the Hydra Project Steering Group.
9
+ If the contributor works for an institution, the institution must have a Corporate Contributor License Agreement (cCLA) on file.
10
+
11
+ https://wiki.duraspace.org/display/hydra/Hydra+Project+Intellectual+Property+Licensing+and+Ownership
12
+
13
+ ## Contribution Tasks
14
+
15
+ * Reporting Issues
16
+ * Making Changes
17
+ * Submitting Changes
18
+ * Merging Changes
19
+
20
+ ### Reporting Issues
21
+
22
+ * Make sure you have a [GitHub account](https://github.com/signup/free)
23
+ * Submit a [Github issue](./issues) by:
24
+ * Clearly describing the issue
25
+ * Provide a descriptive summary
26
+ * Explain the expected behavior
27
+ * Explain the actual behavior
28
+ * Provide steps to reproduce the actual behavior
29
+
30
+ ### Making Changes
31
+
32
+ * Fork the repository on GitHub
33
+ * Create a topic branch from where you want to base your work.
34
+ * This is usually the master branch.
35
+ * To quickly create a topic branch based on master; `git branch fix/master/my_contribution master`
36
+ * Then checkout the new branch with `git checkout fix/master/my_contribution`.
37
+ * Please avoid working directly on the `master` branch.
38
+ * You may find the [hub suite of commands](https://github.com/defunkt/hub) helpful
39
+ * Make commits of logical units.
40
+ * Your commit should include a high level description of your work in HISTORY.textile
41
+ * Check for unnecessary whitespace with `git diff --check` before committing.
42
+ * Make sure your commit messages are [well formed](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
43
+ * If you created an issue, you can close it by including "Closes #issue" in your commit message. See [Github's blog post for more details](https://github.com/blog/1386-closing-issues-via-commit-messages)
44
+
45
+ ```
46
+ Present tense short summary (50 characters or less)
47
+
48
+ More detailed description, if necessary. It should be wrapped to 72
49
+ characters. Try to be as descriptive as you can, even if you think that
50
+ the commit content is obvious, it may not be obvious to others. You
51
+ should add such description also if it's already present in bug tracker,
52
+ it should not be necessary to visit a webpage to check the history.
53
+
54
+ Include Closes #<issue-number> when relavent.
55
+
56
+ Description can have multiple paragraphs and you can use code examples
57
+ inside, just indent it with 4 spaces:
58
+
59
+ class PostsController
60
+ def index
61
+ respond_with Post.limit(10)
62
+ end
63
+ end
64
+
65
+ You can also add bullet points:
66
+
67
+ - you can use dashes or asterisks
68
+
69
+ - also, try to indent next line of a point for readability, if it's too
70
+ long to fit in 72 characters
71
+ ```
72
+
73
+ * Make sure you have added the necessary tests for your changes.
74
+ * Run _all_ the tests to assure nothing else was accidentally broken.
75
+ * When you are ready to submit a pull request
76
+
77
+ ### Submitting Changes
78
+
79
+ [Detailed Walkthrough of One Pull Request per Commit](http://ndlib.github.io/practices/one-commit-per-pull-request/)
80
+
81
+ * Read the article ["Using Pull Requests"](https://help.github.com/articles/using-pull-requests) on GitHub.
82
+ * Make sure your branch is up to date with its parent branch (i.e. master)
83
+ * `git checkout master`
84
+ * `git pull --rebase`
85
+ * `git checkout <your-branch>`
86
+ * `git rebase master`
87
+ * It is likely a good idea to run your tests again.
88
+ * Squash the commits for your branch into one commit
89
+ * `git rebase --interactive HEAD~<number-of-commits>` ([See Github help](https://help.github.com/articles/interactive-rebase))
90
+ * To determine the number of commits on your branch: `git log master..<your-branch> --oneline | wc -l`
91
+ * Squashing your branch's changes into one commit is "good form" and helps the person merging your request to see everything that is going on.
92
+ * Push your changes to a topic branch in your fork of the repository.
93
+ * Submit a pull request from your fork to the project.
94
+
95
+ ### Merging Changes
96
+
97
+ * It is considered "poor from" to merge your own request.
98
+ * Please take the time to review the changes and get a sense of what is being changed. Things to consider:
99
+ * Does the commit message explain what is going on?
100
+ * Does the code changes have tests? _Not all changes need new tests, some changes are refactorings_
101
+ * Does the commit contain more than it should? Are two separate concerns being addressed in one commit?
102
+ * Did the Travis tests complete successfully?
103
+ * If you are uncertain, bring other contributors into the conversation by creating a comment that includes their @username.
104
+ * If you like the pull request, but want others to chime in, create a +1 comment and tag a user.
105
+
106
+ # Additional Resources
107
+
108
+ * [General GitHub documentation](http://help.github.com/)
109
+ * [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
110
+ * [Pro Git](http://git-scm.com/book) is both a free and excellent book about Git.
111
+ * [A Git Config for Contributing](http://ndlib.github.io/practices/my-typical-per-project-git-config/)
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ gemspec
6
6
  gem 'curation_concerns-models', path: './curation_concerns-models'
7
7
 
8
8
  group :development, :test do
9
- gem 'rubocop', require: false
9
+ gem 'rubocop', '~> 0.37.0', require: false
10
10
  gem 'rubocop-rspec', '~> 1.3.1', require: false
11
11
  gem 'simplecov', '~> 0.9', require: false
12
12
  gem 'coveralls', require: false
data/README.md CHANGED
@@ -11,6 +11,18 @@
11
11
 
12
12
  A Hydra-based Rails Engine that extends an application, adding the ability to Create, Read, Update and Destroy (CRUD) objects (based on [Hydra::Works](http://github.com/projecthydra-labs/hydra-works)) and providing a generator for defining object types with custom workflows, views, access controls, etc.
13
13
 
14
+ ## Prerequisites
15
+
16
+ Curation Concerns requires the following software to work:
17
+
18
+ 1. Solr
19
+ 1. [Fedora Commons](http://www.fedora-commons.org/) digital repository
20
+ 1. A SQL RDBMS (MySQL, PostgreSQL), though **note** that SQLite will be used by default if you're looking to get up and running quickly
21
+ 1. [Redis](http://redis.io/), a key-value store
22
+ 1. [ImageMagick](http://www.imagemagick.org/) with JPEG-2000 support
23
+ 1. [FITS](#characterization) version 0.6.x
24
+ 1. [LibreOffice](#derivatives)
25
+
14
26
  ## Installation
15
27
 
16
28
  Checkout the dependencies for [curation_concerns-models](https://github.com/projecthydra-labs/curation_concerns/tree/master/curation_concerns-models#dependencies), which is installed as part of curation_concerns.
@@ -58,3 +70,7 @@ Or you can do all the steps manually:
58
70
  # in another window
59
71
  $ rake engine_cart:generate
60
72
  $ rake curation_concerns:spec
73
+
74
+ ## Help
75
+
76
+ If you have questions or need help, please email [the Hydra community tech list](mailto:hydra-tech@googlegroups.com) or stop by [the Hydra community IRC channel](irc://irc.freenode.net/projecthydra).
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.0
1
+ 0.11.0.rc1
@@ -5,7 +5,7 @@ class SaveManager {
5
5
  }
6
6
 
7
7
  override_save_button() {
8
- jQuery(() => {
8
+ Blacklight.onLoad(() => {
9
9
  this.save_button.click(this.clicked_save)
10
10
  })
11
11
  }
@@ -1,7 +1,3 @@
1
- body {
2
- padding:0 1em 1em;
3
- }
4
-
5
1
  #brand-bar-wrapper, #title-bar-wrapper {
6
2
  margin-left:-1em;
7
3
  margin-right:-1em;
@@ -14,10 +14,6 @@ module CurationConcerns::CatalogController
14
14
  end
15
15
 
16
16
  module ClassMethods
17
- def t(*args)
18
- I18n.translate(*args)
19
- end
20
-
21
17
  def uploaded_field
22
18
  # system_create_dtsi
23
19
  solr_name('date_uploaded', :stored_sortable, type: :date)
@@ -28,6 +24,7 @@ module CurationConcerns::CatalogController
28
24
  end
29
25
 
30
26
  def search_config
27
+ ActiveSupport::Deprecation.warn("#{self.class}.search_config is deprecated and will be removed in CurationConcerns 1.0")
31
28
  { 'qf' => %w(title_tesim name_tesim), 'qt' => 'search', 'rows' => 10 }
32
29
  end
33
30
  end
@@ -8,6 +8,10 @@ module CurationConcerns
8
8
  before_action :filter_docs_with_read_access!, except: :show
9
9
  layout 'curation_concerns/1_column'
10
10
  skip_load_and_authorize_resource only: :show
11
+
12
+ class_attribute :presenter_class, :form_class
13
+ self.presenter_class = CurationConcerns::CollectionPresenter
14
+ self.form_class = CurationConcerns::Forms::CollectionEditForm
11
15
  end
12
16
 
13
17
  def new
@@ -65,10 +69,6 @@ module CurationConcerns
65
69
  end
66
70
  end
67
71
 
68
- def presenter_class
69
- CurationConcerns::CollectionPresenter
70
- end
71
-
72
72
  def collection_search_builder_class
73
73
  CurationConcerns::WorkSearchBuilder
74
74
  end
@@ -97,10 +97,6 @@ module CurationConcerns
97
97
  @form ||= form_class.new(@collection)
98
98
  end
99
99
 
100
- def form_class
101
- CurationConcerns::Forms::CollectionEditForm
102
- end
103
-
104
100
  # Include 'catalog' and 'curation_concerns/base' in the search path for views
105
101
  def _prefixes
106
102
  @_prefixes ||= super + ['catalog', 'curation_concerns/base']
@@ -9,17 +9,27 @@ module CurationConcerns::CurationConcernController
9
9
  with_themed_layout '1_column'
10
10
  helper CurationConcerns::AbilityHelper
11
11
 
12
- class_attribute :curation_concern_type
12
+ class_attribute :_curation_concern_type, :show_presenter
13
+ self.show_presenter = CurationConcerns::WorkShowPresenter
13
14
  attr_accessor :curation_concern
14
15
  helper_method :curation_concern
15
16
  end
16
17
 
17
18
  module ClassMethods
18
19
  def set_curation_concern_type(curation_concern_type)
19
- load_and_authorize_resource class: curation_concern_type, instance_name: :curation_concern, except: [:show, :file_manager]
20
+ Deprecation.warn self, "set_curation_concern_type is deprecated and will be removed in curation_concerns 1.0. Use self.curation_concern_type = #{curation_concern_type} instead."
20
21
  self.curation_concern_type = curation_concern_type
21
22
  end
22
23
 
24
+ def curation_concern_type=(curation_concern_type)
25
+ load_and_authorize_resource class: curation_concern_type, instance_name: :curation_concern, except: [:show, :file_manager]
26
+ self._curation_concern_type = curation_concern_type
27
+ end
28
+
29
+ def curation_concern_type
30
+ _curation_concern_type
31
+ end
32
+
23
33
  def cancan_resource_class
24
34
  CurationConcerns::ControllerResource
25
35
  end
@@ -54,7 +64,7 @@ module CurationConcerns::CurationConcernController
54
64
  # load and authorize @curation_concern manually because it's skipped for html
55
65
  # This has to use #find instead of #load_instance_from_solr because
56
66
  # we want to return values like file_set_ids in the json
57
- @curation_concern = curation_concern_type.find(params[:id]) unless curation_concern
67
+ @curation_concern = _curation_concern_type.find(params[:id]) unless curation_concern
58
68
  authorize! :show, @curation_concern
59
69
  render :show, status: :ok
60
70
  end
@@ -94,16 +104,10 @@ module CurationConcerns::CurationConcernController
94
104
 
95
105
  protected
96
106
 
97
- # Gives the class of the show presenter. Override this if you want
98
- # to use a different presenter.
99
- def show_presenter
100
- CurationConcerns::WorkShowPresenter
101
- end
102
-
103
107
  # Gives the class of the form. Override this if you want
104
108
  # to use a different form.
105
109
  def form_class
106
- CurationConcerns.const_get("#{self.class.curation_concern_type.to_s.demodulize}Form")
110
+ CurationConcerns.const_get("#{_curation_concern_type.to_s.demodulize}Form")
107
111
  end
108
112
 
109
113
  def build_form
@@ -154,7 +158,7 @@ module CurationConcerns::CurationConcernController
154
158
  end
155
159
 
156
160
  def hash_key_for_curation_concern
157
- self.class.curation_concern_type.model_name.param_key
161
+ _curation_concern_type.model_name.param_key
158
162
  end
159
163
 
160
164
  # Override this method to add additional response
@@ -11,6 +11,10 @@ module CurationConcerns
11
11
  helper_method :curation_concern
12
12
  include CurationConcerns::ParentContainer
13
13
  copy_blacklight_config_from(::CatalogController)
14
+
15
+ class_attribute :show_presenter, :form_class
16
+ self.show_presenter = CurationConcerns::FileSetPresenter
17
+ self.form_class = CurationConcerns::Forms::FileSetEditForm
14
18
  end
15
19
 
16
20
  def curation_concern
@@ -65,18 +69,6 @@ module CurationConcerns
65
69
  end
66
70
  end
67
71
 
68
- # Gives the class of the show presenter. Override this if you want
69
- # to use a different presenter.
70
- def show_presenter
71
- CurationConcerns::FileSetPresenter
72
- end
73
-
74
- # Gives the class of the form. Override this if you want
75
- # to use a different form.
76
- def form_class
77
- CurationConcerns::Forms::FileSetEditForm
78
- end
79
-
80
72
  def destroy
81
73
  parent = @file_set.in_works.first
82
74
  actor.destroy
@@ -211,7 +203,7 @@ module CurationConcerns
211
203
  else
212
204
  msg = @file_set.errors.full_messages.join(', ')
213
205
  flash[:error] = msg
214
- json_error "Error creating generic file: #{msg}"
206
+ json_error "Error creating generic file #{file.original_filename}: #{msg}"
215
207
  end
216
208
  end
217
209
 
@@ -1,18 +1,18 @@
1
1
  class CurationConcerns::PermissionsController < ApplicationController
2
2
  include CurationConcerns::CurationConcernController
3
3
  with_themed_layout '1_column'
4
- self.curation_concern_type = ActiveFedora::Base
5
4
 
6
5
  def confirm
7
6
  end
8
7
 
9
8
  def copy
10
- VisibilityCopyJob.perform_later(curation_concern.id)
9
+ authorize! :edit, curation_concern
10
+ VisibilityCopyJob.perform_later(curation_concern)
11
11
  flash_message = 'Updating file permissions. This may take a few minutes. You may want to refresh your browser or return to this record later to see the updated file permissions.'
12
12
  redirect_to [main_app, curation_concern], notice: flash_message
13
13
  end
14
14
 
15
15
  def curation_concern
16
- @curation_concern ||= curation_concern_type.find(params[:id], cast: true)
16
+ @curation_concern ||= ActiveFedora::Base.find(params[:id])
17
17
  end
18
18
  end
@@ -55,7 +55,7 @@ module CurationConcerns
55
55
  private
56
56
 
57
57
  def all_files
58
- member_presenters.flat_map(&:file_presenters).map { |x| [x.to_s, x.id] }
58
+ member_presenters.flat_map(&:file_set_presenters).map { |x| [x.to_s, x.id] }
59
59
  end
60
60
 
61
61
  def member_presenters
@@ -16,6 +16,8 @@ module CurationConcerns
16
16
  :visibility_during_lease, :lease_expiration_date, :visibility_after_lease,
17
17
  :visibility, :ordered_member_ids]
18
18
 
19
+ self.required_fields = [:title]
20
+
19
21
  # @param [ActiveFedora::Base,#member_ids] model
20
22
  # @param [Ability] current_ability
21
23
  def initialize(model, current_ability)
@@ -47,10 +47,27 @@ module CurationConcerns::CollectionsHelper
47
47
  # If you have implement User.collections, the results of that will be used.
48
48
  def current_users_collections
49
49
  if current_user.respond_to?(:collections)
50
- current_user.collections.map { |c| [c.title.join(', '), c.id] }
51
- else
52
- query = ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: Collection.to_class_uri)
53
- ActiveFedora::SolrService.query(query, fl: 'title_tesim id', rows: 1000).map { |r| [r['title_tesim'].join(', '), r['id']] }.sort { |a, b| a.first <=> b.first }
50
+ return current_user.collections.map { |c| [c.title.join(', '), c.id] }
54
51
  end
52
+ query = ActiveFedora::SolrQueryBuilder
53
+ .construct_query_for_rel(
54
+ has_model: Collection.to_class_uri)
55
+ convert_solr_docs_to_select_options(
56
+ ActiveFedora::SolrService.query(query,
57
+ fl: 'title_tesim id',
58
+ rows: 1000)
59
+ )
60
+ end
61
+
62
+ def convert_solr_docs_to_select_options(results)
63
+ results
64
+ .map { |r| [SolrDocument.new(r).title, r['id']] }
65
+ .sort do |a, b|
66
+ if a.first && b.first
67
+ a.first <=> b.first
68
+ else
69
+ a.first ? -1 : 1
70
+ end
71
+ end
55
72
  end
56
73
  end
@@ -1,9 +1,7 @@
1
- class VisibilityCopyJob < ActiveFedoraIdBasedJob
1
+ class VisibilityCopyJob < ActiveJob::Base
2
2
  queue_as :permissions
3
3
 
4
- def perform(id)
5
- @id = id
6
- work = object
4
+ def perform(work)
7
5
  work.file_sets.each do |file|
8
6
  file.visibility = work.visibility # visibility must come first, because it can clear an embargo/lease
9
7
  if work.lease
@@ -21,7 +21,7 @@ module CurationConcerns
21
21
  :embargo_release_date, :lease_expiration_date, :rights, :date_created, to: :solr_document
22
22
 
23
23
  def size
24
- number_to_human_size(@solr_document['bytes_is'])
24
+ number_to_human_size(@solr_document['bytes_lts'])
25
25
  end
26
26
 
27
27
  def total_items
@@ -24,20 +24,43 @@ module CurationConcerns
24
24
  :creator, :contributor, :subject, :publisher, :language, :embargo_release_date,
25
25
  :lease_expiration_date, :rights, to: :solr_document
26
26
 
27
+ # @return [Array<FileSetPresenter>] presenters for the orderd_members that are FileSets
28
+ def file_set_presenters
29
+ @file_set_presenters ||= member_presenters(ordered_ids & file_set_ids)
30
+ end
31
+
32
+ # @deprecated
33
+ # @return [Array<FileSetPresenter>] presenters for the orderd_members that are FileSets
27
34
  def file_presenters
28
- @file_sets ||= PresenterFactory.build_presenters(ordered_ids,
29
- file_presenter_class,
30
- current_ability)
35
+ Deprecation.warn WorkShowPresenter, "file_presenters is deprecated and will be removed in CurationConcerns 1.0. Use file_set_presenters or member_presenters instead."
36
+ member_presenters
37
+ end
38
+
39
+ # @return [Array<FileSetPresenter>] presenters for the ordered_members (not filtered by class)
40
+ def member_presenters(ids = ordered_ids)
41
+ PresenterFactory.build_presenters(ids,
42
+ file_presenter_class,
43
+ current_ability)
31
44
  end
32
45
 
33
46
  private
34
47
 
35
48
  # TODO: Extract this to ActiveFedora::Aggregations::ListSource
36
49
  def ordered_ids
37
- ActiveFedora::SolrService.query("proxy_in_ssi:#{id}", fl: "ordered_targets_ssim")
50
+ ActiveFedora::SolrService.query("proxy_in_ssi:#{id}",
51
+ fl: "ordered_targets_ssim")
38
52
  .flat_map { |x| x.fetch("ordered_targets_ssim", []) }
39
53
  end
40
54
 
55
+ # These are the file sets that belong to this work, but not necessarily
56
+ # in order.
57
+ def file_set_ids
58
+ ActiveFedora::SolrService.query("{!field f=has_model_ssim}FileSet",
59
+ fl: "id",
60
+ fq: "{!join from=ordered_targets_ssim to=id}id:\"#{id}/list_source\"")
61
+ .flat_map { |x| x.fetch("id", []) }
62
+ end
63
+
41
64
  # Override this method if you want to use an alternate presenter class for the files
42
65
  def file_presenter_class
43
66
  FileSetPresenter
@@ -14,9 +14,16 @@ module CurationConcerns
14
14
 
15
15
  private
16
16
 
17
+ # Override this method if you want to limit some of the registered
18
+ # types from appearing in search results
19
+ # @returns [Array<Class>] the list of work types to include in searches
20
+ def work_types
21
+ CurationConcerns.config.curation_concerns
22
+ end
23
+
17
24
  def work_clauses
18
25
  return [] if blacklight_params.key?(:f) && Array(blacklight_params[:f][:generic_type_sim]).include?('Collection')
19
- CurationConcerns.config.registered_curation_concern_types.map(&:constantize).map do |klass|
26
+ work_types.map do |klass|
20
27
  ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: klass.to_class_uri)
21
28
  end
22
29
  end
@@ -1,17 +1,10 @@
1
- class CurationConcerns::SearchBuilder < Hydra::SearchBuilder
2
- include BlacklightAdvancedSearch::AdvancedSearchBuilder
3
- include CurationConcerns::FilterByType
4
-
5
- # Override Hydra::AccessControlsEnforcement (or Hydra::PolicyAwareAccessControlsEnforcement)
6
- # Allows admin users to see everything (don't apply any gated_discovery_filters for those users)
7
- def gated_discovery_filters(permission_types = discovery_permissions, ability = current_ability)
8
- return [] if ability.current_user.groups.include? 'admin'
9
- super
10
- end
11
-
12
- # show only files with edit permissions in lib/hydra/access_controls_enforcement.rb apply_gated_discovery
13
- def discovery_permissions
14
- return ['edit'] if blacklight_params[:works] == 'mine'
1
+ class CurationConcerns::SearchBuilder < Blacklight::SearchBuilder
2
+ include Blacklight::Solr::SearchBuilderBehavior
3
+ include Hydra::AccessControlsEnforcement
4
+ include CurationConcerns::SearchFilters
5
+ extend Deprecation
6
+ def initialize(*)
7
+ Deprecation.warn CurationConcerns::SearchBuilder, "CurationConcerns::SearchBuilder is deprecated and will be removed in CurationConcerns 1.0. Add CurationConcerns::SearchFilters to your own SearchBuilder instead"
15
8
  super
16
9
  end
17
10
  end
@@ -0,0 +1,18 @@
1
+ module CurationConcerns::SearchFilters
2
+ extend ActiveSupport::Concern
3
+ include BlacklightAdvancedSearch::AdvancedSearchBuilder
4
+ include CurationConcerns::FilterByType
5
+
6
+ # Override Hydra::AccessControlsEnforcement (or Hydra::PolicyAwareAccessControlsEnforcement)
7
+ # Allows admin users to see everything (don't apply any gated_discovery_filters for those users)
8
+ def gated_discovery_filters(permission_types = discovery_permissions, ability = current_ability)
9
+ return [] if ability.current_user.groups.include? 'admin'
10
+ super
11
+ end
12
+
13
+ # show only files with edit permissions in lib/hydra/access_controls_enforcement.rb apply_gated_discovery
14
+ def discovery_permissions
15
+ return ['edit'] if blacklight_params[:works] == 'mine'
16
+ super
17
+ end
18
+ end
@@ -7,7 +7,7 @@ module CurationConcerns
7
7
  end
8
8
 
9
9
  def find_one(solr_parameters)
10
- solr_parameters[:fq] << "_query_:\"{!raw f=id}#{blacklight_params.fetch(:id)}\""
10
+ solr_parameters[:fq] << "_query_:\"{!field f=id}#{blacklight_params.fetch(:id)}\""
11
11
  end
12
12
  end
13
13
  end
@@ -1,5 +1,5 @@
1
1
  module CurationConcerns
2
- class SingleUseLinkSearchBuilder < CurationConcerns::SearchBuilder
2
+ class SingleUseLinkSearchBuilder < ::SearchBuilder
3
3
  include CurationConcerns::SingleResult
4
4
  self.default_processor_chain = [:find_one]
5
5
  end
@@ -1,5 +1,5 @@
1
1
  module CurationConcerns
2
- class WorkSearchBuilder < CurationConcerns::SearchBuilder
2
+ class WorkSearchBuilder < ::SearchBuilder
3
3
  include CurationConcerns::SingleResult
4
4
  end
5
5
  end
@@ -0,0 +1,12 @@
1
+ <tr class="<%= dom_class(member) %> attributes">
2
+ <td class="thumbnail">
3
+ <%= render_thumbnail_tag member %>
4
+ </td>
5
+ <td class="attribute filename"><%= link_to(member.link_name, main_app.curation_concerns_file_set_path(member)) %></td>
6
+ <td class="attribute date_uploaded"><%= member.date_uploaded %></td>
7
+ <td class="attribute permission"><%= member.permission_badge %></td>
8
+ <td>
9
+ <%= render 'curation_concerns/file_sets/actions', file_set: member %>
10
+ </td>
11
+ </tr>
12
+
@@ -1,4 +1,4 @@
1
- <% if presenter.file_presenters.present? %>
1
+ <% if presenter.file_set_presenters.present? %>
2
2
  <div class="panel panel-default related_files">
3
3
  <div class="panel-heading">
4
4
  <h2>Files</h2>
@@ -14,7 +14,7 @@
14
14
  </tr>
15
15
  </thead>
16
16
  <tbody>
17
- <%= render presenter.file_presenters %>
17
+ <%= render partial: 'member', collection: presenter.file_set_presenters %>
18
18
  </tbody>
19
19
  </table>
20
20
  </div>
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
17
  spec.require_paths = ["lib"]
18
18
 
19
- spec.add_dependency 'hydra-head', '~> 9.6'
19
+ spec.add_dependency 'hydra-head', '~> 9.9'
20
20
  spec.add_dependency 'blacklight', '~> 6.0'
21
21
  spec.add_dependency "breadcrumbs_on_rails", "~> 2.3"
22
22
  spec.add_dependency "jquery-ui-rails"
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency 'blacklight_advanced_search', '~> 6.0'
27
27
  spec.add_dependency 'rails_autolink'
28
28
  spec.add_dependency 'sprockets-es6'
29
+ spec.add_dependency 'kaminari_route_prefix', '~> 0.0.1'
29
30
 
30
31
  spec.add_development_dependency 'solr_wrapper', '~> 0.4'
31
32
  spec.add_development_dependency 'fcrepo_wrapper', '~> 0.1'
@@ -1,3 +1,3 @@
1
1
  module CurationConcerns
2
- VERSION = "0.10.0".freeze
2
+ VERSION = "0.11.0.rc1".freeze
3
3
  end