hyrax 2.0.0.rc1 → 2.0.0.rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +5 -1
- data/app/assets/stylesheets/hyrax/_header.scss +6 -0
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +1 -1
- data/app/controllers/hyrax/admin/permission_template_accesses_controller.rb +4 -3
- data/app/controllers/hyrax/collections_controller.rb +2 -0
- data/app/forms/hyrax/forms/permission_template_form.rb +113 -48
- data/app/jobs/ingest_local_file_job.rb +0 -1
- data/app/renderers/hyrax/renderers/rights_statement_attribute_renderer.rb +25 -0
- data/app/search_builders/hyrax/deposit_search_builder.rb +6 -3
- data/app/search_builders/hyrax/stats/work_status_search_builder.rb +4 -5
- data/app/services/hyrax/default_middleware_stack.rb +0 -1
- data/app/services/hyrax/file_set_derivatives_service.rb +13 -4
- data/app/services/hyrax/statistics/depositors/summary.rb +1 -1
- data/app/services/hyrax/workflow/abstract_notification.rb +3 -2
- data/app/services/hyrax/workflow/notification_service.rb +3 -12
- data/app/services/hyrax/workflow/permission_query.rb +3 -3
- data/app/services/hyrax/workflow/status_list_service.rb +1 -1
- data/app/views/hyrax/admin/admin_sets/_form_participants.html.erb +1 -0
- data/app/views/hyrax/admin/admin_sets/_form_visibility.html.erb +1 -1
- data/app/views/hyrax/base/_attribute_rows.html.erb +1 -1
- data/app/views/hyrax/collections/show.html.erb +3 -0
- data/app/views/hyrax/dashboard/_index_partials/_proxy_rights.html.erb +1 -0
- data/app/views/hyrax/notifications/_notifications.html.erb +1 -0
- data/config/locales/hyrax.de.yml +7 -3
- data/config/locales/hyrax.en.yml +16 -12
- data/config/locales/hyrax.es.yml +4 -0
- data/config/locales/hyrax.fr.yml +4 -0
- data/config/locales/hyrax.it.yml +4 -0
- data/config/locales/hyrax.pt-BR.yml +4 -0
- data/config/locales/hyrax.zh.yml +4 -0
- data/hyrax.gemspec +2 -2
- data/lib/generators/hyrax/templates/config/locales/hyrax.de.yml +1 -1
- data/lib/generators/hyrax/templates/config/locales/hyrax.en.yml +1 -1
- data/lib/generators/hyrax/templates/config/locales/hyrax.es.yml +1 -1
- data/lib/generators/hyrax/templates/config/locales/hyrax.fr.yml +1 -1
- data/lib/generators/hyrax/templates/config/locales/hyrax.it.yml +1 -1
- data/lib/generators/hyrax/templates/config/locales/hyrax.pt-BR.yml +1 -1
- data/lib/generators/hyrax/templates/config/locales/hyrax.zh.yml +1 -1
- data/lib/hyrax/configuration.rb +11 -0
- data/lib/hyrax/version.rb +1 -1
- data/spec/abilities/file_set_abilities_spec.rb +3 -3
- data/spec/abilities/generic_work_abilities_spec.rb +5 -5
- data/spec/actors/hyrax/actors/generic_work_actor_spec.rb +12 -12
- data/spec/actors/hyrax/actors/transactional_request_spec.rb +1 -1
- data/spec/controllers/hyrax/api/items_controller_spec.rb +6 -6
- data/spec/controllers/hyrax/citations_controller_spec.rb +2 -2
- data/spec/controllers/hyrax/collections_controller_spec.rb +1 -0
- data/spec/controllers/hyrax/content_blocks_controller_spec.rb +5 -5
- data/spec/controllers/hyrax/dashboard/profiles_controller_spec.rb +2 -2
- data/spec/controllers/hyrax/downloads_controller_spec.rb +3 -3
- data/spec/controllers/hyrax/featured_work_lists_controller_spec.rb +2 -2
- data/spec/controllers/hyrax/generic_works_controller_spec.rb +1 -1
- data/spec/controllers/hyrax/homepage_controller_spec.rb +1 -1
- data/spec/controllers/hyrax/pages_controller_spec.rb +6 -6
- data/spec/controllers/hyrax/users_controller_spec.rb +1 -1
- data/spec/controllers/hyrax/workflow_actions_controller_spec.rb +1 -1
- data/spec/conversions/power_converters/polymorphic_type_spec.rb +1 -1
- data/spec/factories/admin_sets.rb +1 -1
- data/spec/factories/api_items.rb +1 -1
- data/spec/factories/collections_factory.rb +2 -2
- data/spec/factories/content_blocks.rb +1 -1
- data/spec/factories/featured_works.rb +1 -1
- data/spec/factories/file_sets.rb +3 -3
- data/spec/factories/generic_works.rb +15 -15
- data/spec/factories/operations.rb +1 -1
- data/spec/factories/permission_template_accesses.rb +1 -1
- data/spec/factories/permission_templates.rb +1 -1
- data/spec/factories/proxy_deposit_requests.rb +2 -2
- data/spec/factories/single_use_links.rb +1 -1
- data/spec/factories/sipity_entities.rb +1 -1
- data/spec/factories/uploaded_files.rb +1 -1
- data/spec/factories/users.rb +2 -2
- data/spec/factories/workflow_actions.rb +1 -1
- data/spec/factories/workflow_states.rb +1 -1
- data/spec/factories/workflows.rb +1 -1
- data/spec/features/notifications_spec.rb +1 -1
- data/spec/forms/hyrax/forms/permission_template_form_spec.rb +113 -2
- data/spec/helpers/hyrax/collections_helper_spec.rb +2 -2
- data/spec/helpers/hyrax/content_block_helper_spec.rb +1 -1
- data/spec/helpers/hyrax/trophy_helper_spec.rb +1 -1
- data/spec/jobs/create_derivatives_job_spec.rb +3 -4
- data/spec/jobs/ingest_local_file_job_spec.rb +2 -5
- data/spec/lib/hyrax/arkivo/actor_spec.rb +2 -2
- data/spec/lib/hyrax/arkivo/metadata_munger_spec.rb +1 -1
- data/spec/lib/hyrax/arkivo/schema_validator_spec.rb +1 -1
- data/spec/lib/hyrax/configuration_spec.rb +4 -0
- data/spec/models/file_set_spec.rb +1 -1
- data/spec/models/generic_work_spec.rb +1 -1
- data/spec/models/hyrax/user_usage_stats_spec.rb +1 -1
- data/spec/models/sipity/entity_spec.rb +1 -1
- data/spec/models/user_spec.rb +7 -7
- data/spec/presenters/hyrax/admin/users_presenter_spec.rb +2 -2
- data/spec/renderers/hyrax/renderers/rights_statement_attribute_renderer_spec.rb +20 -0
- data/spec/search_builders/hyrax/stats/work_status_search_builder_spec.rb +12 -12
- data/spec/services/hyrax/default_middleware_stack_spec.rb +0 -1
- data/spec/services/hyrax/embargo_service_spec.rb +4 -4
- data/spec/services/hyrax/workflow/notification_service_spec.rb +0 -35
- data/spec/services/hyrax/workflow/permission_generator_spec.rb +1 -1
- data/spec/services/hyrax/workflow/status_list_service_spec.rb +12 -0
- data/spec/spec_helper.rb +6 -6
- data/spec/support/features/session_helpers.rb +1 -1
- data/spec/views/hyrax/admin/users/index.html.erb_spec.rb +1 -1
- data/spec/views/hyrax/base/_attribute_rows.html.erb_spec.rb +1 -1
- data/spec/views/hyrax/base/file_manager.html.erb_spec.rb +1 -1
- data/spec/views/hyrax/collections/show.html.erb_spec.rb +23 -5
- data/spec/views/pages/show.html.erb_spec.rb +1 -1
- data/template.rb +1 -1
- metadata +8 -6
- data/app/actors/hyrax/actors/assign_representative_actor.rb +0 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 96df4577f120f0763bf3216037a0dc709b80c316
|
|
4
|
+
data.tar.gz: 953bbd05cdda6a6f180249e38d9803392552fdf2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d82b1d0a1dbd9918594b5d1e68bef52bdbb2a1cba9ef0ccb73a7ce2dce642ce332b23dc8d3381e2a017838c91168ca49530eb9e5a6c1bb501c866617ef4dd661
|
|
7
|
+
data.tar.gz: 4518771b62f4def96f0cab00e4e562193c80cd1898fdcea4b2133a862b10ae2753320c06ae367d960d9c1c1c75757d03cd840e5602b80cf33ead75c491c9a359
|
data/README.md
CHANGED
|
@@ -63,7 +63,7 @@ The Samvera community is here to help. Please see our [support guide](./.github/
|
|
|
63
63
|
# Getting started
|
|
64
64
|
|
|
65
65
|
This document contains instructions specific to setting up an app with __Hyrax
|
|
66
|
-
v2.0.0.
|
|
66
|
+
v2.0.0.rc2__. If you are looking for instructions on installing a different
|
|
67
67
|
version, be sure to select the appropriate branch or tag from the drop-down
|
|
68
68
|
menu above.
|
|
69
69
|
|
|
@@ -160,7 +160,7 @@ NOTE: The steps need to be done in order to create a new Hyrax based app.
|
|
|
160
160
|
Generate a new Rails application using the template.
|
|
161
161
|
|
|
162
162
|
```
|
|
163
|
-
rails _5.0.6_ new my_app -m https://raw.githubusercontent.com/samvera/hyrax/v2.0.0.
|
|
163
|
+
rails _5.0.6_ new my_app -m https://raw.githubusercontent.com/samvera/hyrax/v2.0.0.rc2/template.rb
|
|
164
164
|
```
|
|
165
165
|
|
|
166
166
|
Generating a new Rails application using Hyrax's template above takes cares of a number of steps for you, including:
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
module Hyrax
|
|
2
2
|
module Actors
|
|
3
|
-
#
|
|
3
|
+
# If there is a key `:remote_files' in the attributes, it attaches the files at the specified URIs
|
|
4
|
+
# to the work. e.g.:
|
|
5
|
+
# attributes[:remote_files] = filenames.map do |name|
|
|
6
|
+
# { url: "https://example.com/file/#{name}", file_name: name }
|
|
7
|
+
# end
|
|
4
8
|
class CreateWithRemoteFilesActor < Hyrax::Actors::AbstractActor
|
|
5
9
|
# @param [Hyrax::Actors::Environment] env
|
|
6
10
|
# @return [Boolean] true if create was successful
|
|
@@ -6,13 +6,13 @@ module Hyrax
|
|
|
6
6
|
|
|
7
7
|
included do
|
|
8
8
|
layout :decide_layout
|
|
9
|
-
|
|
10
9
|
copy_blacklight_config_from(::CatalogController)
|
|
11
10
|
|
|
12
11
|
class_attribute :_curation_concern_type, :show_presenter, :work_form_service, :search_builder_class
|
|
13
12
|
self.show_presenter = Hyrax::WorkShowPresenter
|
|
14
13
|
self.work_form_service = Hyrax::WorkFormService
|
|
15
14
|
self.search_builder_class = WorkSearchBuilder
|
|
15
|
+
self.theme = 'hyrax/1_column'
|
|
16
16
|
attr_accessor :curation_concern
|
|
17
17
|
helper_method :curation_concern, :contextual_path
|
|
18
18
|
|
|
@@ -6,7 +6,7 @@ module Hyrax
|
|
|
6
6
|
def destroy
|
|
7
7
|
ActiveRecord::Base.transaction do
|
|
8
8
|
@permission_template_access.destroy
|
|
9
|
-
|
|
9
|
+
remove_access!
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
if @permission_template_access.destroyed?
|
|
@@ -28,8 +28,9 @@ module Hyrax
|
|
|
28
28
|
@admin_set_id ||= @permission_template_access.permission_template.admin_set_id
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
def
|
|
32
|
-
Forms::PermissionTemplateForm.new(@permission_template_access.permission_template)
|
|
31
|
+
def remove_access!
|
|
32
|
+
Forms::PermissionTemplateForm.new(@permission_template_access.permission_template)
|
|
33
|
+
.remove_access!(@permission_template_access)
|
|
33
34
|
end
|
|
34
35
|
end
|
|
35
36
|
end
|
|
@@ -5,6 +5,8 @@ module Hyrax
|
|
|
5
5
|
layout :decide_layout
|
|
6
6
|
load_and_authorize_resource except: [:index, :show, :create], instance_name: :collection
|
|
7
7
|
|
|
8
|
+
self.theme = 'hyrax/1_column'
|
|
9
|
+
|
|
8
10
|
# Renders a JSON response with a list of files in this collection
|
|
9
11
|
# This is used by the edit form to populate the thumbnail_id dropdown
|
|
10
12
|
def files
|
|
@@ -20,6 +20,9 @@ module Hyrax
|
|
|
20
20
|
# Stores the selected
|
|
21
21
|
attr_writer :workflow_id
|
|
22
22
|
|
|
23
|
+
# Adding attributes hash to state to avoid having to pass it around
|
|
24
|
+
attr_accessor :attributes
|
|
25
|
+
|
|
23
26
|
def workflow_id
|
|
24
27
|
@workflow_id || active_workflow.try(:id)
|
|
25
28
|
end
|
|
@@ -41,54 +44,114 @@ module Hyrax
|
|
|
41
44
|
# @return [Hash{Symbol => String, Boolean}] { :content_tab (for confirmation message),
|
|
42
45
|
# :updated (true/false),
|
|
43
46
|
# :error_code (for flash error lookup) }
|
|
47
|
+
# rubocop:disable Metrics/MethodLength
|
|
44
48
|
def update(attributes)
|
|
45
|
-
|
|
49
|
+
@attributes = attributes
|
|
50
|
+
return_info = { content_tab: tab_to_update }
|
|
46
51
|
error_code = nil
|
|
47
52
|
case return_info[:content_tab]
|
|
48
53
|
when "participants"
|
|
49
|
-
update_participants_options
|
|
54
|
+
update_participants_options
|
|
50
55
|
when "visibility"
|
|
51
|
-
error_code = update_visibility_options
|
|
56
|
+
error_code = update_visibility_options
|
|
52
57
|
when "workflow"
|
|
53
|
-
grant_workflow_roles
|
|
58
|
+
grant_workflow_roles
|
|
54
59
|
end
|
|
55
60
|
return_info[:error_code] = error_code if error_code
|
|
56
61
|
return_info[:updated] = error_code ? false : true
|
|
57
62
|
return_info
|
|
58
63
|
end
|
|
64
|
+
# rubocop:enable Metrics/MethodLength
|
|
59
65
|
|
|
60
|
-
# If management roles have been granted or removed, then copy this access
|
|
61
|
-
# to the edit permissions of the AdminSet and to the WorkflowResponsibilities
|
|
62
|
-
# of the active workflow
|
|
63
66
|
def update_management
|
|
64
67
|
admin_set.update_access_controls!
|
|
65
|
-
|
|
68
|
+
update_workflow_responsibilities
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# This method is used to revoke access to an Admin Set and its workflows
|
|
72
|
+
#
|
|
73
|
+
# @return [Void]
|
|
74
|
+
def remove_access!(permission_template_access)
|
|
75
|
+
construct_attributes_from_template_access!(permission_template_access)
|
|
76
|
+
admin_set.update_access_controls!
|
|
77
|
+
update_workflow_responsibilities(remove_agent: true)
|
|
66
78
|
end
|
|
67
79
|
|
|
68
80
|
private
|
|
69
81
|
|
|
70
82
|
# @return [String]
|
|
71
|
-
def tab_to_update
|
|
83
|
+
def tab_to_update
|
|
72
84
|
return "participants" if attributes[:access_grants_attributes].present?
|
|
73
85
|
return "workflow" if attributes[:workflow_id].present?
|
|
74
86
|
return "visibility" if attributes.key?(:visibility)
|
|
75
87
|
end
|
|
76
88
|
|
|
89
|
+
# This method is used to build the attributes that this class
|
|
90
|
+
# relies on using the passed-in PermissionTemplateAccess
|
|
91
|
+
# instance. This allows the class to use the same methods for
|
|
92
|
+
# granting access (when a new Admin Set manager is added, for
|
|
93
|
+
# instance), when called via #update, for revoking access as
|
|
94
|
+
# well when called via #remove_access!
|
|
95
|
+
#
|
|
77
96
|
# @return [Void]
|
|
78
|
-
def
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
97
|
+
def construct_attributes_from_template_access!(permission_template_access)
|
|
98
|
+
@attributes = {
|
|
99
|
+
access_grants_attributes: {
|
|
100
|
+
"0" => {
|
|
101
|
+
access: permission_template_access.access,
|
|
102
|
+
agent_type: permission_template_access.agent_type,
|
|
103
|
+
agent_id: permission_template_access.agent_id
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# @return [Void]
|
|
110
|
+
def update_participants_options
|
|
111
|
+
update_permission_template
|
|
112
|
+
update_workflow_responsibilities
|
|
113
|
+
# if managers were added or removed, recalculate update the access controls on the AdminSet
|
|
114
|
+
admin_set.update_access_controls! if managers_updated?
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Grant appropriate workflow roles based on access specified
|
|
118
|
+
def update_workflow_responsibilities(remove_agent: false)
|
|
119
|
+
return unless available_workflows
|
|
120
|
+
roles = roles_for_agent
|
|
121
|
+
return if roles.none?
|
|
122
|
+
agents = remove_agent ? manager_agents - agents_from_attributes : manager_agents + agents_from_attributes
|
|
123
|
+
available_workflows.each do |workflow|
|
|
124
|
+
roles.each do |role|
|
|
125
|
+
workflow.update_responsibilities(role: role, agents: agents)
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def roles_for_agent
|
|
131
|
+
roles = []
|
|
132
|
+
grants_as_collection.each do |grant|
|
|
133
|
+
case grant[:access]
|
|
134
|
+
when Hyrax::PermissionTemplateAccess::DEPOSIT
|
|
135
|
+
roles << Sipity::Role.find_by(name: Hyrax::RoleRegistry::DEPOSITING)
|
|
136
|
+
when Hyrax::PermissionTemplateAccess::MANAGE
|
|
137
|
+
roles += Sipity::Role.where(name: Hyrax::RoleRegistry.new.role_names)
|
|
138
|
+
# TODO: Figure out what to do here
|
|
139
|
+
# when Hyrax::PermissionTemplateAccess::VIEW
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
roles.uniq
|
|
83
143
|
end
|
|
84
144
|
|
|
85
|
-
#
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
145
|
+
# @return [Array<Sipity::Agent>] a list sipity agents extracted from attrs
|
|
146
|
+
def agents_from_attributes
|
|
147
|
+
grants_as_collection.map do |grant|
|
|
148
|
+
agent = if grant[:agent_type] == 'user'
|
|
149
|
+
::User.find_by_user_key(grant[:agent_id])
|
|
150
|
+
else
|
|
151
|
+
Hyrax::Group.new(grant[:agent_id])
|
|
152
|
+
end
|
|
153
|
+
PowerConverter.convert_to_sipity_agent(agent)
|
|
154
|
+
end
|
|
92
155
|
end
|
|
93
156
|
|
|
94
157
|
# @return [Array<Sipity::Agent>] a list of sipity agents corresponding to the manager role of the permission_template
|
|
@@ -107,17 +170,17 @@ module Hyrax
|
|
|
107
170
|
|
|
108
171
|
# @return [Array<PermissionTemplateAccess>] a list of grants corresponding to the manager role of the permission_template
|
|
109
172
|
def manager_grants
|
|
110
|
-
model.access_grants.where(access:
|
|
173
|
+
model.access_grants.where(access: Hyrax::PermissionTemplateAccess::MANAGE)
|
|
111
174
|
end
|
|
112
175
|
|
|
113
176
|
# @return [String, Nil] error_code if validation fails, nil otherwise
|
|
114
|
-
def update_visibility_options
|
|
115
|
-
error_code = validate_visibility_combinations
|
|
177
|
+
def update_visibility_options
|
|
178
|
+
error_code = validate_visibility_combinations
|
|
116
179
|
return error_code if error_code
|
|
117
|
-
update_permission_template
|
|
180
|
+
update_permission_template
|
|
118
181
|
end
|
|
119
182
|
|
|
120
|
-
def
|
|
183
|
+
def activate_workflow_from_attributes
|
|
121
184
|
new_active_workflow_id = attributes[:workflow_id] || attributes['workflow_id']
|
|
122
185
|
if active_workflow
|
|
123
186
|
return active_workflow if new_active_workflow_id.to_s == active_workflow.id.to_s
|
|
@@ -131,28 +194,29 @@ module Hyrax
|
|
|
131
194
|
# have all the roles for the new workflow
|
|
132
195
|
# @return [Void]
|
|
133
196
|
# @todo Instead of granting the manage users all of the roles (which means lots of emails), can we agree on a Managing role that all workflows should have?
|
|
134
|
-
def grant_workflow_roles
|
|
135
|
-
new_active_workflow =
|
|
197
|
+
def grant_workflow_roles
|
|
198
|
+
new_active_workflow = activate_workflow_from_attributes
|
|
136
199
|
return unless new_active_workflow
|
|
137
200
|
manager_agents.each do |agent|
|
|
138
|
-
active_workflow.workflow_roles.each do |
|
|
139
|
-
Sipity::
|
|
201
|
+
active_workflow.workflow_roles.each do |workflow_role|
|
|
202
|
+
new_workflow_role = Sipity::WorkflowRole.find_or_create_by!(workflow: new_active_workflow, role: workflow_role.role)
|
|
203
|
+
Sipity::WorkflowResponsibility.find_or_create_by!(workflow_role: new_workflow_role, agent: agent)
|
|
140
204
|
end
|
|
141
205
|
end
|
|
142
206
|
end
|
|
143
207
|
|
|
144
208
|
# @return [Nil]
|
|
145
|
-
def update_permission_template
|
|
146
|
-
model.update(permission_template_update_params
|
|
209
|
+
def update_permission_template
|
|
210
|
+
model.update(permission_template_update_params)
|
|
147
211
|
nil
|
|
148
212
|
end
|
|
149
213
|
|
|
150
|
-
def managers_updated?
|
|
151
|
-
grants_as_collection
|
|
214
|
+
def managers_updated?
|
|
215
|
+
grants_as_collection.any? { |x| x[:access] == Hyrax::PermissionTemplateAccess::MANAGE }
|
|
152
216
|
end
|
|
153
217
|
|
|
154
218
|
# This allows the attributes
|
|
155
|
-
def grants_as_collection
|
|
219
|
+
def grants_as_collection
|
|
156
220
|
return [] unless attributes[:access_grants_attributes]
|
|
157
221
|
attributes_collection = attributes[:access_grants_attributes]
|
|
158
222
|
if attributes_collection.respond_to?(:permitted?)
|
|
@@ -188,36 +252,36 @@ module Hyrax
|
|
|
188
252
|
# @return [Hash] attributes used to update the model
|
|
189
253
|
# rubocop:disable Metrics/CyclomaticComplexity
|
|
190
254
|
# rubocop:disable Metrics/PerceivedComplexity
|
|
191
|
-
def permission_template_update_params
|
|
192
|
-
|
|
255
|
+
def permission_template_update_params
|
|
256
|
+
filtered_attributes = attributes.except(:release_varies, :release_embargo)
|
|
193
257
|
# If 'varies' before date option selected, then set release_period='before' and save release_date as-is
|
|
194
|
-
if
|
|
195
|
-
|
|
258
|
+
if attributes[:release_varies] == Hyrax::PermissionTemplate::RELEASE_TEXT_VALUE_BEFORE_DATE
|
|
259
|
+
filtered_attributes[:release_period] = Hyrax::PermissionTemplate::RELEASE_TEXT_VALUE_BEFORE_DATE
|
|
196
260
|
# Else if 'varies' + embargo selected, save embargo as the release_period
|
|
197
|
-
elsif
|
|
198
|
-
|
|
199
|
-
|
|
261
|
+
elsif attributes[:release_varies] == Hyrax::PermissionTemplate::RELEASE_TEXT_VALUE_EMBARGO &&
|
|
262
|
+
attributes[:release_embargo]
|
|
263
|
+
filtered_attributes[:release_period] = attributes[:release_embargo]
|
|
200
264
|
# In an embargo, the release_date should be unspecified as it is based on deposit date
|
|
201
|
-
|
|
265
|
+
filtered_attributes[:release_date] = nil
|
|
202
266
|
end
|
|
203
267
|
|
|
204
|
-
if
|
|
268
|
+
if filtered_attributes[:release_period] == Hyrax::PermissionTemplate::RELEASE_TEXT_VALUE_NO_DELAY || (filtered_attributes[:release_period].blank? && attributes[:release_varies].blank?)
|
|
205
269
|
# If release is "no delay" or is "varies" and "allow depositor to decide",
|
|
206
270
|
# then a release_date should never be allowed/specified
|
|
207
|
-
|
|
271
|
+
filtered_attributes[:release_date] = nil
|
|
208
272
|
end
|
|
209
273
|
|
|
210
|
-
|
|
274
|
+
filtered_attributes
|
|
211
275
|
end
|
|
212
276
|
# rubocop:enable Metrics/CyclomaticComplexity
|
|
213
277
|
# rubocop:enable Metrics/PerceivedComplexity
|
|
214
278
|
|
|
215
279
|
# validate the hash of attributes used to update the visibility tab of the model
|
|
216
|
-
# @param [Hash] attributes
|
|
217
280
|
# @return [String, Nil] the error code if invalid, nil if valid
|
|
218
281
|
# rubocop:disable Metrics/CyclomaticComplexity
|
|
219
282
|
# rubocop:disable Metrics/PerceivedComplexity
|
|
220
|
-
|
|
283
|
+
# rubocop:disable Metrics/AbcSize
|
|
284
|
+
def validate_visibility_combinations
|
|
221
285
|
return unless attributes.key?(:visibility) # only the visibility tab has validations
|
|
222
286
|
|
|
223
287
|
# if "save" without any selections - none of the attributes are present
|
|
@@ -234,6 +298,7 @@ module Hyrax
|
|
|
234
298
|
end
|
|
235
299
|
# rubocop:enable Metrics/CyclomaticComplexity
|
|
236
300
|
# rubocop:enable Metrics/PerceivedComplexity
|
|
301
|
+
# rubocop:enable Metrics/AbcSize
|
|
237
302
|
end
|
|
238
303
|
end
|
|
239
304
|
end
|
|
@@ -10,7 +10,6 @@ class IngestLocalFileJob < Hyrax::ApplicationJob
|
|
|
10
10
|
actor = Hyrax::Actors::FileSetActor.new(file_set, user)
|
|
11
11
|
|
|
12
12
|
if actor.create_content(File.open(path))
|
|
13
|
-
FileUtils.rm(path)
|
|
14
13
|
Hyrax.config.callback.run(:after_import_local_file_success, file_set, user, path)
|
|
15
14
|
else
|
|
16
15
|
Hyrax.config.callback.run(:after_import_local_file_failure, file_set, user, path)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Hyrax
|
|
2
|
+
module Renderers
|
|
3
|
+
# This is used by PresentsAttributes to show licenses
|
|
4
|
+
# e.g.: presenter.attribute_to_html(:rights_statement, render_as: :rights_statement)
|
|
5
|
+
class RightsStatementAttributeRenderer < AttributeRenderer
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
##
|
|
9
|
+
# Special treatment for license/rights. A URL from the Hyrax gem's config/hyrax.rb is stored in the descMetadata of the
|
|
10
|
+
# curation_concern. If that URL is valid in form, then it is used as a link. If it is not valid, it is used as plain text.
|
|
11
|
+
def attribute_value_to_html(value)
|
|
12
|
+
begin
|
|
13
|
+
parsed_uri = URI.parse(value)
|
|
14
|
+
rescue
|
|
15
|
+
nil
|
|
16
|
+
end
|
|
17
|
+
if parsed_uri.nil?
|
|
18
|
+
ERB::Util.h(value)
|
|
19
|
+
else
|
|
20
|
+
%(<a href=#{ERB::Util.h(value)} target="_blank">#{Hyrax.config.rights_statement_service_class.new.label(value)}</a>)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -12,9 +12,6 @@ module Hyrax
|
|
|
12
12
|
# the number of users in the database
|
|
13
13
|
solr_parameters[:"facet.limit"] = ::User.count
|
|
14
14
|
|
|
15
|
-
# only get work information
|
|
16
|
-
solr_parameters[:fq] = Hyrax::WorkRelation.new.search_model_clause
|
|
17
|
-
|
|
18
15
|
# we only want the facte counts not the actual data
|
|
19
16
|
solr_parameters[:rows] = 0
|
|
20
17
|
end
|
|
@@ -22,5 +19,11 @@ module Hyrax
|
|
|
22
19
|
def self.depositor_field
|
|
23
20
|
@depositor_field ||= Solrizer.solr_name('depositor', :symbol).freeze
|
|
24
21
|
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def only_works?
|
|
26
|
+
true
|
|
27
|
+
end
|
|
25
28
|
end
|
|
26
29
|
end
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
module Hyrax
|
|
2
2
|
module Stats
|
|
3
3
|
class WorkStatusSearchBuilder < ::SearchBuilder
|
|
4
|
-
self.default_processor_chain = [:include_suppressed_facet]
|
|
4
|
+
self.default_processor_chain = [:include_suppressed_facet, :filter_models]
|
|
5
|
+
|
|
5
6
|
# includes the suppressed facet to get information on deposits.
|
|
6
7
|
# use caution when combining this with other searches as it sets the rows to
|
|
7
8
|
# zero to just get the facet information
|
|
@@ -9,8 +10,6 @@ module Hyrax
|
|
|
9
10
|
def include_suppressed_facet(solr_parameters)
|
|
10
11
|
solr_parameters[:"facet.field"].concat([IndexesWorkflow.suppressed_field])
|
|
11
12
|
solr_parameters[:'facet.missing'] = true
|
|
12
|
-
# only get work information
|
|
13
|
-
solr_parameters[:fq] = work_relation.search_model_clause
|
|
14
13
|
|
|
15
14
|
# we only want the facet counts not the actual data
|
|
16
15
|
solr_parameters[:rows] = 0
|
|
@@ -18,8 +17,8 @@ module Hyrax
|
|
|
18
17
|
|
|
19
18
|
private
|
|
20
19
|
|
|
21
|
-
def
|
|
22
|
-
|
|
20
|
+
def only_works?
|
|
21
|
+
true
|
|
23
22
|
end
|
|
24
23
|
end
|
|
25
24
|
end
|