hyrax 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +0 -1
  3. data/README.md +2 -2
  4. data/app/assets/javascripts/hyrax/autocomplete.es6 +1 -1
  5. data/app/assets/javascripts/hyrax/batch_select.js +1 -1
  6. data/app/assets/javascripts/hyrax/collections.js +6 -7
  7. data/app/authorities/qa/authorities/find_works.rb +2 -0
  8. data/app/controllers/concerns/hyrax/download_behavior.rb +1 -1
  9. data/app/controllers/concerns/hyrax/transfers_controller_behavior.rb +2 -1
  10. data/app/forms/hyrax/forms/batch_edit_form.rb +1 -1
  11. data/app/helpers/hyrax/hyrax_helper_behavior.rb +0 -12
  12. data/app/models/concerns/hyrax/ability.rb +32 -1
  13. data/app/models/concerns/hyrax/collection_behavior.rb +18 -8
  14. data/app/models/proxy_deposit_request.rb +1 -1
  15. data/app/models/sipity/entity.rb +7 -0
  16. data/app/presenters/hyrax/collection_presenter.rb +1 -1
  17. data/app/search_builders/hyrax/find_works_search_builder.rb +2 -1
  18. data/app/services/hyrax/microdata.rb +1 -1
  19. data/app/services/hyrax/persist_directly_contained_output_file_service.rb +27 -12
  20. data/app/services/hyrax/workflow/abstract_notification.rb +28 -0
  21. data/app/services/hyrax/workflow/permission_query.rb +5 -2
  22. data/app/views/hyrax/base/_browse_everything.html.erb +1 -1
  23. data/app/views/hyrax/batch_uploads/_form.html.erb +6 -1
  24. data/app/views/hyrax/collections/_button_for_update_collection.html.erb +4 -1
  25. data/app/views/hyrax/transfers/new.html.erb +5 -17
  26. data/config/locales/hyrax.en.yml +8 -0
  27. data/config/locales/hyrax.es.yml +8 -0
  28. data/config/locales/hyrax.zh.yml +8 -0
  29. data/hyrax.gemspec +14 -5
  30. data/lib/hyrax/version.rb +1 -1
  31. data/spec/abilities/ability_spec.rb +1 -0
  32. data/spec/controllers/hyrax/downloads_controller_spec.rb +2 -1
  33. data/spec/controllers/hyrax/transfers_controller_spec.rb +2 -2
  34. data/spec/features/ownership_transfer_spec.rb +3 -3
  35. data/spec/features/work_show_spec.rb +8 -1
  36. data/spec/forms/hyrax/forms/batch_edit_form_spec.rb +18 -14
  37. data/spec/models/proxy_deposit_request_spec.rb +1 -1
  38. data/spec/presenters/hyrax/collection_presenter_spec.rb +11 -5
  39. data/spec/services/hyrax/persist_directly_contained_output_file_service_spec.rb +7 -5
  40. data/spec/support/selectors.rb +0 -6
  41. data/spec/views/hyrax/base/_browse_everything.html.erb_spec.rb +1 -0
  42. data/spec/views/hyrax/batch_edits/edit.html.erb_spec.rb +1 -1
  43. data/spec/views/hyrax/batch_uploads/_form.html.erb_spec.rb +2 -0
  44. data/template.rb +1 -1
  45. metadata +38 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ba1e774b9fb00e5c4384e30c0001161c3dac629
4
- data.tar.gz: b3c1f51c995c1a56bbbeeb447dbd9d0c2f41161a
3
+ metadata.gz: 53d0448b486959ee94b0d0162e0c63ce940ba4e7
4
+ data.tar.gz: 24c811f8e483eb5de9a5cbb05b763cb45748e0ba
5
5
  SHA512:
6
- metadata.gz: a7fede837b32421d36837ebea2aaec223fc81c89005009336cedf60fbf6e9605b726a30c8cbcbb17b3e30ebf23cdb80d7fe32aaf0ad3142882b45b50c6a88a24
7
- data.tar.gz: d05a6e8047084d8de30add25123d815c634f6880ea37d6a0b681667ddb46bd7be8594f5b6722af92b25fd1b7678b86801fe6a2d9cc2c3c52d0de545b1566d121
6
+ metadata.gz: 8e52f858b31059312c2905af9000b0035424ac47589ff0d5c40a87d6e3b92fd94c35ee9b6456bbebee70fae3804841fcc66b6a913b64e2fb8f47dfad66e1449c
7
+ data.tar.gz: 16c3b93cdbebcd3c2cbdee9527db865e88d9ad635e46d32979bb337862023a2ecf1992babe2a7ac196510e01f539c5a663706725220b6699a281c94e306e2f95
@@ -153,7 +153,6 @@ RSpec/AnyInstance:
153
153
  - 'spec/controllers/hyrax/mailbox_controller_spec.rb'
154
154
  - 'spec/controllers/hyrax/stats_controller_spec.rb'
155
155
  - 'spec/controllers/hyrax/users_controller_spec.rb'
156
- - 'spec/controllers/hyrax/transfers_controller_spec.rb'
157
156
  - 'spec/jobs/file_set_attached_event_job_spec.rb'
158
157
  - 'spec/jobs/content_update_event_job_spec.rb'
159
158
  - 'spec/jobs/content_restored_version_event_job_spec.rb'
data/README.md CHANGED
@@ -59,7 +59,7 @@ If you have questions or need help, please email [the Hydra community tech list]
59
59
  # Getting started
60
60
 
61
61
  This document contains instructions specific to setting up an app with __Hyrax
62
- v1.0.2__. If you are looking for instructions on installing a different
62
+ v1.0.3__. If you are looking for instructions on installing a different
63
63
  version, be sure to select the appropriate branch or tag from the drop-down
64
64
  menu above.
65
65
 
@@ -133,7 +133,7 @@ Rails requires that you have a JavaScript runtime -- for example, nodejs -- inst
133
133
  Generate a new Rails application using the template.
134
134
 
135
135
  ```
136
- rails new my_app -m https://raw.githubusercontent.com/samvera/hyrax/v1.0.2/template.rb
136
+ rails new my_app -m https://raw.githubusercontent.com/samvera/hyrax/v1.0.3/template.rb
137
137
  ```
138
138
 
139
139
  Generating a new Rails application using Hyrax's template above takes cares of a number of steps for you, including:
@@ -12,7 +12,7 @@ export default class Autocomplete {
12
12
  element,
13
13
  data.autocompleteUrl,
14
14
  data.user,
15
- data.id
15
+ element.data('exclude-work')
16
16
  )
17
17
  break
18
18
  default:
@@ -1,6 +1,6 @@
1
1
  Blacklight.onLoad(function () {
2
2
  $('input.submits-batches').on('click', function() {
3
- var form = $(this).closest("form");
3
+ var form = $(this).closest("form");
4
4
  $.map( $(".batch_document_selector:checked"), function(document, i) {
5
5
  var id = document.id.substring("batch_document_".length);
6
6
  if (form.children("input[value='"+id+"']").length == 0)
@@ -1,13 +1,12 @@
1
1
  Blacklight.onLoad(function () {
2
2
 
3
3
  // change the action based which collection is selected
4
- $('input.updates-collection').on('click', function() {
5
-
6
- var form = $(this).closest("form");
7
- var collection_id = $(".collection-selector:checked")[0].value;
8
- form[0].action = form[0].action.replace("collection_replace_id",collection_id);
4
+ // This expects the form to have a path that includes the string 'collection_replace_id'
5
+ $('[data-behavior="updates-collection"]').on('click', function() {
6
+ var string_to_replace = "collection_replace_id"
7
+ var form = $(this).closest("form");
8
+ var collection_id = $(".collection-selector:checked")[0].value;
9
+ form[0].action = form[0].action.replace(string_to_replace, collection_id);
9
10
  form.append('<input type="hidden" value="add" name="collection[members]"></input>');
10
-
11
11
  });
12
-
13
12
  });
@@ -1,6 +1,8 @@
1
1
  module Qa::Authorities
2
2
  class FindWorks < Qa::Authorities::Base
3
3
  def search(_q, controller)
4
+ # The FindWorksSearchBuilder expects a current_user
5
+ return [] unless controller.current_user
4
6
  repo = CatalogController.new.repository
5
7
  builder = Hyrax::FindWorksSearchBuilder.new(controller)
6
8
  response = repo.search(builder)
@@ -39,7 +39,7 @@ module Hyrax
39
39
  # Hydra::Ability#download_permissions can't be used in this case because it assumes
40
40
  # that files are in a LDP basic container, and thus, included in the asset's uri.
41
41
  def authorize_download!
42
- authorize! :read, params[asset_param_key]
42
+ authorize! :download, params[asset_param_key]
43
43
  rescue CanCan::AccessDenied
44
44
  redirect_to default_image
45
45
  end
@@ -28,7 +28,8 @@ module Hyrax
28
28
  if @proxy_deposit_request.save
29
29
  redirect_to hyrax.transfers_path, notice: "Transfer request created"
30
30
  else
31
- redirect_to root_url, alert: @proxy_deposit_request.errors.full_messages.to_sentence
31
+ @work = Hyrax::WorkRelation.new.find(params[:id])
32
+ render :new
32
33
  end
33
34
  end
34
35
 
@@ -41,7 +41,7 @@ module Hyrax
41
41
  permissions = []
42
42
  # For each of the files in the batch, set the attributes to be the concatenation of all the attributes
43
43
  batch_document_ids.each do |doc_id|
44
- work = model_class.find(doc_id)
44
+ work = ActiveFedora::Base.find(doc_id)
45
45
  terms.each do |key|
46
46
  combined_attributes[key] ||= []
47
47
  combined_attributes[key] = (combined_attributes[key] + work[key].to_a).uniq
@@ -46,18 +46,6 @@ module Hyrax
46
46
  user_agent.include? 'Chrome'
47
47
  end
48
48
 
49
- def error_messages_for(object)
50
- return '' unless object.try(:errors) && object.errors.full_messages.any?
51
- content_tag(:div, class: 'alert alert-block alert-error validation-errors') do
52
- content_tag(:h4, I18n.t('hyrax.errors.header', model: object.class.model_name.human.downcase), class: 'alert-heading') +
53
- content_tag(:ul) do
54
- object.errors.full_messages.map do |message|
55
- content_tag(:li, message)
56
- end.join('').html_safe
57
- end
58
- end
59
- end
60
-
61
49
  # @param [ProxyDepositRequest] req
62
50
  def show_transfer_request_title(req)
63
51
  if req.deleted_work? || req.canceled?
@@ -19,6 +19,25 @@ module Hyrax
19
19
  :trophy_abilities]
20
20
  end
21
21
 
22
+ # Samvera doesn't use download user/groups, so make it an alias to read
23
+ # Grant all groups with read or edit access permission to download
24
+ def download_groups(id)
25
+ doc = permissions_doc(id)
26
+ return [] if doc.nil?
27
+ groups = Array(doc[self.class.read_group_field]) + Array(doc[self.class.edit_group_field])
28
+ Rails.logger.debug("[CANCAN] download_groups: #{groups.inspect}")
29
+ groups
30
+ end
31
+
32
+ # Grant all users with read or edit access permission to download
33
+ def download_users(id)
34
+ doc = permissions_doc(id)
35
+ return [] if doc.nil?
36
+ users = Array(doc[self.class.read_user_field]) + Array(doc[self.class.edit_user_field])
37
+ Rails.logger.debug("[CANCAN] download_users: #{users.inspect}")
38
+ users
39
+ end
40
+
22
41
  # Returns true if can create at least one type of work
23
42
  def can_create_any_work?
24
43
  Hyrax.config.curation_concerns.any? do |curation_concern_type|
@@ -34,6 +53,18 @@ module Hyrax
34
53
 
35
54
  private
36
55
 
56
+ # This overrides hydra-head, (and restores the method from blacklight-access-controls)
57
+ def download_permissions
58
+ can :download, String do |id|
59
+ test_download(id)
60
+ end
61
+
62
+ can :download, SolrDocument do |obj|
63
+ cache.put(obj.id, obj)
64
+ test_download(obj.id)
65
+ end
66
+ end
67
+
37
68
  # Add this to your ability_logic if you want all logged in users to be able
38
69
  # to submit content
39
70
  def everyone_can_create_curation_concerns
@@ -142,7 +173,7 @@ module Hyrax
142
173
  alias_action :edit, to: :update
143
174
  alias_action :show, to: :read
144
175
  alias_action :discover, to: :read
145
-
176
+ can :download, String # The identifier of a work or FileSet
146
177
  can :manage, curation_concerns_models
147
178
  can :manage, Sipity::WorkflowResponsibility
148
179
  end
@@ -56,30 +56,40 @@ module Hyrax
56
56
  # @return [Fixnum] size of collection in bytes
57
57
  # @raise [RuntimeError] unsaved record does not exist in solr
58
58
  def bytes
59
- return 0 if member_ids.empty?
59
+ return 0 if member_object_ids.empty?
60
60
 
61
61
  raise "Collection must be saved to query for bytes" if new_record?
62
62
 
63
63
  # One query per member_id because Solr is not a relational database
64
- sizes = member_ids.collect do |work_id|
64
+ member_object_ids.collect { |work_id| size_for_work(work_id) }.sum
65
+ end
66
+
67
+ private
68
+
69
+ # Use this query to get the ids of the member objects (since the containment
70
+ # association has been flipped)
71
+ def member_object_ids
72
+ return [] unless id
73
+ ActiveFedora::Base.search_with_conditions("member_of_collection_ids_ssim:#{id}").map(&:id)
74
+ end
75
+
76
+ # Calculate the size of all the files in the work
77
+ # @param work_id [String] identifer for a work
78
+ # @return [Integer] the size in bytes
79
+ def size_for_work(work_id)
65
80
  argz = { fl: "id, #{file_size_field}",
66
81
  fq: "{!join from=#{member_ids_field} to=id}id:#{work_id}" }
67
82
  files = ::FileSet.search_with_conditions({}, argz)
68
83
  files.reduce(0) { |sum, f| sum + f[file_size_field].to_i }
69
84
  end
70
85
 
71
- sizes.reduce(0, :+)
72
- end
73
-
74
- private
75
-
76
86
  # Field name to look up when locating the size of each file in Solr.
77
87
  # Override for your own installation if using something different
78
88
  def file_size_field
79
89
  Solrizer.solr_name(:file_size, Hyrax::FileSetIndexer::STORED_LONG)
80
90
  end
81
91
 
82
- # Solr field name collections and works use to index member ids
92
+ # Solr field name works use to index member ids
83
93
  def member_ids_field
84
94
  Solrizer.solr_name('member_ids', :symbol)
85
95
  end
@@ -64,7 +64,7 @@ class ProxyDepositRequest < ActiveRecord::Base
64
64
  end
65
65
 
66
66
  def sending_user_should_not_be_receiving_user
67
- errors.add(:sending_user, 'must specify another user to receive the work') if receiving_user && receiving_user.user_key == sending_user.user_key
67
+ errors.add(:transfer_to, 'specify a different user to receive the work') if receiving_user && receiving_user.user_key == sending_user.user_key
68
68
  end
69
69
 
70
70
  def should_not_be_already_part_of_a_transfer
@@ -5,6 +5,13 @@ module Sipity
5
5
  #
6
6
  # The goal is to keep this behavior separate, so that we can possibly
7
7
  # extract the information.
8
+ # @example To get the Sipity::Entity for a work
9
+ # work = GenericWork.first
10
+ # work_global_id = work.to_global_id.to_s
11
+ # => "gid://whatever/GenericWork/3x816m604"
12
+ # Sipity::Entity.where(proxy_for_global_id: work_global_id).first
13
+ # => #<Sipity::Entity id: 1, proxy_for_global_id: "gid://whatever/GenericWork/3x816m604",
14
+ # workflow_id: 8, workflow_state_id: 20, created_at: "2017-07-07 13:39:42", updated_at: "2017-07-07 13:39:42">
8
15
  class Entity < ActiveRecord::Base
9
16
  self.table_name = 'sipity_entities'
10
17
 
@@ -51,7 +51,7 @@ module Hyrax
51
51
  end
52
52
 
53
53
  def total_items
54
- @solr_document.fetch('member_ids_ssim', []).length
54
+ ActiveFedora::Base.where("member_of_collection_ids_ssim:#{id}").count
55
55
  end
56
56
  end
57
57
  end
@@ -8,7 +8,8 @@ class Hyrax::FindWorksSearchBuilder < Hyrax::SearchBuilder
8
8
  # Excludes the id that is part of the params
9
9
  def initialize(context)
10
10
  super(context)
11
- @id = context.params[:id]
11
+ # Without an id this class will produce an invalid query.
12
+ @id = context.params[:id] || raise("missing required parameter: id")
12
13
  @q = context.params[:q]
13
14
  end
14
15
 
@@ -1,7 +1,7 @@
1
1
  module Hyrax
2
2
  class Microdata
3
3
  include Singleton
4
- FILENAME = 'config/schema_org.yml'.freeze
4
+ FILENAME = Hyrax::Engine.root + 'config/schema_org.yml'
5
5
  TOP_KEY = 'schema_org'.freeze
6
6
 
7
7
  def self.fetch(key, options = {})
@@ -5,22 +5,37 @@ module Hyrax
5
5
  # This method conforms to the signature of the .call method on Hydra::Derivatives::PersistOutputFileService
6
6
  # * Persists the file within the DirectContainer specified by :container
7
7
  #
8
- # @param [String] the data to be persisted
9
- # @param [Hash] directives directions which can be used to determine where to persist to.
8
+ # @param content [String] the data to be persisted
9
+ # @param directives [Hash] directions which can be used to determine where to persist to.
10
10
  # @option directives [String] url URI for the parent object.
11
11
  # @option directives [String] container Name of the container association.
12
- def self.call(string, directives)
13
- file = Hydra::Derivatives::IoDecorator.new(string, new_mime_type(directives.fetch(:format)))
14
- o_name = determine_original_name(file)
15
- m_type = determine_mime_type(file)
16
- uri = URI(directives.fetch(:url))
17
- raise ArgumentError, "#{uri} is not an http(s) uri" unless uri.is_a?(URI::HTTP)
18
- file_set = ActiveFedora::Base.find(ActiveFedora::Base.uri_to_id(uri.to_s))
19
- remote_file = file_set.send("build_#{directives.fetch(:container)}".to_sym)
12
+ def self.call(content, directives)
13
+ file = io(content, directives)
14
+ file_set = retrieve_file_set(directives)
15
+ remote_file = retrieve_remote_file(file_set, directives)
20
16
  remote_file.content = file
21
- remote_file.mime_type = m_type
22
- remote_file.original_name = o_name
17
+ remote_file.mime_type = determine_mime_type(file)
18
+ remote_file.original_name = determine_original_name(file)
23
19
  file_set.save
24
20
  end
21
+
22
+ # @param directives [Hash] directions which can be used to determine where to persist to.
23
+ # @option directives [String] url URI for the parent object.
24
+ def self.retrieve_file_set(directives)
25
+ uri = URI(directives.fetch(:url))
26
+ raise ArgumentError, "#{uri} is not an http(s) uri" unless uri.is_a?(URI::HTTP)
27
+ ActiveFedora::Base.find(ActiveFedora::Base.uri_to_id(uri.to_s))
28
+ end
29
+ private_class_method :retrieve_file_set
30
+
31
+ # Override this implementation if you need a remote file from a different location
32
+ # @param file_set [FileSet] the container of the remote file
33
+ # @param directives [Hash] directions which can be used to determine where to persist to
34
+ # @option directives [String] container Name of the container association.
35
+ # @return [ActiveFedora::File]
36
+ def self.retrieve_remote_file(file_set, directives)
37
+ file_set.send("build_#{directives.fetch(:container)}".to_sym)
38
+ end
39
+ private_class_method :retrieve_remote_file
25
40
  end
26
41
  end
@@ -1,5 +1,27 @@
1
1
  module Hyrax
2
2
  module Workflow
3
+ # @abstract A notification that happens when a state transition occurs. Subclass AbstractNotification to create a notification.
4
+ # @example
5
+ # module Hyrax
6
+ # module Workflow
7
+ # class LocalApprovedNotification < AbstractNotification
8
+ # private
9
+ #
10
+ # def subject
11
+ # "Deposit #{title} has been approved"
12
+ # end
13
+ #
14
+ # def message
15
+ # "#{title} (#{link_to work_id, document_path}) has been approved by #{user.display_name} #{comment}"
16
+ # end
17
+ #
18
+ # # Add the user who initiated this action to the list of users being notified
19
+ # def users_to_notify
20
+ # super << user
21
+ # end
22
+ # end
23
+ # end
24
+ # end
3
25
  class AbstractNotification
4
26
  include ActionView::Helpers::UrlHelper
5
27
 
@@ -9,6 +31,12 @@ module Hyrax
9
31
 
10
32
  attr_reader :work_id, :title, :comment, :user, :recipients
11
33
 
34
+ # @param [Sipity::Entity] entity - the Sipity::Entity that is a proxy for the relevant Hyrax work
35
+ # @param [#comment] comment - the comment associated with the action being taken, could be a Sipity::Comment, or anything that responds to a #comment method
36
+ # @param [Hyrax::User] user - the user who has performed the relevant action
37
+ # @param [Hash] recipients - a hash with keys "to" and (optionally) "cc"
38
+ # @option recipients [Array<Hyrax::User>] :to a list of users to which to send the notification
39
+ # @option recipients [Array<Hyrax::User>] :cc a list of users to which to copy on the notification
12
40
  def initialize(entity, comment, user, recipients)
13
41
  @work_id = entity.proxy_for_global_id.sub(/.*\//, '')
14
42
  @title = entity.proxy_for.title.first
@@ -257,8 +257,11 @@ module Hyrax
257
257
  .and(entity_responsibilities[:entity_id].eq(entity.id))
258
258
  )
259
259
 
260
- # PostgreSQL requires an explicit cast from string to integer
261
- cast = Arel::Nodes::NamedFunction.new "CAST", [agent_table[:proxy_for_id].as("integer")]
260
+ # Default to "integer" for adapters like Postgres and Sqlite, but cast
261
+ # to "signed" for Mysql. The type CAST causes a SQL syntax error for an
262
+ # unsupported type depending on which adapter is being used.
263
+ type = ActiveRecord::Base.connection.adapter_name.casecmp("mysql2").zero? ? "signed" : "integer"
264
+ cast = Arel::Nodes::NamedFunction.new "CAST", [agent_table[:proxy_for_id].as(type)]
262
265
 
263
266
  sub_query_for_user = agent_table.project(cast).where(
264
267
  agent_table[:id].in(workflow_agent_id_subquery)
@@ -3,4 +3,4 @@
3
3
  </div>
4
4
  <%= button_tag(t('hyrax.upload.browse_everything.browse_files_button'), type: 'button', class: 'btn btn-lg btn-success', id: "browse-btn",
5
5
  'data-toggle' => 'browse-everything', 'data-route' => browse_everything_engine.root_path,
6
- 'data-target' => "##{f.object.persisted? ? 'edit' : 'new'}_#{f.object.model.model_name.param_key}" ) %>
6
+ 'data-target' => "#{f.object.persisted? ? "#edit_#{f.object.model.model_name.param_key}_#{f.object.model.id}" : "#new_#{f.object.model.model_name.param_key}"}" ) %>
@@ -1,4 +1,9 @@
1
- <%= simple_form_for [hyrax, @form], html: { multipart: true } do |f| %>
1
+ <%= simple_form_for [hyrax, @form],
2
+ html: {
3
+ data: { behavior: 'work-form',
4
+ 'param-key' => @form.model_name.param_key },
5
+ multipart: true
6
+ } do |f| %>
2
7
  <% content_for :files_tab do %>
3
8
  <p class="instructions"><%= t("hyrax.batch_uploads.files.instructions") %></p>
4
9
  <p class="switch-upload-type"><%= t("hyrax.batch_uploads.files.upload_type_instructions") %>
@@ -1,4 +1,7 @@
1
1
  <%# button for updating a collections %>
2
2
  <%# collection_id -- collection to be updated (use 'collection_replace_id' if you wish the form to be updated by a form value) %>
3
3
  <%# label -- button label %>
4
- <%= button_to label, collection_path(collection_id), method: :put, class: "btn btn-primary updates-collection submits-batches collection-update", 'data-behavior'=>'hydra-collections', id: 'hydra-collection-update' %>
4
+ <%= button_to label, collection_path(collection_id),
5
+ method: :put,
6
+ class: "btn btn-primary submits-batches",
7
+ data: { behavior: 'updates-collection' } %>
@@ -1,23 +1,11 @@
1
1
  <h1>Transfer ownership of "<%= @proxy_deposit_request.to_s %>"</h1>
2
2
  <span class="sr-only">Select a user to transfer <%= @proxy_deposit_request.to_s %> to, add optional comments and then press transfer.</span>
3
- <%= form_for @proxy_deposit_request,
4
- url: hyrax.work_transfers_path(@work),
5
- html: { class: 'form-horizontal', id: 'new_transfer' } do |f| %>
6
- <%= error_messages_for(f.object) %>
7
- <div class="control-group">
8
- <%= f.label :transfer_to, "User", class: 'control-label' %>
9
- <div class="controls">
10
- <%= f.text_field :transfer_to, "aria-hidden" => true %>
11
- </div>
12
- </div>
13
- <div class="control-group">
14
- <%= f.label :sender_comment, "Comments", class: 'control-label' %>
15
- <div class="controls">
16
- <%= f.text_area :sender_comment %>
17
- </div>
18
- </div>
3
+ <%= simple_form_for @proxy_deposit_request,
4
+ url: hyrax.work_transfers_path(@work) do |f| %>
5
+ <%= f.input :transfer_to %>
6
+ <%= f.input :sender_comment %>
19
7
 
20
8
  <div class="form-actions">
21
- <%= f.submit "Transfer", class: 'btn btn-primary', data: {confirm: "Are you sure you want to transfer ownership of this work to another user? Click Ok to transfer or Cancel to return to the transfer screen"} %>
9
+ <%= f.submit class: 'btn btn-primary', data: { confirm: t('.confirm') } %>
22
10
  </div>
23
11
  <% end %>
@@ -42,6 +42,8 @@ en:
42
42
  update: 'Save'
43
43
  hyrax_permission_template_access:
44
44
  create: 'Add'
45
+ proxy_deposit_request:
46
+ create: 'Transfer'
45
47
  update: 'Save'
46
48
  hyrax:
47
49
  account_label: "User"
@@ -568,6 +570,9 @@ en:
568
570
  menu: "Works"
569
571
  my: "My Works"
570
572
  new: "New Work"
573
+ transfers:
574
+ new:
575
+ confirm: "Are you sure you want to transfer ownership of this work to another user? Click Ok to transfer or Cancel to return to the transfer screen"
571
576
  upload:
572
577
  alert:
573
578
  contact_href_text: "contact form"
@@ -728,5 +733,8 @@ en:
728
733
  visibility_after_lease: 'then restrict it to'
729
734
  visibility_during_embargo: 'Restricted to'
730
735
  visibility_during_lease: 'Is available for'
736
+ proxy_deposit_request:
737
+ transfer_to: "User"
738
+ sender_comment: "Comments"
731
739
  required:
732
740
  html: '<span class="label label-info required-tag">required</span>'
@@ -42,6 +42,8 @@ es:
42
42
  update: 'Guardar'
43
43
  hyrax_permission_template_access:
44
44
  create: 'Agregar'
45
+ proxy_deposit_request:
46
+ create: 'Transferir'
45
47
  update: 'Guardar'
46
48
  hyrax:
47
49
  account_label: "Usuario"
@@ -567,6 +569,9 @@ es:
567
569
  menu: "Trabajos"
568
570
  my: "Mis Trabajos"
569
571
  new: "Nuevo"
572
+ transfers:
573
+ new:
574
+ confirm: "¿Está seguro de que desea transferir la propiedad de este trabajo a otro usuario? Haga clic en Aceptar para transferir o Cancelar para volver a la pantalla de transferencia"
570
575
  upload:
571
576
  alert:
572
577
  contact_href_text: "formulario de contacto"
@@ -727,5 +732,8 @@ es:
727
732
  visibility_after_lease: 'luego restringirlo a'
728
733
  visibility_during_embargo: 'Restringido a'
729
734
  visibility_during_lease: 'Está disponible para'
735
+ proxy_deposit_request:
736
+ transfer_to: "Usuario"
737
+ sender_comment: "Comentarios"
730
738
  required:
731
739
  html: '<span class="label label-info required-tag">obligatorio</span>'
@@ -53,6 +53,8 @@ zh:
53
53
  update: '保存'
54
54
  hyrax_permission_template_access:
55
55
  create: '添加'
56
+ proxy_deposit_request:
57
+ create: '转让'
56
58
  update: '保存'
57
59
  hyrax:
58
60
  account_label: "用户"
@@ -578,6 +580,9 @@ zh:
578
580
  logout: "退出登录"
579
581
  sr_action: "阅览"
580
582
  sr_target: "个人资料"
583
+ transfers:
584
+ new:
585
+ confirm: "您确定要将此作品的所有权转让给其他使用者吗? 单击确定转移或取消返回到传输屏幕"
581
586
  upload:
582
587
  alert:
583
588
  contact_href_text: "联系表格"
@@ -726,5 +731,8 @@ zh:
726
731
  visibility_after_lease: '仅限'
727
732
  visibility_during_embargo: '仅限'
728
733
  visibility_during_lease: '可使用'
734
+ proxy_deposit_request:
735
+ transfer_to: "用户"
736
+ sender_comment: "注释"
729
737
  required:
730
738
  html: '<span class="label label-info required-tag">需要的</span>'
@@ -6,9 +6,16 @@ require 'hyrax/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.authors = ["Justin Coyne", 'Michael J. Giarlo', "Carolyn Cole", "Matt Zumwalt", 'Jeremy Friesen', 'Trey Pendragon', 'Esmé Cowles']
8
8
  spec.email = ["jcoyne85@stanford.edu", 'mjgiarlo@stanford.edu', 'cam156@psu.edu', 'matt@databindery.com', "jeremy.n.friesen@gmail.com", 'tpendragon@princeton.edu', 'escowles@ticklefish.org']
9
- spec.description = 'Hyrax is a featureful Hydra front-end based on the latest and greatest Hydra software components.'
10
- spec.summary = "Hyrax is a front-end based on the robust Hydra framework, providing a user interface for common repository features. Hyrax offers the ability to create repository object types on demand, to deposit content via multiple workflows, and to describe content with flexible metadata. Numerous optional features may be turned on in the administrative dashboard or added through plugins."
11
- spec.homepage = "http://github.com/projecthydra-labs/hyrax"
9
+ spec.description = 'Hyrax is a featureful Samvera front-end based on the latest and greatest Samvera software components.'
10
+ spec.summary = <<-EOF
11
+ Hyrax is a front-end based on the robust Samvera framework, providing a user
12
+ interface for common repository features. Hyrax offers the ability to create
13
+ repository object types on demand, to deposit content via multiple workflows,
14
+ and to describe content with flexible metadata. Numerous optional features may
15
+ be turned on in the administrative dashboard or added through plugins.
16
+ EOF
17
+
18
+ spec.homepage = "http://github.com/samvera/hyrax"
12
19
 
13
20
  spec.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
14
21
  spec.executables = spec.files.grep(%r{^bin/}).map { |f| File.basename(f) }
@@ -16,11 +23,12 @@ Gem::Specification.new do |spec|
16
23
  spec.name = "hyrax"
17
24
  spec.require_paths = ["lib"]
18
25
  spec.version = Hyrax::VERSION
19
- spec.license = 'Apache2'
26
+ spec.license = 'Apache-2.0'
20
27
 
21
28
  spec.add_dependency 'hydra-head', '>= 10.4.0'
22
29
  spec.add_dependency 'hydra-editor', '~> 3.2'
23
30
  spec.add_dependency 'hydra-works', '~> 0.16'
31
+ spec.add_dependency 'hydra-derivatives', '~> 3.3'
24
32
  spec.add_dependency 'browse-everything', '>= 0.10.5'
25
33
  spec.add_dependency 'blacklight', '~> 6.9'
26
34
  spec.add_dependency 'blacklight-gallery', '~> 0.7'
@@ -59,7 +67,8 @@ Gem::Specification.new do |spec|
59
67
  spec.add_dependency 'active_attr', '~> 0.9'
60
68
  spec.add_dependency 'redlock', '~> 0.1.2'
61
69
  spec.add_dependency 'retriable', '>= 2.9', '< 4.0'
62
- spec.add_dependency 'active-fedora', '>= 11.1.3'
70
+ spec.add_dependency 'active-fedora', '>= 11.3.1'
71
+ spec.add_dependency 'linkeddata' # Required for getting values from geonames
63
72
 
64
73
  spec.add_development_dependency 'engine_cart', '~> 1.0'
65
74
  spec.add_development_dependency 'mida', '~> 0.3'
@@ -1,3 +1,3 @@
1
1
  module Hyrax
2
- VERSION = '1.0.2'.freeze
2
+ VERSION = '1.0.3'.freeze
3
3
  end
@@ -43,6 +43,7 @@ describe 'Hyrax::Ability', type: :model do
43
43
  it { is_expected.to be_able_to(:update, ContentBlock) }
44
44
  it { is_expected.to be_able_to(:read, ContentBlock) }
45
45
  it { is_expected.to be_able_to(:read, Hyrax::Statistics) }
46
+ it { is_expected.to be_able_to(:download, 'abcd123') } # an id for a work/FileSet
46
47
  it { is_expected.to be_able_to(:read, :admin_dashboard) }
47
48
  it { is_expected.to be_able_to(:manage, AdminSet) }
48
49
  it { is_expected.to be_able_to(:create, AdminSet) }
@@ -31,7 +31,7 @@ describe Hyrax::DownloadsController do
31
31
  end
32
32
 
33
33
  it 'authorizes the resource using only the id' do
34
- expect(controller).to receive(:authorize!).with(:read, file_set.id)
34
+ expect(controller).to receive(:authorize!).with(:download, file_set.id)
35
35
  get :show, params: { id: file_set.to_param }
36
36
  end
37
37
  end
@@ -55,6 +55,7 @@ describe Hyrax::DownloadsController do
55
55
 
56
56
  it 'sends requested file content' do
57
57
  get :show, params: { id: file_set, file: 'thumbnail' }
58
+ expect(response).to be_success
58
59
  expect(response.body).to eq content
59
60
  expect(response.headers['Content-Length']).to eq "4218"
60
61
  expect(response.headers['Accept-Ranges']).to eq "bytes"
@@ -71,7 +71,6 @@ describe Hyrax::TransfersController, type: :controller do
71
71
  describe "#create" do
72
72
  let(:work) { create(:work, user: user) }
73
73
  it "is successful" do
74
- allow_any_instance_of(User).to receive(:display_name).and_return("Jill Z. User")
75
74
  expect do
76
75
  post :create, params: {
77
76
  id: work.id,
@@ -99,7 +98,8 @@ describe Hyrax::TransfersController, type: :controller do
99
98
  post :create, params: { id: work.id, proxy_deposit_request: { transfer_to: 'foo' } }
100
99
  end.not_to change(ProxyDepositRequest, :count)
101
100
  expect(assigns[:proxy_deposit_request].errors[:transfer_to]).to eq(['must be an existing user'])
102
- expect(response).to redirect_to(root_path)
101
+ expect(assigns[:work]).to be_instance_of GenericWork
102
+ expect(response).to be_success
103
103
  end
104
104
  end
105
105
 
@@ -20,8 +20,8 @@ RSpec.describe 'Transferring work ownership:', type: :feature do
20
20
 
21
21
  context 'To myself' do
22
22
  before { transfer_ownership_of_work work, original_owner }
23
- it 'Displays an appropriate error message' do
24
- expect(page).to have_content 'Sending user must specify another user to receive the work'
23
+ it 'displays an appropriate error message' do
24
+ expect(page).to have_content 'specify a different user to receive the work'
25
25
  end
26
26
  end
27
27
 
@@ -94,6 +94,6 @@ RSpec.describe 'Transferring work ownership:', type: :feature do
94
94
  new_owner_search_field.set new_owner.user_key
95
95
  new_owner_search_result.click
96
96
  fill_in 'proxy_deposit_request[sender_comment]', with: 'Work transfer comments'
97
- submit_button.click
97
+ click_button "Transfer"
98
98
  end
99
99
  end
@@ -5,7 +5,14 @@ describe "display a work as its owner" do
5
5
  end
6
6
 
7
7
  context "as the work owner" do
8
- let(:work) { create(:work_with_one_file, title: ["Magnificent splendor"], source: ["The Internet"], based_near: ["USA"], user: user) }
8
+ let(:work) do
9
+ create(:work_with_one_file,
10
+ with_admin_set: true,
11
+ title: ["Magnificent splendor"],
12
+ source: ["The Internet"],
13
+ based_near: ["USA"],
14
+ user: user)
15
+ end
9
16
  let(:user) { create(:user) }
10
17
  before do
11
18
  sign_in user
@@ -15,22 +15,26 @@ RSpec.describe Hyrax::Forms::BatchEditForm do
15
15
  related_url: ['related_url1']
16
16
  end
17
17
 
18
+ # Using a different work type in order to show that the form supports
19
+ # batches containing multiple types of works
18
20
  let(:work2) do
19
- create :generic_work,
20
- title: ["title 2"],
21
- keyword: ["123"],
22
- creator: ["Fred"],
23
- publisher: ['Rand McNally'],
24
- language: ['en'],
25
- resource_type: ['bar'],
26
- contributor: ['contributor2'],
27
- description: ['description2'],
28
- rights: ['rights2'],
29
- subject: ['subject2'],
30
- identifier: ['id2'],
31
- based_near: ['based_near2'],
32
- related_url: ['related_url2']
21
+ RareBooks::Atlas.create!(
22
+ title: ["title 2"],
23
+ keyword: ["123"],
24
+ creator: ["Fred"],
25
+ publisher: ['Rand McNally'],
26
+ language: ['en'],
27
+ resource_type: ['bar'],
28
+ contributor: ['contributor2'],
29
+ description: ['description2'],
30
+ rights: ['rights2'],
31
+ subject: ['subject2'],
32
+ identifier: ['id2'],
33
+ based_near: ['based_near2'],
34
+ related_url: ['related_url2']
35
+ )
33
36
  end
37
+
34
38
  let(:batch) { [work1.id, work2.id] }
35
39
  let(:form) { described_class.new(model, ability, batch) }
36
40
  let(:ability) { Ability.new(user) }
@@ -124,7 +124,7 @@ describe ProxyDepositRequest, type: :model do
124
124
  it 'raises an error' do
125
125
  subject.transfer_to = sender.user_key
126
126
  expect(subject).not_to be_valid
127
- expect(subject.errors[:sending_user]).to eq(['must specify another user to receive the work'])
127
+ expect(subject.errors[:transfer_to]).to eq(['specify a different user to receive the work'])
128
128
  end
129
129
  end
130
130
 
@@ -75,12 +75,12 @@ describe Hyrax::CollectionPresenter do
75
75
  it { is_expected.to eq ['adc12v'] }
76
76
  end
77
77
 
78
- describe "#size" do
78
+ describe "#size", :clean_repo do
79
79
  subject { presenter.size }
80
80
  it { is_expected.to eq '0 Bytes' }
81
81
  end
82
82
 
83
- describe "#total_items" do
83
+ describe "#total_items", :clean_repo do
84
84
  subject { presenter.total_items }
85
85
 
86
86
  context "empty collection" do
@@ -88,13 +88,19 @@ describe Hyrax::CollectionPresenter do
88
88
  end
89
89
 
90
90
  context "collection with work" do
91
- let(:work) { build(:work, title: ['unimaginitive title']) }
92
- before { collection.members << work }
91
+ let(:work) { create(:work, title: ['unimaginitive title']) }
92
+
93
+ before do
94
+ work.member_of_collections << collection
95
+ work.save!
96
+ end
97
+
93
98
  it { is_expected.to eq 1 }
94
99
  end
95
100
 
96
101
  context "null members" do
97
- let(:presenter) { described_class.new({}, nil) }
102
+ let(:presenter) { described_class.new(SolrDocument.new(id: '123'), nil) }
103
+
98
104
  it { is_expected.to eq 0 }
99
105
  end
100
106
  end
@@ -2,17 +2,19 @@ require 'spec_helper'
2
2
 
3
3
  RSpec.describe Hyrax::PersistDirectlyContainedOutputFileService do
4
4
  # PersistDirectlyContainedOutputFileService is used by FullTextExtract.output_file_service
5
- let(:object) { FileSet.create! { |fs| fs.apply_depositor_metadata('justin') } }
6
- let(:stream) { "fake file content" }
5
+ let(:file_set) { FileSet.create! { |fs| fs.apply_depositor_metadata('justin') } }
6
+ let(:content) { "fake file content" }
7
7
  subject(:call) do
8
- described_class.call(stream,
8
+ described_class.call(content,
9
9
  format: 'txt',
10
- url: object.uri,
10
+ url: file_set.uri,
11
11
  container: 'extracted_text')
12
12
  end
13
+ let(:resource) { file_set.reload.extracted_text }
13
14
 
14
15
  it "persists the file to the specified destination on the given object" do
15
16
  expect(call).to be true
16
- expect(object.reload.extracted_text.content).to eq("fake file content")
17
+ expect(resource.content).to eq("fake file content")
18
+ expect(resource.content.encoding).to eq(Encoding::UTF_8)
17
19
  end
18
20
  end
@@ -23,12 +23,6 @@ module Selectors
23
23
  find '.select2-result-selectable'
24
24
  end
25
25
  end
26
-
27
- def submit_button
28
- within '#new_transfer' do
29
- find 'input[type=submit]'
30
- end
31
- end
32
26
  end
33
27
 
34
28
  module Transfers
@@ -9,5 +9,6 @@ describe 'hyrax/base/_browse_everything.html.erb', type: :view do
9
9
  render 'hyrax/base/browse_everything', f: f
10
10
  page = Capybara::Node::Simple.new(rendered)
11
11
  expect(page).to have_selector('div.alert-success', text: /Please note that if you upload a large number of files/i, count: 1)
12
+ expect(page).to have_selector("button[id='browse-btn'][data-target='#edit_generic_work_#{form.model.id}']")
12
13
  end
13
14
  end
@@ -4,7 +4,7 @@ describe 'hyrax/batch_edits/edit.html.erb', type: :view do
4
4
  let(:form) { Hyrax::Forms::BatchEditForm.new(generic_work, nil, batch) }
5
5
 
6
6
  before do
7
- allow(GenericWork).to receive(:find).and_return(generic_work)
7
+ allow(ActiveFedora::Base).to receive(:find).and_return(generic_work)
8
8
 
9
9
  # this prevents AF from hitting Fedora (permissions is a related object)
10
10
  allow(generic_work).to receive(:permissions_attributes=)
@@ -18,6 +18,8 @@ describe 'hyrax/batch_uploads/_form.html.erb', type: :view do
18
18
 
19
19
  it "draws the page" do
20
20
  expect(page).to have_selector("form[action='/batch_uploads']")
21
+ expect(page).to have_selector("form[action='/batch_uploads'][data-behavior='work-form']")
22
+ expect(page).to have_selector("form[action='/batch_uploads'][data-param-key='batch_upload_item']")
21
23
  # No title, because it's captured per file (e.g. Display label)
22
24
  expect(page).not_to have_selector("input#generic_work_title")
23
25
  expect(view.content_for(:files_tab)).to have_link("New Work", href: "/concern/generic_works/new")
@@ -1,4 +1,4 @@
1
- gem 'hyrax', '1.0.0.rc2'
1
+ gem 'hyrax', '1.0.3'
2
2
 
3
3
  run 'bundle install'
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyrax
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2017-06-30 00:00:00.000000000 Z
17
+ date: 2017-07-19 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: hydra-head
@@ -58,6 +58,20 @@ dependencies:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0.16'
61
+ - !ruby/object:Gem::Dependency
62
+ name: hydra-derivatives
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.3'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '3.3'
61
75
  - !ruby/object:Gem::Dependency
62
76
  name: browse-everything
63
77
  requirement: !ruby/object:Gem::Requirement
@@ -614,14 +628,28 @@ dependencies:
614
628
  requirements:
615
629
  - - ">="
616
630
  - !ruby/object:Gem::Version
617
- version: 11.1.3
631
+ version: 11.3.1
632
+ type: :runtime
633
+ prerelease: false
634
+ version_requirements: !ruby/object:Gem::Requirement
635
+ requirements:
636
+ - - ">="
637
+ - !ruby/object:Gem::Version
638
+ version: 11.3.1
639
+ - !ruby/object:Gem::Dependency
640
+ name: linkeddata
641
+ requirement: !ruby/object:Gem::Requirement
642
+ requirements:
643
+ - - ">="
644
+ - !ruby/object:Gem::Version
645
+ version: '0'
618
646
  type: :runtime
619
647
  prerelease: false
620
648
  version_requirements: !ruby/object:Gem::Requirement
621
649
  requirements:
622
650
  - - ">="
623
651
  - !ruby/object:Gem::Version
624
- version: 11.1.3
652
+ version: '0'
625
653
  - !ruby/object:Gem::Dependency
626
654
  name: engine_cart
627
655
  requirement: !ruby/object:Gem::Requirement
@@ -908,8 +936,8 @@ dependencies:
908
936
  - - ">="
909
937
  - !ruby/object:Gem::Version
910
938
  version: '0'
911
- description: Hyrax is a featureful Hydra front-end based on the latest and greatest
912
- Hydra software components.
939
+ description: Hyrax is a featureful Samvera front-end based on the latest and greatest
940
+ Samvera software components.
913
941
  email:
914
942
  - jcoyne85@stanford.edu
915
943
  - mjgiarlo@stanford.edu
@@ -2543,9 +2571,9 @@ files:
2543
2571
  - vendor/assets/javascripts/webcomponentsjs/0.5.4/CustomElements.min.js
2544
2572
  - vendor/assets/stylesheets/morris.js/0.5.1/morris.css
2545
2573
  - vendor/assets/stylesheets/sharing_buttons.css
2546
- homepage: http://github.com/projecthydra-labs/hyrax
2574
+ homepage: http://github.com/samvera/hyrax
2547
2575
  licenses:
2548
- - Apache2
2576
+ - Apache-2.0
2549
2577
  metadata: {}
2550
2578
  post_install_message:
2551
2579
  rdoc_options: []
@@ -2563,10 +2591,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
2563
2591
  version: '0'
2564
2592
  requirements: []
2565
2593
  rubyforge_project:
2566
- rubygems_version: 2.6.8
2594
+ rubygems_version: 2.5.2
2567
2595
  signing_key:
2568
2596
  specification_version: 4
2569
- summary: Hyrax is a front-end based on the robust Hydra framework, providing a user
2597
+ summary: Hyrax is a front-end based on the robust Samvera framework, providing a user
2570
2598
  interface for common repository features. Hyrax offers the ability to create repository
2571
2599
  object types on demand, to deposit content via multiple workflows, and to describe
2572
2600
  content with flexible metadata. Numerous optional features may be turned on in the