curation_concerns 0.3.0 → 0.4.0

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.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +8 -0
  4. data/Gemfile +1 -2
  5. data/README.md +1 -1
  6. data/Rakefile +1 -1
  7. data/VERSION +1 -1
  8. data/app/assets/javascripts/curation_concerns/curation_concerns.js +2 -0
  9. data/app/assets/javascripts/curation_concerns/uploader.js +4 -4
  10. data/app/assets/stylesheets/curation_concerns/_modules.scss +1 -0
  11. data/app/assets/stylesheets/curation_concerns/_positioning.scss +3 -0
  12. data/app/assets/stylesheets/curation_concerns/modules/icons.scss +11 -0
  13. data/app/controllers/concerns/curation_concerns/api.rb +1 -12
  14. data/app/controllers/concerns/curation_concerns/application_controller_behavior.rb +20 -6
  15. data/app/controllers/concerns/curation_concerns/curation_concern_controller.rb +44 -25
  16. data/app/controllers/concerns/curation_concerns/file_sets_controller_behavior.rb +32 -23
  17. data/app/controllers/concerns/curation_concerns/parent_container.rb +0 -11
  18. data/app/controllers/concerns/curation_concerns/single_use_links_controller_behavior.rb +1 -1
  19. data/app/controllers/concerns/curation_concerns/single_use_links_viewer_controller_behavior.rb +7 -1
  20. data/app/controllers/concerns/curation_concerns/upload_sets_controller_behavior.rb +19 -7
  21. data/app/controllers/curation_concerns/permissions_controller.rb +1 -1
  22. data/app/forms/curation_concerns/forms/collection_edit_form.rb +6 -2
  23. data/app/forms/curation_concerns/forms/work_form.rb +14 -3
  24. data/app/forms/curation_concerns/upload_set_form.rb +43 -0
  25. data/app/helpers/curation_concerns/ability_helper.rb +12 -18
  26. data/app/helpers/curation_concerns/file_set_helper.rb +1 -1
  27. data/app/helpers/curation_concerns/main_app_helpers.rb +1 -0
  28. data/app/helpers/curation_concerns/permissions_helper.rb +20 -0
  29. data/app/helpers/curation_concerns/url_helper.rb +3 -11
  30. data/app/inputs/multi_value_with_help_input.rb +8 -0
  31. data/app/inputs/select_with_help_input.rb +3 -0
  32. data/app/inputs/select_with_modal_help_input.rb +36 -0
  33. data/app/inputs/with_help_icon.rb +34 -0
  34. data/app/presenters/curation_concerns/collection_presenter.rb +9 -0
  35. data/app/presenters/curation_concerns/file_set_presenter.rb +2 -1
  36. data/app/presenters/curation_concerns/presents_attributes.rb +16 -0
  37. data/app/presenters/curation_concerns/work_show_presenter.rb +3 -2
  38. data/app/renderers/curation_concerns/attribute_renderer.rb +22 -4
  39. data/app/renderers/curation_concerns/configured_microdata.rb +40 -0
  40. data/app/services/curation_concerns/parent_service.rb +1 -1
  41. data/app/views/catalog/_action_menu_partials/_default.html.erb +2 -2
  42. data/app/views/collections/_form.html.erb +8 -9
  43. data/app/views/collections/_sort_and_per_page.html.erb +25 -23
  44. data/app/views/collections/show.html.erb +1 -1
  45. data/app/views/curation_concerns/base/_attributes.html.erb +1 -1
  46. data/app/views/curation_concerns/base/_form.html.erb +6 -7
  47. data/app/views/curation_concerns/base/_form_permission.html.erb +3 -0
  48. data/app/views/curation_concerns/base/_multiple_upload.html.erb +3 -0
  49. data/app/views/curation_concerns/base/_show_actions.html.erb +2 -2
  50. data/app/views/curation_concerns/base/_versioning.html.erb +1 -1
  51. data/app/views/curation_concerns/base/_visibility.html.erb +17 -0
  52. data/app/views/curation_concerns/base/show.html.erb +1 -1
  53. data/app/views/curation_concerns/classify_concerns/new.html.erb +1 -1
  54. data/app/views/curation_concerns/file_sets/_actions.html.erb +2 -2
  55. data/app/views/curation_concerns/file_sets/_form.html.erb +1 -1
  56. data/app/views/curation_concerns/file_sets/_rights_modal.html.erb +41 -0
  57. data/app/views/curation_concerns/file_sets/media_display/_default.html.erb +4 -1
  58. data/app/views/curation_concerns/file_sets/media_display/_image.html.erb +9 -8
  59. data/app/views/curation_concerns/file_sets/media_display/_office_document.html.erb +9 -7
  60. data/app/views/curation_concerns/file_sets/media_display/_pdf.html.erb +7 -5
  61. data/app/views/curation_concerns/file_sets/show.html.erb +2 -2
  62. data/app/views/curation_concerns/file_sets/upload/_alerts.html.erb +3 -3
  63. data/app/views/curation_concerns/file_sets/upload/_form.html.erb +1 -1
  64. data/app/views/curation_concerns/file_sets/upload/_script_templates.html.erb +1 -1
  65. data/app/views/curation_concerns/permissions/confirm.html.erb +1 -1
  66. data/app/views/curation_concerns/single_use_links_viewer/show.html.erb +1 -1
  67. data/app/views/embargoes/edit.html.erb +4 -4
  68. data/app/views/layouts/curation_concerns.html.erb +1 -1
  69. data/app/views/leases/edit.html.erb +3 -3
  70. data/app/views/shared/_add_works.html.erb +6 -3
  71. data/app/views/upload_sets/_base_metadata.html.erb +12 -0
  72. data/app/views/upload_sets/_metadata.html.erb +3 -13
  73. data/app/views/upload_sets/edit.html.erb +1 -1
  74. data/config/locales/curation_concerns.en.yml +46 -0
  75. data/curation_concerns.gemspec +5 -4
  76. data/lib/curation_concerns/engine.rb +5 -0
  77. data/lib/curation_concerns/form_builder.rb +16 -0
  78. data/lib/curation_concerns/rails/routes.rb +7 -5
  79. data/lib/generators/curation_concerns/install_generator.rb +1 -1
  80. data/lib/generators/curation_concerns/work/work_generator.rb +1 -1
  81. data/spec/actors/curation_concerns/file_set_actor_spec.rb +26 -16
  82. data/spec/controllers/curation_concerns/file_sets_controller_json_spec.rb +14 -4
  83. data/spec/controllers/curation_concerns/file_sets_controller_spec.rb +3 -3
  84. data/spec/controllers/curation_concerns/generic_works_controller_json_spec.rb +4 -4
  85. data/spec/controllers/curation_concerns/generic_works_controller_spec.rb +21 -0
  86. data/spec/controllers/curation_concerns/single_use_links_controller_spec.rb +2 -2
  87. data/spec/controllers/curation_concerns/single_use_links_viewer_controller_spec.rb +1 -1
  88. data/spec/controllers/upload_sets_controller_spec.rb +20 -27
  89. data/spec/factories/file_sets.rb +1 -0
  90. data/spec/factories/generic_works.rb +1 -0
  91. data/spec/factories/users.rb +0 -12
  92. data/spec/features/collection_spec.rb +1 -3
  93. data/spec/forms/collection_edit_form_spec.rb +16 -1
  94. data/spec/forms/upload_set_form_spec.rb +55 -0
  95. data/spec/forms/work_form_spec.rb +68 -3
  96. data/spec/helpers/curation_concerns/ability_helper_spec.rb +45 -0
  97. data/spec/helpers/curation_concerns/permissions_helper_spec.rb +12 -0
  98. data/spec/helpers/url_helper_spec.rb +0 -3
  99. data/spec/indexers/collection_indexer_spec.rb +5 -0
  100. data/spec/indexers/{file_set_indexing_service_spec.rb → file_set_indexer_spec.rb} +40 -2
  101. data/spec/indexers/{generic_work_indexing_service_spec.rb → work_indexer_spec.rb} +1 -1
  102. data/spec/inputs/multi_value_with_help_input_spec.rb +32 -0
  103. data/spec/inputs/select_with_help_input_spec.rb +43 -0
  104. data/spec/inputs/select_with_modal_help_input_spec.rb +21 -0
  105. data/spec/jobs/import_url_job_spec.rb +33 -1
  106. data/spec/jobs/ingest_file_job_spec.rb +29 -16
  107. data/spec/jobs/upload_set_update_job_spec.rb +24 -11
  108. data/spec/lib/curation_concerns/messages_spec.rb +2 -2
  109. data/spec/lib/curation_concerns/name_spec.rb +20 -0
  110. data/spec/lib/curation_concerns/null_logger_spec.rb +10 -0
  111. data/spec/models/curation_concerns/collection_behavior_spec.rb +41 -10
  112. data/spec/models/curation_concerns/work_behavior_spec.rb +1 -13
  113. data/spec/models/file_set_spec.rb +19 -4
  114. data/spec/models/generic_work_spec.rb +7 -2
  115. data/spec/models/quick_classification_query_spec.rb +35 -0
  116. data/spec/models/upload_set_spec.rb +5 -7
  117. data/spec/presenters/curation_concerns/collection_presenter_spec.rb +20 -0
  118. data/spec/presenters/curation_concerns/file_set_presenter_spec.rb +10 -3
  119. data/spec/presenters/curation_concerns/work_show_presenter_spec.rb +13 -1
  120. data/spec/renderers/curation_concerns/attribute_renderer_spec.rb +41 -8
  121. data/spec/routing/curation_concerns/routes_spec.rb +2 -2
  122. data/spec/routing/route_spec.rb +1 -1
  123. data/spec/services/file_set_audit_service_spec.rb +46 -4
  124. data/spec/spec_helper.rb +5 -7
  125. data/spec/views/collections/_sort_and_per_page.html.erb_spec.rb +32 -0
  126. data/spec/views/curation_concerns/base/_attributes.html.erb_spec.rb +8 -1
  127. data/spec/views/curation_concerns/base/show.html.erb_spec.rb +36 -2
  128. data/spec/views/curation_concerns/file_sets/_file_set.html.erb_spec.rb +3 -2
  129. data/spec/views/curation_concerns/file_sets/show.html.erb_spec.rb +56 -0
  130. data/spec/views/curation_concerns/single_use_links_viewer/show.html.erb_spec.rb +19 -0
  131. data/spec/views/shared/_add_content.html.erb_spec.rb +3 -3
  132. data/spec/views/single_use_links/new_download.html.erb_spec.rb +1 -1
  133. data/spec/views/upload_sets/_metadata.html.erb_spec.rb +28 -0
  134. metadata +80 -50
  135. data/app/assets/stylesheets/curation_concerns/help_requests.scss +0 -3
  136. data/app/controllers/concerns/curation_concerns/without_namespace.rb +0 -16
  137. data/app/controllers/registrations_controller.rb +0 -19
  138. data/app/controllers/sessions_controller.rb +0 -4
  139. data/app/views/curation_concerns/file_sets/_multiple_upload.html.erb +0 -3
  140. data/spec/fixtures/Example.ogg +0 -0
  141. data/spec/fixtures/charter.docx +0 -0
  142. data/spec/fixtures/countdown.avi +0 -0
  143. data/spec/fixtures/curation_concerns_generic_stub.txt +0 -1
  144. data/spec/fixtures/empty_file.txt +0 -0
  145. data/spec/fixtures/files/image.png +0 -0
  146. data/spec/fixtures/image.jp2 +0 -0
  147. data/spec/fixtures/image.jpg +0 -0
  148. data/spec/fixtures/piano_note.wav +0 -0
  149. data/spec/fixtures/sample_mpeg4.mp4 +0 -0
  150. data/spec/fixtures/small_file.txt +0 -1
  151. data/spec/fixtures/spoken-text.m4a +0 -0
  152. data/spec/fixtures/test.pdf +0 -0
  153. data/spec/fixtures/test4.pdf +0 -0
  154. data/spec/fixtures/test5.mp3 +0 -0
  155. data/spec/fixtures/world.png +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a6a05c11364b9cc72ba7f97963f9a3c32252d17
4
- data.tar.gz: 61ad7ed57f29b8661b302527f9c2634eef19a52d
3
+ metadata.gz: 489a8d74c2cc2694cae734316ac806ccb728ba35
4
+ data.tar.gz: dc4312a11afa53f206991fe1777d9f5ea416e08c
5
5
  SHA512:
6
- metadata.gz: f79451b81f8820ee146a1438136f9bb3c526be5ed1e2d50922278c841d77cfb4ec276e6a7442c7c24b8172fa368775b2a500ea9752f4a3ac63a63922a29a101e
7
- data.tar.gz: d5cba535b0c5d4279402f0b3709b0cc333c691e49713c150ac5110077c95b5e28074c58e01f9c3f10fe2f39cd2d73fa5ecae9c27d1f9de55954746bbbdc8f682
6
+ metadata.gz: bbadbe42f6cb6b7153ad122fdd935ca085f7bfc9bae9fca0d5a0fc6390926063b8ac6f34693187a052c6ae56e7f9184942b6fa332a0e584e40e2eddd9de585a0
7
+ data.tar.gz: 8b029a62c46cdf9748048bed0b3d5f6eb1945f346ea165555253257f8dc87b9a4cb7235d00cbe0087667a53220f352ca1a473acf661152ca0676fb39f3f15568
data/.gitignore CHANGED
@@ -10,4 +10,5 @@ jetty
10
10
  solr_conf/
11
11
  spec/internal
12
12
  .internal_test_app
13
+ .byebug_history
13
14
  spec/mock_upload_directory
data/.travis.yml CHANGED
@@ -6,3 +6,11 @@ rvm:
6
6
  env:
7
7
  global:
8
8
  - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
9
+ notifications:
10
+ irc:
11
+ channels:
12
+ - "irc.freenode.org#projecthydra"
13
+ template:
14
+ - "%{repository}//%{branch}@%{commit} by %{author}: %{message} - %{build_url}"
15
+ before_script:
16
+ - jdk_switcher use oraclejdk8
data/Gemfile CHANGED
@@ -1,10 +1,9 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem 'hydra-works', github: 'projecthydra-labs/hydra-works'
3
4
  # Specify your gem's dependencies in curation_concerns.gemspec
4
5
  gemspec
5
6
 
6
- gem 'slop', '~> 3.6.0' # This just helps us generate a valid Gemfile.lock when Rails 4.2 is installed (which requires byebug which has a dependency on slop)
7
-
8
7
  gem 'curation_concerns-models', path: './curation_concerns-models'
9
8
 
10
9
  group :development, :test do
data/README.md CHANGED
@@ -23,7 +23,7 @@ And then execute:
23
23
 
24
24
  $ bundle install
25
25
 
26
- Then:
26
+ Then run the install generator. You will be prompted if you want to overwrite the default `app/controllers/catalog_controller.rb`, to which you should type `Y` (yes). If you don't want to be prompted on overwrite, you may run the generator with the `-f` (force) option.
27
27
 
28
28
  $ rails generate curation_concerns:install
29
29
  $ rake db:migrate
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ Dir.glob('tasks/*.rake').each { |r| import r }
10
10
  # This makes it possible to run curation_concerns:jetty:config from here.
11
11
  import 'curation_concerns-models/lib/tasks/curation_concerns-models_tasks.rake'
12
12
 
13
- Jettywrapper.hydra_jetty_version = 'v8.3.1'
13
+ Jettywrapper.hydra_jetty_version = 'v8.6.0'
14
14
 
15
15
  desc 'Run style checker'
16
16
  RuboCop::RakeTask.new(:rubocop) do |task|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
@@ -10,5 +10,7 @@ Blacklight.onLoad(function() {
10
10
  $('abbr').tooltip();
11
11
 
12
12
  $("[data-toggle='dropdown']").dropdown();
13
+ $('a[data-toggle="popover"]').popover({ html: true })
14
+ .click(function() { return false });
13
15
 
14
16
  });
@@ -60,6 +60,7 @@ var filestoupload =0;
60
60
  $($('#fileupload .files .cancel button')[data.context[0].rowIndex]).click();
61
61
  }
62
62
  var total_sz = parseInt($('#total_upload_size').val()) + data.files[0].size;
63
+ $('#total_upload_size').val( total_sz );
63
64
  // is file size too big
64
65
  if (data.files[0].size > max_file_size) {
65
66
  $($('#fileupload .files .cancel button')[data.context[0].rowIndex]).click();
@@ -69,7 +70,9 @@ var filestoupload =0;
69
70
  // cumulative upload file size is too big
70
71
  else if( total_sz > max_total_file_size) {
71
72
  if (first_file_after_max == '') first_file_after_max = data.files[0].name;
72
- $($('#fileupload .files .cancel button')[data.context[0].rowIndex]).click();
73
+ $($('#fileupload .files .cancel button')[data.context[0].rowIndex]).click();
74
+ // artificially bump size to max so small files don't sneak in out of order.
75
+ $('#total_upload_size').val( max_total_file_size );
73
76
  $("#errmsg").html("All files selected from " + first_file_after_max + " and after will not be uploaded because your total upload is too big. You may not upload more than " + max_total_file_size_str + " in one upload.");
74
77
  $("#errmsg").fadeIn('slow');
75
78
  }
@@ -79,9 +82,6 @@ var filestoupload =0;
79
82
  $("#errmsg").html("All files selected from " + first_file_after_max + " and after will not be uploaded because your total number of files is too big. You may not upload more than " + max_file_count + " files in one upload.");
80
83
  $("#errmsg").fadeIn('slow');
81
84
  }
82
- else {
83
- $('#total_upload_size').val( parseInt($('#total_upload_size').val()) + data.files[0].size );
84
- }
85
85
  }
86
86
 
87
87
 
@@ -10,4 +10,5 @@
10
10
  @import 'modules/site_search';
11
11
  @import 'modules/pagination';
12
12
  @import 'modules/embargoes';
13
+ @import 'modules/icons';
13
14
 
@@ -142,3 +142,6 @@ legend + .form-group {
142
142
  }
143
143
  }
144
144
 
145
+ .img-responsive, figure {
146
+ display: inline-block;
147
+ }
@@ -0,0 +1,11 @@
1
+ .large-icon {
2
+ font-size: 1.5em;
3
+ }
4
+
5
+ .help-icon {
6
+ @extend .glyphicon;
7
+ @extend .glyphicon-question-sign;
8
+ @extend .large-icon;
9
+ top: 5px;
10
+ }
11
+
@@ -4,22 +4,11 @@ module CurationConcerns
4
4
 
5
5
  def self.generate_response_body(response_type: :success, message: nil, options: {})
6
6
  json_body = default_responses[response_type].merge(options)
7
- json_body[:description] = message if message && !messages_to_override.include?(message)
7
+ json_body[:description] = message if message
8
8
  json_body
9
9
  end
10
10
 
11
- # Messages that should be overridden by defaults from locale file
12
- # ie. exception messages from CanCan::AccessDenied
13
-
14
- def self.messages_to_override
15
- [
16
- 'You are not authorized to access this page.',
17
- 'ActiveFedora::ObjectNotFoundError'
18
- ]
19
- end
20
-
21
11
  # Default (json) responses for various response types
22
-
23
12
  def self.default_responses
24
13
  {
25
14
  success: {
@@ -7,31 +7,45 @@ module CurationConcerns
7
7
  included do
8
8
  helper CurationConcerns::MainAppHelpers
9
9
 
10
- rescue_from ActiveFedora::ObjectNotFoundError do |exception|
10
+ rescue_from ActiveFedora::ObjectNotFoundError do |_exception|
11
11
  respond_to do |wants|
12
- wants.html { render file: "#{Rails.root}/public/404", format: :html, status: :not_found, layout: false }
13
- wants.json { render_json_response(response_type: :not_found, message: exception.message) }
12
+ wants.json { render_json_response(response_type: :not_found) }
13
+ # default to HTML response, even for other non-HTML formats we don't
14
+ # neccesarily know about, seems to be consistent with what Rails4 does
15
+ # by default with uncaught ActiveRecord::RecordNotFound in production
16
+ wants.any do
17
+ # use standard, possibly locally overridden, 404.html file. Even for
18
+ # possibly non-html formats, this is consistent with what Rails does
19
+ # on raising an ActiveRecord::RecordNotFound. Rails.root IS needed
20
+ # for it to work under testing, without worrying about CWD.
21
+ render file: "#{Rails.root}/public/404.html", status: :not_found, layout: false
22
+ end
14
23
  end
15
24
  end
16
25
  end
17
26
 
27
+ # Called by Hydra::Controller::ControllerBehavior when CanCan::AccessDenied is caught
28
+ # @param [CanCan::AccessDenied] exception error to handle
18
29
  def deny_access(exception)
30
+ # For the JSON message, we don't want to display the default CanCan messages,
31
+ # just custom Hydra messages such as "This item is under embargo.", etc.
32
+ json_message = exception.message if exception.is_a? Hydra::AccessDenied
19
33
  if current_user && current_user.persisted?
20
34
  respond_to do |wants|
21
35
  wants.html do
22
- if [:show, :edit, :update, :destroy].include? exception.action
36
+ if [:show, :edit, :create, :update, :destroy].include? exception.action
23
37
  render 'curation_concerns/base/unauthorized', status: :unauthorized
24
38
  else
25
39
  redirect_to main_app.root_url, alert: exception.message
26
40
  end
27
41
  end
28
- wants.json { render_json_response(response_type: :forbidden, message: exception.message) }
42
+ wants.json { render_json_response(response_type: :forbidden, message: json_message) }
29
43
  end
30
44
  else
31
45
  session['user_return_to'.freeze] = request.url
32
46
  respond_to do |wants|
33
47
  wants.html { redirect_to main_app.new_user_session_path, alert: exception.message }
34
- wants.json { render_json_response(response_type: :unauthorized, message: exception.message) }
48
+ wants.json { render_json_response(response_type: :unauthorized, message: json_message) }
35
49
  end
36
50
  end
37
51
  end
@@ -26,6 +26,7 @@ module CurationConcerns::CurationConcernController
26
26
  end
27
27
 
28
28
  def new
29
+ build_form
29
30
  end
30
31
 
31
32
  def create
@@ -46,12 +47,7 @@ module CurationConcerns::CurationConcernController
46
47
  # or the user doesn't have access to it.
47
48
  def show
48
49
  respond_to do |wants|
49
- wants.html do
50
- _, document_list = search_results(params, CatalogController.search_params_logic + [:find_one])
51
- curation_concern = document_list.first
52
- raise CanCan::AccessDenied.new(nil, :show) unless curation_concern
53
- @presenter = show_presenter.new(curation_concern, current_ability)
54
- end
50
+ wants.html { presenter }
55
51
  wants.json do
56
52
  # load and authorize @curation_concern manually because it's skipped for html
57
53
  # This has to use #find instead of #load_instance_from_solr because
@@ -60,23 +56,12 @@ module CurationConcerns::CurationConcernController
60
56
  authorize! :show, @curation_concern
61
57
  render :show, status: :ok
62
58
  end
59
+ additional_response_formats(wants)
63
60
  end
64
61
  end
65
62
 
66
- # Gives the class of the show presenter. Override this if you want
67
- # to use a different presenter.
68
- def show_presenter
69
- CurationConcerns::WorkShowPresenter
70
- end
71
-
72
- # Gives the class of the form. Override this if you want
73
- # to use a different form.
74
- def form_class
75
- CurationConcerns.const_get("#{self.class.curation_concern_type}Form")
76
- end
77
-
78
63
  def edit
79
- @form = form_class.new(curation_concern, current_ability)
64
+ build_form
80
65
  end
81
66
 
82
67
  def update
@@ -86,7 +71,7 @@ module CurationConcerns::CurationConcernController
86
71
  setup_form
87
72
  respond_to do |wants|
88
73
  wants.html do
89
- @form = form_class.new(curation_concern, current_ability)
74
+ build_form
90
75
  render 'edit', status: :unprocessable_entity
91
76
  end
92
77
  wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors: curation_concern.errors }) }
@@ -104,10 +89,30 @@ module CurationConcerns::CurationConcernController
104
89
 
105
90
  protected
106
91
 
92
+ # Gives the class of the show presenter. Override this if you want
93
+ # to use a different presenter.
94
+ def show_presenter
95
+ CurationConcerns::WorkShowPresenter
96
+ end
97
+
98
+ # Gives the class of the form. Override this if you want
99
+ # to use a different form.
100
+ def form_class
101
+ CurationConcerns.const_get("#{self.class.curation_concern_type.to_s.demodulize}Form")
102
+ end
103
+
104
+ def build_form
105
+ @form = form_class.new(curation_concern, current_ability)
106
+ end
107
+
107
108
  def actor
108
109
  @actor ||= CurationConcerns::CurationConcern.actor(curation_concern, current_user, attributes_for_actor)
109
110
  end
110
111
 
112
+ def presenter
113
+ @presenter ||= show_presenter.new(curation_concern_from_search_results, current_ability)
114
+ end
115
+
111
116
  # Override setup_form in concrete controllers to get the form ready for display
112
117
  def setup_form
113
118
  return unless curation_concern.respond_to?(:contributor) && curation_concern.contributor.blank?
@@ -120,8 +125,8 @@ module CurationConcerns::CurationConcernController
120
125
 
121
126
  def after_create_response
122
127
  respond_to do |wants|
123
- wants.html { redirect_to [main_app, :curation_concerns, curation_concern] }
124
- wants.json { render :show, status: :created, location: polymorphic_path([main_app, :curation_concerns, curation_concern]) }
128
+ wants.html { redirect_to [main_app, curation_concern] }
129
+ wants.json { render :show, status: :created, location: polymorphic_path([main_app, curation_concern]) }
125
130
  end
126
131
  end
127
132
 
@@ -131,8 +136,8 @@ module CurationConcerns::CurationConcernController
131
136
  redirect_to main_app.confirm_curation_concerns_permission_path(curation_concern)
132
137
  else
133
138
  respond_to do |wants|
134
- wants.html { redirect_to [main_app, :curation_concerns, curation_concern] }
135
- wants.json { render :show, status: :ok, location: polymorphic_path([main_app, :curation_concerns, curation_concern]) }
139
+ wants.html { redirect_to [main_app, curation_concern] }
140
+ wants.json { render :show, status: :ok, location: polymorphic_path([main_app, curation_concern]) }
136
141
  end
137
142
  end
138
143
  end
@@ -150,6 +155,20 @@ module CurationConcerns::CurationConcernController
150
155
  end
151
156
 
152
157
  def hash_key_for_curation_concern
153
- self.class.curation_concern_type.name.underscore.to_sym
158
+ self.class.curation_concern_type.model_name.param_key
159
+ end
160
+
161
+ # Override this method to add additional response
162
+ # formats to your local app
163
+ def additional_response_formats(_)
164
+ # nop
165
+ end
166
+
167
+ private
168
+
169
+ def curation_concern_from_search_results
170
+ _, document_list = search_results(params, CatalogController.search_params_logic + [:find_one])
171
+ raise CanCan::AccessDenied.new(nil, :show) if document_list.empty?
172
+ document_list.first
154
173
  end
155
174
  end
@@ -23,7 +23,7 @@ module CurationConcerns
23
23
 
24
24
  # routed to /files/:id/edit
25
25
  def edit
26
- @groups = current_user.groups
26
+ initialize_edit_form
27
27
  end
28
28
 
29
29
  # routed to /files (POST)
@@ -45,7 +45,7 @@ module CurationConcerns
45
45
  end
46
46
  rescue RSolr::Error::Http => error
47
47
  logger.error "FileSetController::create rescued #{error.class}\n\t#{error}\n #{error.backtrace.join("\n")}\n\n"
48
- render_json_response(response_type: :internal_error, options: { message: 'Error occurred while creating generic file.' })
48
+ render_json_response(response_type: :internal_error, options: { message: 'Error occurred while creating a FileSet.' })
49
49
  ensure
50
50
  # remove the tempfile (only if it is a temp file)
51
51
  file.tempfile.delete if file.respond_to?(:tempfile)
@@ -54,19 +54,13 @@ module CurationConcerns
54
54
  # routed to /files/:id
55
55
  def show
56
56
  respond_to do |wants|
57
- wants.html do
58
- _, document_list = search_results(params, [:add_access_controls_to_solr_params, :find_one, :only_file_sets])
59
- curation_concern = document_list.first
60
- raise CanCan::AccessDenied unless curation_concern
61
- @presenter = show_presenter.new(curation_concern, current_ability)
62
- end
57
+ wants.html { presenter }
63
58
  wants.json do
64
59
  # load and authorize @curation_concern manually because it's skipped for html
65
60
  @file_set = curation_concern_type.load_instance_from_solr(params[:id]) unless curation_concern
66
61
  authorize! :show, @file_set
67
62
  render :show, status: :ok
68
63
  end
69
- additional_response_formats(wants)
70
64
  end
71
65
  end
72
66
 
@@ -76,9 +70,16 @@ module CurationConcerns
76
70
  CurationConcerns::FileSetPresenter
77
71
  end
78
72
 
73
+ # Gives the class of the form. Override this if you want
74
+ # to use a different form.
75
+ def form_class
76
+ CurationConcerns::Forms::FileSetEditForm
77
+ end
78
+
79
79
  def destroy
80
+ parent = @file_set.in_works.first
80
81
  actor.destroy
81
- redirect_to [main_app, :curation_concerns, @file_set.in_works.first], notice: 'The file has been deleted.'
82
+ redirect_to [main_app, parent], notice: 'The file has been deleted.'
82
83
  end
83
84
 
84
85
  # routed to /files/:id (PUT)
@@ -95,14 +96,16 @@ module CurationConcerns
95
96
  if success
96
97
  respond_to do |wants|
97
98
  wants.html do
98
- redirect_to [main_app, :curation_concerns, @file_set], notice:
99
- "The file #{view_context.link_to(@file_set, [main_app, :curation_concerns, @file_set])} has been updated."
99
+ redirect_to [main_app, @file_set], notice: "The file #{view_context.link_to(@file_set, [main_app, @file_set])} has been updated."
100
100
  end
101
- wants.json { render :show, status: :ok, location: polymorphic_path([main_app, :curation_concerns, @file_set]) }
101
+ wants.json { render :show, status: :ok, location: polymorphic_path([main_app, @file_set]) }
102
102
  end
103
103
  else
104
104
  respond_to do |wants|
105
- wants.html { render 'edit', status: :unprocessable_entity }
105
+ wants.html do
106
+ initialize_edit_form
107
+ render 'edit', status: :unprocessable_entity
108
+ end
106
109
  wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors: @file_set.errors }) }
107
110
  end
108
111
  end
@@ -118,16 +121,23 @@ module CurationConcerns
118
121
 
119
122
  # this is provided so that implementing application can override this behavior and map params to different attributes
120
123
  def update_metadata
121
- file_attributes = CurationConcerns::Forms::FileSetEditForm.model_attributes(attributes)
124
+ file_attributes = form_class.model_attributes(attributes)
122
125
  actor.update_metadata(file_attributes)
123
126
  end
124
127
 
125
128
  protected
126
129
 
127
- # Override this method to add additional response
128
- # formats to your local app
129
- def additional_response_formats(_)
130
- # nop
130
+ def presenter
131
+ @presenter ||= begin
132
+ _, document_list = search_results(params, [:add_access_controls_to_solr_params, :find_one, :only_file_sets])
133
+ curation_concern = document_list.first
134
+ raise CanCan::AccessDenied unless curation_concern
135
+ show_presenter.new(curation_concern, current_ability)
136
+ end
137
+ end
138
+
139
+ def initialize_edit_form
140
+ @groups = current_user.groups
131
141
  end
132
142
 
133
143
  def file_set_params
@@ -169,19 +179,18 @@ module CurationConcerns
169
179
 
170
180
  def process_file(file)
171
181
  update_metadata_from_upload_screen
172
- parent = ActiveFedora::Base.find(parent_id)
173
- actor.create_metadata(params[:upload_set_id], parent, params[:file_set])
182
+ actor.create_metadata(find_parent_by_id, params[:file_set])
174
183
  if actor.create_content(file)
175
184
  respond_to do |format|
176
185
  format.html do
177
186
  if request.xhr?
178
187
  render 'jq_upload', formats: 'json', content_type: 'text/html'
179
188
  else
180
- redirect_to [main_app, :curation_concerns, @file_set.in_works.first]
189
+ redirect_to [main_app, @file_set.in_works.first]
181
190
  end
182
191
  end
183
192
  format.json do
184
- render 'jq_upload', status: :created, location: polymorphic_path([main_app, :curation_concerns, curation_concern])
193
+ render 'jq_upload', status: :created, location: polymorphic_path([main_app, curation_concern])
185
194
  end
186
195
  end
187
196
  else
@@ -3,7 +3,6 @@ module CurationConcerns::ParentContainer
3
3
 
4
4
  included do
5
5
  helper_method :parent
6
- # before_filter :authorize_edit_parent_rights!, except: [:show] # Not sure we actually want this enforced any more (was originally in worthwhile), especially since GenericFiles and GenericWorks (which are PCDM::Objects)can belong to multiple parents
7
6
  end
8
7
 
9
8
  # TODO: this is slow, refactor to return a Presenter (fetch from solr)
@@ -36,14 +35,4 @@ module CurationConcerns::ParentContainer
36
35
  def new_or_create?
37
36
  %w(create new).include? action_name
38
37
  end
39
-
40
- def namespaced_parent_id
41
- # Sufia::Noid.namespaceize(params[:parent_id])
42
- end
43
-
44
- # restricts edit access so that you can only edit a record if you can also edit its parent.
45
-
46
- def authorize_edit_parent_rights!
47
- authorize! :edit, parent_id
48
- end
49
38
  end
@@ -26,7 +26,7 @@ module CurationConcerns
26
26
  end
27
27
 
28
28
  def new_show
29
- @su = SingleUseLink.create itemId: params[:id], path: polymorphic_path([main_app, :curation_concerns, asset])
29
+ @su = SingleUseLink.create itemId: params[:id], path: polymorphic_path([main_app, asset])
30
30
  @link = curation_concerns.show_single_use_link_path(@su.downloadKey)
31
31
 
32
32
  respond_to do |format|
@@ -29,7 +29,7 @@ module CurationConcerns
29
29
  # Authorize using SingleUseLinksViewerController::Ability
30
30
  authorize! :read, curation_concern
31
31
 
32
- raise not_found_exception unless single_use_link.path == polymorphic_path([main_app, :curation_concerns, curation_concern])
32
+ raise not_found_exception unless single_use_link.path == polymorphic_path([main_app, curation_concern])
33
33
 
34
34
  # show the file
35
35
  @presenter = presenter_class.new(curation_concern, current_ability)
@@ -41,6 +41,12 @@ module CurationConcerns
41
41
 
42
42
  protected
43
43
 
44
+ def content_options
45
+ super.tap do |options|
46
+ options[:disposition] = 'attachment' if action_name == 'download'
47
+ end
48
+ end
49
+
44
50
  # This is called in a before filter. It causes @asset to be set.
45
51
  def authorize_download!
46
52
  authorize! :read, asset
@@ -8,31 +8,43 @@ module CurationConcerns
8
8
  with_themed_layout '1_column'
9
9
 
10
10
  class_attribute :edit_form_class
11
- self.edit_form_class = CurationConcerns::Forms::FileSetEditForm
11
+ self.edit_form_class = CurationConcerns::UploadSetForm
12
12
  end
13
13
 
14
14
  def edit
15
+ # TODO: redlock this line so that two processes don't attempt to create at the same time.
15
16
  @upload_set = UploadSet.find_or_create(params[:id])
16
17
  @form = edit_form
17
18
  end
18
19
 
19
20
  def update
20
21
  authenticate_user!
21
- @upload_set = UploadSet.find_or_create(params[:id])
22
+ @upload_set = UploadSet.find(params[:id])
22
23
  @upload_set.status = ["processing"]
23
24
  @upload_set.save
24
- file_attributes = edit_form_class.model_attributes(params[:file_set])
25
- UploadSetUpdateJob.perform_later(current_user.user_key, params[:id], params[:title], file_attributes, params[:visibility])
25
+ create_update_job
26
26
  flash[:notice] = 'Your files are being processed by ' + t('curation_concerns.product_name') + ' in the background. The metadata and access controls you specified are being applied. Files will be marked <span class="label label-danger" title="Private">Private</span> until this process is complete (shouldn\'t take too long, hang in there!). You may need to refresh your dashboard to see these updates.'
27
27
 
28
- redirect_to main_app.curation_concerns_generic_works_path
28
+ redirect_after_update
29
29
  end
30
30
 
31
31
  protected
32
32
 
33
+ # Override this method if you want to go elsewhere
34
+ def redirect_after_update
35
+ redirect_to main_app.curation_concerns_generic_works_path
36
+ end
37
+
33
38
  def edit_form
34
- file_set = ::FileSet.new(creator: [current_user.user_key], title: @upload_set.file_sets.map(&:label))
35
- edit_form_class.new(file_set)
39
+ edit_form_class.new(@upload_set, current_ability)
40
+ end
41
+
42
+ def create_update_job
43
+ UploadSetUpdateJob.perform_later(current_user.user_key,
44
+ params[:id],
45
+ params[:title],
46
+ edit_form_class.model_attributes(params[:upload_set]),
47
+ params[:visibility])
36
48
  end
37
49
  end
38
50
  end
@@ -9,7 +9,7 @@ class CurationConcerns::PermissionsController < ApplicationController
9
9
  def copy
10
10
  VisibilityCopyJob.perform_later(curation_concern.id)
11
11
  flash_message = 'Updating file permissions. This may take a few minutes. You may want to refresh your browser or return to this record later to see the updated file permissions.'
12
- redirect_to polymorphic_path([main_app, :curation_concerns, curation_concern]), notice: flash_message
12
+ redirect_to [main_app, curation_concern], notice: flash_message
13
13
  end
14
14
 
15
15
  def curation_concern
@@ -3,8 +3,12 @@ module CurationConcerns
3
3
  class CollectionEditForm
4
4
  include HydraEditor::Form
5
5
  self.model_class = ::Collection
6
- self.terms = [:resource_type, :title, :creator, :contributor, :description, :tag, :rights,
7
- :publisher, :date_created, :subject, :language, :identifier, :based_near,
6
+
7
+ delegate :human_readable_type, :member_ids, to: :model
8
+
9
+ self.terms = [:resource_type, :title, :creator, :contributor, :description,
10
+ :tag, :rights, :publisher, :date_created, :subject, :language,
11
+ :representative_id, :thumbnail_id, :identifier, :based_near,
8
12
  :related_url, :visibility]
9
13
 
10
14
  # Test to see if the given field is required
@@ -4,9 +4,14 @@ module CurationConcerns
4
4
  include HydraEditor::Form
5
5
  attr_accessor :current_ability
6
6
 
7
+ delegate :human_readable_type, :open_access?, :authenticated_only_access?,
8
+ :open_access_with_embargo_release_date?, :private_access?,
9
+ :embargo_release_date, :lease_expiration_date, :member_ids, to: :model
10
+
7
11
  self.terms = [:title, :creator, :contributor, :description,
8
- :subject, :publisher, :source, :language,
9
- :representative_id, :thumbnail_id, :rights, :files,
12
+ :tag, :rights, :publisher, :date_created, :subject, :language,
13
+ :identifier, :based_near, :related_url,
14
+ :representative_id, :thumbnail_id, :files,
10
15
  :visibility_during_embargo, :embargo_release_date, :visibility_after_embargo,
11
16
  :visibility_during_lease, :lease_expiration_date, :visibility_after_lease,
12
17
  :visibility]
@@ -14,8 +19,14 @@ module CurationConcerns
14
19
  # @param [ActiveFedora::Base,#member_ids] model
15
20
  # @param [Ability] current_ability
16
21
  def initialize(model, current_ability)
17
- @model = model
18
22
  @current_ability = current_ability
23
+ super(model)
24
+ end
25
+
26
+ # The value for embargo_relase_date and lease_expiration_date should not
27
+ # be initialized to empty string
28
+ def initialize_field(key)
29
+ super unless [:embargo_release_date, :lease_expiration_date].include?(key)
19
30
  end
20
31
 
21
32
  # The possible values for the representative_id dropdown