worthwhile 0.0.1.alpha → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/.rspec +1 -0
- data/.travis.yml +19 -0
- data/Gemfile +7 -11
- data/README.md +8 -12
- data/Rakefile +17 -2
- data/app/actors/concerns/worthwhile/manages_embargoes_actor.rb +79 -0
- data/app/actors/curation_concern/base_actor.rb +68 -0
- data/app/actors/curation_concern/generic_file_actor.rb +40 -0
- data/app/actors/curation_concern/generic_work_actor.rb +92 -0
- data/app/actors/curation_concern/linked_resource_actor.rb +4 -0
- data/app/assets/images/default.png +0 -0
- data/app/assets/images/nope.png +0 -0
- data/app/assets/javascripts/.gitkeep +0 -0
- data/app/assets/javascripts/modernizr.js +3 -0
- data/app/assets/javascripts/worthwhile/.gitkeep +0 -0
- data/app/assets/javascripts/worthwhile/accept_contributor_agreement.js +15 -0
- data/app/assets/javascripts/worthwhile/application.js +18 -0
- data/app/assets/javascripts/worthwhile/browse_everything_implement.js +7 -0
- data/app/assets/javascripts/worthwhile/embargoes.js +17 -0
- data/app/assets/javascripts/worthwhile/facet_mine.js +22 -0
- data/app/assets/javascripts/worthwhile/help_modal.js +36 -0
- data/app/assets/javascripts/worthwhile/link_groups.js.coffee +123 -0
- data/app/assets/javascripts/worthwhile/link_users.js.coffee +126 -0
- data/app/assets/javascripts/worthwhile/manage_repeating_fields.js +74 -0
- data/app/assets/javascripts/worthwhile/proxy_rights.js.coffee +95 -0
- data/app/assets/javascripts/worthwhile/proxy_submission.js +23 -0
- data/app/assets/javascripts/worthwhile/select_works.js.coffee +20 -0
- data/app/assets/javascripts/worthwhile/worthwhile.js +45 -0
- data/app/assets/stylesheets/worthwhile.css.scss +23 -0
- data/app/assets/stylesheets/worthwhile/_global-variables.css.scss +5 -0
- data/app/assets/stylesheets/worthwhile/_modules.css.scss +14 -0
- data/app/assets/stylesheets/worthwhile/_positioning.css.scss +138 -0
- data/app/assets/stylesheets/worthwhile/_theme.css.scss +46 -0
- data/app/assets/stylesheets/worthwhile/_typography.css.scss +142 -0
- data/app/assets/stylesheets/worthwhile/_variables_bootstrap.css.scss +7 -0
- data/app/assets/stylesheets/worthwhile/_worthwhile.css.scss +7 -0
- data/app/assets/stylesheets/worthwhile/downloads.css.scss +3 -0
- data/app/assets/stylesheets/worthwhile/help_requests.css.scss +3 -0
- data/app/assets/stylesheets/worthwhile/modules/accessibility.css.scss +50 -0
- data/app/assets/stylesheets/worthwhile/modules/accordion.css.scss +33 -0
- data/app/assets/stylesheets/worthwhile/modules/attributes.css.scss +26 -0
- data/app/assets/stylesheets/worthwhile/modules/classify_work.css.scss +100 -0
- data/app/assets/stylesheets/worthwhile/modules/collections.css.scss +42 -0
- data/app/assets/stylesheets/worthwhile/modules/embargoes.css.scss +15 -0
- data/app/assets/stylesheets/worthwhile/modules/emphatic_action_area.css.scss +14 -0
- data/app/assets/stylesheets/worthwhile/modules/forms.css.scss +116 -0
- data/app/assets/stylesheets/worthwhile/modules/multi_value_fields.css.scss +52 -0
- data/app/assets/stylesheets/worthwhile/modules/pagination.css.scss +4 -0
- data/app/assets/stylesheets/worthwhile/modules/search_results.css.scss +55 -0
- data/app/assets/stylesheets/worthwhile/modules/site_actions.css.scss +53 -0
- data/app/assets/stylesheets/worthwhile/modules/site_search.css.scss +46 -0
- data/app/controllers/catalog_controller.rb +3 -0
- data/app/controllers/collections_controller.rb +59 -0
- data/app/controllers/concerns/worthwhile/application_controller_behavior.rb +23 -0
- data/app/controllers/concerns/worthwhile/catalog_controller.rb +347 -0
- data/app/controllers/concerns/worthwhile/curation_concern_controller.rb +131 -0
- data/app/controllers/concerns/worthwhile/files_controller.rb +149 -0
- data/app/controllers/concerns/worthwhile/manages_embargoes.rb +22 -0
- data/app/controllers/concerns/worthwhile/parent_container.rb +31 -0
- data/app/controllers/concerns/worthwhile/themed_layout_controller.rb +31 -0
- data/app/controllers/concerns/worthwhile/without_namespace.rb +15 -0
- data/app/controllers/curation_concern/generic_files_controller.rb +6 -0
- data/app/controllers/curation_concern/generic_works_controller.rb +6 -0
- data/app/controllers/curation_concern/linked_resources_controller.rb +68 -0
- data/app/controllers/curation_concern/permissions_controller.rb +19 -0
- data/app/controllers/downloads_controller.rb +4 -0
- data/app/controllers/embargoes_controller.rb +44 -0
- data/app/controllers/leases_controller.rb +34 -0
- data/app/controllers/registrations_controller.rb +20 -0
- data/app/controllers/sessions_controller.rb +4 -0
- data/app/controllers/worthwhile/application_controller.rb +7 -0
- data/app/controllers/worthwhile/classify_concerns_controller.rb +35 -0
- data/app/datastreams/generic_work_metadata.rb +3 -0
- data/app/datastreams/worthwhile/generic_work_rdf_properties.rb +57 -0
- data/app/datastreams/worthwhile/properties_datastream.rb +28 -0
- data/app/helpers/curate/collections_helper.rb +133 -0
- data/app/helpers/worthwhile/ability_helper.rb +46 -0
- data/app/helpers/worthwhile/attribute_helper.rb +67 -0
- data/app/helpers/worthwhile/catalog_helper.rb +38 -0
- data/app/helpers/worthwhile/collections_helper.rb +19 -0
- data/app/helpers/worthwhile/embargo_helper.rb +17 -0
- data/app/helpers/worthwhile/generic_file_helper.rb +19 -0
- data/app/helpers/worthwhile/lease_helper.rb +18 -0
- data/app/helpers/worthwhile/main_app_helpers.rb +14 -0
- data/app/helpers/worthwhile/render_constraints_helper.rb +42 -0
- data/app/helpers/worthwhile/search_paths_helper.rb +13 -0
- data/app/helpers/worthwhile/thumbnail_helper.rb +11 -0
- data/app/helpers/worthwhile/title_helper.rb +23 -0
- data/app/helpers/worthwhile/url_helper.rb +16 -0
- data/app/inputs/multi_value_input.rb +72 -0
- data/app/models/collection.rb +15 -0
- data/app/models/concerns/curation_concern/collection_model.rb +62 -0
- data/app/models/concerns/curation_concern/curatable.rb +77 -0
- data/app/models/concerns/curation_concern/has_representative.rb +14 -0
- data/app/models/concerns/curation_concern/human_readable_type.rb +23 -0
- data/app/models/concerns/curation_concern/with_basic_metadata.rb +49 -0
- data/app/models/concerns/curation_concern/with_editors.rb +44 -0
- data/app/models/concerns/curation_concern/with_generic_files.rb +23 -0
- data/app/models/concerns/curation_concern/with_linked_resources.rb +21 -0
- data/app/models/concerns/curation_concern/work.rb +24 -0
- data/app/models/concerns/worthwhile/ability.rb +34 -0
- data/app/models/concerns/worthwhile/generic_file/versioned_content.rb +18 -0
- data/app/models/concerns/worthwhile/generic_file_base.rb +64 -0
- data/app/models/concerns/worthwhile/solr_document_behavior.rb +140 -0
- data/app/models/generic_work.rb +5 -0
- data/app/models/worthwhile/classify_concern.rb +47 -0
- data/app/models/worthwhile/content_version.rb +23 -0
- data/app/models/worthwhile/contributor_agreement.rb +23 -0
- data/app/models/worthwhile/generic_file.rb +5 -0
- data/app/models/worthwhile/linked_resource.rb +41 -0
- data/app/models/worthwhile/quick_classification_query.rb +31 -0
- data/app/services/worthwhile/curation_concern.rb +21 -0
- data/app/services/worthwhile/embargo_service.rb +26 -0
- data/app/services/worthwhile/lease_service.rb +23 -0
- data/app/views/catalog/_action_menu_partials/_collection.html.erb +27 -0
- data/app/views/catalog/_action_menu_partials/_default.html.erb +27 -0
- data/app/views/catalog/_document.html.erb +3 -0
- data/app/views/catalog/_document_list.html.erb +5 -0
- data/app/views/catalog/_home_text.html.erb +8 -0
- data/app/views/catalog/_index_default.html.erb +17 -0
- data/app/views/catalog/_index_header_list_default.html.erb +17 -0
- data/app/views/catalog/_navbar.html.erb +12 -0
- data/app/views/catalog/_show_partials/_default.html.erb +22 -0
- data/app/views/catalog/_show_partials/_default_details.html.erb +15 -0
- data/app/views/catalog/_show_partials/_facets.html.erb +52 -0
- data/app/views/catalog/index.html.erb +48 -0
- data/app/views/collections/_batch_edits_actions.html.erb +3 -0
- data/app/views/collections/_button_for_creating_empty_collection.html.erb +3 -0
- data/app/views/collections/_collection.html.erb +1 -0
- data/app/views/collections/_dashboard_document_list.html.erb +6 -0
- data/app/views/collections/_document_list.html.erb +7 -0
- data/app/views/collections/_edit_actions.html.erb +5 -0
- data/app/views/collections/_edit_descriptions.html.erb +20 -0
- data/app/views/collections/_form.html.erb +26 -0
- data/app/views/collections/_form_for_select_collection.html.erb +34 -0
- data/app/views/collections/_form_permission.html.erb +36 -0
- data/app/views/collections/_form_required_information.html.erb +11 -0
- data/app/views/collections/_identifier_and_action.html.erb +15 -0
- data/app/views/collections/_media_display.html.erb +1 -0
- data/app/views/collections/_paginate.html.erb +6 -0
- data/app/views/collections/_search_collection_dashboard_form.html.erb +10 -0
- data/app/views/collections/_show_actions.html.erb +8 -0
- data/app/views/collections/_show_descriptions.html.erb +10 -0
- data/app/views/collections/_show_fields.html.erb +0 -0
- data/app/views/collections/_single_item_action_fields.html.erb +6 -0
- data/app/views/collections/_sort_and_per_page.html.erb +29 -0
- data/app/views/collections/_view_type_group.html.erb +13 -0
- data/app/views/collections/edit.html.erb +22 -0
- data/app/views/collections/new.html.erb +15 -0
- data/app/views/collections/show.html.erb +24 -0
- data/app/views/curate/collections/_add_to_collection_modal.html.erb +15 -0
- data/app/views/curate/collections/_button_remove_from_collection.html.erb +6 -0
- data/app/views/curate/collections/_form_to_add_member.html.erb +27 -0
- data/app/views/curate/collections/add_member_form.html.erb +6 -0
- data/app/views/curation_concern/base/_attributes.html.erb +25 -0
- data/app/views/curation_concern/base/_collections.html.erb +26 -0
- data/app/views/curation_concern/base/_form.html.erb +27 -0
- data/app/views/curation_concern/base/_form_additional_information.html.erb +9 -0
- data/app/views/curation_concern/base/_form_content_license.html.erb +16 -0
- data/app/views/curation_concern/base/_form_contributor_agreement.html.erb +29 -0
- data/app/views/curation_concern/base/_form_descriptive_fields.erb +23 -0
- data/app/views/curation_concern/base/_form_files_and_links.html.erb +29 -0
- data/app/views/curation_concern/base/_form_permission.html.erb +52 -0
- data/app/views/curation_concern/base/_form_permission_embargo.html.erb +6 -0
- data/app/views/curation_concern/base/_form_permission_lease.html.erb +6 -0
- data/app/views/curation_concern/base/_form_permission_under_embargo.html.erb +16 -0
- data/app/views/curation_concern/base/_form_permission_under_lease.html.erb +18 -0
- data/app/views/curation_concern/base/_form_representative_image.html.erb +13 -0
- data/app/views/curation_concern/base/_form_required_information.html.erb +11 -0
- data/app/views/curation_concern/base/_form_supplementary_fields.html.erb +15 -0
- data/app/views/curation_concern/base/_legally_binding_text.html.erb +33 -0
- data/app/views/curation_concern/base/_related_files.html.erb +24 -0
- data/app/views/curation_concern/base/_related_resources.html.erb +40 -0
- data/app/views/curation_concern/base/_representative_media.html.erb +8 -0
- data/app/views/curation_concern/base/edit.html.erb +15 -0
- data/app/views/curation_concern/base/new.html.erb +14 -0
- data/app/views/curation_concern/base/show.html.erb +32 -0
- data/app/views/curation_concern/base/unauthorized.html.erb +3 -0
- data/app/views/curation_concern/generic_files/_form.html.erb +35 -0
- data/app/views/curation_concern/generic_files/_media_display.html.erb +20 -0
- data/app/views/curation_concern/generic_files/edit.html.erb +5 -0
- data/app/views/curation_concern/generic_files/show.html.erb +15 -0
- data/app/views/curation_concern/generic_works/_generic_work.html.erb +3 -0
- data/app/views/curation_concern/linked_resources/_form.html.erb +11 -0
- data/app/views/curation_concern/linked_resources/edit.html.erb +5 -0
- data/app/views/curation_concern/linked_resources/new.html.erb +5 -0
- data/app/views/curation_concern/permissions/confirm.html.erb +13 -0
- data/app/views/curation_concern/worthwhile/generic_files/_actions.html.erb +16 -0
- data/app/views/curation_concern/worthwhile/generic_files/_generic_file.html.erb +12 -0
- data/app/views/embargoes/_embargo_history.html.erb +7 -0
- data/app/views/embargoes/_list_active_embargoes.html.erb +16 -0
- data/app/views/embargoes/_list_deactivated_embargoes.html.erb +10 -0
- data/app/views/embargoes/_list_expired_active_embargoes.html.erb +44 -0
- data/app/views/embargoes/edit.html.erb +43 -0
- data/app/views/embargoes/index.html.erb +18 -0
- data/app/views/layouts/boilerplate.html.erb +22 -0
- data/app/views/layouts/common_objects.html.erb +36 -0
- data/app/views/layouts/curate_nd.html.erb +33 -0
- data/app/views/layouts/curate_nd/1_column.html.erb +22 -0
- data/app/views/layouts/curate_nd/2_column.html.erb +26 -0
- data/app/views/layouts/curate_nd/catalog.html.erb +38 -0
- data/app/views/layouts/curate_nd/dashboard.html.erb +22 -0
- data/app/views/leases/_lease_history.html.erb +7 -0
- data/app/views/leases/_list_active_leases.html.erb +16 -0
- data/app/views/leases/_list_deactivated_leases.html.erb +4 -0
- data/app/views/leases/_list_expired_active_leases.html.erb +38 -0
- data/app/views/leases/edit.html.erb +43 -0
- data/app/views/leases/index.html.erb +18 -0
- data/app/views/shared/_add_content.html.erb +32 -0
- data/app/views/shared/_brand_bar.html.erb +10 -0
- data/app/views/shared/_flash_message.html.erb +17 -0
- data/app/views/shared/_footer.html.erb +10 -0
- data/app/views/shared/_ga.html.erb +6 -0
- data/app/views/shared/_header.html.erb +12 -0
- data/app/views/shared/_my_actions.html.erb +21 -0
- data/app/views/shared/_site_actions.html.erb +7 -0
- data/app/views/shared/_site_search.html.erb +12 -0
- data/app/views/shared/_title_bar.html.erb +16 -0
- data/app/views/worthwhile/classify_concerns/new.html.erb +27 -0
- data/app/workers/visibility_copy_worker.rb +29 -0
- data/config/initializers/simple_form.rb +31 -0
- data/config/locales/sufia.en.yml +26 -0
- data/config/locales/worthwhile.en.yml +68 -0
- data/config/routes.rb +4 -0
- data/lib/generators/worthwhile/install_generator.rb +74 -0
- data/lib/generators/worthwhile/templates/worthwhile.css.scss +3 -0
- data/lib/generators/worthwhile/templates/worthwhile.js +1 -0
- data/lib/generators/worthwhile/templates/worthwhile_config.rb +3 -0
- data/lib/generators/worthwhile/templates/worthwhile_helper.rb +4 -0
- data/lib/worthwhile.rb +3 -1
- data/lib/worthwhile/configuration.rb +74 -0
- data/lib/worthwhile/controller_resource.rb +10 -0
- data/lib/worthwhile/engine.rb +20 -0
- data/lib/worthwhile/rails/routes.rb +78 -0
- data/lib/worthwhile/spec_support.rb +10 -0
- data/lib/worthwhile/version.rb +1 -1
- data/spec/abilities/generic_file_abilities_spec.rb +62 -0
- data/spec/abilities/generic_work_abilities_spec.rb +58 -0
- data/spec/actors/curation_concern/generic_work_actor_spec.rb +215 -0
- data/spec/actors/curation_concern/linked_resource_actor_spec.rb +36 -0
- data/spec/actors/worthwile/manages_embargoes_actor_spec.rb +95 -0
- data/spec/controllers/catalog_controller_spec.rb +114 -0
- data/spec/controllers/collections_controller_spec.rb +216 -0
- data/spec/controllers/curation_concern/generic_files_controller_spec.rb +258 -0
- data/spec/controllers/curation_concern/generic_works_controller_spec.rb +171 -0
- data/spec/controllers/curation_concern/linked_resources_controller_spec.rb +123 -0
- data/spec/controllers/curation_concern/permissions_controller_spec.rb +29 -0
- data/spec/controllers/downloads_controller_spec.rb +53 -0
- data/spec/controllers/embargoes_controller_spec.rb +107 -0
- data/spec/controllers/leases_controller_spec.rb +95 -0
- data/spec/controllers/worthwhile/classify_concerns_controller_spec.rb +35 -0
- data/spec/factories/collections_factory.rb +21 -0
- data/spec/factories/create_curation_concern.rb +3 -0
- data/spec/factories/generic_files.rb +18 -0
- data/spec/factories/generic_works.rb +37 -0
- data/spec/factories/linked_resources_factory.rb +18 -0
- data/spec/factories/users.rb +15 -0
- data/spec/features/add_external_link_spec.rb +25 -0
- data/spec/features/add_file_spec.rb +28 -0
- data/spec/features/collection_spec.rb +238 -0
- data/spec/features/embargo_spec.rb +45 -0
- data/spec/features/lease_spec.rb +43 -0
- data/spec/features/update_file_spec.rb +28 -0
- data/spec/fixtures/files/image.png +0 -0
- data/spec/helpers/catalog_helper_spec.rb +58 -0
- data/spec/helpers/configuration_helper_spec.rb +13 -0
- data/spec/helpers/render_constraints_helper_spec.rb +19 -0
- data/spec/helpers/thumbnail_helper_spec.rb +21 -0
- data/spec/helpers/url_helper_spec.rb +19 -0
- data/spec/matchers.rb +24 -0
- data/spec/matchers/metadata_field_matchers.rb +28 -0
- data/spec/models/collection_spec.rb +136 -0
- data/spec/models/curation_concern/collection_model_spec.rb +50 -0
- data/spec/models/curation_concern/work_spec.rb +30 -0
- data/spec/models/generic_work_spec.rb +24 -0
- data/spec/models/worthwhile/content_version_spec.rb +27 -0
- data/spec/models/worthwhile/generic_file_spec.rb +77 -0
- data/spec/models/worthwhile/linked_resource_spec.rb +76 -0
- data/spec/routing/worthwhile/routes_spec.rb +23 -0
- data/spec/services/embargo_service_spec.rb +38 -0
- data/spec/services/lease_service_spec.rb +37 -0
- data/spec/spec_helper.rb +30 -5
- data/spec/support/controllers/engine_helpers.rb +7 -0
- data/spec/support/curation_concern/factory_helpers.rb +14 -0
- data/spec/support/features.rb +19 -0
- data/spec/support/features/fixture_file_upload.rb +14 -0
- data/spec/support/features/session_helpers.rb +41 -0
- data/spec/support/shared/shared_examples_has_dc_metadata.rb +17 -0
- data/spec/support/shared/shared_examples_is_a_curation_concern_model.rb +40 -0
- data/spec/support/shared/shared_examples_is_embargoable.rb +8 -0
- data/spec/support/shared/shared_examples_with_access_rights.rb +63 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +8 -29
- data/spec/views/curation_concern/base/_attributes.html.erb_spec.rb +25 -0
- data/spec/views/curation_concern/base/show.html.erb_spec.rb +25 -0
- data/spec/views/shared/_add_content.html.erb_spec.rb +42 -0
- data/spec/views/shared/_my_actions.html.erb_spec.rb +23 -0
- data/spec/workers/visibility_copy_worker_spec.rb +68 -0
- data/vendor/assets/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/vendor/assets/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/vendor/assets/javascripts/handlebars.js +2278 -0
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.autocomplete.js +602 -0
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.core.js +356 -0
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.effect-highlight.js +50 -0
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.effect.js +1276 -0
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.menu.js +610 -0
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.position.js +498 -0
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.widget.js +528 -0
- data/vendor/assets/javascripts/jquery.tokeninput.js +1061 -0
- data/vendor/assets/stylesheets/jquery-ui-lightness.css +474 -0
- data/vendor/assets/stylesheets/token-input-facebook.css +122 -0
- data/vendor/assets/stylesheets/token-input-mac.css +204 -0
- data/vendor/assets/stylesheets/token-input.css +127 -0
- data/worthwhile.gemspec +9 -3
- metadata +469 -9
@@ -0,0 +1,77 @@
|
|
1
|
+
# Replaces Curate's CurationConcern::Model
|
2
|
+
module CurationConcern::Curatable
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
include ::CurationConcern::HumanReadableType
|
7
|
+
include Sufia::Noid
|
8
|
+
include Sufia::ModelMethods
|
9
|
+
include Hydra::Collections::Collectible
|
10
|
+
include Solrizer::Common
|
11
|
+
include ::CurationConcern::HasRepresentative
|
12
|
+
|
13
|
+
# Modules in Curate's CurationConcern::Model that we _might_ pull in later
|
14
|
+
# include Curate::ActiveModelAdaptor
|
15
|
+
|
16
|
+
has_metadata 'properties', type: Worthwhile::PropertiesDatastream
|
17
|
+
has_attributes :relative_path, :depositor, :owner, datastream: :properties, multiple: false
|
18
|
+
class_attribute :human_readable_short_description
|
19
|
+
attr_accessor :files
|
20
|
+
end
|
21
|
+
|
22
|
+
def as_json(options)
|
23
|
+
{ pid: pid, title: title, model: self.class.to_s, curation_concern_type: human_readable_type }
|
24
|
+
end
|
25
|
+
|
26
|
+
def as_rdf_object
|
27
|
+
RDF::URI.new(internal_uri)
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_solr(solr_doc={}, opts={})
|
31
|
+
super.tap do |solr_doc|
|
32
|
+
index_collection_pids(solr_doc)
|
33
|
+
solr_doc[Solrizer.solr_name('noid', Sufia::GenericFile.noid_indexer)] = noid
|
34
|
+
add_derived_date_created(solr_doc)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_s
|
39
|
+
title.join(', ')
|
40
|
+
end
|
41
|
+
|
42
|
+
# Returns a string identifying the path associated with the object. ActionPack uses this to find a suitable partial to represent the object.
|
43
|
+
def to_partial_path
|
44
|
+
"curation_concern/#{super}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def can_be_member_of_collection?(collection)
|
48
|
+
collection == self ? false : true
|
49
|
+
end
|
50
|
+
|
51
|
+
protected
|
52
|
+
|
53
|
+
# A searchable date field that is derived from the (text) field date_created
|
54
|
+
def add_derived_date_created(solr_doc)
|
55
|
+
if self.respond_to?(:date_created)
|
56
|
+
self.class.create_and_insert_terms('date_created_derived', derived_dates, [:dateable], solr_doc)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def derived_dates
|
61
|
+
dates = Array(date_created)
|
62
|
+
dates.map { |date| Curate::DateFormatter.parse(date.to_s).to_s }
|
63
|
+
end
|
64
|
+
|
65
|
+
def index_collection_pids(solr_doc)
|
66
|
+
solr_doc[Solrizer.solr_name(:collection, :facetable)] ||= []
|
67
|
+
solr_doc[Solrizer.solr_name(:collection)] ||= []
|
68
|
+
self.collection_ids.each do |collection_id|
|
69
|
+
collection_obj = ActiveFedora::Base.load_instance_from_solr(collection_id)
|
70
|
+
if collection_obj.is_a?(Collection)
|
71
|
+
solr_doc[Solrizer.solr_name(:collection, :facetable)] << collection_id
|
72
|
+
solr_doc[Solrizer.solr_name(:collection)] << collection_id
|
73
|
+
end
|
74
|
+
end
|
75
|
+
solr_doc
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module CurationConcern::HasRepresentative
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
has_attributes :representative, datastream: :properties, multiple: false
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_solr(solr_doc={}, opts={})
|
9
|
+
super.tap do |solr_doc|
|
10
|
+
solr_doc[Solrizer.solr_name('representative', :stored_searchable)] = representative
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module CurationConcern
|
2
|
+
module HumanReadableType
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
class_attribute :human_readable_short_description, :human_readable_type
|
7
|
+
self.human_readable_type = name.demodulize.titleize
|
8
|
+
end
|
9
|
+
|
10
|
+
def human_readable_type
|
11
|
+
self.class.human_readable_type
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_solr(solr_doc={}, opts={})
|
15
|
+
super(solr_doc, opts)
|
16
|
+
solr_doc[Solrizer.solr_name('human_readable_type',:facetable)] = human_readable_type
|
17
|
+
solr_doc[Solrizer.solr_name('human_readable_type', :stored_searchable)] = human_readable_type
|
18
|
+
return solr_doc
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# Basic metadata for all Works
|
2
|
+
# Required fields:
|
3
|
+
# dc:title
|
4
|
+
# dc:rights
|
5
|
+
#
|
6
|
+
# Optional fields:
|
7
|
+
# dc:contributor
|
8
|
+
# dc:coverage
|
9
|
+
# dc:creator
|
10
|
+
# dc:date
|
11
|
+
# dc:description
|
12
|
+
# dc:format
|
13
|
+
# dc:identifier
|
14
|
+
# dc:language
|
15
|
+
# dc:publisher
|
16
|
+
# dc:relation
|
17
|
+
# dc:source
|
18
|
+
# dc:subject
|
19
|
+
# dc:type
|
20
|
+
module CurationConcern::WithBasicMetadata
|
21
|
+
extend ActiveSupport::Concern
|
22
|
+
|
23
|
+
included do
|
24
|
+
has_metadata "descMetadata", type: ::GenericWorkMetadata
|
25
|
+
# Validations that apply to all types of Work AND Collections
|
26
|
+
validates_presence_of :title, message: 'Your work must have a title.'
|
27
|
+
|
28
|
+
|
29
|
+
# Single-value fields
|
30
|
+
has_attributes :created, :date_modified, :date_uploaded, datastream: :descMetadata, multiple: false
|
31
|
+
|
32
|
+
# Multi-value fields
|
33
|
+
has_attributes :contributor, :creator, :coverage, :date, :description, :content_format, :identifier,
|
34
|
+
:language, :publisher, :relation, :rights, :source, :subject, :title, :type,
|
35
|
+
datastream: :descMetadata, multiple: true
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
# TODO created and date_uploaded?
|
40
|
+
# TODO created and date_created
|
41
|
+
# has_attributes :date_uploaded, :date_modified, :title, :description,
|
42
|
+
# datastream: :descMetadata, multiple: false
|
43
|
+
#
|
44
|
+
# has_attributes :related_url, :based_near, :part_of, :creator, :contributor,
|
45
|
+
# :tag, :rights, :publisher, :date_created, :subject, :resource_type,
|
46
|
+
# :identifier, :language,
|
47
|
+
# datastream: :descMetadata, multiple: true
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module CurationConcern
|
2
|
+
module WithEditors
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
def add_editor_group(group_name)
|
6
|
+
self.edit_groups += [group]
|
7
|
+
end
|
8
|
+
|
9
|
+
# @param groups [Array<String>] a list of group names to add
|
10
|
+
def add_editor_groups(groups)
|
11
|
+
groups.each { |g| add_editor_group(g) }
|
12
|
+
end
|
13
|
+
|
14
|
+
def remove_editor_group(group)
|
15
|
+
self.edit_groups -= [group]
|
16
|
+
end
|
17
|
+
|
18
|
+
# @param groups [Array<String>] a list of users to remove
|
19
|
+
def remove_editor_groups(groups)
|
20
|
+
groups.each { |g| remove_editor_group(g) }
|
21
|
+
end
|
22
|
+
|
23
|
+
# @param user [String] the user account you want to grant edit access to.
|
24
|
+
def add_editor(user)
|
25
|
+
self.edit_users += [user]
|
26
|
+
end
|
27
|
+
|
28
|
+
# @param users [Array<String>] a list of users to add
|
29
|
+
def add_editors(users)
|
30
|
+
users.each { |u| add_editor(u) }
|
31
|
+
end
|
32
|
+
|
33
|
+
# @param user [String] the user account you want to revoke edit access for.
|
34
|
+
def remove_editor(user)
|
35
|
+
self.edit_users -= [user]
|
36
|
+
end
|
37
|
+
|
38
|
+
# @param users [Array<String>] a list of users to remove
|
39
|
+
def remove_editors(users)
|
40
|
+
users.each { |u| remove_editor(u) }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Copied from Curate
|
2
|
+
module CurationConcern
|
3
|
+
module WithGenericFiles
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
has_many :generic_files, property: :is_part_of, class_name: "Worthwhile::GenericFile"
|
8
|
+
before_destroy :before_destroy_cleanup_generic_files
|
9
|
+
end
|
10
|
+
|
11
|
+
def before_destroy_cleanup_generic_files
|
12
|
+
generic_files.each(&:destroy)
|
13
|
+
end
|
14
|
+
|
15
|
+
def copy_visibility_to_files
|
16
|
+
generic_files.each do |gf|
|
17
|
+
gf.visibility = visibility
|
18
|
+
gf.save!
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module CurationConcern
|
2
|
+
module WithLinkedResources
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
|
7
|
+
# attribute :linked_resource_urls, multiple: true
|
8
|
+
attr_accessor :linked_resource_urls
|
9
|
+
|
10
|
+
has_many :linked_resources, property: :is_part_of, class_name:"Worthwhile::LinkedResource"
|
11
|
+
|
12
|
+
after_destroy :after_destroy_cleanup_linked_resources
|
13
|
+
end
|
14
|
+
|
15
|
+
def after_destroy_cleanup_linked_resources
|
16
|
+
linked_resources.each(&:destroy)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module CurationConcern::Work
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
include ::CurationConcern::Curatable
|
4
|
+
include ::CurationConcern::WithGenericFiles
|
5
|
+
include Hydra::AccessControls::Embargoable
|
6
|
+
include ::CurationConcern::WithEditors
|
7
|
+
include CurationConcern::WithLinkedResources
|
8
|
+
|
9
|
+
# Modules in Curate's CurationConcern::Work that we _might_ pull in later
|
10
|
+
# include Curate::ActiveModelAdaptor
|
11
|
+
# include CurationConcern::WithLinkedContributors
|
12
|
+
# include CurationConcern::WithRelatedWorks
|
13
|
+
|
14
|
+
included do
|
15
|
+
has_metadata "properties", type: Worthwhile::PropertiesDatastream
|
16
|
+
has_attributes :depositor, :representative, datastream: :properties, multiple: false
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_solr(solr_doc={}, opts={})
|
20
|
+
super(solr_doc, opts)
|
21
|
+
Solrizer.set_field(solr_doc, 'generic_type', 'Work', :facetable)
|
22
|
+
return solr_doc
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Worthwhile
|
2
|
+
module Ability
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
included do
|
5
|
+
self.ability_logic += [:worthwhile_permissions]
|
6
|
+
end
|
7
|
+
|
8
|
+
def worthwhile_permissions
|
9
|
+
|
10
|
+
unless current_user.new_record?
|
11
|
+
can :create, Worthwhile::ClassifyConcern
|
12
|
+
can :create, [Worthwhile::GenericFile, Worthwhile::LinkedResource]
|
13
|
+
end
|
14
|
+
|
15
|
+
if user_groups.include? 'admin'
|
16
|
+
can [:discover, :show, :read, :edit, :update, :destroy], :all
|
17
|
+
end
|
18
|
+
|
19
|
+
can :collect, :all
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
# Add this to your ability_logic if you want all logged in users to be able to submit content
|
24
|
+
def everyone_can_create_curation_concerns
|
25
|
+
unless current_user.new_record?
|
26
|
+
can :create, [Worthwhile.configuration.curation_concerns]
|
27
|
+
can :create, Collection
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Worthwhile
|
2
|
+
class GenericFile
|
3
|
+
module VersionedContent
|
4
|
+
def versions
|
5
|
+
return [] unless persisted?
|
6
|
+
@versions ||= content.versions.collect {|version| Worthwhile::ContentVersion.new(content, version)}
|
7
|
+
end
|
8
|
+
|
9
|
+
def latest_version
|
10
|
+
versions.first || Worthwhile::ContentVersion::Null.new(content)
|
11
|
+
end
|
12
|
+
|
13
|
+
def current_version_id
|
14
|
+
latest_version.version_id
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Worthwhile
|
2
|
+
module GenericFileBase
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
include Hydra::AccessControls::Embargoable
|
5
|
+
include Sufia::ModelMethods
|
6
|
+
include Sufia::Noid
|
7
|
+
include Sufia::GenericFile::MimeTypes
|
8
|
+
include Sufia::GenericFile::Characterization
|
9
|
+
include Sufia::GenericFile::Audit
|
10
|
+
include Sufia::GenericFile::WebForm
|
11
|
+
include Sufia::GenericFile::Derivatives
|
12
|
+
include Sufia::GenericFile::Metadata
|
13
|
+
include Sufia::GenericFile::Versions
|
14
|
+
include Sufia::Permissions::Readable
|
15
|
+
include Worthwhile::GenericFile::VersionedContent
|
16
|
+
|
17
|
+
included do
|
18
|
+
belongs_to :batch, property: :is_part_of, class_name: 'ActiveFedora::Base'
|
19
|
+
|
20
|
+
before_destroy :remove_representative_relationship
|
21
|
+
|
22
|
+
attr_accessor :file
|
23
|
+
|
24
|
+
# make filename single-value (Sufia::GenericFile::Characterization makes it multivalue)
|
25
|
+
# has_attributes :filename, datastream: :characterization, multiple: false
|
26
|
+
def filename
|
27
|
+
content.label
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def human_readable_type
|
32
|
+
self.class.to_s.demodulize.titleize
|
33
|
+
end
|
34
|
+
|
35
|
+
def representative
|
36
|
+
to_param
|
37
|
+
end
|
38
|
+
|
39
|
+
def copy_permissions_from(obj)
|
40
|
+
self.datastreams['rightsMetadata'].ng_xml = obj.datastreams['rightsMetadata'].ng_xml
|
41
|
+
end
|
42
|
+
|
43
|
+
def update_parent_representative_if_empty(obj)
|
44
|
+
return unless obj.representative.blank?
|
45
|
+
obj.representative = self.pid
|
46
|
+
obj.save
|
47
|
+
end
|
48
|
+
|
49
|
+
def remove_representative_relationship
|
50
|
+
return unless ActiveFedora::Base.exists?(batch)
|
51
|
+
return unless batch.representative == self.pid
|
52
|
+
batch.representative = nil
|
53
|
+
batch.save
|
54
|
+
end
|
55
|
+
|
56
|
+
def to_solr(solr_doc = {})
|
57
|
+
super.tap do |solr_doc|
|
58
|
+
# Enables Riiif to not have to recalculate this each time.
|
59
|
+
solr_doc['height_isi'] = Integer(height.first) if height.present?
|
60
|
+
solr_doc['width_isi'] = Integer(width.first) if width.present?
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
# This was moved out of sufia-models and into sufia/app/models.
|
2
|
+
# Copied the file in here to retain the functionality until/unless the file gets moved back into sufia-models.
|
3
|
+
# -*- encoding : utf-8 -*-
|
4
|
+
module Worthwhile
|
5
|
+
module SolrDocumentBehavior
|
6
|
+
def title_or_label
|
7
|
+
title || label
|
8
|
+
end
|
9
|
+
|
10
|
+
##
|
11
|
+
# Give our SolrDocument an ActiveModel::Naming appropriate route_key
|
12
|
+
def route_key
|
13
|
+
get(Solrizer.solr_name('has_model', :symbol)).split(':').last.downcase
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_param
|
17
|
+
noid || id
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
title_or_label
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# Offer the source (ActiveFedora-based) model to Rails for some of the
|
26
|
+
# Rails methods (e.g. link_to).
|
27
|
+
# @example
|
28
|
+
# link_to '...', SolrDocument(:id => 'bXXXXXX5').new => <a href="/dams_object/bXXXXXX5">...</a>
|
29
|
+
def to_model
|
30
|
+
m = ActiveFedora::Base.load_instance_from_solr(id, self)
|
31
|
+
m.class == ActiveFedora::Base ? self : m
|
32
|
+
end
|
33
|
+
|
34
|
+
def collection?
|
35
|
+
hydra_model == 'Collection'
|
36
|
+
end
|
37
|
+
|
38
|
+
# Method to return the ActiveFedora model
|
39
|
+
def hydra_model
|
40
|
+
self[Solrizer.solr_name('active_fedora_model', Solrizer::Descriptor.new(:string, :stored, :indexed))]
|
41
|
+
end
|
42
|
+
|
43
|
+
def noid
|
44
|
+
self[Solrizer.solr_name('noid', Sufia::GenericFile.noid_indexer)]
|
45
|
+
end
|
46
|
+
|
47
|
+
def human_readable_type
|
48
|
+
Array(self[Solrizer.solr_name('human_readable_type', :stored_searchable)]).first
|
49
|
+
end
|
50
|
+
|
51
|
+
def representative
|
52
|
+
Array(self[Solrizer.solr_name('representative', :stored_searchable)]).first
|
53
|
+
end
|
54
|
+
|
55
|
+
def date_uploaded
|
56
|
+
field = self[Solrizer.solr_name("desc_metadata__date_uploaded", :stored_sortable, type: :date)]
|
57
|
+
return unless field.present?
|
58
|
+
begin
|
59
|
+
Date.parse(field).to_formatted_s(:standard)
|
60
|
+
rescue
|
61
|
+
Rails.logger.info "Unable to parse date: #{field.first.inspect} for #{self['id']}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def depositor(default = '')
|
66
|
+
val = Array(self[Solrizer.solr_name("depositor")]).first
|
67
|
+
val.present? ? val : default
|
68
|
+
end
|
69
|
+
|
70
|
+
def title
|
71
|
+
Array(self[Solrizer.solr_name('desc_metadata__title')]).first
|
72
|
+
end
|
73
|
+
|
74
|
+
def description
|
75
|
+
Array(self[Solrizer.solr_name('desc_metadata__description')]).first
|
76
|
+
end
|
77
|
+
|
78
|
+
def label
|
79
|
+
Array(self[Solrizer.solr_name('label')]).first
|
80
|
+
end
|
81
|
+
|
82
|
+
def file_format
|
83
|
+
Array(self[Solrizer.solr_name('file_format')]).first
|
84
|
+
end
|
85
|
+
|
86
|
+
def creator
|
87
|
+
Array(self[Solrizer.solr_name("desc_metadata__creator")]).first
|
88
|
+
end
|
89
|
+
|
90
|
+
def tags
|
91
|
+
Array(self[Solrizer.solr_name("desc_metadata__tag")])
|
92
|
+
end
|
93
|
+
|
94
|
+
def resource_type
|
95
|
+
Array(self[Solrizer.solr_name("desc_metadata__resource_type")])
|
96
|
+
end
|
97
|
+
|
98
|
+
def mime_type
|
99
|
+
Array(self[Solrizer.solr_name("mime_type")]).first
|
100
|
+
end
|
101
|
+
|
102
|
+
def read_groups
|
103
|
+
Array(self[::Ability.read_group_field])
|
104
|
+
end
|
105
|
+
|
106
|
+
def edit_groups
|
107
|
+
Array(self[::Ability.edit_group_field])
|
108
|
+
end
|
109
|
+
|
110
|
+
def edit_people
|
111
|
+
Array(self[::Ability.edit_user_field])
|
112
|
+
end
|
113
|
+
|
114
|
+
def public?
|
115
|
+
read_groups.include?('public')
|
116
|
+
end
|
117
|
+
|
118
|
+
def registered?
|
119
|
+
read_groups.include?('registered')
|
120
|
+
end
|
121
|
+
|
122
|
+
def pdf?
|
123
|
+
['application/pdf'].include? self.mime_type
|
124
|
+
end
|
125
|
+
|
126
|
+
def image?
|
127
|
+
['image/png','image/jpeg', 'image/jpg', 'image/jp2', 'image/bmp', 'image/gif', 'image/tiff'].include? self.mime_type
|
128
|
+
end
|
129
|
+
|
130
|
+
def video?
|
131
|
+
['video/mpeg', 'video/mp4', 'video/webm', 'video/x-msvideo', 'video/avi', 'video/quicktime', 'application/mxf'].include? self.mime_type
|
132
|
+
end
|
133
|
+
|
134
|
+
def audio?
|
135
|
+
# audio/x-wave is the mime type that fits 0.6.0 returns for a wav file.
|
136
|
+
# audio/mpeg is the mime type that fits 0.6.0 returns for an mp3 file.
|
137
|
+
['audio/mp3', 'audio/mpeg', 'audio/x-wave', 'audio/x-wav', 'audio/ogg'].include? self.mime_type
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|