curate 0.0.1 → 0.1.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 (250) hide show
  1. data/LICENSE +14 -0
  2. data/app/controllers/application_controller.rb +69 -0
  3. data/app/controllers/catalog_controller.rb +336 -0
  4. data/app/controllers/classify_concerns_controller.rb +29 -0
  5. data/app/controllers/common_objects_controller.rb +27 -0
  6. data/app/controllers/curation_concern/base_controller.rb +26 -0
  7. data/app/controllers/curation_concern/generic_files_controller.rb +82 -0
  8. data/app/controllers/dashboard_controller.rb +85 -0
  9. data/app/controllers/downloads_controller.rb +22 -0
  10. data/app/controllers/errors_controller.rb +19 -0
  11. data/app/controllers/help_requests_controller.rb +38 -0
  12. data/app/controllers/terms_of_service_agreements_controller.rb +44 -0
  13. data/app/controllers/welcome_controller.rb +14 -0
  14. data/app/helpers/application_helper.rb +89 -0
  15. data/app/helpers/blacklight_helper.rb +19 -0
  16. data/app/helpers/common_objects_helper.rb +5 -0
  17. data/app/inputs/multi_value_input.rb +71 -0
  18. data/app/models/access_right.rb +53 -0
  19. data/app/models/classify_concern.rb +30 -0
  20. data/app/models/contributor_agreement.rb +58 -0
  21. data/app/models/digital_object_identifier.rb +83 -0
  22. data/app/models/doi_config.rb +26 -0
  23. data/app/models/help_request.rb +34 -0
  24. data/app/models/mint_doi.rb +51 -0
  25. data/app/models/mint_purl.rb +40 -0
  26. data/app/models/object_access.rb +17 -0
  27. data/app/models/purl.rb +18 -0
  28. data/app/models/purl_config.rb +10 -0
  29. data/app/models/repo_object.rb +24 -0
  30. data/app/models/solr_document.rb +35 -0
  31. data/app/repository_datastreams/file_content_datastream.rb +36 -0
  32. data/app/repository_models/curation_concern/embargoable.rb +43 -0
  33. data/app/repository_models/curation_concern/with_access_right.rb +31 -0
  34. data/app/repository_models/generic_file.rb +36 -0
  35. data/app/services/anti_virus_scanner.rb +28 -0
  36. data/app/services/curation_concern.rb +22 -0
  37. data/app/services/curation_concern/base_actor.rb +48 -0
  38. data/app/services/curation_concern/generic_file_actor.rb +38 -0
  39. data/app/validators/future_date_validator.rb +19 -0
  40. data/app/views/_footer.html.erb +19 -0
  41. data/app/views/_ga.html.erb +6 -0
  42. data/app/views/_logo.html.erb +34 -0
  43. data/app/views/_masthead.html.erb +34 -0
  44. data/app/views/catalog/_bookmark_control.html.erb +25 -0
  45. data/app/views/catalog/_bookmark_form.html.erb +8 -0
  46. data/app/views/catalog/_citation.html.erb +11 -0
  47. data/app/views/catalog/_constraints.html.erb +6 -0
  48. data/app/views/catalog/_constraints_element.html.erb +20 -0
  49. data/app/views/catalog/_delete_partials/_default.html.erb +29 -0
  50. data/app/views/catalog/_did_you_mean.html.erb +10 -0
  51. data/app/views/catalog/_document.html.erb +19 -0
  52. data/app/views/catalog/_document_list.html.erb +2 -0
  53. data/app/views/catalog/_edit_partials/_default.html.erb +58 -0
  54. data/app/views/catalog/_edit_partials/_default_details.html.erb +13 -0
  55. data/app/views/catalog/_email_form.html.erb +11 -0
  56. data/app/views/catalog/_facet_layout.html.erb +12 -0
  57. data/app/views/catalog/_facet_limit.html.erb +19 -0
  58. data/app/views/catalog/_facet_selected.html.erb +12 -0
  59. data/app/views/catalog/_facets.html.erb +5 -0
  60. data/app/views/catalog/_folder_control.html.erb +12 -0
  61. data/app/views/catalog/_home.html.erb +2 -0
  62. data/app/views/catalog/_home_text.html.erb +10 -0
  63. data/app/views/catalog/_index_default.html.erb +11 -0
  64. data/app/views/catalog/_index_partials/_default_group.html.erb +37 -0
  65. data/app/views/catalog/_marc_view.html.erb +33 -0
  66. data/app/views/catalog/_opensearch_response_metadata.html.erb +2 -0
  67. data/app/views/catalog/_previous_next_doc.html.erb +6 -0
  68. data/app/views/catalog/_refworks_form.html.erb +7 -0
  69. data/app/views/catalog/_results_pagination.html.erb +6 -0
  70. data/app/views/catalog/_search_form.html.erb +20 -0
  71. data/app/views/catalog/_show_default.html.erb +9 -0
  72. data/app/views/catalog/_show_partials/_default.html.erb +22 -0
  73. data/app/views/catalog/_show_partials/_default_details.html.erb +15 -0
  74. data/app/views/catalog/_show_partials/_facets.html.erb +52 -0
  75. data/app/views/catalog/_show_sidebar.html.erb +1 -0
  76. data/app/views/catalog/_show_tools.html.erb +46 -0
  77. data/app/views/catalog/_sms_form.html.erb +21 -0
  78. data/app/views/catalog/_sort_and_per_page.html.erb +38 -0
  79. data/app/views/catalog/_uva_tabs.html.erb +10 -0
  80. data/app/views/catalog/about.html.erb +0 -0
  81. data/app/views/catalog/citation.html.erb +1 -0
  82. data/app/views/catalog/email.erb +1 -0
  83. data/app/views/catalog/endnote.endnote.erb +1 -0
  84. data/app/views/catalog/index.atom.builder +109 -0
  85. data/app/views/catalog/index.html.erb +55 -0
  86. data/app/views/catalog/index.rss.builder +19 -0
  87. data/app/views/catalog/librarian_view.html.erb +3 -0
  88. data/app/views/catalog/opensearch.json.erb +0 -0
  89. data/app/views/catalog/opensearch.xml.builder +10 -0
  90. data/app/views/catalog/send_email_record.erb +0 -0
  91. data/app/views/catalog/show.endnote.erb +1 -0
  92. data/app/views/catalog/show.html.erb +40 -0
  93. data/app/views/catalog/show.refworks.erb +1 -0
  94. data/app/views/catalog/sms.erb +1 -0
  95. data/app/views/classify_concerns/new.html.erb +24 -0
  96. data/app/views/common_objects/_generic_file.html.erb +0 -0
  97. data/app/views/common_objects/_senior_thesis.html.erb +2 -0
  98. data/app/views/common_objects/show.html.erb +11 -0
  99. data/app/views/common_objects/show_stub_information.html.erb +13 -0
  100. data/app/views/curation_concern/_content_license.html.erb +16 -0
  101. data/app/views/curation_concern/_contributor_agreement.html.erb +27 -0
  102. data/app/views/curation_concern/_doi.html.erb +43 -0
  103. data/app/views/curation_concern/_media_display.html.erb +1 -0
  104. data/app/views/curation_concern/_permission.html.erb +39 -0
  105. data/app/views/curation_concern/_related_files.html.erb +46 -0
  106. data/app/views/curation_concern/generic_files/_attributes.html.erb +63 -0
  107. data/app/views/curation_concern/generic_files/_form.html.erb +57 -0
  108. data/app/views/curation_concern/generic_files/edit.html.erb +5 -0
  109. data/app/views/curation_concern/generic_files/new.html.erb +5 -0
  110. data/app/views/curation_concern/generic_files/show.html.erb +12 -0
  111. data/app/views/curation_concern/senior_theses/_attributes.html.erb +13 -0
  112. data/app/views/curation_concern/senior_theses/_form.html.erb +88 -0
  113. data/app/views/curation_concern/senior_theses/edit.html.erb +15 -0
  114. data/app/views/curation_concern/senior_theses/new.html.erb +14 -0
  115. data/app/views/curation_concern/senior_theses/show.html.erb +18 -0
  116. data/app/views/dashboard/_constraints.html.erb +22 -0
  117. data/app/views/dashboard/_did_you_mean.html.erb +26 -0
  118. data/app/views/dashboard/_document_list.html.erb +20 -0
  119. data/app/views/dashboard/_facet_layout.html.erb +27 -0
  120. data/app/views/dashboard/_facet_limit.html.erb +35 -0
  121. data/app/views/dashboard/_facet_pagination.html.erb +25 -0
  122. data/app/views/dashboard/_facet_selected.html.erb +28 -0
  123. data/app/views/dashboard/_facets.html.erb +22 -0
  124. data/app/views/dashboard/_index_partials/_default_group.html.erb +37 -0
  125. data/app/views/dashboard/_index_partials/_list_files.html.erb +66 -0
  126. data/app/views/dashboard/_index_partials/_thumbnail_display.html.erb +0 -0
  127. data/app/views/dashboard/_results_pagination.html.erb +22 -0
  128. data/app/views/dashboard/_search_form.html.erb +36 -0
  129. data/app/views/dashboard/_show_partials/_default.html.erb +38 -0
  130. data/app/views/dashboard/_show_partials/_default_details.html.erb +31 -0
  131. data/app/views/dashboard/_show_partials/_facets.html.erb +103 -0
  132. data/app/views/dashboard/_sort_and_per_page.html.erb +18 -0
  133. data/app/views/dashboard/facet.html.erb +38 -0
  134. data/app/views/dashboard/get_related_file.html.erb +4 -0
  135. data/app/views/dashboard/index.html.erb +60 -0
  136. data/app/views/errors/401.html.erb +5 -0
  137. data/app/views/errors/404.html.erb +16 -0
  138. data/app/views/errors/500.html.erb +10 -0
  139. data/app/views/help_requests/new.html.erb +60 -0
  140. data/app/views/layouts/application.html.erb +14 -0
  141. data/app/views/layouts/boilerplate.html.erb +28 -0
  142. data/app/views/layouts/common_objects.html.erb +45 -0
  143. data/app/views/layouts/curate_nd.html.erb +55 -0
  144. data/app/views/layouts/curate_nd/1_column.html.erb +22 -0
  145. data/app/views/layouts/curate_nd/2_column.html.erb +26 -0
  146. data/app/views/layouts/curate_nd/catalog.html.erb +22 -0
  147. data/app/views/layouts/curate_nd/dashboard.html.erb +22 -0
  148. data/app/views/layouts/hydra-head.html.erb +95 -0
  149. data/app/views/shared/_action_bar.html.erb +30 -0
  150. data/app/views/shared/_flash_message.html.erb +9 -0
  151. data/app/views/shared/_site_search.html.erb +18 -0
  152. data/app/views/terms_of_service_agreements/new.html.erb +136 -0
  153. data/app/views/welcome/index.html.erb +21 -0
  154. data/app/workers/characterize_job.rb +4 -0
  155. data/app/workers/doi_worker.rb +16 -0
  156. data/config/routes.rb +35 -0
  157. data/lib/curate.rb +6 -0
  158. data/lib/curate/engine.rb +46 -0
  159. data/lib/curate/version.rb +1 -1
  160. data/spec/abilities/generic_file_abilities_spec.rb +55 -0
  161. data/spec/controllers/application_controller_spec.rb +38 -0
  162. data/spec/controllers/classify_concerns_controller_spec.rb +36 -0
  163. data/spec/controllers/common_objects_controller_spec.rb +112 -0
  164. data/spec/controllers/curation_concern/base_controller_spec.rb +14 -0
  165. data/spec/controllers/curation_concern/generic_files_controller_spec.rb +156 -0
  166. data/spec/controllers/dashboard_controller_spec.rb +85 -0
  167. data/spec/controllers/downloads_controller_spec.rb +42 -0
  168. data/spec/controllers/help_requests_controller_spec.rb +42 -0
  169. data/spec/controllers/terms_of_service_agreements_controller_spec.rb +30 -0
  170. data/spec/controllers/welcome_controller_spec.rb +10 -0
  171. data/spec/dummy/app/models/solr_document.rb +4 -0
  172. data/spec/dummy/app/models/user.rb +13 -0
  173. data/spec/dummy/config/application.rb +8 -1
  174. data/spec/dummy/config/database.yml +21 -22
  175. data/spec/dummy/config/doi.yml +11 -0
  176. data/spec/dummy/config/fedora.yml +20 -0
  177. data/spec/dummy/config/initializers/devise.rb +232 -0
  178. data/spec/dummy/config/initializers/hydra_config.rb +41 -0
  179. data/spec/dummy/config/initializers/mailboxer.rb +17 -0
  180. data/spec/dummy/config/initializers/redis_config.rb +45 -0
  181. data/spec/dummy/config/initializers/sufia.rb +66 -0
  182. data/spec/dummy/config/purl.yml +15 -0
  183. data/spec/dummy/config/redis.yml +6 -0
  184. data/spec/dummy/config/role_map_ci.yml +15 -0
  185. data/spec/dummy/config/role_map_cucumber.yml +10 -0
  186. data/spec/dummy/config/role_map_development.yml +12 -0
  187. data/spec/dummy/config/role_map_pre_production.yml +2 -0
  188. data/spec/dummy/config/role_map_production.yml +2 -0
  189. data/spec/dummy/config/role_map_test.yml +15 -0
  190. data/spec/dummy/config/routes.rb +4 -55
  191. data/spec/dummy/config/solr.yml +17 -0
  192. data/spec/dummy/db/migrate/20130130142162_create_purl.rb +55 -0
  193. data/spec/dummy/db/migrate/20130312135359_create_help_requests.rb +22 -0
  194. data/spec/dummy/db/migrate/20130408165008_create_users.rb +11 -0
  195. data/spec/dummy/db/migrate/20130408165009_acts_as_follower_migration.rb +31 -0
  196. data/spec/dummy/db/migrate/20130408165010_add_social_to_users.rb +27 -0
  197. data/spec/dummy/db/migrate/20130408165011_create_single_use_links.rb +12 -0
  198. data/spec/dummy/db/migrate/20130408165012_add_ldap_attrs_to_user.rb +41 -0
  199. data/spec/dummy/db/migrate/20130408165013_add_avatars_to_users.rb +23 -0
  200. data/spec/dummy/db/migrate/20130408165014_create_checksum_audit_logs.rb +34 -0
  201. data/spec/dummy/db/migrate/20130408165015_create_version_committers.rb +29 -0
  202. data/spec/dummy/db/migrate/20130408165016_add_groups_to_users.rb +25 -0
  203. data/spec/dummy/db/migrate/20130408165017_create_local_authorities.rb +64 -0
  204. data/spec/dummy/db/migrate/20130408165018_create_trophies.rb +10 -0
  205. data/spec/dummy/db/migrate/20130408165022_create_mailboxer.mailboxer_engine.rb +62 -0
  206. data/spec/dummy/db/migrate/20130408165023_add_notified_object.mailboxer_engine.rb +18 -0
  207. data/spec/dummy/db/migrate/20130408165024_add_notification_code.mailboxer_engine.rb +14 -0
  208. data/spec/dummy/db/migrate/20130408165025_add_attachments.mailboxer_engine.rb +10 -0
  209. data/spec/dummy/db/migrate/20130408165026_rename_receipts_read.mailboxer_engine.rb +10 -0
  210. data/spec/dummy/db/schema.rb +197 -0
  211. data/spec/dummy/db/test.sqlite3 +0 -0
  212. data/spec/dummy/fedora_conf/conf/development/fedora.fcfg +953 -0
  213. data/spec/dummy/fedora_conf/conf/test/fedora.fcfg +953 -0
  214. data/spec/dummy/log/development.log +1791 -0
  215. data/spec/dummy/log/test.log +176333 -0
  216. data/spec/dummy/solr_conf/conf/schema.xml +692 -0
  217. data/spec/dummy/solr_conf/conf/solrconfig.xml +299 -0
  218. data/spec/dummy/solr_conf/solr.xml +35 -0
  219. data/spec/factories/create_curation_concern.rb +11 -0
  220. data/spec/factories/create_generic_file.rb +36 -0
  221. data/spec/factories/help_requests.rb +10 -0
  222. data/spec/factories/mock_curation_concerns.rb +4 -0
  223. data/spec/factories/users.rb +8 -0
  224. data/spec/helpers/application_helper_spec.rb +139 -0
  225. data/spec/helpers/common_objects_helper_spec.rb +9 -0
  226. data/spec/models/access_right_spec.rb +47 -0
  227. data/spec/models/classify_concern_spec.rb +30 -0
  228. data/spec/models/contributor_agreement_spec.rb +45 -0
  229. data/spec/models/digital_object_identifier_spec.rb +50 -0
  230. data/spec/models/help_request_spec.rb +5 -0
  231. data/spec/models/mint_doi_spec.rb +79 -0
  232. data/spec/models/mint_purl_spec.rb +38 -0
  233. data/spec/models/object_access_spec.rb +24 -0
  234. data/spec/models/purl_spec.rb +22 -0
  235. data/spec/models/repo_object_spec.rb +39 -0
  236. data/spec/repository_models/curation_concern/embargoable_spec.rb +69 -0
  237. data/spec/repository_models/generic_file_spec.rb +38 -0
  238. data/spec/services/anti_virus_scanner_spec.rb +26 -0
  239. data/spec/services/curation_concern/base_actor_spec.rb +28 -0
  240. data/spec/services/curation_concern/generic_file_actor_spec.rb +75 -0
  241. data/spec/services/curation_concern_spec.rb +34 -0
  242. data/spec/spec_helper.rb +54 -1
  243. data/spec/support/environment_override.rb +17 -0
  244. data/spec/support/matchers/raise_rescue_response_type_matcher.rb +42 -0
  245. data/spec/support/mock_curation_concern.rb +61 -0
  246. data/spec/support/shared/shared_examples_is_embargoable.rb +9 -0
  247. data/spec/support/shared/shared_examples_with_access_rights.rb +33 -0
  248. data/spec/workers/characterize_job_spec.rb +26 -0
  249. metadata +686 -10
  250. data/MIT-LICENSE +0 -20
@@ -0,0 +1,27 @@
1
+ require File.expand_path('../../helpers/common_objects_helper', __FILE__)
2
+ class CommonObjectsController < ApplicationController
3
+ layout 'common_objects'
4
+
5
+ respond_to(:html)
6
+ include Sufia::Noid # for normalize_identifier method
7
+ prepend_before_filter :normalize_identifier
8
+ def curation_concern
9
+ @curation_concern ||= ActiveFedora::Base.find(params[:id], cast: true)
10
+ end
11
+ before_filter :curation_concern
12
+ helper_method :curation_concern
13
+ helper CommonObjectsHelper
14
+
15
+ before_filter :enforce_show_permissions, only: [:show]
16
+ rescue_from Hydra::AccessDenied do |exception|
17
+ redirect_to common_object_stub_information_path(curation_concern)
18
+ end
19
+
20
+ def show
21
+ respond_with(curation_concern)
22
+ end
23
+
24
+ def show_stub_information
25
+ respond_with(curation_concern)
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ module CurationConcern
2
+ class BaseController < ApplicationController
3
+ layout 'curate_nd'
4
+ include Sufia::Noid # for normalize_identifier method
5
+
6
+ before_filter :authenticate_user!, :except => [:show]
7
+ before_filter :agreed_to_terms_of_service!
8
+ prepend_before_filter :normalize_identifier, except: [:index, :new, :create]
9
+ before_filter :curation_concern, except: [:index]
10
+ load_and_authorize_resource :curation_concern, except: [:index, :new, :create], class: "ActiveFedora::Base"
11
+
12
+ attr_reader :curation_concern
13
+ helper_method :curation_concern
14
+
15
+ def contributor_agreement
16
+ @contributor_agreement ||= ContributorAgreement.new(curation_concern, current_user, params)
17
+ end
18
+ helper_method :contributor_agreement
19
+
20
+ def save_and_add_related_files_submit_value(override_name = action_name)
21
+ verb_name = ['create', 'new'].include?(override_name) ? 'Create' : 'Update'
22
+ "#{verb_name} and Add Related Files..."
23
+ end
24
+ helper_method :save_and_add_related_files_submit_value
25
+ end
26
+ end
@@ -0,0 +1,82 @@
1
+ class CurationConcern::GenericFilesController < CurationConcern::BaseController
2
+ respond_to(:html)
3
+
4
+ before_filter :parent
5
+ def parent
6
+ @parent ||=
7
+ if params[:id]
8
+ curation_concern.batch
9
+ else
10
+ ActiveFedora::Base.find(namespaced_parent_id,cast: true)
11
+ end
12
+ end
13
+ helper_method :parent
14
+
15
+ def namespaced_parent_id
16
+ Sufia::Noid.namespaceize(params[:parent_id])
17
+ end
18
+ protected :namespaced_parent_id
19
+
20
+ before_filter :authorize_edit_parent_rights!, except: [:show]
21
+ def authorize_edit_parent_rights!
22
+ authorize! :edit, parent
23
+ end
24
+ protected :authorize_edit_parent_rights!
25
+
26
+ before_filter :curation_concern
27
+ load_and_authorize_resource :curation_concern, class: "ActiveFedora::Base", except: [:new, :create]
28
+
29
+ def curation_concern
30
+ @curation_concern ||=
31
+ if params[:id]
32
+ GenericFile.find(params[:id])
33
+ else
34
+ GenericFile.new(params[:generic_file])
35
+ end
36
+ end
37
+
38
+ def new
39
+ respond_with(curation_concern)
40
+ end
41
+
42
+ def create
43
+ curation_concern.batch = parent
44
+ actor.create!
45
+ respond_with([:curation_concern, parent])
46
+ rescue ActiveFedora::RecordInvalid
47
+ respond_with([:curation_concern, curation_concern]) { |wants|
48
+ wants.html { render 'new', status: :unprocessable_entity }
49
+ }
50
+ end
51
+
52
+
53
+ def show
54
+ respond_with(curation_concern)
55
+ end
56
+
57
+ def edit
58
+ respond_with(curation_concern)
59
+ end
60
+
61
+ def update
62
+ actor.update!
63
+ respond_with([:curation_concern, curation_concern])
64
+ rescue ActiveFedora::RecordInvalid
65
+ respond_with([:curation_concern, curation_concern]) { |wants|
66
+ wants.html { render 'edit', status: :unprocessable_entity }
67
+ }
68
+ end
69
+
70
+ def destroy
71
+ parent = curation_concern.batch
72
+ title = curation_concern.to_s
73
+ curation_concern.destroy
74
+ flash[:notice] = "Deleted #{title}"
75
+ respond_with([:curation_concern, parent])
76
+ end
77
+
78
+ include Morphine
79
+ register :actor do
80
+ CurationConcern.actor(curation_concern, current_user, params[:generic_file])
81
+ end
82
+ end
@@ -0,0 +1,85 @@
1
+ require 'blacklight/catalog'
2
+ require File.expand_path("../catalog_controller", __FILE__)
3
+ class DashboardController < ApplicationController
4
+ include Hydra::BatchEditBehavior
5
+ include Blacklight::Catalog
6
+ include Blacklight::Configurable # comply with BL 3.7
7
+
8
+ # This is needed as of BL 3.7; This must come before mixing in
9
+ # BlacklightAdvancedSearch::Controller
10
+ self.copy_blacklight_config_from(CatalogController)
11
+
12
+ include Hydra::Controller::ControllerBehavior
13
+ include ActionView::Helpers::DateHelper
14
+ include BlacklightAdvancedSearch::ParseBasicQ
15
+ include BlacklightAdvancedSearch::Controller
16
+
17
+ layout 'curate_nd/dashboard'
18
+
19
+ before_filter :authenticate_user!
20
+ before_filter :agreed_to_terms_of_service!
21
+ before_filter :enforce_show_permissions, :only=>:show
22
+ before_filter :enforce_viewing_context_for_show_requests, :only=>:show
23
+
24
+ # This applies appropriate access controls to all solr queries (the internal method of this is overidden bellow to only include edit files)
25
+ DashboardController.solr_search_params_logic += [:add_access_controls_to_solr_params]
26
+ # This filters out objects that you want to exclude from search results, like FileAssets
27
+ DashboardController.solr_search_params_logic += [:exclude_unwanted_models]
28
+
29
+ def index
30
+ extra_head_content << view_context.auto_discovery_link_tag(:rss, url_for(params.merge(:format => 'rss')), :title => "RSS for results")
31
+ extra_head_content << view_context.auto_discovery_link_tag(:atom, url_for(params.merge(:format => 'atom')), :title => "Atom for results")
32
+ (@response, @document_list) = get_search_results
33
+ @user = current_user
34
+ @events = @user.events(100)
35
+ @last_event_timestamp = @user.events.first[:timestamp].to_i || 0 rescue 0
36
+ @filters = params[:f] || []
37
+
38
+ # adding a key to the session so that the history will be saved so that batch_edits select all will work
39
+ search_session[:dashboard] = true
40
+ respond_to do |format|
41
+ format.html { save_current_search_params }
42
+ format.rss { render :layout => false }
43
+ format.atom { render :layout => false }
44
+ end
45
+
46
+ # set up some parameters for allowing the batch controls to show appropiately
47
+ @max_batch_size = 80
48
+ count_on_page = @document_list.count {|doc| batch.index(doc.id)}
49
+ @disable_select_all = @document_list.count > @max_batch_size
50
+ batch_size = batch.uniq.size
51
+ @result_set_size = @response.response["numFound"]
52
+ @empty_batch = batch.empty?
53
+ @all_checked = (count_on_page == @document_list.count)
54
+ @entire_result_set_selected = @response.response["numFound"] == batch_size
55
+ @batch_size_on_other_page = batch_size - count_on_page
56
+ @batch_part_on_other_page = (@batch_size_on_other_page) > 0
57
+ end
58
+
59
+ def get_related_file
60
+ @user = current_user
61
+ #Need to make sure if params get in ways of searching (like page,per_page,q,f). If that happens then have to remove from params and put back in
62
+ extra_controller_params = {}
63
+ extra_controller_params.merge!(:fq=>"")
64
+ @response, @document_list = get_solr_response_for_field_values("is_part_of_s",["info:fedora/#{params[:id]}"],extra_controller_params)
65
+ end
66
+
67
+ private
68
+
69
+ def show_site_search?
70
+ false
71
+ end
72
+
73
+ protected
74
+ # show only files with edit permissions in lib/hydra/access_controls_enforcement.rb apply_gated_discovery
75
+ def discovery_permissions
76
+ ["edit"]
77
+ end
78
+
79
+ def exclude_unwanted_models(solr_parameters, user_parameters)
80
+ super
81
+ solr_parameters[:fq] ||= []
82
+ solr_parameters[:fq] << "-has_model_s:\"info:fedora/afmodel:GenericFile\""
83
+ return solr_parameters
84
+ end
85
+ end
@@ -0,0 +1,22 @@
1
+ require 'sufia/noid'
2
+
3
+ class DownloadsController < ApplicationController
4
+ include Sufia::Noid # for normalize_identifier method
5
+
6
+ def generic_file
7
+ @generic_file ||= GenericFile.find(params[:id])
8
+ end
9
+ before_filter :generic_file
10
+ prepend_before_filter :normalize_identifier, except: [:index, :new, :create]
11
+ load_and_authorize_resource :generic_file, class: "GenericFile"
12
+
13
+ def show
14
+ send_data(
15
+ generic_file.content.content,
16
+ type: generic_file.content.mimeType,
17
+ filename: generic_file.filename,
18
+ disposition: 'inline'
19
+ )
20
+ end
21
+
22
+ end
@@ -0,0 +1,19 @@
1
+ class ErrorsController < ApplicationController
2
+ layout 'curate_nd'
3
+
4
+ def show
5
+ render_response_for_error(exception_wrapper)
6
+ end
7
+
8
+ def exception
9
+ @exception ||= env['action_dispatch.exception']
10
+ end
11
+ protected :exception
12
+
13
+ def exception_wrapper
14
+ @exception_wrapper ||= ActionDispatch::ExceptionWrapper.new(env, exception)
15
+ end
16
+ helper_method :exception_wrapper
17
+ protected :exception_wrapper
18
+
19
+ end
@@ -0,0 +1,38 @@
1
+ class HelpRequestsController < ApplicationController
2
+ SUCCESS_NOTICE = "Thank you for your input!"
3
+ layout 'curate_nd'
4
+ before_filter :authenticate_user!
5
+ before_filter :agreed_to_terms_of_service!
6
+
7
+ respond_to(:html)
8
+ def help_request
9
+ @help_request ||= build_help_request
10
+ end
11
+ helper_method :help_request
12
+
13
+ def new
14
+ respond_with(help_request)
15
+ end
16
+
17
+ def create
18
+ help_request.save!
19
+ respond_with(help_request) do |wants|
20
+ wants.html { redirect_to dashboard_index_path, notice: SUCCESS_NOTICE}
21
+ end
22
+ rescue ActiveRecord::RecordInvalid
23
+ respond_with(help_request)
24
+ end
25
+
26
+ private
27
+
28
+ def build_help_request
29
+ help_request = HelpRequest.new(params[:help_request])
30
+ help_request.user_agent ||= user_agent_from_request
31
+ help_request.release_version = Rails.configuration.build_identifier
32
+ help_request
33
+ end
34
+
35
+ def user_agent_from_request
36
+ request.headers['HTTP_USER_AGENT']
37
+ end
38
+ end
@@ -0,0 +1,44 @@
1
+ class TermsOfServiceAgreementsController < ApplicationController
2
+ before_filter :authenticate_user!
3
+ respond_to(:html)
4
+
5
+ layout 'curate_nd/1_column'
6
+ def new
7
+ end
8
+
9
+ def create
10
+ if user_just_agreed_to_tos?
11
+ current_user.agree_to_terms_of_service!
12
+ redirect_to new_classify_concern_path
13
+ else
14
+ flash.now[:notice] = "To proceed, you must agree to the Terms of Service."
15
+ render 'new'
16
+ end
17
+ end
18
+ def user_just_agreed_to_tos?
19
+ params[:commit] == i_agree_text
20
+ end
21
+ protected :user_just_agreed_to_tos?
22
+
23
+ I_AGREE_TEXT = "I Agree"
24
+ I_DO_NOT_AGREE_TEXT = "I Do Not Agree"
25
+ def i_agree_text
26
+ I_AGREE_TEXT
27
+ end
28
+ helper_method :i_agree_text
29
+
30
+ def i_do_not_agree_text
31
+ I_DO_NOT_AGREE_TEXT
32
+ end
33
+ helper_method :i_do_not_agree_text
34
+
35
+ private
36
+
37
+ def show_action_bar?
38
+ false
39
+ end
40
+
41
+ def show_site_search?
42
+ false
43
+ end
44
+ end
@@ -0,0 +1,14 @@
1
+ class WelcomeController < ApplicationController
2
+ layout 'curate_nd/2_column'
3
+
4
+ respond_to :html
5
+ def index
6
+ respond_with
7
+ end
8
+
9
+ private
10
+
11
+ def show_action_bar?
12
+ false
13
+ end
14
+ end
@@ -0,0 +1,89 @@
1
+ require 'active_support'
2
+
3
+ module ApplicationHelper
4
+ # This is included to hopefully catch most of the sufia method calls that are
5
+ # vestigal for the Sufia engine being included in the Gemfile but unmounted.
6
+ def sufia
7
+ self
8
+ end
9
+
10
+ def construct_page_title(*elements)
11
+ (elements.flatten.compact + [application_name]).join(" // ")
12
+ end
13
+
14
+ def curation_concern_page_title(curation_concern)
15
+ if curation_concern.persisted?
16
+ construct_page_title(curation_concern.title, "#{curation_concern.human_readable_type} [#{curation_concern.to_param}]")
17
+ else
18
+ construct_page_title("New #{curation_concern.human_readable_type}")
19
+ end
20
+ end
21
+
22
+ def default_page_title
23
+ text = controller_name.singularize.titleize
24
+ if action_name
25
+ text = "#{action_name.titleize} " + text
26
+ end
27
+ construct_page_title(text)
28
+ end
29
+
30
+ def curation_concern_attribute_to_html(curation_concern, method_name, label)
31
+ markup = ""
32
+ subject = curation_concern.send(method_name)
33
+ return markup unless subject.present?
34
+ markup << %(<dt>#{label}</dt>\n)
35
+ [subject].flatten.compact.each do |value|
36
+ markup << %(<dd class="attribute #{method_name}">#{h(value)}</dd>\n)
37
+ end
38
+ markup.html_safe
39
+ end
40
+
41
+ def classify_for_display(curation_concern)
42
+ curation_concern.human_readable_type.downcase
43
+ end
44
+
45
+ def bootstrap_navigation_element(name, path)
46
+ markup = ""
47
+
48
+ if current_page? path
49
+ markup = <<HTML
50
+ <li class="disabled">#{link_to name, '#', tabindex: :'-1'}</li>
51
+ HTML
52
+ else
53
+ markup = <<HTML
54
+ <li>#{link_to name, path}</li>
55
+ HTML
56
+ end
57
+
58
+ markup.html_safe()
59
+ end
60
+
61
+ def link_to_edit_permissions(curation_concern, solr_document = nil)
62
+ markup = <<-HTML
63
+ <a href="#{edit_polymorphic_path([:curation_concern, curation_concern])}" id="permission_#{curation_concern.to_param}">
64
+ #{permission_badge_for(curation_concern, solr_document)}
65
+ </a>
66
+ HTML
67
+ markup.html_safe
68
+ end
69
+
70
+ def permission_badge_for(curation_concern, solr_document = nil)
71
+ solr_document ||= curation_concern.to_solr
72
+ dom_label_class, link_title = extract_dom_label_class_and_link_title(solr_document)
73
+ %(<span class="label #{dom_label_class}" title="#{link_title}">#{link_title}</span>).html_safe
74
+ end
75
+
76
+ def extract_dom_label_class_and_link_title(document)
77
+ hash = document.stringify_keys
78
+ dom_label_class, link_title = "label-important", "Private"
79
+ if hash['read_access_group_t'].present?
80
+ if hash['read_access_group_t'].include?('public')
81
+ dom_label_class, link_title = 'label-success', 'Open Access'
82
+ elsif hash['read_access_group_t'].include?('registered')
83
+ dom_label_class, link_title = "label-info", t('sufia.institution_name')
84
+ end
85
+ end
86
+ return dom_label_class, link_title
87
+ end
88
+ private :extract_dom_label_class_and_link_title
89
+ end