hyrax 2.1.0.beta2 → 2.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODE_OF_CONDUCT.md +5 -5
  3. data/.github/CONTRIBUTING.md +2 -2
  4. data/.rubocop.yml +1 -0
  5. data/.rubocop_fixme.yml +2 -0
  6. data/Gemfile +1 -0
  7. data/README.md +3 -2
  8. data/app/actors/hyrax/actors/collections_membership_actor.rb +3 -0
  9. data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +4 -3
  10. data/app/actors/hyrax/actors/default_admin_set_actor.rb +9 -6
  11. data/app/assets/javascripts/hyrax.js +3 -0
  12. data/app/assets/javascripts/hyrax/app.js.erb +14 -0
  13. data/app/assets/javascripts/hyrax/batch_edit.js +2 -1
  14. data/app/assets/javascripts/hyrax/collection_types.es6 +97 -36
  15. data/app/assets/javascripts/hyrax/collections.js +15 -49
  16. data/app/assets/javascripts/hyrax/collections_utils.es6 +116 -0
  17. data/app/assets/javascripts/hyrax/collections_v2.es6 +57 -0
  18. data/app/assets/javascripts/hyrax/content_blocks.js +1 -13
  19. data/app/assets/javascripts/hyrax/nav_safety.js +41 -0
  20. data/app/assets/javascripts/hyrax/turbolinks_events.js +3 -0
  21. data/app/assets/stylesheets/hyrax/_collection_types.scss +46 -2
  22. data/app/assets/stylesheets/hyrax/_work-show.scss +6 -9
  23. data/app/assets/stylesheets/hyrax/dashboard.scss +2 -0
  24. data/app/assets/stylesheets/hyrax/sidebar.scss +4 -0
  25. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +10 -2
  26. data/app/controllers/hyrax/admin/admin_sets_controller.rb +2 -9
  27. data/app/controllers/hyrax/admin/collection_types_controller.rb +1 -1
  28. data/app/controllers/hyrax/batch_edits_controller.rb +30 -4
  29. data/app/controllers/hyrax/dashboard/collection_members_controller.rb +1 -0
  30. data/app/controllers/hyrax/dashboard/collections_controller.rb +4 -1
  31. data/app/controllers/hyrax/downloads_controller.rb +7 -1
  32. data/app/forms/hyrax/forms/admin/collection_type_form.rb +1 -1
  33. data/app/indexers/hyrax/repository_reindexer.rb +1 -1
  34. data/app/jobs/attach_files_to_work_job.rb +8 -4
  35. data/app/jobs/import_url_job.rb +11 -5
  36. data/app/models/admin_set.rb +25 -3
  37. data/app/models/concerns/hyrax/collection_behavior.rb +23 -11
  38. data/app/models/concerns/hyrax/collection_nesting.rb +22 -3
  39. data/app/models/hyrax/permission_template_access.rb +7 -4
  40. data/app/presenters/hyrax/admin_set_presenter.rb +21 -0
  41. data/app/presenters/hyrax/collection_presenter.rb +23 -1
  42. data/app/presenters/hyrax/dashboard/user_presenter.rb +4 -0
  43. data/app/presenters/hyrax/presents_attributes.rb +6 -2
  44. data/app/presenters/hyrax/work_show_presenter.rb +4 -0
  45. data/app/renderers/hyrax/renderers/attribute_renderer.rb +14 -0
  46. data/app/services/hyrax/adapters/nesting_index_adapter.rb +19 -39
  47. data/app/services/hyrax/admin_set_create_service.rb +1 -1
  48. data/app/services/hyrax/collection_types/create_service.rb +4 -0
  49. data/app/services/hyrax/collections/migration_service.rb +25 -2
  50. data/app/services/hyrax/collections/nested_collection_persistence_service.rb +8 -3
  51. data/app/services/hyrax/collections/nested_collection_query_service.rb +3 -3
  52. data/app/services/hyrax/default_middleware_stack.rb +3 -3
  53. data/app/services/hyrax/multiple_membership_checker.rb +4 -2
  54. data/app/views/catalog/_index_header_list_collection.html.erb +1 -1
  55. data/app/views/catalog/_search_form.html.erb +0 -4
  56. data/app/views/hyrax/admin/admin_sets/_show_actions.html.erb +27 -0
  57. data/app/views/hyrax/admin/admin_sets/show.html.erb +1 -25
  58. data/app/views/hyrax/admin/collection_types/_form.html.erb +17 -6
  59. data/app/views/hyrax/admin/collection_types/_form_appearance.html.erb +5 -0
  60. data/app/views/hyrax/admin/collection_types/_form_participant_table.html.erb +1 -1
  61. data/app/views/hyrax/admin/collection_types/_form_participants.html.erb +56 -52
  62. data/app/views/hyrax/admin/collection_types/edit.html.erb +9 -7
  63. data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
  64. data/app/views/hyrax/base/_attribute_rows.html.erb +15 -14
  65. data/app/views/hyrax/base/_form.html.erb +1 -0
  66. data/app/views/hyrax/base/_form_collections_error.html.erb +1 -0
  67. data/app/views/hyrax/base/_items.html.erb +3 -2
  68. data/app/views/hyrax/base/_metadata.html.erb +5 -7
  69. data/app/views/hyrax/base/_relationships.html.erb +3 -5
  70. data/app/views/hyrax/base/_relationships_parent_row.html.erb +4 -5
  71. data/app/views/hyrax/base/_relationships_parent_rows.html.erb +2 -1
  72. data/app/views/hyrax/base/_show_actions.html.erb +11 -1
  73. data/app/views/hyrax/batch_edits/edit.html.erb +57 -17
  74. data/app/views/hyrax/collections/_list_collections.html.erb +1 -1
  75. data/app/views/hyrax/collections/show.html.erb +1 -1
  76. data/app/views/hyrax/content_blocks/_form.html.erb +8 -7
  77. data/app/views/hyrax/dashboard/_index_partials/_current_proxy_rights.html.erb +17 -0
  78. data/app/views/hyrax/dashboard/collections/_collection_title.html.erb +1 -3
  79. data/app/views/hyrax/dashboard/collections/_default_group.html.erb +30 -0
  80. data/app/views/hyrax/dashboard/collections/_form_branding.html.erb +2 -2
  81. data/app/views/hyrax/dashboard/collections/_form_for_select_collection.html.erb +1 -1
  82. data/app/views/hyrax/dashboard/collections/_form_share.html.erb +2 -2
  83. data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +13 -2
  84. data/app/views/hyrax/dashboard/show_user.html.erb +10 -9
  85. data/app/views/hyrax/my/collections/_list_collections.html.erb +10 -3
  86. data/app/views/hyrax/my/collections/_modal_add_subcollection.html.erb +1 -1
  87. data/app/views/hyrax/my/collections/_modal_add_to_collection.html.erb +1 -1
  88. data/app/views/hyrax/my/collections/_modal_delete_collections_deny.html.erb +14 -0
  89. data/app/views/hyrax/my/collections/index.html.erb +1 -0
  90. data/app/views/shared/_nav_safety_modal.html.erb +12 -0
  91. data/config/features.rb +4 -0
  92. data/config/initializers/samvera-nesting_indexer_initializer.rb +1 -0
  93. data/config/locales/hyrax.de.yml +26 -11
  94. data/config/locales/hyrax.en.yml +21 -6
  95. data/config/locales/hyrax.es.yml +17 -2
  96. data/config/locales/hyrax.fr.yml +17 -2
  97. data/config/locales/hyrax.it.yml +17 -2
  98. data/config/locales/hyrax.pt-BR.yml +17 -2
  99. data/config/locales/hyrax.zh.yml +17 -2
  100. data/config/locales/simple_form.en.yml +6 -27
  101. data/hyrax.gemspec +2 -2
  102. data/lib/generators/hyrax/assets_generator.rb +4 -0
  103. data/lib/generators/hyrax/install_generator.rb +10 -0
  104. data/lib/generators/hyrax/templates/app/assets/images/unauthorized.png +0 -0
  105. data/lib/generators/hyrax/templates/config/locales/hyrax.en.yml +6 -5
  106. data/lib/generators/hyrax/templates/config/tinymce.yml +12 -7
  107. data/lib/generators/hyrax/templates/db/migrate/20180406202557_add_badge_color_to_collection_types.rb.erb +5 -0
  108. data/lib/hyrax/configuration.rb +1 -1
  109. data/lib/hyrax/version.rb +1 -1
  110. data/spec/actors/hyrax/actors/collections_membership_actor_spec.rb +24 -0
  111. data/spec/actors/hyrax/actors/create_with_remote_files_actor_spec.rb +19 -1
  112. data/spec/actors/hyrax/actors/default_admin_set_actor_spec.rb +41 -8
  113. data/spec/actors/hyrax/actors/file_set_actor_spec.rb +4 -12
  114. data/spec/actors/hyrax/actors/generic_work_actor_spec.rb +3 -7
  115. data/spec/controllers/hyrax/admin/strategies_controller_spec.rb +13 -2
  116. data/spec/controllers/hyrax/batch_edits_controller_spec.rb +83 -8
  117. data/spec/controllers/hyrax/dashboard/collections_controller_spec.rb +3 -0
  118. data/spec/controllers/hyrax/downloads_controller_spec.rb +26 -5
  119. data/spec/controllers/hyrax/file_sets_controller_spec.rb +3 -6
  120. data/spec/controllers/hyrax/generic_works_controller_json_spec.rb +4 -4
  121. data/spec/controllers/hyrax/generic_works_controller_spec.rb +3 -23
  122. data/spec/controllers/hyrax/transfers_controller_spec.rb +1 -1
  123. data/spec/factories/admin_sets_lw.rb +215 -0
  124. data/spec/factories/collections.rb +10 -10
  125. data/spec/factory_tests/adminsets_factory_spec.rb +132 -0
  126. data/spec/factory_tests/collections_factory_spec.rb +3 -3
  127. data/spec/features/batch_create_spec.rb +5 -8
  128. data/spec/features/batch_edit_spec.rb +49 -2
  129. data/spec/features/collection_multi_membership_spec.rb +29 -14
  130. data/spec/features/collection_type_spec.rb +9 -2
  131. data/spec/features/create_work_admin_spec.rb +1 -1
  132. data/spec/features/create_work_spec.rb +1 -1
  133. data/spec/features/dashboard/collection_spec.rb +16 -12
  134. data/spec/features/edit_content_block_admin_spec.rb +29 -12
  135. data/spec/features/embargo_spec.rb +55 -0
  136. data/spec/features/proxy_spec.rb +3 -1
  137. data/spec/features/work_show_spec.rb +20 -4
  138. data/spec/forms/hyrax/forms/admin/collection_type_form_spec.rb +1 -0
  139. data/spec/indexers/hyrax/repository_reindexer_spec.rb +1 -1
  140. data/spec/jobs/attach_files_to_work_job_spec.rb +15 -3
  141. data/spec/jobs/batch_create_job_spec.rb +6 -6
  142. data/spec/jobs/create_work_job_spec.rb +1 -1
  143. data/spec/models/admin_set_spec.rb +10 -8
  144. data/spec/models/collection_spec.rb +1 -1
  145. data/spec/models/concerns/hyrax/collection_nesting_spec.rb +6 -3
  146. data/spec/models/flipflop_spec.rb +8 -0
  147. data/spec/models/hyrax/work_behavior_spec.rb +1 -1
  148. data/spec/presenters/hyrax/admin_set_presenter_spec.rb +70 -0
  149. data/spec/presenters/hyrax/collection_presenter_spec.rb +66 -0
  150. data/spec/renderers/hyrax/renderers/attribute_renderer_spec.rb +19 -0
  151. data/spec/services/hyrax/adapters/nesting_index_adapter_spec.rb +31 -21
  152. data/spec/services/hyrax/collection_types/create_service_spec.rb +7 -4
  153. data/spec/services/hyrax/collections/migration_service_spec.rb +204 -17
  154. data/spec/services/hyrax/collections/nested_collection_persistence_service_spec.rb +1 -1
  155. data/spec/services/hyrax/collections/permissions_create_service_spec.rb +1 -1
  156. data/spec/services/hyrax/collections/permissions_service_spec.rb +4 -0
  157. data/spec/services/hyrax/default_middleware_stack_spec.rb +1 -1
  158. data/spec/services/hyrax/multiple_membership_checker_spec.rb +4 -4
  159. data/spec/services/hyrax/workflow/grant_edit_to_depositor_spec.rb +1 -1
  160. data/spec/services/hyrax/workflow/grant_read_to_depositor_spec.rb +1 -1
  161. data/spec/services/hyrax/workflow/revoke_edit_from_depositor_spec.rb +1 -1
  162. data/spec/spec_helper.rb +35 -2
  163. data/spec/support/features/batch_edit_actions.rb +1 -1
  164. data/spec/support/selectors.rb +15 -0
  165. data/spec/views/hyrax/admin/admin_sets/_show_actions.html.erb_spec.rb +66 -0
  166. data/spec/views/hyrax/admin/admin_sets/show.html.erb_spec.rb +5 -34
  167. data/spec/views/hyrax/admin/collection_types/_form.html.erb_spec.rb +3 -1
  168. data/spec/views/hyrax/admin/collection_types/_form_appearance.html.erb_spec.rb +22 -0
  169. data/spec/views/hyrax/admin/collection_types/_form_participants.html.erb_spec.rb +11 -3
  170. data/spec/views/hyrax/base/_items.html.erb_spec.rb +46 -0
  171. data/spec/views/hyrax/base/_relationships.html.erb_spec.rb +1 -1
  172. data/spec/views/hyrax/base/_show_actions.html.erb_spec.rb +4 -2
  173. data/spec/views/hyrax/dashboard/collections/_default_group.html.erb_spec.rb +43 -0
  174. data/spec/views/hyrax/dashboard/collections/_list_collections.html.erb_spec.rb +51 -0
  175. data/spec/views/hyrax/dashboard/collections/show.html.erb_spec.rb +1 -0
  176. data/spec/views/hyrax/dashboard/show_user_spec.rb +5 -2
  177. data/spec/views/hyrax/my/collections/_list_collections.html.erb_spec.rb +2 -0
  178. data/template.rb +1 -1
  179. metadata +30 -13
  180. data/app/views/hyrax/content_blocks/_modal_content_block.html.erb +0 -15
@@ -25,6 +25,7 @@ module Hyrax
25
25
  after_update_error(err_msg) if err_msg.present?
26
26
  return if err_msg.present?
27
27
 
28
+ collection.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX
28
29
  members = collection.add_member_objects batch_ids
29
30
  messages = members.collect { |member| member.errors.full_messages }.flatten
30
31
  if messages.size == members.size
@@ -144,6 +144,8 @@ module Hyrax
144
144
 
145
145
  process_member_changes
146
146
  @collection.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE unless @collection.discoverable?
147
+ # we don't have to reindex the full graph when updating collection
148
+ @collection.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX
147
149
  if @collection.update(collection_params.except(:members))
148
150
  after_update
149
151
  else
@@ -337,9 +339,10 @@ module Hyrax
337
339
 
338
340
  def extract_old_style_permission_attributes(attributes)
339
341
  # TODO: REMOVE in 3.0 - part of deprecation of permission attributes
340
- Deprecation.warn(self, "passing in permissions with a new collection is deprecated and will be removed from Hyrax 3.0 ()") # TODO: elr - add alternative in ()
341
342
  permissions = attributes.delete("permissions_attributes")
342
343
  return [] unless permissions
344
+ Deprecation.warn(self, "Passing in permissions_attributes parameter with a new collection is deprecated and support will be removed from Hyrax 3.0. " \
345
+ "Use Hyrax::PermissionTemplate instead to grant Manage, Deposit, or View access.")
343
346
  participants = []
344
347
  permissions.each do |p|
345
348
  access = access(p)
@@ -42,7 +42,13 @@ module Hyrax
42
42
  def authorize_download!
43
43
  authorize! :download, params[asset_param_key]
44
44
  rescue CanCan::AccessDenied
45
- redirect_to default_image
45
+ unauthorized_image = Rails.root.join("app", "assets", "images", "unauthorized.png")
46
+ if File.exist? unauthorized_image
47
+ send_file unauthorized_image, status: :unauthorized
48
+ else
49
+ Deprecation.warn(self, "redirect_to default_image is deprecated and will be removed from Hyrax 3.0 (copy unauthorized.png image to directory assets/images instead)")
50
+ redirect_to default_image
51
+ end
46
52
  end
47
53
 
48
54
  def default_image
@@ -9,7 +9,7 @@ module Hyrax
9
9
  delegate :title, :description, :brandable, :discoverable, :nestable, :sharable, :share_applies_to_new_works,
10
10
  :require_membership, :allow_multiple_membership, :assigns_workflow,
11
11
  :assigns_visibility, :id, :collection_type_participants, :persisted?,
12
- :collections?, :admin_set?, :user_collection?, to: :collection_type
12
+ :collections?, :admin_set?, :user_collection?, :badge_color, to: :collection_type
13
13
 
14
14
  def all_settings_disabled?
15
15
  collections? || admin_set? || user_collection?
@@ -10,7 +10,7 @@ module Hyrax
10
10
  # overrides https://github.com/samvera/active_fedora/blob/master/lib/active_fedora/indexing.rb#L95-L125
11
11
  # see implementation details in adapters/nesting_index_adapter.rb#each_perservation_document_id_and_parent_ids
12
12
  def reindex_everything(*)
13
- Samvera::NestingIndexer.reindex_all!
13
+ Samvera::NestingIndexer.reindex_all!(extent: Hyrax::Adapters::NestingIndexAdapter::FULL_REINDEX)
14
14
  end
15
15
  end
16
16
  end
@@ -6,10 +6,7 @@ class AttachFilesToWorkJob < Hyrax::ApplicationJob
6
6
  # @param [Array<Hyrax::UploadedFile>] uploaded_files - an array of files to attach
7
7
  def perform(work, uploaded_files, **work_attributes)
8
8
  validate_files!(uploaded_files)
9
- # When running as a background job (as opposed to running inline), a work with files attached
10
- # by a proxy user will set the depositor as the intended user that the proxy user was depositing on
11
- # behalf of. See ticket #2764.
12
- depositor = work.on_behalf_of || work.depositor
9
+ depositor = proxy_or_depositor(work)
13
10
  user = User.find_by_user_key(depositor)
14
11
  work_permissions = work.permissions.map(&:to_hash)
15
12
  metadata = visibility_attributes(work_attributes)
@@ -39,4 +36,11 @@ class AttachFilesToWorkJob < Hyrax::ApplicationJob
39
36
  raise ArgumentError, "Hyrax::UploadedFile required, but #{uploaded_file.class} received: #{uploaded_file.inspect}"
40
37
  end
41
38
  end
39
+
40
+ ##
41
+ # A work with files attached by a proxy user will set the depositor as the intended user
42
+ # that the proxy was depositing on behalf of. See tickets #2764, #2902.
43
+ def proxy_or_depositor(work)
44
+ work.on_behalf_of.blank? ? work.depositor : work.on_behalf_of
45
+ end
42
46
  end
@@ -10,19 +10,23 @@ class ImportUrlJob < Hyrax::ApplicationJob
10
10
  queue_as Hyrax.config.ingest_queue_name
11
11
 
12
12
  before_enqueue do |job|
13
- operation = job.arguments.last
14
13
  operation.pending_job(job)
15
14
  end
16
15
 
16
+ # Retrieves the operation for the job
17
+ def operation
18
+ arguments.reduce(:merge).fetch(:operation)
19
+ end
20
+
17
21
  # @param [FileSet] file_set
18
22
  # @param [Hyrax::BatchCreateOperation] operation
19
- def perform(file_set, operation)
23
+ def perform(file_set, operation, headers = {})
20
24
  operation.performing!
21
25
  user = User.find_by_user_key(file_set.depositor)
22
26
  uri = URI(file_set.import_url)
23
27
  # @todo Use Hydra::Works::AddExternalFileToFileSet instead of manually
24
28
  # copying the file here. This will be gnarly.
25
- copy_remote_file(uri) do |f|
29
+ copy_remote_file(uri, headers) do |f|
26
30
  # reload the FileSet once the data is copied since this is a long running task
27
31
  file_set.reload
28
32
 
@@ -47,13 +51,15 @@ class ImportUrlJob < Hyrax::ApplicationJob
47
51
  # metadata.
48
52
  # @param uri [URI] the uri of the file to download
49
53
  # @yield [IO] the stream to write to
50
- def copy_remote_file(uri)
54
+ def copy_remote_file(uri, headers = {})
51
55
  filename = File.basename(uri.path)
52
56
  dir = Dir.mktmpdir
53
57
  Rails.logger.debug("ImportUrlJob: Copying <#{uri}> to #{dir}")
58
+
54
59
  File.open(File.join(dir, filename), 'wb') do |f|
55
60
  retriever = BrowseEverything::Retriever.new
56
- retriever.retrieve('url' => uri) do |chunk|
61
+ uri_spec = { 'url' => uri }.merge(headers)
62
+ retriever.retrieve(uri_spec) do |chunk|
57
63
  f.write(chunk)
58
64
  end
59
65
  f.rewind
@@ -83,13 +83,35 @@ class AdminSet < ActiveFedora::Base
83
83
  # Calculate and update who should have edit access based on who
84
84
  # has "manage" access in the PermissionTemplateAccess
85
85
  def reset_access_controls!
86
- # NOTE: This is different from Collections in that it doesn't update read access. See the notes in services/hyrax/collections/permissions_service.rb
87
- update!(edit_users: permission_template.agent_ids_for(access: 'manage', agent_type: 'user'),
88
- edit_groups: permission_template.agent_ids_for(access: 'manage', agent_type: 'group'))
86
+ # NOTE: This is different from Collections in that it doesn't update read access based on visibility.
87
+ # See also app/models/concerns/hyrax/collection_behavior.rb#reset_access_controls!
88
+ update!(edit_users: permission_template_edit_users,
89
+ edit_groups: permission_template_edit_groups,
90
+ read_users: permission_template_read_users,
91
+ read_groups: permission_template_read_groups)
89
92
  end
90
93
 
91
94
  private
92
95
 
96
+ def permission_template_edit_users
97
+ permission_template.agent_ids_for(access: 'manage', agent_type: 'user')
98
+ end
99
+
100
+ def permission_template_edit_groups
101
+ permission_template.agent_ids_for(access: 'manage', agent_type: 'group')
102
+ end
103
+
104
+ def permission_template_read_users
105
+ (permission_template.agent_ids_for(access: 'view', agent_type: 'user') +
106
+ permission_template.agent_ids_for(access: 'deposit', agent_type: 'user')).uniq
107
+ end
108
+
109
+ def permission_template_read_groups
110
+ (permission_template.agent_ids_for(access: 'view', agent_type: 'group') +
111
+ permission_template.agent_ids_for(access: 'deposit', agent_type: 'group')).uniq -
112
+ [::Ability.registered_group_name, ::Ability.public_group_name]
113
+ end
114
+
93
115
  def destroy_permission_template
94
116
  permission_template.destroy
95
117
  rescue ActiveRecord::RecordNotFound
@@ -125,21 +125,33 @@ module Hyrax
125
125
  # Calculate and update who should have read/edit access to the collections based on who
126
126
  # has access in PermissionTemplateAccess
127
127
  def reset_access_controls!
128
- edit_users = permission_template.agent_ids_for(access: 'manage', agent_type: 'user')
129
- edit_groups = permission_template.agent_ids_for(access: 'manage', agent_type: 'group')
130
- read_users = permission_template.agent_ids_for(access: 'view', agent_type: 'user') +
131
- permission_template.agent_ids_for(access: 'deposit', agent_type: 'user')
132
- read_groups = (permission_template.agent_ids_for(access: 'view', agent_type: 'group') +
133
- permission_template.agent_ids_for(access: 'deposit', agent_type: 'group') +
134
- visibility_group).uniq
135
- update!(edit_users: edit_users,
136
- edit_groups: edit_groups,
137
- read_users: read_users,
138
- read_groups: read_groups)
128
+ update!(edit_users: permission_template_edit_users,
129
+ edit_groups: permission_template_edit_groups,
130
+ read_users: permission_template_read_users,
131
+ read_groups: (permission_template_read_groups + visibility_group).uniq)
139
132
  end
140
133
 
141
134
  private
142
135
 
136
+ def permission_template_edit_users
137
+ permission_template.agent_ids_for(access: 'manage', agent_type: 'user')
138
+ end
139
+
140
+ def permission_template_edit_groups
141
+ permission_template.agent_ids_for(access: 'manage', agent_type: 'group')
142
+ end
143
+
144
+ def permission_template_read_users
145
+ (permission_template.agent_ids_for(access: 'view', agent_type: 'user') +
146
+ permission_template.agent_ids_for(access: 'deposit', agent_type: 'user')).uniq
147
+ end
148
+
149
+ def permission_template_read_groups
150
+ (permission_template.agent_ids_for(access: 'view', agent_type: 'group') +
151
+ permission_template.agent_ids_for(access: 'deposit', agent_type: 'group')).uniq -
152
+ [::Ability.registered_group_name, ::Ability.public_group_name]
153
+ end
154
+
143
155
  def visibility_group
144
156
  return [Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_PUBLIC] if visibility == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
145
157
  return [Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED] if visibility == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
@@ -22,18 +22,18 @@ module Hyrax
22
22
 
23
23
  def after_update_nested_collection_relationship_indices
24
24
  @during_save = false
25
- Hyrax.config.nested_relationship_reindexer.call(id: id)
25
+ reindex_nested_relationships_for(id: id, extent: reindex_extent)
26
26
  end
27
27
 
28
28
  def update_nested_collection_relationship_indices
29
29
  return if @during_save
30
- Hyrax.config.nested_relationship_reindexer.call(id: id)
30
+ reindex_nested_relationships_for(id: id, extent: reindex_extent)
31
31
  end
32
32
 
33
33
  def update_child_nested_collection_relationship_indices
34
34
  children = find_children_of(destroyed_id: id)
35
35
  children.each do |child|
36
- Hyrax.config.nested_relationship_reindexer.call(id: child.id)
36
+ reindex_nested_relationships_for(id: child.id, extent: Hyrax::Adapters::NestingIndexAdapter::FULL_REINDEX)
37
37
  end
38
38
  end
39
39
  end
@@ -46,8 +46,27 @@ module Hyrax
46
46
  ActiveFedora::SolrService.query(ActiveFedora::SolrQueryBuilder.construct_query(member_of_collection_ids_ssim: destroyed_id))
47
47
  end
48
48
 
49
+ # Only models which include Hyrax::CollectionNesting will respond to this method.
50
+ # Used to determine whether a model gets reindexed via Samvera::NestingIndexer during full repository reindexing,
49
51
  def use_nested_reindexing?
50
52
  true
51
53
  end
54
+
55
+ # The following methods allow an option to reindex an object only if the nesting indexer fields are not
56
+ # already in the object's solr document. Added to prevent unnecessary indexing of all ancestors of a parent
57
+ # when one child gets added to the parent. By default, we do the full graph indexing.
58
+ def reindex_extent
59
+ @reindex_extent ||= Hyrax::Adapters::NestingIndexAdapter::FULL_REINDEX
60
+ end
61
+
62
+ def reindex_extent=(val)
63
+ @reindex_extent = val
64
+ end
65
+
66
+ private
67
+
68
+ def reindex_nested_relationships_for(id:, extent:)
69
+ Hyrax.config.nested_relationship_reindexer.call(id: id, extent: extent)
70
+ end
52
71
  end
53
72
  end
@@ -15,6 +15,9 @@ module Hyrax
15
15
  DEPOSIT = 'deposit'.freeze
16
16
  MANAGE = 'manage'.freeze
17
17
 
18
+ GROUP = 'group'.freeze
19
+ USER = 'user'.freeze
20
+
18
21
  enum(
19
22
  access: {
20
23
  VIEW => VIEW,
@@ -41,7 +44,7 @@ module Hyrax
41
44
  end
42
45
 
43
46
  def label
44
- return agent_id unless agent_type == 'group'
47
+ return agent_id unless agent_type == GROUP
45
48
  case agent_id
46
49
  when 'registered'
47
50
  I18n.t('hyrax.admin.admin_sets.form_participant_table.registered_users')
@@ -53,7 +56,7 @@ module Hyrax
53
56
  end
54
57
 
55
58
  def admin_group?
56
- agent_type == 'group' && agent_id == ::Ability.admin_group_name
59
+ agent_type == GROUP && agent_id == ::Ability.admin_group_name
57
60
  end
58
61
 
59
62
  # @api private
@@ -67,7 +70,7 @@ module Hyrax
67
70
  # If calling from Abilities, pass the ability. If you try to get the ability from the user, you end up in an infinit loop.
68
71
  def self.user_where(access:, ability:)
69
72
  where_clause = {}
70
- where_clause[:agent_type] = 'user'
73
+ where_clause[:agent_type] = USER
71
74
  where_clause[:agent_id] = ability.current_user.user_key
72
75
  where_clause[:access] = access
73
76
  where_clause
@@ -86,7 +89,7 @@ module Hyrax
86
89
  # If calling from Abilities, pass the ability. If you try to get the ability from the user, you end up in an infinit loop.
87
90
  def self.group_where(access:, ability:, exclude_groups: [])
88
91
  where_clause = {}
89
- where_clause[:agent_type] = 'group'
92
+ where_clause[:agent_type] = GROUP
90
93
  where_clause[:agent_id] = ability.user_groups - exclude_groups
91
94
  where_clause[:access] = access
92
95
  where_clause
@@ -30,5 +30,26 @@ module Hyrax
30
30
  def available_parent_collections(*)
31
31
  []
32
32
  end
33
+
34
+ # For the Managed Collections tab, determine the label to use for the level of access the user has for this admin set.
35
+ # Checks from most permissive to most restrictive.
36
+ # @return String the access label (e.g. Manage, Deposit, View)
37
+ def managed_access
38
+ return I18n.t('hyrax.dashboard.my.collection_list.managed_access.manage') if current_ability.can?(:edit, solr_document)
39
+ return I18n.t('hyrax.dashboard.my.collection_list.managed_access.deposit') if current_ability.can?(:deposit, solr_document)
40
+ return I18n.t('hyrax.dashboard.my.collection_list.managed_access.view') if current_ability.can?(:read, solr_document)
41
+ ''
42
+ end
43
+
44
+ # Determine if the user can perform batch operations on this admin set. Currently, the only
45
+ # batch operation allowed is deleting, so this is equivalent to checking if the user can delete
46
+ # the admin set determined by criteria...
47
+ # * user must be able to edit the admin set to be able to delete it
48
+ # * the admin set itself must be able to be deleted (i.e., there cannot be any works in the admin set)
49
+ # @return Boolean true if the user can perform batch actions; otherwise, false
50
+ def allow_batch?
51
+ return false unless current_ability.can?(:edit, solr_document)
52
+ !disable_delete?
53
+ end
33
54
  end
34
55
  end
@@ -3,6 +3,7 @@ module Hyrax
3
3
  include ModelProxy
4
4
  include PresentsAttributes
5
5
  include ActionView::Helpers::NumberHelper
6
+ include ActionView::Helpers::TagHelper
6
7
  attr_accessor :solr_document, :current_ability, :request
7
8
  attr_reader :subcollection_count
8
9
  attr_accessor :parent_collections # This is expected to be a Blacklight::Solr::Response with all of the parent collections
@@ -80,7 +81,7 @@ module Hyrax
80
81
  end
81
82
 
82
83
  def collection_type_badge
83
- collection_type.title
84
+ content_tag(:span, collection_type.title, class: "label", style: "background-color: " + collection_type.badge_color + ";")
84
85
  end
85
86
 
86
87
  # The total number of parents that this collection belongs to, visible or not.
@@ -158,5 +159,26 @@ module Hyrax
158
159
  def subcollection_count=(total)
159
160
  @subcollection_count = total unless total.nil?
160
161
  end
162
+
163
+ # For the Managed Collections tab, determine the label to use for the level of access the user has for this admin set.
164
+ # Checks from most permissive to most restrictive.
165
+ # @return String the access label (e.g. Manage, Deposit, View)
166
+ def managed_access
167
+ return I18n.t('hyrax.dashboard.my.collection_list.managed_access.manage') if current_ability.can?(:edit, solr_document)
168
+ return I18n.t('hyrax.dashboard.my.collection_list.managed_access.deposit') if current_ability.can?(:deposit, solr_document)
169
+ return I18n.t('hyrax.dashboard.my.collection_list.managed_access.view') if current_ability.can?(:read, solr_document)
170
+ ''
171
+ end
172
+
173
+ # Determine if the user can perform batch operations on this collection. Currently, the only
174
+ # batch operation allowed is deleting, so this is equivalent to checking if the user can delete
175
+ # the collection determined by criteria...
176
+ # * user must be able to edit the collection to be able to delete it
177
+ # * the collection does not have to be empty
178
+ # @return Boolean true if the user can perform batch actions; otherwise, false
179
+ def allow_batch?
180
+ return true if current_ability.can?(:edit, solr_document)
181
+ false
182
+ end
161
183
  end
162
184
  end
@@ -41,6 +41,10 @@ module Hyrax
41
41
  link_to t('hyrax.dashboard.additional_notifications'), hyrax.notifications_path
42
42
  end
43
43
 
44
+ def link_to_manage_proxies
45
+ link_to t('hyrax.dashboard.manage_proxies'), hyrax.depositors_path
46
+ end
47
+
44
48
  private
45
49
 
46
50
  attr_reader :current_user, :view_context, :since
@@ -1,7 +1,7 @@
1
1
  module Hyrax
2
2
  module PresentsAttributes
3
3
  ##
4
- # Present the attribute as an HTML table row.
4
+ # Present the attribute as an HTML table row or dl row.
5
5
  #
6
6
  # @param [Hash] options
7
7
  # @option options [Symbol] :render_as use an alternate renderer
@@ -18,7 +18,11 @@ module Hyrax
18
18
  return
19
19
  end
20
20
 
21
- renderer_for(field, options).new(field, send(field), options).render
21
+ if options[:html_dl]
22
+ renderer_for(field, options).new(field, send(field), options).render_dl_row
23
+ else
24
+ renderer_for(field, options).new(field, send(field), options).render
25
+ end
22
26
  end
23
27
 
24
28
  def permission_badge
@@ -152,6 +152,10 @@ module Hyrax
152
152
 
153
153
  delegate :member_presenters, :file_set_presenters, :work_presenters, to: :member_presenter_factory
154
154
 
155
+ def exclude_unauthorized_file_sets
156
+ member_presenters.delete_if { |m| m.is_a?(Hyrax::FileSetPresenter) && !current_ability.can?(:read, m.id) }
157
+ end
158
+
155
159
  def manifest_url
156
160
  manifest_helper.polymorphic_url([:manifest, self])
157
161
  end
@@ -33,6 +33,20 @@ module Hyrax
33
33
  markup.html_safe
34
34
  end
35
35
 
36
+ # Draw the dl row for the attribute
37
+ def render_dl_row
38
+ markup = ''
39
+
40
+ return markup if values.blank? && !options[:include_empty]
41
+ markup << %(<dt>#{label}</dt>\n<dd><ul class='tabular'>)
42
+ attributes = microdata_object_attributes(field).merge(class: "attribute attribute-#{field}")
43
+ Array(values).each do |value|
44
+ markup << "<li#{html_attributes(attributes)}>#{attribute_value_to_html(value.to_s)}</li>"
45
+ end
46
+ markup << %(</ul></dd>)
47
+ markup.html_safe
48
+ end
49
+
36
50
  # @return The human-readable label for this field.
37
51
  # @note This is a central location for determining the label of a field
38
52
  # name. Can be overridden if more complicated logic is needed.