curation_concerns 0.12.0.pre1 → 0.12.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (212) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +24 -16
  3. data/Gemfile +0 -4
  4. data/README.md +14 -0
  5. data/RELEASING.md +2 -2
  6. data/Rakefile +2 -0
  7. data/app/actors/concerns/curation_concerns/manages_embargoes_actor.rb +28 -0
  8. data/app/actors/curation_concerns/abstract_actor.rb +28 -0
  9. data/app/actors/curation_concerns/add_to_collection_actor.rb +38 -0
  10. data/app/actors/curation_concerns/apply_order_actor.rb +24 -0
  11. data/app/actors/curation_concerns/assign_identifier_actor.rb +7 -0
  12. data/app/actors/curation_concerns/assign_representative_actor.rb +18 -0
  13. data/app/actors/curation_concerns/attach_files_actor.rb +39 -0
  14. data/app/actors/curation_concerns/base_actor.rb +71 -0
  15. data/app/actors/curation_concerns/embargo_actor.rb +19 -0
  16. data/app/actors/curation_concerns/file_actor.rb +79 -0
  17. data/app/actors/curation_concerns/file_set_actor.rb +146 -0
  18. data/app/actors/curation_concerns/interpret_visibility_actor.rb +123 -0
  19. data/app/actors/curation_concerns/lease_actor.rb +19 -0
  20. data/app/actors/curation_concerns/root_actor.rb +17 -0
  21. data/app/actors/curation_concerns/work_actor_behavior.rb +8 -0
  22. data/app/assets/javascripts/curation_concerns/batch_select.js +42 -0
  23. data/app/assets/javascripts/curation_concerns/collections.js +13 -0
  24. data/app/assets/javascripts/curation_concerns/curation_concerns.js +2 -0
  25. data/app/assets/stylesheets/curation_concerns/_curation_concerns.scss +0 -3
  26. data/app/assets/stylesheets/curation_concerns/_modules.scss +1 -1
  27. data/app/assets/stylesheets/curation_concerns/_positioning.scss +3 -6
  28. data/app/assets/stylesheets/curation_concerns/_theme.scss +0 -39
  29. data/app/assets/stylesheets/curation_concerns/_typography.scss +0 -69
  30. data/app/assets/stylesheets/curation_concerns/modules/classify_work.scss +0 -2
  31. data/app/assets/stylesheets/curation_concerns/modules/collections.scss +4 -0
  32. data/app/assets/stylesheets/curation_concerns/modules/forms.scss +0 -4
  33. data/app/assets/stylesheets/curation_concerns/modules/site_actions.scss +34 -29
  34. data/app/assets/stylesheets/curation_concerns/modules/site_search.scss +0 -46
  35. data/app/assets/stylesheets/curation_concerns.scss +4 -0
  36. data/app/controllers/concerns/curation_concerns/collections_controller_behavior.rb +166 -21
  37. data/app/controllers/concerns/curation_concerns/embargoes_controller_behavior.rb +1 -1
  38. data/app/controllers/concerns/curation_concerns/leases_controller_behavior.rb +1 -1
  39. data/app/controllers/concerns/curation_concerns/selects_collections.rb +65 -0
  40. data/app/forms/curation_concerns/forms/collection_edit_form.rb +0 -29
  41. data/app/forms/curation_concerns/forms/work_form.rb +2 -1
  42. data/app/helpers/batch_select_helper.rb +23 -0
  43. data/app/helpers/collections_helper.rb +4 -0
  44. data/app/helpers/curation_concerns/collections_helper.rb +2 -2
  45. data/app/helpers/curation_concerns/collections_helper_behavior.rb +56 -0
  46. data/app/helpers/curation_concerns/render_constraints_helper.rb +14 -35
  47. data/app/helpers/curation_concerns/title_helper.rb +4 -0
  48. data/app/indexers/curation_concerns/collection_indexer.rb +16 -0
  49. data/app/indexers/curation_concerns/file_set_indexer.rb +46 -0
  50. data/app/indexers/curation_concerns/work_indexer.rb +15 -0
  51. data/app/jobs/audit_job.rb +49 -0
  52. data/app/jobs/characterize_job.rb +11 -0
  53. data/app/jobs/create_derivatives_job.rb +21 -0
  54. data/app/jobs/import_url_job.rb +48 -0
  55. data/app/jobs/ingest_file_job.rb +30 -0
  56. data/app/jobs/ingest_local_file_job.rb +20 -0
  57. data/app/jobs/resolrize_job.rb +7 -0
  58. data/app/models/checksum_audit_log.rb +20 -0
  59. data/app/models/collection.rb +6 -0
  60. data/app/models/concerns/curation_concerns/ability.rb +49 -0
  61. data/app/models/concerns/curation_concerns/basic_metadata.rb +64 -0
  62. data/app/models/concerns/curation_concerns/collection.rb +16 -0
  63. data/app/models/concerns/curation_concerns/collection_behavior.rb +62 -0
  64. data/app/models/concerns/curation_concerns/file_set/belongs_to_works.rb +47 -0
  65. data/app/models/concerns/curation_concerns/file_set/derivatives.rb +65 -0
  66. data/app/models/concerns/curation_concerns/file_set/full_text_indexing.rb +11 -0
  67. data/app/models/concerns/curation_concerns/file_set/indexing.rb +14 -0
  68. data/app/models/concerns/curation_concerns/file_set/querying.rb +17 -0
  69. data/app/models/concerns/curation_concerns/file_set_behavior.rb +36 -0
  70. data/app/models/concerns/curation_concerns/has_representative.rb +13 -0
  71. data/app/models/concerns/curation_concerns/human_readable_type.rb +17 -0
  72. data/app/models/concerns/curation_concerns/naming.rb +17 -0
  73. data/app/models/concerns/curation_concerns/permissions/readable.rb +18 -0
  74. data/app/models/concerns/curation_concerns/permissions/writable.rb +34 -0
  75. data/app/models/concerns/curation_concerns/permissions.rb +7 -0
  76. data/app/models/concerns/curation_concerns/required_metadata.rb +30 -0
  77. data/app/models/concerns/curation_concerns/serializers.rb +13 -0
  78. data/app/models/concerns/curation_concerns/solr_document_behavior.rb +147 -0
  79. data/app/models/concerns/curation_concerns/user.rb +18 -0
  80. data/app/models/concerns/curation_concerns/with_file_sets.rb +37 -0
  81. data/app/models/concerns/curation_concerns/work_behavior.rb +45 -0
  82. data/app/models/curation_concerns/classify_concern.rb +49 -0
  83. data/app/models/curation_concerns/quick_classification_query.rb +38 -0
  84. data/app/models/single_use_link.rb +34 -0
  85. data/app/models/version_committer.rb +2 -0
  86. data/app/search_builders/curation_concerns/collection_member_search_builder.rb +1 -1
  87. data/app/search_builders/curation_concerns/collection_search_builder.rb +33 -0
  88. data/app/search_builders/curation_concerns/member_search_builder.rb +17 -0
  89. data/app/services/curation_concerns/derivative_path.rb +49 -0
  90. data/app/services/curation_concerns/file_set_audit_service.rb +105 -0
  91. data/app/services/curation_concerns/indexes_thumbnails.rb +30 -0
  92. data/app/services/curation_concerns/local_file_service.rb +10 -0
  93. data/app/services/curation_concerns/lock_manager.rb +39 -0
  94. data/app/services/curation_concerns/lockable.rb +16 -0
  95. data/app/services/curation_concerns/noid.rb +23 -0
  96. data/app/services/curation_concerns/persist_derivatives.rb +33 -0
  97. data/app/services/curation_concerns/persist_directly_contained_output_file_service.rb +26 -0
  98. data/app/services/curation_concerns/repository_audit_service.rb +7 -0
  99. data/app/services/curation_concerns/thumbnail_path_service.rb +46 -0
  100. data/app/services/curation_concerns/time_service.rb +7 -0
  101. data/app/services/curation_concerns/versioning_service.rb +26 -0
  102. data/app/validators/has_one_title_validator.rb +8 -0
  103. data/app/views/batch_select/_add_button.html.erb +3 -0
  104. data/app/views/batch_select/_check_all.html.erb +4 -0
  105. data/app/views/batch_select/_tools.html.erb +10 -0
  106. data/app/views/catalog/_action_menu_partials/_collection.html.erb +3 -3
  107. data/app/views/catalog/_action_menu_partials/_default.html.erb +1 -1
  108. data/app/views/catalog/_document_list.html.erb +1 -1
  109. data/app/views/collections/_bookmark_control.html.erb +2 -0
  110. data/app/views/collections/_button_create_collection.html.erb +2 -0
  111. data/app/views/collections/_button_for_creating_empty_collection.html.erb +1 -1
  112. data/app/views/collections/_button_for_delete_collection.html.erb +4 -0
  113. data/app/views/collections/_button_for_remove_selected_from_collection.html.erb +8 -0
  114. data/app/views/collections/_button_for_update_collection.html.erb +4 -0
  115. data/app/views/collections/_button_remove_from_collection.html.erb +4 -0
  116. data/app/views/collections/_document_header.html.erb +9 -0
  117. data/app/views/collections/_edit_actions.html.erb +1 -1
  118. data/app/views/collections/_edit_descriptions.html.erb +1 -1
  119. data/app/views/collections/_form.html.erb +2 -2
  120. data/app/views/collections/_form_for_select_destination_collection.html.erb +21 -0
  121. data/app/views/collections/_form_to_add_member.html.erb +1 -1
  122. data/app/views/collections/_index_default.html.erb +2 -0
  123. data/app/views/collections/_index_header_default.html.erb +2 -0
  124. data/app/views/collections/_media_display.html.erb +1 -1
  125. data/app/views/collections/_paginate.html.erb +1 -1
  126. data/app/views/collections/_paginate_compact.html.erb +1 -0
  127. data/app/views/collections/_results_pagination.html.erb +9 -0
  128. data/app/views/collections/_search_collection_dashboard_form.html.erb +1 -1
  129. data/app/views/collections/_search_form.html.erb +1 -1
  130. data/app/views/collections/_search_results.html.erb +23 -0
  131. data/app/views/collections/_show_actions.html.erb +1 -1
  132. data/app/views/collections/_sort_and_per_page.html.erb +1 -1
  133. data/app/views/collections/_view_type_group.html.erb +1 -1
  134. data/app/views/collections/index.html.erb +9 -0
  135. data/app/views/collections/new.html.erb +3 -0
  136. data/app/views/curation_concerns/base/_form_permission.html.erb +10 -11
  137. data/app/views/curation_concerns/base/_form_permission_embargo.html.erb +1 -1
  138. data/app/views/curation_concerns/base/_form_permission_lease.html.erb +1 -1
  139. data/app/views/curation_concerns/base/_legally_binding_text.html.erb +7 -7
  140. data/app/views/curation_concerns/base/_related_files.html.erb +1 -1
  141. data/app/views/curation_concerns/base/_visibility.html.erb +2 -2
  142. data/app/views/curation_concerns/file_sets/_actions.html.erb +1 -1
  143. data/app/views/embargoes/_list_expired_active_embargoes.html.erb +1 -1
  144. data/app/views/error/single_use_error.html.erb +1 -1
  145. data/app/views/shared/_add_content.html.erb +17 -15
  146. data/app/views/shared/_brand_bar.html.erb +19 -10
  147. data/app/views/shared/_header.html.erb +2 -6
  148. data/app/views/shared/_my_actions.html.erb +28 -27
  149. data/app/views/shared/_site_actions.html.erb +5 -1
  150. data/app/views/shared/_site_search.html.erb +3 -2
  151. data/app/views/shared/_title_bar.html.erb +7 -16
  152. data/app/views/welcome/index.html.erb +2 -2
  153. data/config/locales/curation_concerns.en.yml +25 -1
  154. data/curation_concerns.gemspec +21 -5
  155. data/lib/curation_concerns/collections/accepts_batches.rb +53 -0
  156. data/lib/curation_concerns/collections/search_service.rb +57 -0
  157. data/lib/curation_concerns/collections.rb +10 -0
  158. data/lib/curation_concerns/configuration.rb +167 -0
  159. data/lib/curation_concerns/engine.rb +22 -1
  160. data/lib/curation_concerns/messages.rb +68 -0
  161. data/lib/curation_concerns/models.rb +42 -0
  162. data/lib/curation_concerns/name.rb +20 -0
  163. data/lib/curation_concerns/null_logger.rb +10 -0
  164. data/lib/curation_concerns/rails/routes.rb +1 -3
  165. data/lib/curation_concerns/version.rb +1 -1
  166. data/lib/curation_concerns.rb +2 -0
  167. data/lib/generators/curation_concerns/abstract_migration_generator.rb +31 -0
  168. data/lib/generators/curation_concerns/clamav_generator.rb +19 -0
  169. data/lib/generators/curation_concerns/collection_generator.rb +15 -0
  170. data/lib/generators/curation_concerns/install_generator.rb +1 -2
  171. data/lib/generators/curation_concerns/models_generator.rb +62 -0
  172. data/lib/generators/curation_concerns/templates/app/models/collection.rb +6 -0
  173. data/lib/generators/curation_concerns/templates/app/models/file_set.rb +4 -0
  174. data/lib/generators/curation_concerns/templates/config/clamav.rb +1 -0
  175. data/lib/generators/curation_concerns/templates/config/curation_concerns.rb +61 -0
  176. data/lib/generators/curation_concerns/templates/config/mime_types.rb +6 -0
  177. data/lib/generators/curation_concerns/templates/config/redis.yml +9 -0
  178. data/lib/generators/curation_concerns/templates/config/redis_config.rb +29 -0
  179. data/lib/generators/curation_concerns/templates/config/resque-pool.yml +1 -0
  180. data/lib/generators/curation_concerns/templates/config/resque_config.rb +6 -0
  181. data/lib/generators/curation_concerns/templates/curation_concerns.scss +3 -2
  182. data/lib/generators/curation_concerns/templates/migrations/create_checksum_audit_logs.rb +19 -0
  183. data/lib/generators/curation_concerns/templates/migrations/create_single_use_links.rb +12 -0
  184. data/lib/generators/curation_concerns/templates/migrations/create_version_committers.rb +15 -0
  185. data/lib/tasks/migrate.rake +11 -0
  186. data/lib/tasks/resque.rake +14 -0
  187. data/lib/tasks/solr_reindex.rake +8 -0
  188. data/spec/actors/curation_concerns/file_set_actor_spec.rb +31 -0
  189. data/spec/controllers/accepts_batches_controller_spec.rb +65 -0
  190. data/spec/controllers/collections_controller_spec.rb +272 -0
  191. data/spec/controllers/curation_concerns/collections_controller_spec.rb +1 -2
  192. data/spec/controllers/selects_collections_controller_spec.rb +109 -0
  193. data/spec/features/create_work_spec.rb +1 -1
  194. data/spec/features/work_generator_spec.rb +1 -1
  195. data/spec/forms/collection_edit_form_spec.rb +2 -9
  196. data/spec/forms/work_form_spec.rb +5 -0
  197. data/spec/helpers/collections_helper_spec.rb +129 -0
  198. data/spec/helpers/curation_concerns/collections_helper_spec.rb +2 -2
  199. data/spec/helpers/render_constraints_helper_spec.rb +23 -1
  200. data/spec/lib/curation_concerns/collections/search_service_spec.rb +33 -0
  201. data/spec/models/collection_spec.rb +165 -0
  202. data/spec/tasks/rake_spec.rb +1 -1
  203. data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
  204. data/spec/views/curation_concerns/base/_form_permission.html.erb_spec.rb +4 -1
  205. data/spec/views/curation_concerns/file_sets/show.html.erb_spec.rb +1 -0
  206. data/spec/views/shared/_add_content.html.erb_spec.rb +3 -3
  207. metadata +341 -24
  208. data/VERSION +0 -1
  209. data/app/assets/stylesheets/curation_concerns/_global-variables.scss +0 -5
  210. data/app/assets/stylesheets/curation_concerns/modules/multi_value_fields.scss +0 -52
  211. data/app/views/collections/_form_required_information.html.erb +0 -11
  212. data/tasks/release.rake +0 -93
@@ -0,0 +1,146 @@
1
+ module CurationConcerns
2
+ # Actions are decoupled from controller logic so that they may be called from a controller or a background job.
3
+ class FileSetActor
4
+ include CurationConcerns::Lockable
5
+
6
+ attr_reader :file_set, :user, :attributes
7
+
8
+ def initialize(file_set, user)
9
+ @file_set = file_set
10
+ @user = user
11
+ end
12
+
13
+ # Adds the appropriate metadata, visibility and relationships to file_set
14
+ #
15
+ # *Note*: In past versions of Sufia this method did not perform a save because it is mainly used in conjunction with
16
+ # create_content, which also performs a save. However, due to the relationship between Hydra::PCDM objects,
17
+ # we have to save both the parent work and the file_set in order to record the "metadata" relationship
18
+ # between them.
19
+ # @param [ActiveFedora::Base] work the parent work that will contain the file_set.
20
+ # @param [Hash] file_set specifying the visibility, lease and/or embargo of the file set. If you don't provide at least one of visibility, embargo_release_date or lease_expiration_date, visibility will be copied from the parent.
21
+
22
+ def create_metadata(work, file_set_params = {})
23
+ file_set.apply_depositor_metadata(user)
24
+ now = CurationConcerns::TimeService.time_in_utc
25
+ file_set.date_uploaded = now
26
+ file_set.date_modified = now
27
+ file_set.creator = [user.user_key]
28
+
29
+ CurationConcern::ActorStack.new(file_set, user, [InterpretVisibilityActor]).create(file_set_params) if assign_visibility?(file_set_params)
30
+ attach_file_to_work(work, file_set, file_set_params) if work
31
+ yield(file_set) if block_given?
32
+ end
33
+
34
+ # @param [File, ActionDigest::HTTP::UploadedFile, Tempfile] file the file uploaded by the user.
35
+ # @param [String] relation ('original_file')
36
+ def create_content(file, relation = 'original_file')
37
+ # If the file set doesn't have a title or label assigned, set a default.
38
+ file_set.label ||= file.respond_to?(:original_filename) ? file.original_filename : ::File.basename(file)
39
+ file_set.title = [file_set.label] if file_set.title.blank?
40
+
41
+ # Need to save the file_set in order to get an id
42
+ return false unless file_set.save
43
+
44
+ file_actor_class.new(file_set, relation, user).ingest_file(file)
45
+ true
46
+ end
47
+
48
+ # @param [String] revision_id the revision to revert to
49
+ # @param [String] relation ('original_file')
50
+ def revert_content(revision_id, relation = 'original_file')
51
+ file_actor = file_actor_class.new(file_set, relation, user)
52
+ if file_actor.revert_to(revision_id)
53
+ CurationConcerns.config.callback.run(:after_revert_content, file_set, user, revision_id)
54
+ true
55
+ else
56
+ false
57
+ end
58
+ end
59
+
60
+ # @param [File, ActionDigest::HTTP::UploadedFile, Tempfile] file the file uploaded by the user.
61
+ # @param [String] relation ('original_file')
62
+ def update_content(file, relation = 'original_file')
63
+ file_actor_class.new(file_set, relation, user).ingest_file(file)
64
+ CurationConcerns.config.callback.run(:after_update_content, file_set, user)
65
+ true
66
+ end
67
+
68
+ def update_metadata(attributes)
69
+ stack = CurationConcern::ActorStack.new(file_set,
70
+ user,
71
+ [InterpretVisibilityActor, BaseActor])
72
+ if result = stack.update(attributes)
73
+ CurationConcerns.config.callback.run(:after_update_metadata, file_set, user)
74
+ end
75
+ result
76
+ end
77
+
78
+ def destroy
79
+ file_set.destroy
80
+ CurationConcerns.config.callback.run(:after_destroy, file_set.id, user)
81
+ end
82
+
83
+ def file_actor_class
84
+ CurationConcerns::FileActor
85
+ end
86
+
87
+ private
88
+
89
+ # Takes an optional block and executes the block if the save was successful.
90
+ # returns false if the save was unsuccessful
91
+ def save
92
+ save_tries = 0
93
+ begin
94
+ return false unless file_set.save
95
+ rescue RSolr::Error::Http => error
96
+ ActiveFedora::Base.logger.warn "CurationConcerns::FileSetActor#save Caught RSOLR error #{error.inspect}"
97
+ save_tries += 1
98
+ # fail for good if the tries is greater than 3
99
+ raise error if save_tries >= 3
100
+ sleep 0.01
101
+ retry
102
+ end
103
+ yield if block_given?
104
+ true
105
+ end
106
+
107
+ # Adds a FileSet to the work using ore:Aggregations.
108
+ # Locks to ensure that only one process is operating on
109
+ # the list at a time.
110
+ def attach_file_to_work(work, file_set, file_set_params)
111
+ acquire_lock_for(work.id) do
112
+ # Ensure we have an up-to-date copy of the members association, so
113
+ # that we append to the end of the list.
114
+ work.reload unless work.new_record?
115
+ unless assign_visibility?(file_set_params)
116
+ copy_visibility(work, file_set)
117
+ end
118
+ work.ordered_members << file_set
119
+ set_representative(work, file_set)
120
+ set_thumbnail(work, file_set)
121
+
122
+ # Save the work so the association between the work and the file_set is persisted (head_id)
123
+ work.save
124
+ end
125
+ end
126
+
127
+ def assign_visibility?(file_set_params = {})
128
+ !((file_set_params || {}).keys & %w(visibility embargo_release_date lease_expiration_date)).empty?
129
+ end
130
+
131
+ # copy visibility from source_concern to destination_concern
132
+ def copy_visibility(source_concern, destination_concern)
133
+ destination_concern.visibility = source_concern.visibility
134
+ end
135
+
136
+ def set_representative(work, file_set)
137
+ return unless work.representative_id.blank?
138
+ work.representative = file_set
139
+ end
140
+
141
+ def set_thumbnail(work, file_set)
142
+ return unless work.thumbnail_id.blank?
143
+ work.thumbnail = file_set
144
+ end
145
+ end
146
+ end
@@ -0,0 +1,123 @@
1
+ module CurationConcerns
2
+ class InterpretVisibilityActor < AbstractActor
3
+ class Intention
4
+ def initialize(attributes)
5
+ @attributes = attributes
6
+ end
7
+
8
+ # returns a copy of attributes with the necessary params removed
9
+ # If the lease or embargo is valid, or if they selected something besides lease
10
+ # or embargo, remove all the params.
11
+ def sanitize_params
12
+ if valid_lease?
13
+ @attributes.except(:visibility,
14
+ :embargo_release_date,
15
+ :visibility_during_embargo,
16
+ :visibility_after_embargo)
17
+ elsif valid_embargo?
18
+ @attributes.except(:visibility,
19
+ :lease_expiration_date,
20
+ :visibility_during_lease,
21
+ :visibility_after_lease)
22
+ elsif !wants_lease? && !wants_embargo?
23
+ @attributes.except(:lease_expiration_date,
24
+ :visibility_during_lease,
25
+ :visibility_after_lease,
26
+ :embargo_release_date,
27
+ :visibility_during_embargo,
28
+ :visibility_after_embargo)
29
+ else
30
+ @attributes
31
+ end
32
+ end
33
+
34
+ def wants_lease?
35
+ visibility == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_LEASE
36
+ end
37
+
38
+ def wants_embargo?
39
+ visibility == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_EMBARGO
40
+ end
41
+
42
+ def valid_lease?
43
+ wants_lease? && @attributes[:lease_expiration_date].present?
44
+ end
45
+
46
+ def valid_embargo?
47
+ wants_embargo? && @attributes[:embargo_release_date].present?
48
+ end
49
+
50
+ def lease_params
51
+ [:lease_expiration_date,
52
+ :visibility_during_lease,
53
+ :visibility_after_lease].map { |key| @attributes[key] }
54
+ end
55
+
56
+ def embargo_params
57
+ [:embargo_release_date,
58
+ :visibility_during_embargo,
59
+ :visibility_after_embargo].map { |key| @attributes[key] }
60
+ end
61
+
62
+ private
63
+
64
+ def visibility
65
+ @attributes[:visibility]
66
+ end
67
+ end
68
+
69
+ def create(attributes)
70
+ @intention = Intention.new(attributes)
71
+ attributes = @intention.sanitize_params
72
+ validate && apply_visibility(attributes) && next_actor.create(attributes)
73
+ end
74
+
75
+ def update(attributes)
76
+ @intention = Intention.new(attributes)
77
+ attributes = @intention.sanitize_params
78
+ validate && apply_visibility(attributes) && next_actor.update(attributes)
79
+ end
80
+
81
+ private
82
+
83
+ def validate
84
+ validate_lease && validate_embargo
85
+ end
86
+
87
+ def apply_visibility(attributes)
88
+ result = apply_lease && apply_embargo
89
+ if attributes[:visibility]
90
+ curation_concern.visibility = attributes[:visibility]
91
+ end
92
+ result
93
+ end
94
+
95
+ def validate_lease
96
+ return true unless @intention.wants_lease? && !@intention.valid_lease?
97
+ curation_concern.errors.add(:visibility, 'When setting visibility to "lease" you must also specify lease expiration date.')
98
+ false
99
+ end
100
+
101
+ def validate_embargo
102
+ return true unless @intention.wants_embargo? && !@intention.valid_embargo?
103
+ curation_concern.errors.add(:visibility, 'When setting visibility to "embargo" you must also specify embargo release date.')
104
+ false
105
+ end
106
+
107
+ # If they want a lease, we can assume it's valid
108
+ def apply_lease
109
+ return true unless @intention.wants_lease?
110
+ curation_concern.apply_lease(*@intention.lease_params)
111
+ return unless curation_concern.lease
112
+ curation_concern.lease.save # see https://github.com/projecthydra/hydra-head/issues/226
113
+ end
114
+
115
+ # If they want an embargo, we can assume it's valid
116
+ def apply_embargo
117
+ return true unless @intention.wants_embargo?
118
+ curation_concern.apply_embargo(*@intention.embargo_params)
119
+ return unless curation_concern.embargo
120
+ curation_concern.embargo.save # see https://github.com/projecthydra/hydra-head/issues/226
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,19 @@
1
+ module CurationConcerns
2
+ class LeaseActor
3
+ attr_reader :work
4
+
5
+ # @param [Hydra::Works::Work] work
6
+ def initialize(work)
7
+ @work = work
8
+ end
9
+
10
+ # Update the visibility of the work to match the correct state of the lease, then clear the lease date, etc.
11
+ # Saves the lease and the work
12
+ def destroy
13
+ work.lease_visibility! # If the lease has lapsed, update the current visibility.
14
+ work.deactivate_lease!
15
+ work.lease.save!
16
+ work.save!
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ module CurationConcerns
2
+ class RootActor
3
+ attr_reader :curation_concern, :user, :cloud_resources
4
+ def initialize(curation_concern, user, _more_actors)
5
+ @curation_concern = curation_concern
6
+ @user = user
7
+ end
8
+
9
+ def create(_)
10
+ true
11
+ end
12
+
13
+ def update(_)
14
+ true
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ module CurationConcerns::WorkActorBehavior
2
+ extend ActiveSupport::Concern
3
+ extend Deprecation
4
+
5
+ included do
6
+ Deprecation.warn(CurationConcerns::WorkActorBehavior, "CurationConcerns::WorkActorBehavior is deprecated and will be removed in CurationConcerns 1.0")
7
+ end
8
+ end
@@ -0,0 +1,42 @@
1
+ Blacklight.onLoad(function () {
2
+
3
+ // add the batch ids to any submit of a batch update
4
+ var batch_ids = null;
5
+ $('input.updates-batches').on('click', function() {
6
+ var form = $(this).closest("form");
7
+ var hash, id;
8
+
9
+ // pull the ids from the url
10
+ if (!batch_ids) {
11
+ batch_ids = [];
12
+ // pull the ids from the url
13
+ var q = document.URL.split('?')[1];
14
+ if(q != undefined){
15
+ q = q.split('&');
16
+ for(var i = 0; i < q.length; i++){
17
+ hash = q[i].split('=');
18
+ if (hash[0] == "batch_document_ids%5B%5D")
19
+ batch_ids.push(unescape(hash[1]));
20
+ }
21
+ }
22
+ }
23
+
24
+ // push the ids in the form
25
+ for(var j = 0; j < batch_ids.length; j++){
26
+ if (form.children("input[value='"+batch_ids[j]+"']").length == 0)
27
+ form.append('<input type="hidden" multiple="multiple" name="batch_document_ids[]" value="'+batch_ids[j]+'" />');
28
+ }
29
+
30
+ });
31
+ $('input.submits-batches').on('click', function() {
32
+ var form = $(this).closest("form");
33
+ $.map( $(".batch_document_selector:checked"), function(document, i) {
34
+ var id = document.id.substring("batch_document_".length);
35
+ if (form.children("input[value='"+id+"']").length == 0)
36
+ form.append('<input type="hidden" multiple="multiple" name="batch_document_ids[]" value="'+id+'" />');
37
+ });
38
+
39
+
40
+ });
41
+
42
+ });
@@ -0,0 +1,13 @@
1
+ Blacklight.onLoad(function () {
2
+
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);
9
+ form.append('<input type="hidden" value="add" name="collection[members]"></input>');
10
+
11
+ });
12
+
13
+ });
@@ -7,6 +7,8 @@
7
7
  //= require curation_concerns/file_manager/sorting
8
8
  //= require curation_concerns/file_manager/save_manager
9
9
  //= require curation_concerns/file_manager/member
10
+ //= require curation_concerns/batch_select
11
+ //= require curation_concerns/collections
10
12
 
11
13
 
12
14
  // Initialize plugins and Bootstrap dropdowns on jQuery's ready event as well as
@@ -1,7 +1,4 @@
1
- @import 'bootstrap-sprockets';
2
- @import 'bootstrap';
3
1
  @import 'blacklight/facets';
4
- @import "curation_concerns/global-variables";
5
2
  @import "curation_concerns/positioning";
6
3
  @import "curation_concerns/modules";
7
4
  @import "curation_concerns/theme";
@@ -1,6 +1,5 @@
1
1
  @import 'modules/classify_work';
2
2
  @import 'modules/forms';
3
- @import 'modules/multi_value_fields';
4
3
  @import 'modules/search_results';
5
4
  @import 'modules/site_actions';
6
5
  @import 'modules/site_search';
@@ -8,3 +7,4 @@
8
7
  @import 'modules/embargoes';
9
8
  @import 'modules/icons';
10
9
  @import 'modules/file_manager';
10
+ @import 'modules/collections';
@@ -1,9 +1,6 @@
1
- #brand-bar-wrapper, #title-bar-wrapper {
2
- margin-left:-1em;
3
- margin-right:-1em;
4
- h2, h3 {
5
- line-height: 40px;
6
- }
1
+ #brand-bar {
2
+ margin-bottom :0;
3
+ z-index: $zindex-navbar + 1;
7
4
  }
8
5
 
9
6
  .form-actions > form.button_to {
@@ -1,42 +1,3 @@
1
- #brand-bar-wrapper {
2
- background-color: $blue-dark;
3
- background-image: linear-gradient(#0d407b,#07366c 85%,#001834);
4
- border-bottom:1px solid #001834;
5
-
6
- h2 a, h3 a {
7
- color:#FFF;
8
- }
9
-
10
- .division {
11
- float:right;
12
- }
13
- }
14
-
15
- #title-bar-wrapper {
16
- background-color:$yellow;
17
- background-image: linear-gradient(#f5e59e,#dcb439 98%,#9c7012);
18
- border-top:1px solid #FFF;
19
- margin-bottom:.3em;
20
- }
21
-
22
- #site-title {
23
- h1 {
24
- text-shadow: #fff 0 0 1px;
25
- }
26
-
27
- a,
28
- a:hover,
29
- a:visited {
30
- color:$blue;
31
- }
32
- }
33
-
34
- #main {
35
- h1,h2,h3,h4,h5,h6 {
36
- color:$blue;
37
- }
38
- }
39
-
40
1
  #footer {
41
2
  color: $gray-light;
42
3
 
@@ -1,51 +1,8 @@
1
- @import 'global-variables';
2
-
3
- #banner {
4
- h1,h2,h3 {
5
- font-weight:normal;
6
- }
7
-
8
- a {
9
- text-decoration:none;
10
- }
11
- }
12
-
13
1
  #brand-bar-wrapper {
14
- font-family: $font-family-serif;
15
- letter-spacing:.2em;
16
- padding:.15em 0;
17
- text-transform:uppercase;
18
-
19
- h2, h3 {
20
- font-size:.95em;
21
- margin:0;
22
- }
23
-
24
- .division {
25
- text-align:right;
26
- }
27
-
28
- i {
29
- letter-spacing:0;
30
- padding:0 .2em;
31
- text-transform:none;
32
- }
33
- }
34
-
35
- #site-title h1 {
36
- font-family: $font-family-serif;
37
- font-size:2.4em;
38
- line-height:1.2em;
39
- text-align:center;
40
2
  }
41
3
 
42
4
  #main,
43
5
  .modal-header {
44
- h1,h2,h3,h4,h5,h6 {
45
- font-family:$headings-font-family;
46
- font-weight:normal;
47
- text-rendering: optimizeLegibility;
48
- }
49
6
  h1 {
50
7
  .human_readable_type {
51
8
  font-size:.66em;
@@ -63,24 +20,12 @@ legend {
63
20
  }
64
21
  }
65
22
 
66
- .table-heading {
67
- text-align:left;
68
-
69
- h1,h2,h3,h4,h5,h6 {
70
- padding-top:1em;
71
- }
72
- }
73
-
74
23
  .nested-field-heading {
75
24
  font-family: $font-family-sans-serif;
76
25
  font-size: 14px;
77
26
  font-weight:normal;
78
27
  }
79
28
 
80
- .redacted {
81
- font-family:'BLOKKNeue-Regular';
82
- }
83
-
84
29
  #footer {
85
30
  text-align:center;
86
31
 
@@ -89,16 +34,6 @@ legend {
89
34
  }
90
35
  }
91
36
 
92
- .centered {
93
- text-align:center;
94
- }
95
-
96
- .doi {
97
- font-size:200%;
98
- margin:1em 0;
99
- text-align:center;
100
- }
101
-
102
37
  .inline-item-actions {
103
38
  padding:0 .5em;
104
39
 
@@ -120,7 +55,3 @@ legend {
120
55
  }
121
56
  }
122
57
  }
123
-
124
- .center {
125
- text-align:center;
126
- }
@@ -1,5 +1,3 @@
1
- @import 'curation_concerns/global-variables';
2
-
3
1
  /* Aligning content types by leveraging text-align:justify
4
2
  http://www.barrelny.com/blog/text-align-justify-and-rwd/
5
3
  */
@@ -0,0 +1,4 @@
1
+ .collection-list {
2
+ max-height: 200px;
3
+ overflow-y: scroll;
4
+ }
@@ -31,10 +31,6 @@ legend small {
31
31
  color:$gray-dark;
32
32
  }
33
33
 
34
- .form-actions .btn-link {
35
- color: $blue;
36
- }
37
-
38
34
  .form-actions {
39
35
  margin-top: 1em;
40
36
  }
@@ -1,46 +1,33 @@
1
- #site-actions {
2
- .dropdown-menu {
3
- text-align:left;
4
- }
5
-
6
- // Overriding default boostrap behavior
7
- .btn-group + .btn-group {
8
- margin-left:0;
9
- }
10
- }
11
-
12
1
  .dropdown-menu {
13
- .item-with-options,
14
- .item-option {
15
- display:block;
2
+ .item-with-options {
3
+ display: block;
16
4
  padding:3px 20px;
17
- line-height:20px;
18
- color:#333;
5
+ line-height: $line-height-base;
6
+ color: $dropdown-link-color;
19
7
  }
20
8
 
21
9
  .item-options{
22
10
  margin:0;
23
11
  padding:0;
24
12
  list-style-type:none;
25
- }
26
13
 
27
- .item-option{
28
- padding-left:30px;
14
+ // Links within the dropdown menu
15
+ > li > a {
16
+ display: block;
17
+ padding: 3px 20px 3px 30px;
18
+ clear: both;
19
+ font-weight: normal;
20
+ line-height: $line-height-base;
21
+ color: $dropdown-link-color;
22
+ white-space: nowrap; // prevent links from randomly breaking onto new lines
23
+ }
29
24
  }
30
25
 
31
- /* TODO: convert this from compiled bootstrap styles to SASS mixins if available. */
32
26
  .item-option:hover,
33
27
  .item-option:focus {
34
28
  text-decoration: none;
35
- color: white;
36
- background-color: #0056b7;
37
- background-image: -moz-linear-gradient(top, #005bc1, #004fa8);
38
- background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#005bc1), to(#004fa8));
39
- background-image: -webkit-linear-gradient(top, #005bc1, #004fa8);
40
- background-image: -o-linear-gradient(top, #005bc1, #004fa8);
41
- background-image: linear-gradient(to bottom, #005bc1, #004fa8);
42
- background-repeat: repeat-x;
43
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FF005BC1', endColorstr='#FF004FA8', GradientType=0);
29
+ color: $dropdown-link-hover-color;
30
+ background-color: $dropdown-link-hover-bg;
44
31
  }
45
32
 
46
33
  .menu-heading {
@@ -51,3 +38,21 @@
51
38
  font-style:italic;
52
39
  }
53
40
  }
41
+
42
+ @media (max-width: $grid-float-breakpoint-max) {
43
+ .navbar-inverse {
44
+ .item-with-options {
45
+ color: $navbar-inverse-link-color;
46
+ }
47
+ .item-options {
48
+ > li > a {
49
+ color: $navbar-inverse-link-color;
50
+ &:hover,
51
+ &:focus {
52
+ color: $navbar-inverse-link-hover-color;
53
+ background-color: $navbar-inverse-link-hover-bg;
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }