curation_concerns 2.0.0.rc1 → 2.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +0 -12
  3. data/.travis.yml +6 -1
  4. data/CONTRIBUTING.md +68 -20
  5. data/app/actors/curation_concerns/actors/add_as_member_of_collections_actor.rb +3 -0
  6. data/app/actors/curation_concerns/actors/add_to_work_actor.rb +16 -4
  7. data/app/actors/curation_concerns/actors/apply_order_actor.rb +16 -5
  8. data/app/actors/curation_concerns/optimistic_lock_validator.rb +28 -0
  9. data/app/assets/javascripts/curation_concerns/file_manager/sorting.es6 +17 -7
  10. data/app/controllers/concerns/curation_concerns/curation_concern_controller.rb +11 -1
  11. data/app/controllers/concerns/curation_concerns/download_behavior.rb +6 -0
  12. data/app/forms/curation_concerns/forms/file_manager_form.rb +27 -0
  13. data/app/forms/curation_concerns/forms/work_form.rb +8 -0
  14. data/app/indexers/curation_concerns/file_set_indexer.rb +2 -2
  15. data/app/jobs/characterize_job.rb +12 -5
  16. data/app/jobs/create_derivatives_job.rb +10 -5
  17. data/app/jobs/ingest_file_job.rb +13 -9
  18. data/app/models/concerns/curation_concerns/ability.rb +1 -0
  19. data/app/models/concerns/curation_concerns/collection_behavior.rb +1 -1
  20. data/app/models/concerns/curation_concerns/work_behavior.rb +6 -0
  21. data/app/presenters/curation_concerns/admin/workflow_role_presenter.rb +4 -0
  22. data/app/presenters/curation_concerns/member_presenter_factory.rb +70 -0
  23. data/app/presenters/curation_concerns/work_show_presenter.rb +7 -47
  24. data/app/services/curation_concerns/actors/actor_factory.rb +2 -1
  25. data/app/services/curation_concerns/workflow/grant_edit_to_depositor.rb +1 -1
  26. data/app/services/curation_concerns/workflow/permission_query.rb +4 -1
  27. data/app/services/curation_concerns/workflow/workflow_importer.rb +1 -0
  28. data/app/services/curation_concerns/workflow/workflow_schema.rb +1 -0
  29. data/app/views/curation_concerns/admin/workflow_roles/index.html.erb +1 -2
  30. data/app/views/curation_concerns/base/_file_manager_member_resource_options.html.erb +2 -2
  31. data/app/views/curation_concerns/base/_file_manager_members.html.erb +13 -5
  32. data/app/views/curation_concerns/base/_file_manager_resource_form.html.erb +1 -1
  33. data/app/views/curation_concerns/base/_form.html.erb +5 -0
  34. data/app/views/curation_concerns/base/_form_in_works_error.html.erb +3 -0
  35. data/app/views/curation_concerns/base/_form_ordered_members_error.html.erb +3 -0
  36. data/app/views/curation_concerns/base/file_manager.html.erb +2 -2
  37. data/app/views/curation_concerns/base/show.json.jbuilder +2 -1
  38. data/config/locales/curation_concerns.en.yml +4 -0
  39. data/curation_concerns.gemspec +1 -1
  40. data/db/migrate/20170308175556_add_allows_access_grant_to_workflow.rb +5 -0
  41. data/lib/curation_concerns/data_migration/collections_migration.rb +16 -0
  42. data/lib/curation_concerns/version.rb +1 -1
  43. data/lib/generators/curation_concerns/templates/workflow.json.erb +1 -0
  44. data/lib/tasks/curation_concerns.rake +12 -0
  45. data/spec/actors/curation_concerns/add_as_member_of_collections_actor_spec.rb +58 -0
  46. data/spec/actors/curation_concerns/apply_order_actor_spec.rb +20 -0
  47. data/spec/actors/curation_concerns/optimistic_lock_validator_spec.rb +50 -0
  48. data/spec/actors/curation_concerns/work_actor_spec.rb +9 -6
  49. data/spec/controllers/curation_concerns/generic_works_controller_spec.rb +2 -1
  50. data/spec/controllers/downloads_controller_spec.rb +5 -6
  51. data/spec/features/create_child_work_spec.rb +16 -2
  52. data/spec/forms/curation_concerns/forms/file_manager_form_spec.rb +19 -0
  53. data/spec/forms/work_form_spec.rb +8 -0
  54. data/spec/lib/curation_concerns/data_migration/collections_migration_spec.rb +34 -0
  55. data/spec/presenters/curation_concerns/member_presenter_factory_spec.rb +25 -0
  56. data/spec/presenters/curation_concerns/work_show_presenter_spec.rb +11 -21
  57. data/spec/services/curation_concerns/workflow/grant_edit_to_depositor_spec.rb +15 -4
  58. data/spec/services/curation_concerns/workflow/permission_query_spec.rb +7 -1
  59. data/spec/services/curation_concerns/workflow/workflow_importer_spec.rb +5 -2
  60. data/spec/services/curation_concerns/workflow/workflow_schema_spec.rb +1 -0
  61. data/spec/views/curation_concerns/admin/workflow_roles/index.html.erb_spec.rb +33 -0
  62. data/spec/views/curation_concerns/base/_form.html.erb_spec.rb +35 -0
  63. data/spec/views/curation_concerns/base/file_manager.html.erb_spec.rb +10 -8
  64. data/spec/views/curation_concerns/base/show.json.jbuilder_spec.rb +3 -1
  65. metadata +26 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e81b2b7327614964ca1080ca909509a8507c50da
4
- data.tar.gz: fabb27df90a8acf516119dce697de849f7c9844c
3
+ metadata.gz: 29d4c68c5f93e50404f6ea9c1aa9a837db39e4f8
4
+ data.tar.gz: 08c65bfb19049a3c02d02cf25d01fc9714fcda90
5
5
  SHA512:
6
- metadata.gz: 9ef801991780a893dc44f81f87ca732b2760822db90fef34329b51ea1970e591debb298f59ec8b9af811e9b9ba851656e4bd8313b77f15e2ae93057c8a3c5bd2
7
- data.tar.gz: db8aa95e273ca9bff4ddce19a82f36c36142359f426d0876c6c96e9aa098d25b571b3f3f12d42e1c5a3d959b18da66488342ace5c9ab84822b0c21f8f7f82535
6
+ metadata.gz: dcf7ccd7a0e3ab73aca23c0215d7fd97905d24c9008929094314b8fad1b3facd22d88cefbf7d11856c3c9f91c59314f7c1081e078720df868dee47580e2994cb
7
+ data.tar.gz: 66f20ea8d9ac70ef5dea6afbc8a4730658d46b9b47db562b047f012a9bfb0bd80752e232cc11f1730316b91924cd322901bfcde9dd1488d52d8b0928a06f12fa
data/.rubocop.yml CHANGED
@@ -40,7 +40,6 @@ Metrics/ClassLength:
40
40
  Exclude:
41
41
  - lib/curation_concerns/configuration.rb
42
42
  - 'lib/generators/curation_concerns/templates/catalog_controller.rb'
43
- - 'app/actors/curation_concerns/file_set_actor.rb'
44
43
 
45
44
  Metrics/ModuleLength:
46
45
  Exclude:
@@ -119,12 +118,6 @@ Style/GlobalVars:
119
118
  Style/SingleLineBlockParams:
120
119
  Enabled: false
121
120
 
122
- Style/ClassVars:
123
- Exclude:
124
- - 'lib/curation_concerns/models.rb'
125
- - 'lib/curation_concerns/models/engine.rb'
126
- - 'app/models/concerns/curation_concerns/file_set/versions.rb'
127
-
128
121
  Style/SignalException:
129
122
  Enabled: false
130
123
 
@@ -163,13 +156,8 @@ RSpec/NotToNot:
163
156
  RSpec/DescribeClass:
164
157
  Exclude:
165
158
  - 'spec/javascripts/jasmine_spec.rb'
166
- - 'spec/tasks/rake_spec.rb'
167
159
  - 'spec/abilities/**/*'
168
160
  - 'spec/views/**/*'
169
161
  - 'spec/routing/**/*'
170
162
  - 'spec/inputs/**/*'
171
163
  - 'spec/conversions/**/*'
172
-
173
- RSpec/DescribedClass:
174
- Exclude:
175
- - 'spec/actors/curation_concerns/manages_embargoes_actor_spec.rb'
data/.travis.yml CHANGED
@@ -1,8 +1,12 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  sudo: false
4
+
4
5
  rvm:
5
6
  - 2.3.1
7
+
8
+ services: redis
9
+
6
10
  env:
7
11
  global:
8
12
  - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
@@ -10,6 +14,7 @@ env:
10
14
  - RAILS_VERSION=4.2.7.1
11
15
  RDF_VERSION=1.99.1
12
16
  - RAILS_VERSION=5.0.0.1
13
- RDF_VERSION=2.1.0
17
+ RDF_VERSION=2.1.1
18
+
14
19
  before_script:
15
20
  - jdk_switcher use oraclejdk8
data/CONTRIBUTING.md CHANGED
@@ -3,6 +3,13 @@
3
3
  We want your help to make Project Hydra great.
4
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
5
 
6
+ ## Code of Conduct
7
+
8
+ The Hydra community is dedicated to providing a welcoming and positive experience for all its
9
+ members, whether they are at a formal gathering, in a social setting, or taking part in activities
10
+ online. Please see our [Code of Conduct](https://wiki.duraspace.org/display/hydra/Code+of+Conduct)
11
+ for more information.
12
+
6
13
  ## Hydra Project Intellectual Property Licensing and Ownership
7
14
 
8
15
  All code contributors must have an Individual Contributor License Agreement (iCLA) on file with the Hydra Project Steering Group.
@@ -10,12 +17,16 @@ If the contributor works for an institution, the institution must have a Corpora
10
17
 
11
18
  https://wiki.duraspace.org/display/hydra/Hydra+Project+Intellectual+Property+Licensing+and+Ownership
12
19
 
20
+ You should also add yourself to the `CONTRIBUTORS.md` file in the root of the project.
21
+
13
22
  ## Contribution Tasks
14
23
 
15
24
  * Reporting Issues
16
25
  * Making Changes
26
+ * Documenting Code
27
+ * Committing Changes
17
28
  * Submitting Changes
18
- * Merging Changes
29
+ * Reviewing and Merging Changes
19
30
 
20
31
  ### Reporting Issues
21
32
 
@@ -36,8 +47,28 @@ https://wiki.duraspace.org/display/hydra/Hydra+Project+Intellectual+Property+Lic
36
47
  * Then checkout the new branch with `git checkout fix/master/my_contribution`.
37
48
  * Please avoid working directly on the `master` branch.
38
49
  * You may find the [hub suite of commands](https://github.com/defunkt/hub) helpful
50
+ * Make sure you have added sufficient tests and documentation for your changes.
51
+ * Test functionality with RSpec; est features / UI with Capybara.
52
+ * Run _all_ the tests to assure nothing else was accidentally broken.
53
+
54
+ ### Documenting Code
55
+
56
+ * All new public methods, modules, and classes should include inline documentation in [YARD](http://yardoc.org/).
57
+ * Documentation should seek to answer the question "why does this code exist?"
58
+ * Document private / protected methods as desired.
59
+ * If you are working in a file with no prior documentation, do try to document as you gain understanding of the code.
60
+ * If you don't know exactly what a bit of code does, it is extra likely that it needs to be documented. Take a stab at it and ask for feedback in your pull request. You can use the 'blame' button on GitHub to identify the original developer of the code and @mention them in your comment.
61
+ * This work greatly increases the usability of the code base and supports the on-ramping of new committers.
62
+ * We will all be understanding of one another's time constraints in this area.
63
+ * YARD examples:
64
+ * [Hydra::Works::RemoveGenericFile](https://github.com/projecthydra-labs/hydra-works/blob/master/lib/hydra/works/services/generic_work/remove_generic_file.rb)
65
+ * [ActiveTriples::LocalName::Minter](https://github.com/ActiveTriples/active_triples-local_name/blob/master/lib/active_triples/local_name/minter.rb)
66
+ * [Getting started with YARD](http://www.rubydoc.info/gems/yard/file/docs/GettingStarted.md)
67
+
68
+ ### Committing changes
69
+
39
70
  * Make commits of logical units.
40
- * Your commit should include a high level description of your work in HISTORY.textile
71
+ * Your commit should include a high level description of your work in HISTORY.textile
41
72
  * Check for unnecessary whitespace with `git diff --check` before committing.
42
73
  * Make sure your commit messages are [well formed](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
43
74
  * 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)
@@ -58,7 +89,9 @@ https://wiki.duraspace.org/display/hydra/Hydra+Project+Intellectual+Property+Lic
58
89
 
59
90
  class PostsController
60
91
  def index
61
- respond_with Post.limit(10)
92
+ respond_to do |wants|
93
+ wants.html { render 'index' }
94
+ end
62
95
  end
63
96
  end
64
97
 
@@ -70,38 +103,53 @@ https://wiki.duraspace.org/display/hydra/Hydra+Project+Intellectual+Property+Lic
70
103
  long to fit in 72 characters
71
104
  ```
72
105
 
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
106
  ### Submitting Changes
78
107
 
79
- [Detailed Walkthrough of One Pull Request per Commit](http://ndlib.github.io/practices/one-commit-per-pull-request/)
80
-
81
108
  * Read the article ["Using Pull Requests"](https://help.github.com/articles/using-pull-requests) on GitHub.
82
109
  * Make sure your branch is up to date with its parent branch (i.e. master)
83
110
  * `git checkout master`
84
111
  * `git pull --rebase`
85
112
  * `git checkout <your-branch>`
86
113
  * `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`
114
+ * It is a good idea to run your tests again.
115
+ * If you've made more than one commit take a moment to consider whether squashing commits together would help improve their logical grouping.
116
+ * [Detailed Walkthrough of One Pull Request per Commit](http://ndlib.github.io/practices/one-commit-per-pull-request/)
117
+ * `git rebase --interactive master` ([See Github help](https://help.github.com/articles/interactive-rebase))
91
118
  * 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
119
  * Push your changes to a topic branch in your fork of the repository.
93
120
  * Submit a pull request from your fork to the project.
94
121
 
95
- ### Merging Changes
122
+ ### Reviewing and Merging Changes
123
+
124
+ We adopted [Github's Pull Request Review](https://help.github.com/articles/about-pull-request-reviews/) for our repositories.
125
+ Common checks that may occur in our repositories:
126
+
127
+ 1. Travis CI - where our automated tests are running
128
+ 2. Hound CI - where we check for style violations
129
+ 3. Approval Required - Github enforces at least one person approve a pull request. Also, all reviewers that have chimed in must approve.
130
+ 4. CodeClimate - is our code remaining healthy (at least according to static code analysis)
131
+
132
+ If one or more of the required checks failed (or are incomplete), the code should not be merged (and the UI will not allow it). If all of the checks have passed, then anyone on the project (including the pull request submitter) may merge the code.
133
+
134
+ *Example: Carolyn submits a pull request, Justin reviews the pull request and approves. However, Justin is still waiting on other checks (Travis CI is usually the culprit), so he does not merge the pull request. Eventually, all of the checks pass. At this point, Carolyn or anyone else may merge the pull request.*
135
+
136
+ #### Things to Consider When Reviewing
137
+
138
+ First, the person contributing the code is putting themselves out there. Be mindful of what you say in a review.
139
+
140
+ * Ask clarifying questions
141
+ * State your understanding and expectations
142
+ * Provide example code or alternate solutions, and explain why
143
+
144
+ This is your chance for a mentoring moment of another developer. Take time to give an honest and thorough review of what has changed. Things to consider:
96
145
 
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
146
  * 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_
147
+ * Does the code changes have tests? _Not all changes need new tests, some changes are refactors_
148
+ * Do new or changed methods, modules, and classes have documentation?
101
149
  * 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.
150
+ * Does the description of the new/changed specs match your understanding of what the spec is doing?
151
+
152
+ If you are uncertain, bring other contributors into the conversation by assigning them as a reviewer.
105
153
 
106
154
  # Additional Resources
107
155
 
@@ -16,7 +16,10 @@ module CurationConcerns
16
16
  # Maps from collection ids to collection objects
17
17
  def add_to_collections(collection_ids)
18
18
  return true unless collection_ids
19
+ # grab/save collections this user has no edit access to
20
+ other_collections = curation_concern.member_of_collections.select { |coll| !coll.edit_users.include?(user.user_key) }
19
21
  curation_concern.member_of_collections = collection_ids.map { |id| ::Collection.find(id) }
22
+ curation_concern.member_of_collections.concat other_collections
20
23
  end
21
24
  end
22
25
  end
@@ -13,6 +13,14 @@ module CurationConcerns
13
13
 
14
14
  private
15
15
 
16
+ def ability
17
+ ::Ability.new(user)
18
+ end
19
+
20
+ def can_edit_both_works?(work)
21
+ ability.can?(:edit, work) && ability.can?(:edit, curation_concern)
22
+ end
23
+
16
24
  def add_to_works(new_work_ids)
17
25
  return true if new_work_ids.nil?
18
26
  (curation_concern.in_works_ids - new_work_ids).each do |old_id|
@@ -22,13 +30,17 @@ module CurationConcerns
22
30
  work.save
23
31
  end
24
32
 
25
- # add to new
33
+ # add to new so long as the depositor for the parent and child matches, otherwise inject an error
26
34
  (new_work_ids - curation_concern.in_works_ids).each do |work_id|
27
35
  work = ::ActiveFedora::Base.find(work_id)
28
- work.ordered_members << curation_concern
29
- work.save
36
+ if can_edit_both_works?(work)
37
+ work.ordered_members << curation_concern
38
+ work.save
39
+ else
40
+ curation_concern.errors[:in_works_ids] << "Works can only be related to each other if user has ability to edit both."
41
+ end
30
42
  end
31
- true
43
+ curation_concern.errors[:in_works_ids].empty?
32
44
  end
33
45
  end
34
46
  end
@@ -3,12 +3,19 @@ module CurationConcerns
3
3
  class ApplyOrderActor < AbstractActor
4
4
  def update(attributes)
5
5
  ordered_member_ids = attributes.delete(:ordered_member_ids)
6
- sync_members(ordered_member_ids)
7
- apply_order(ordered_member_ids) && next_actor.update(attributes)
6
+ sync_members(ordered_member_ids) && apply_order(ordered_member_ids) && next_actor.update(attributes)
8
7
  end
9
8
 
10
9
  private
11
10
 
11
+ def ability
12
+ ::Ability.new(user)
13
+ end
14
+
15
+ def can_edit_both_works?(work)
16
+ ability.can?(:edit, work) && ability.can?(:edit, curation_concern)
17
+ end
18
+
12
19
  def sync_members(ordered_member_ids)
13
20
  return true if ordered_member_ids.nil?
14
21
  existing_members_ids = curation_concern.ordered_member_ids
@@ -20,10 +27,14 @@ module CurationConcerns
20
27
 
21
28
  (ordered_member_ids - existing_members_ids).each do |work_id|
22
29
  work = ::ActiveFedora::Base.find(work_id)
23
- curation_concern.ordered_members << work
30
+ if can_edit_both_works?(work)
31
+ curation_concern.ordered_members << work
32
+ curation_concern.save
33
+ else
34
+ curation_concern.errors[:ordered_member_ids] << "Works can only be related to each other if user has ability to edit both."
35
+ end
24
36
  end
25
- curation_concern.save
26
- true
37
+ curation_concern.errors[:ordered_member_ids].empty?
27
38
  end
28
39
 
29
40
  def apply_order(new_order)
@@ -0,0 +1,28 @@
1
+ module CurationConcerns
2
+ # Validates that the submitted version is the most recent version in the datastore.
3
+ # Caveat: we are not detecting if the version is changed by a different process between
4
+ # the time this validator is run and when the object is saved
5
+ class OptimisticLockValidator < Actors::AbstractActor
6
+ class_attribute :version_field
7
+ self.version_field = 'version'
8
+
9
+ def update(attributes)
10
+ validate_lock(version_attribute(attributes)) && next_actor.update(attributes)
11
+ end
12
+
13
+ private
14
+
15
+ # @return [Boolean] returns true if the lock is missing or
16
+ # if it matches the current object version.
17
+ def validate_lock(version)
18
+ return true if version.blank? || version == curation_concern.etag
19
+ curation_concern.errors.add(:base, :conflict)
20
+ false
21
+ end
22
+
23
+ # Removes the version attribute
24
+ def version_attribute(attributes)
25
+ attributes.delete(version_field)
26
+ end
27
+ end
28
+ end
@@ -15,18 +15,14 @@ export default class SortManager {
15
15
  }
16
16
 
17
17
  persist() {
18
- let params = {}
19
- params[this.singular_class_name] = {
20
- "ordered_member_ids": this.order
21
- }
22
- params["_method"] = "PATCH"
23
18
  this.element.addClass("pending")
24
19
  this.element.removeClass("success")
25
20
  this.element.removeClass("failure")
26
21
  let persisting = $.post(
27
22
  `/concern/${this.class_name}/${this.id}.json`,
28
- params
29
- ).done(() => {
23
+ this.params()
24
+ ).done((response) => {
25
+ this.element.data('version', response.version)
30
26
  this.element.data("current-order", this.order)
31
27
  this.element.addClass("success")
32
28
  this.element.removeClass("failure")
@@ -39,6 +35,16 @@ export default class SortManager {
39
35
  return persisting
40
36
  }
41
37
 
38
+ params() {
39
+ let params = {}
40
+ params[this.singular_class_name] = {
41
+ "version": this.version,
42
+ "ordered_member_ids": this.order
43
+ }
44
+ params["_method"] = "PATCH"
45
+ return params
46
+ }
47
+
42
48
  get_sort_position(item) {
43
49
  return this.element.children().index(item)
44
50
  }
@@ -88,6 +94,10 @@ export default class SortManager {
88
94
  ).toArray()
89
95
  }
90
96
 
97
+ get version() {
98
+ return this.element.data('version')
99
+ }
100
+
91
101
  get alpha_sort_button() {
92
102
  return $("*[data-action='alpha-sort-action']")
93
103
  }
@@ -22,6 +22,11 @@ module CurationConcerns
22
22
  module ClassMethods
23
23
  def curation_concern_type=(curation_concern_type)
24
24
  load_and_authorize_resource class: curation_concern_type, instance_name: :curation_concern, except: [:show, :file_manager, :inspect_work]
25
+
26
+ # Load the fedora resource to get the etag.
27
+ # No need to authorize for the file manager, because it does authorization via the presenter.
28
+ load_resource class: curation_concern_type, instance_name: :curation_concern, only: :file_manager
29
+
25
30
  self._curation_concern_type = curation_concern_type
26
31
  end
27
32
 
@@ -104,7 +109,7 @@ module CurationConcerns
104
109
  end
105
110
 
106
111
  def file_manager
107
- presenter
112
+ @form = Forms::FileManagerForm.new(curation_concern, current_ability)
108
113
  end
109
114
 
110
115
  def inspect_work
@@ -218,6 +223,7 @@ module CurationConcerns
218
223
  message = I18n.t("curation_concerns.workflow.unauthorized")
219
224
  respond_to do |wants|
220
225
  wants.html do
226
+ unavailable_presenter
221
227
  flash[:notice] = message
222
228
  render 'unavailable', status: :unauthorized
223
229
  end
@@ -236,5 +242,9 @@ module CurationConcerns
236
242
  end
237
243
  end
238
244
  end
245
+
246
+ def unavailable_presenter
247
+ @presenter ||= show_presenter.new(::SolrDocument.find(params[:id]), current_ability, request)
248
+ end
239
249
  end
240
250
  end
@@ -40,6 +40,12 @@ module CurationConcerns
40
40
  # that files are in a LDP basic container, and thus, included in the asset's uri.
41
41
  def authorize_download!
42
42
  authorize! :read, params[asset_param_key]
43
+ rescue CanCan::AccessDenied
44
+ redirect_to default_image
45
+ end
46
+
47
+ def default_image
48
+ ActionController::Base.helpers.image_path 'default.png'
43
49
  end
44
50
 
45
51
  # Overrides Hydra::Controller::DownloadBehavior#load_file, which is hard-coded to assume files are in BasicContainer.
@@ -0,0 +1,27 @@
1
+ module CurationConcerns
2
+ module Forms
3
+ class FileManagerForm
4
+ include HydraEditor::Form
5
+ self.terms = []
6
+ delegate :id, :thumbnail_id, :representative_id, :to_s, to: :model
7
+ attr_reader :current_ability, :request
8
+ def initialize(work, ability)
9
+ super(work)
10
+ @current_ability = ability
11
+ @request = nil
12
+ end
13
+
14
+ def version
15
+ model.etag
16
+ end
17
+
18
+ delegate :member_presenters, to: :member_presenter_factory
19
+
20
+ private
21
+
22
+ def member_presenter_factory
23
+ MemberPresenterFactory.new(model, current_ability)
24
+ end
25
+ end
26
+ end
27
+ end