enju_biblio 0.1.3 → 0.2.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +3 -3
- data/app/controllers/agent_import_files_controller.rb +13 -3
- data/app/controllers/agent_import_results_controller.rb +12 -1
- data/app/controllers/agent_merge_lists_controller.rb +11 -1
- data/app/controllers/agent_merges_controller.rb +12 -2
- data/app/controllers/agent_relationship_types_controller.rb +13 -2
- data/app/controllers/agent_relationships_controller.rb +13 -4
- data/app/controllers/agent_types_controller.rb +13 -2
- data/app/controllers/agents_controller.rb +18 -12
- data/app/controllers/carrier_types_controller.rb +12 -2
- data/app/controllers/concerns/enju_biblio/controller.rb +99 -0
- data/app/controllers/content_types_controller.rb +12 -1
- data/app/controllers/countries_controller.rb +12 -1
- data/app/controllers/create_types_controller.rb +13 -2
- data/app/controllers/creates_controller.rb +13 -4
- data/app/controllers/donates_controller.rb +11 -1
- data/app/controllers/form_of_works_controller.rb +13 -2
- data/app/controllers/frequencies_controller.rb +13 -2
- data/app/controllers/identifier_types_controller.rb +13 -2
- data/app/controllers/import_requests_controller.rb +19 -9
- data/app/controllers/items_controller.rb +25 -13
- data/app/controllers/languages_controller.rb +12 -1
- data/app/controllers/licenses_controller.rb +13 -2
- data/app/controllers/manifestation_relationship_types_controller.rb +12 -1
- data/app/controllers/manifestation_relationships_controller.rb +13 -4
- data/app/controllers/manifestations_controller.rb +58 -30
- data/app/controllers/medium_of_performances_controller.rb +13 -2
- data/app/controllers/owns_controller.rb +12 -3
- data/app/controllers/picture_files_controller.rb +13 -3
- data/app/controllers/produce_types_controller.rb +13 -2
- data/app/controllers/produces_controller.rb +13 -4
- data/app/controllers/realize_types_controller.rb +13 -2
- data/app/controllers/realizes_controller.rb +13 -4
- data/app/controllers/resource_export_files_controller.rb +13 -3
- data/app/controllers/resource_import_files_controller.rb +14 -4
- data/app/controllers/resource_import_results_controller.rb +12 -1
- data/app/controllers/series_statement_merge_lists_controller.rb +11 -1
- data/app/controllers/series_statement_merges_controller.rb +12 -2
- data/app/controllers/series_statements_controller.rb +13 -5
- data/app/helpers/manifestations_helper.rb +8 -8
- data/app/jobs/agent_import_file_job.rb +7 -0
- data/app/jobs/resource_export_file_job.rb +7 -0
- data/app/jobs/resource_import_file_job.rb +7 -0
- data/app/models/agent.rb +23 -1
- data/app/models/agent_import_file.rb +0 -1
- data/app/models/carrier_type.rb +0 -1
- data/app/models/identifier.rb +1 -1
- data/app/models/item.rb +2 -9
- data/app/models/manifestation.rb +180 -75
- data/app/models/picture_file.rb +1 -1
- data/app/models/resource_export_file.rb +5 -3
- data/app/models/resource_import_file.rb +34 -50
- data/app/models/series_statement.rb +8 -1
- data/app/policies/agent_import_file_policy.rb +21 -0
- data/app/policies/agent_import_result_policy.rb +21 -0
- data/app/policies/agent_merge_list_policy.rb +25 -0
- data/app/policies/agent_merge_policy.rb +25 -0
- data/app/policies/agent_policy.rb +30 -0
- data/app/policies/agent_relationship_policy.rb +21 -0
- data/app/policies/agent_relationship_type_policy.rb +21 -0
- data/app/policies/agent_type_policy.rb +23 -0
- data/app/policies/carrier_type_policy.rb +23 -0
- data/app/policies/content_type_policy.rb +23 -0
- data/app/policies/country_policy.rb +21 -0
- data/app/policies/create_policy.rb +21 -0
- data/app/policies/create_type_policy.rb +21 -0
- data/app/policies/donate_policy.rb +21 -0
- data/app/policies/form_of_work_policy.rb +21 -0
- data/app/policies/frequency_policy.rb +23 -0
- data/app/policies/identifier_type_policy.rb +23 -0
- data/app/policies/import_request_policy.rb +21 -0
- data/app/policies/item_policy.rb +27 -0
- data/app/policies/language_policy.rb +21 -0
- data/app/policies/license_policy.rb +21 -0
- data/app/policies/manifestation_policy.rb +67 -0
- data/app/policies/manifestation_relationship_policy.rb +21 -0
- data/app/policies/manifestation_relationship_type_policy.rb +21 -0
- data/app/policies/medium_of_performance_policy.rb +21 -0
- data/app/policies/own_policy.rb +21 -0
- data/app/policies/picture_file_policy.rb +32 -0
- data/app/policies/produce_policy.rb +21 -0
- data/app/policies/produce_type_policy.rb +21 -0
- data/app/policies/realize_policy.rb +21 -0
- data/app/policies/realize_type_policy.rb +21 -0
- data/app/policies/resource_export_file_policy.rb +21 -0
- data/app/policies/resource_import_file_policy.rb +21 -0
- data/app/policies/resource_import_result_policy.rb +21 -0
- data/app/policies/series_statement_merge_list_policy.rb +25 -0
- data/app/policies/series_statement_merge_policy.rb +25 -0
- data/app/policies/series_statement_policy.rb +25 -0
- data/app/views/agent_relationship_types/index.html.erb +4 -4
- data/app/views/agent_types/index.html.erb +4 -4
- data/app/views/agent_types/show.html.erb +1 -1
- data/app/views/agents/_agent.html.erb +2 -2
- data/app/views/agents/_index.html.erb +1 -1
- data/app/views/agents/_index_agent.html.erb +4 -4
- data/app/views/agents/_index_agent_merge_list.html.erb +2 -2
- data/app/views/agents/_index_expression.html.erb +3 -3
- data/app/views/agents/_index_manifestation.html.erb +3 -3
- data/app/views/agents/_index_work.html.erb +3 -3
- data/app/views/agents/edit.html.erb +1 -1
- data/app/views/agents/{index.mobile.erb → index.html+phone.erb} +0 -0
- data/app/views/agents/index.json.jbuilder +5 -0
- data/app/views/agents/index.rss.builder +2 -2
- data/app/views/agents/{show.mobile.erb → show.html+phone.erb} +0 -0
- data/app/views/agents/show.html.erb +3 -3
- data/app/views/carrier_types/_form.html.erb +1 -1
- data/app/views/carrier_types/index.html.erb +4 -4
- data/app/views/carrier_types/show.html.erb +1 -1
- data/app/views/content_types/index.html.erb +4 -4
- data/app/views/content_types/show.html.erb +1 -1
- data/app/views/countries/index.html.erb +3 -3
- data/app/views/countries/show.html.erb +1 -1
- data/app/views/create_types/index.html.erb +4 -4
- data/app/views/creates/_index.html.erb +2 -2
- data/app/views/creates/_index_agent.html.erb +3 -3
- data/app/views/creates/_index_work.html.erb +2 -2
- data/app/views/donates/index.html.erb +2 -2
- data/app/views/form_of_works/index.html.erb +4 -4
- data/app/views/form_of_works/show.html.erb +1 -1
- data/app/views/frequencies/index.html.erb +4 -4
- data/app/views/frequencies/show.html.erb +1 -1
- data/app/views/identifier_types/index.html.erb +4 -4
- data/app/views/identifier_types/show.html.erb +1 -1
- data/app/views/import_requests/index.html.erb +1 -1
- data/app/views/items/{_shelf_picture.mobile.erb → _shelf_picture.html+phone.erb} +0 -0
- data/app/views/items/edit.html.erb +2 -2
- data/app/views/items/{index.mobile.erb → index.html+phone.erb} +1 -1
- data/app/views/items/index.html.erb +2 -2
- data/app/views/items/new.html.erb +1 -5
- data/app/views/items/{show.mobile.erb → show.html+phone.erb} +0 -0
- data/app/views/items/show.html.erb +10 -6
- data/app/views/languages/index.html.erb +3 -3
- data/app/views/languages/show.html.erb +1 -1
- data/app/views/layouts/{agents.mobile.erb → agents.html+phone.erb} +1 -1
- data/app/views/layouts/agents.html.erb +2 -2
- data/app/views/layouts/{manifestations.mobile.erb → manifestations.html+phone.erb} +1 -1
- data/app/views/layouts/manifestations.html.erb +2 -2
- data/app/views/licenses/index.html.erb +4 -4
- data/app/views/manifestation_relationship_types/index.html.erb +4 -4
- data/app/views/manifestations/_attachment_file.html.erb +1 -1
- data/app/views/manifestations/_carrier_type_facet.html.erb +1 -1
- data/app/views/manifestations/_classification_facet.html.erb +2 -2
- data/app/views/manifestations/_contributor_fields.html.erb +4 -0
- data/app/views/manifestations/_creator_fields.html.erb +5 -0
- data/app/views/manifestations/_edit_detail.html.erb +1 -1
- data/app/views/manifestations/_export_list.html.erb +3 -3
- data/app/views/manifestations/_form.html.erb +25 -30
- data/app/views/manifestations/_holding.html.erb +6 -8
- data/app/views/manifestations/_identifier_fields.html.erb +5 -0
- data/app/views/manifestations/_index_form_contributor.html.erb +2 -2
- data/app/views/manifestations/_index_form_creator.html.erb +2 -2
- data/app/views/manifestations/_index_form_item.html.erb +2 -2
- data/app/views/manifestations/_index_form_manifestation.html.erb +2 -2
- data/app/views/manifestations/_index_form_parent.html.erb +1 -1
- data/app/views/manifestations/_index_form_publisher.html.erb +2 -2
- data/app/views/manifestations/_index_form_series_statement.html.erb +2 -2
- data/app/views/manifestations/_language_facet.html.erb +1 -1
- data/app/views/manifestations/_library_facet.html.erb +1 -1
- data/app/views/manifestations/_manifestation.html.erb +6 -2
- data/app/views/manifestations/_manifestation.txt.erb +1 -1
- data/app/views/manifestations/_paginate_id_store.html.erb +8 -6
- data/app/views/manifestations/_pub_year_facet.html.erb +1 -1
- data/app/views/manifestations/_publisher_fields.html.erb +4 -0
- data/app/views/manifestations/_reservable_facet.html.erb +2 -2
- data/app/views/manifestations/_series_statement_fields.html.erb +13 -0
- data/app/views/manifestations/_show.rdf.builder +3 -87
- data/app/views/manifestations/{_show_creators.mobile.erb → _show_creators.html+phone.erb} +0 -0
- data/app/views/manifestations/_show_creators.html.erb +0 -1
- data/app/views/manifestations/_show_detail_librarian.html.erb +20 -22
- data/app/views/manifestations/_show_detail_user.html.erb +13 -15
- data/app/views/manifestations/{_show_holding.mobile.erb → _show_holding.html+phone.erb} +0 -0
- data/app/views/manifestations/_show_holding.html.erb +1 -1
- data/app/views/manifestations/{_show_index.mobile.erb → _show_index.html+phone.erb} +0 -0
- data/app/views/manifestations/_submenu_parent.html.erb +3 -3
- data/app/views/manifestations/{_title.mobile.erb → _title.html+phone.erb} +0 -0
- data/app/views/manifestations/edit.html.erb +2 -6
- data/app/views/manifestations/{index.mobile.erb → index.html+phone.erb} +0 -0
- data/app/views/manifestations/index.html.erb +40 -24
- data/app/views/manifestations/index.rdf.builder +5 -3
- data/app/views/manifestations/index.rss.builder +2 -2
- data/app/views/manifestations/index.txt.erb +1 -2
- data/app/views/manifestations/{show.mobile.erb → show.html+phone.erb} +1 -1
- data/app/views/manifestations/show.html.erb +1 -1
- data/app/views/manifestations/show.txt.erb +1 -2
- data/app/views/medium_of_performances/index.html.erb +4 -4
- data/app/views/owns/index.html.erb +2 -2
- data/app/views/picture_files/_index.html.erb +3 -3
- data/app/views/picture_files/_index_agent.html.erb +4 -4
- data/app/views/picture_files/_index_manifestation.html.erb +4 -4
- data/app/views/picture_files/{_link.mobile.erb → _link.html+phone.erb} +0 -0
- data/app/views/picture_files/{show.mobile.erb → show.html+phone.erb} +0 -0
- data/app/views/produce_types/index.html.erb +4 -4
- data/app/views/produces/_index.html.erb +2 -2
- data/app/views/produces/_index_agent.html.erb +2 -2
- data/app/views/produces/_index_manifestation.html.erb +2 -2
- data/app/views/realize_types/index.html.erb +4 -4
- data/app/views/realizes/_index.html.erb +2 -2
- data/app/views/realizes/_index_agent.html.erb +2 -2
- data/app/views/realizes/_index_expression.html.erb +2 -2
- data/app/views/series_statement_merges/show.html.erb +0 -2
- data/app/views/series_statements/_index.html.erb +4 -4
- data/app/views/series_statements/_index_series_statement_merge_list.html.erb +2 -2
- data/app/views/series_statements/show.html.erb +1 -1
- data/config/locales/translation_en.yml +13 -0
- data/config/locales/translation_ja.yml +13 -0
- data/config/routes.rb +3 -43
- data/lib/enju_biblio/engine.rb +0 -1
- data/lib/enju_biblio/version.rb +1 -1
- data/lib/enju_biblio.rb +0 -107
- data/lib/tasks/enju_biblio_tasks.rake +1 -1
- data/spec/cassette_library/ImportRequest/import/should_import_bibliographic_record.yml +43 -43
- data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Administrator/with_isbn_which_is_already_imported/redirects_to_the_created_import_request.yml +45 -45
- data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Administrator/with_valid_params/assigns_a_newly_created_import_request_as_import_request.yml +50 -50
- data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Administrator/with_valid_params/redirects_to_the_created_import_request.yml +44 -44
- data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Librarian/with_valid_params/assigns_a_newly_created_import_request_as_import_request.yml +48 -48
- data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Librarian/with_valid_params/redirects_to_the_created_import_request.yml +41 -41
- data/spec/cassette_library/ResourceImportFile/should_import_in_background.yml +50 -50
- data/spec/cassette_library/ResourceImportFile/when_its_mode_is_create_/ISBN_import/with_record_not_found/should_record_an_error_message.yml +49 -49
- data/spec/cassette_library/ResourceImportFile/when_its_mode_is_create_/when_it_has_only_isbn/should_be_imported.yml +45 -45
- data/spec/cassette_library/ResourceImportFile/when_its_mode_is_create_/when_it_is_written_in_shift_jis/should_be_imported.yml +50 -50
- data/spec/cassette_library/ResourceImportFile/when_its_mode_is_create_/when_it_is_written_in_utf-8/should_be_imported.yml +48 -48
- data/spec/cassette_library/ResourceImportFile/when_its_mode_is_create_/when_it_is_written_in_utf-8/should_be_searchable_right_after_the_import.yml +512 -0
- data/spec/cassette_library/ResourceImportFile/when_its_mode_is_create_/when_it_is_written_in_utf-8/should_send_message_when_import_is_completed.yml +42 -42
- data/spec/controllers/agent_import_files_controller_spec.rb +5 -5
- data/spec/controllers/agent_import_results_controller_spec.rb +3 -3
- data/spec/controllers/agent_merge_lists_controller_spec.rb +9 -9
- data/spec/controllers/agent_merges_controller_spec.rb +9 -9
- data/spec/controllers/agent_relationship_types_controller_spec.rb +14 -14
- data/spec/controllers/agent_relationships_controller_spec.rb +9 -9
- data/spec/controllers/agent_types_controller_spec.rb +2 -2
- data/spec/controllers/agents_controller_spec.rb +8 -8
- data/spec/controllers/carrier_types_controller_spec.rb +1 -1
- data/spec/controllers/content_types_controller_spec.rb +1 -1
- data/spec/controllers/countries_controller_spec.rb +10 -10
- data/spec/controllers/create_types_controller_spec.rb +2 -2
- data/spec/controllers/creates_controller_spec.rb +7 -7
- data/spec/controllers/donates_controller_spec.rb +9 -9
- data/spec/controllers/form_of_works_controller_spec.rb +2 -2
- data/spec/controllers/frequencies_controller_spec.rb +2 -2
- data/spec/controllers/identifier_types_controller_spec.rb +2 -2
- data/spec/controllers/import_requests_controller_spec.rb +9 -9
- data/spec/controllers/items_controller_spec.rb +13 -7
- data/spec/controllers/languages_controller_spec.rb +8 -8
- data/spec/controllers/licenses_controller_spec.rb +2 -2
- data/spec/controllers/manifestation_relationship_types_controller_spec.rb +10 -10
- data/spec/controllers/manifestation_relationships_controller_spec.rb +9 -9
- data/spec/controllers/manifestations_controller_spec.rb +86 -12
- data/spec/controllers/medium_of_performances_controller_spec.rb +2 -2
- data/spec/controllers/owns_controller_spec.rb +7 -7
- data/spec/controllers/picture_files_controller_spec.rb +9 -9
- data/spec/controllers/produce_types_controller_spec.rb +2 -2
- data/spec/controllers/produces_controller_spec.rb +7 -7
- data/spec/controllers/realize_types_controller_spec.rb +2 -2
- data/spec/controllers/realizes_controller_spec.rb +7 -7
- data/spec/controllers/resource_export_files_controller_spec.rb +9 -15
- data/spec/controllers/resource_import_files_controller_spec.rb +7 -7
- data/spec/controllers/resource_import_results_controller_spec.rb +3 -3
- data/spec/controllers/series_statement_merge_lists_controller_spec.rb +9 -9
- data/spec/controllers/series_statement_merges_controller_spec.rb +9 -9
- data/spec/controllers/series_statements_controller_spec.rb +7 -7
- data/spec/dummy/app/assets/javascripts/application.js +0 -2
- data/spec/dummy/app/controllers/application_controller.rb +10 -6
- data/spec/dummy/app/models/user.rb +4 -4
- data/spec/dummy/config/application.rb +13 -41
- data/spec/dummy/config/environments/development.rb +22 -18
- data/spec/dummy/config/environments/production.rb +46 -34
- data/spec/dummy/config/environments/test.rb +19 -14
- data/spec/dummy/config/initializers/assets.rb +1 -1
- data/spec/dummy/config/initializers/enju_leaf.rb +8 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/db/migrate/20150924115059_create_withdraws.rb +13 -0
- data/spec/dummy/db/migrate/20151213070943_add_translation_table_to_library_group.rb +13 -0
- data/spec/dummy/db/migrate/20151213072705_add_footer_banner_to_library_group.rb +9 -0
- data/spec/dummy/db/schema.rb +27 -2
- data/spec/factories/classification_type.rb +5 -0
- data/spec/factories/reserve.rb +12 -0
- data/spec/factories/role.rb +9 -0
- data/spec/factories/subject.rb +7 -0
- data/spec/factories/subject_heading_type.rb +5 -0
- data/spec/factories/subject_heading_type_has_subject.rb +6 -0
- data/spec/factories/subject_type.rb +5 -0
- data/spec/fixtures/checked_items.yml +4 -4
- data/spec/fixtures/checkouts.yml +12 -12
- data/spec/fixtures/classification_types.yml +1 -1
- data/spec/fixtures/classifications.yml +1 -0
- data/spec/fixtures/manifestations.yml +4 -4
- data/spec/fixtures/reserves.yml +16 -16
- data/spec/fixtures/subjects.yml +79 -0
- data/spec/models/agent_import_file_spec.rb +1 -1
- data/spec/models/manifestation_spec.rb +27 -13
- data/spec/models/resource_export_file_spec.rb +15 -2
- data/spec/models/resource_import_file_spec.rb +29 -9
- data/spec/models/series_statement_merge_list_spec.rb +1 -1
- data/spec/policies/manifestation_policy_spec.rb +24 -0
- data/spec/rails_helper.rb +82 -0
- data/spec/spec_helper.rb +81 -56
- data/spec/support/devise.rb +2 -2
- data/spec/support/vcr.rb +8 -0
- data/spec/views/agent_types/index.html.erb_spec.rb +2 -1
- data/spec/views/agent_types/show.html.erb_spec.rb +1 -0
- data/spec/views/create_types/index.html.erb_spec.rb +2 -1
- data/spec/views/creates/edit.html.erb_spec.rb +0 -3
- data/spec/views/creates/index.html.erb_spec.rb +2 -4
- data/spec/views/creates/new.html.erb_spec.rb +0 -3
- data/spec/views/creates/show.html.erb_spec.rb +0 -3
- data/spec/views/import_requests/index.html.erb_spec.rb +3 -2
- data/spec/views/manifestations/index.html.erb_spec.rb +25 -0
- data/spec/views/manifestations/index.rdf.builder_spec.rb +23 -0
- data/spec/views/manifestations/index.txt.erb_spec.rb +17 -0
- data/spec/views/manifestations/show.html.erb_spec.rb +2 -3
- data/spec/views/manifestations/show.txt.erb_spec.rb +16 -0
- data/spec/views/owns/edit.html.erb_spec.rb +0 -3
- data/spec/views/owns/index.html.erb_spec.rb +2 -4
- data/spec/views/owns/new.html.erb_spec.rb +0 -3
- data/spec/views/owns/show.html.erb_spec.rb +0 -3
- data/spec/views/produce_types/index.html.erb_spec.rb +2 -1
- data/spec/views/produces/edit.html.erb_spec.rb +0 -3
- data/spec/views/produces/index.html.erb_spec.rb +2 -4
- data/spec/views/produces/new.html.erb_spec.rb +0 -3
- data/spec/views/produces/show.html.erb_spec.rb +0 -3
- data/spec/views/realize_types/index.html.erb_spec.rb +2 -1
- data/spec/views/realizes/edit.html.erb_spec.rb +0 -3
- data/spec/views/realizes/index.html.erb_spec.rb +2 -4
- data/spec/views/realizes/new.html.erb_spec.rb +0 -3
- data/spec/views/realizes/show.html.erb_spec.rb +0 -3
- data/spec/views/resource_import_files/index.html.erb_spec.rb +0 -3
- data/spec/views/resource_import_files/{show.html.erb_spec.erb → show.html.erb_spec.rb} +0 -3
- data/spec/views/resource_import_results/index.html.erb_spec.rb +0 -3
- data/spec/views/resource_import_results/{show.html.erb_spec.erb → show.html.erb_spec.rb} +1 -4
- data/spec/views/series_statement_merge_lists/index.html.erb_spec.rb +1 -1
- data/spec/views/series_statement_merges/edit.html.erb_spec.rb +0 -3
- data/spec/views/series_statement_merges/index.html.erb_spec.rb +0 -3
- data/spec/views/series_statement_merges/new.html.erb_spec.rb +0 -3
- data/spec/views/series_statement_merges/show.html.erb_spec.rb +0 -3
- metadata +170 -131
- data/app/models/enju_biblio/ability.rb +0 -238
- data/app/workers/agent_import_file_queue.rb +0 -7
- data/app/workers/resource_export_file_queue.rb +0 -7
- data/app/workers/resource_import_file_queue.rb +0 -7
- data/spec/dummy/config/application.yml +0 -42
data/app/models/manifestation.rb
CHANGED
@@ -1,14 +1,8 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
1
|
class Manifestation < ActiveRecord::Base
|
3
|
-
enju_circulation_manifestation_model if defined?(EnjuCirculation)
|
4
|
-
enju_subject_manifestation_model if defined?(EnjuSubject)
|
5
2
|
enju_manifestation_viewer if defined?(EnjuManifestationViewer)
|
6
3
|
enju_ndl_ndl_search if defined?(EnjuNdl)
|
7
4
|
enju_loc_search if defined?(EnjuLoc)
|
8
5
|
enju_nii_cinii_books if defined?(EnjuNii)
|
9
|
-
enju_export if defined?(EnjuExport)
|
10
|
-
enju_oai if defined?(EnjuOai)
|
11
|
-
enju_question_manifestation_model if defined?(EnjuQuestion)
|
12
6
|
enju_bookmark_manifestation_model if defined?(EnjuBookmark)
|
13
7
|
|
14
8
|
has_many :creates, dependent: :destroy, foreign_key: 'work_id'
|
@@ -45,9 +39,9 @@ class Manifestation < ActiveRecord::Base
|
|
45
39
|
:statement_of_responsibility
|
46
40
|
text :item_identifier do
|
47
41
|
if series_master?
|
48
|
-
root_series_statement.root_manifestation.items.pluck(:item_identifier
|
42
|
+
root_series_statement.root_manifestation.items.pluck(:item_identifier, :binding_item_identifier).flatten.compact
|
49
43
|
else
|
50
|
-
items.pluck(:item_identifier
|
44
|
+
items.pluck(:item_identifier, :binding_item_identifier).flatten.compact
|
51
45
|
end
|
52
46
|
end
|
53
47
|
string :call_number, multiple: true do
|
@@ -67,16 +61,7 @@ class Manifestation < ActiveRecord::Base
|
|
67
61
|
publisher.join('').gsub(/\s/, '').downcase
|
68
62
|
end
|
69
63
|
string :isbn, multiple: true do
|
70
|
-
|
71
|
-
isbn10 = isbn13 = isbn10_dash = isbn13_dash = nil
|
72
|
-
isbn10 = Lisbn.new(i).isbn10
|
73
|
-
isbn13 = Lisbn.new(i).isbn13
|
74
|
-
isbn10_dash = Lisbn.new(isbn10).isbn_with_dash if isbn10
|
75
|
-
isbn13_dash = Lisbn.new(isbn13).isbn_with_dash if isbn13
|
76
|
-
[
|
77
|
-
isbn10, isbn13, isbn10_dash, isbn13_dash
|
78
|
-
]
|
79
|
-
}.flatten
|
64
|
+
isbn_characters
|
80
65
|
end
|
81
66
|
string :issn, multiple: true do
|
82
67
|
if series_statements.exists?
|
@@ -106,9 +91,9 @@ class Manifestation < ActiveRecord::Base
|
|
106
91
|
end
|
107
92
|
string :item_identifier, multiple: true do
|
108
93
|
if series_master?
|
109
|
-
root_series_statement.root_manifestation.items.pluck(:item_identifier
|
94
|
+
root_series_statement.root_manifestation.items.pluck(:item_identifier, :binding_item_identifier).flatten.compact
|
110
95
|
else
|
111
|
-
items.pluck(:item_identifier
|
96
|
+
items.pluck(:item_identifier, :binding_item_identifier).flatten.compact
|
112
97
|
end
|
113
98
|
end
|
114
99
|
string :shelf, multiple: true do
|
@@ -181,9 +166,7 @@ class Manifestation < ActiveRecord::Base
|
|
181
166
|
end
|
182
167
|
end
|
183
168
|
text :isbn do # 前方一致検索のためtext指定を追加
|
184
|
-
|
185
|
-
[Lisbn.new(i).isbn10, Lisbn.new(i).isbn13]
|
186
|
-
}.flatten
|
169
|
+
isbn_characters
|
187
170
|
end
|
188
171
|
text :issn do # 前方一致検索のためtext指定を追加
|
189
172
|
if series_statements.exists?
|
@@ -254,7 +237,7 @@ class Manifestation < ActiveRecord::Base
|
|
254
237
|
manifestation.index_series_statement
|
255
238
|
Sunspot.commit
|
256
239
|
end
|
257
|
-
|
240
|
+
strip_attributes only: [:manifestation_identifier, :pub_date, :original_title]
|
258
241
|
paginates_per 10
|
259
242
|
|
260
243
|
attr_accessor :during_import, :parent_id
|
@@ -378,6 +361,7 @@ class Manifestation < ActiveRecord::Base
|
|
378
361
|
|
379
362
|
def extract_text
|
380
363
|
return nil if attachment.path.nil?
|
364
|
+
return nil unless ENV['ENJU_EXTRACT_TEXT'] == 'true'
|
381
365
|
if ENV['ENJU_STORAGE'] == 's3'
|
382
366
|
body = Faraday.get(attachment.expiring_url(10)).body.force_encoding('UTF-8')
|
383
367
|
else
|
@@ -532,7 +516,7 @@ class Manifestation < ActiveRecord::Base
|
|
532
516
|
end
|
533
517
|
end
|
534
518
|
|
535
|
-
def self.
|
519
|
+
def self.csv_header(role, options = {col_sep: "\t", role: :Guest})
|
536
520
|
header = %w(
|
537
521
|
manifestation_id
|
538
522
|
original_title
|
@@ -540,84 +524,183 @@ class Manifestation < ActiveRecord::Base
|
|
540
524
|
contributor
|
541
525
|
publisher
|
542
526
|
pub_date
|
527
|
+
statement_of_responsibility
|
543
528
|
manifestation_price
|
544
529
|
manifestation_created_at
|
545
530
|
manifestation_updated_at
|
546
531
|
manifestation_identifier
|
532
|
+
access_address
|
533
|
+
note
|
547
534
|
)
|
548
|
-
|
549
|
-
|
550
|
-
|
535
|
+
|
536
|
+
header += IdentifierType.order(:position).pluck(:name)
|
537
|
+
if defined?(EnjuSubject)
|
538
|
+
header += SubjectHeadingType.order(:position).pluck(:name).map{|type| "subject:#{type}"}
|
539
|
+
header += ClassificationType.order(:position).pluck(:name).map{|type| "classification:#{type}"}
|
551
540
|
end
|
552
|
-
|
553
|
-
header += identifiers
|
541
|
+
|
554
542
|
header += %w(
|
555
543
|
item_id
|
556
544
|
item_identifier
|
557
545
|
call_number
|
558
|
-
|
546
|
+
)
|
547
|
+
case role.to_sym
|
548
|
+
when :Administrator, :Librarian
|
549
|
+
header << "item_price"
|
550
|
+
end
|
551
|
+
header += %w(
|
559
552
|
acquired_at
|
560
553
|
accepted_at
|
561
|
-
|
562
|
-
|
554
|
+
)
|
555
|
+
case role.to_sym
|
556
|
+
when :Administrator, :Librarian
|
557
|
+
header += %w(
|
558
|
+
bookstore
|
559
|
+
budget_type
|
560
|
+
)
|
561
|
+
end
|
562
|
+
header += %w(
|
563
563
|
circulation_status
|
564
564
|
shelf
|
565
565
|
library
|
566
566
|
item_created_at
|
567
567
|
item_updated_at
|
568
568
|
)
|
569
|
+
|
570
|
+
header.to_csv(options)
|
571
|
+
end
|
572
|
+
|
573
|
+
def to_csv(options = {format: :txt, role: :Guest})
|
569
574
|
lines = []
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
item_lines <<
|
577
|
-
|
578
|
-
item_lines <<
|
579
|
-
|
580
|
-
|
581
|
-
item_lines <<
|
582
|
-
|
583
|
-
item_lines <<
|
584
|
-
|
585
|
-
|
586
|
-
|
575
|
+
if items.exists?
|
576
|
+
items.includes(shelf: :library).each do |i|
|
577
|
+
item_lines = []
|
578
|
+
item_lines << id
|
579
|
+
item_lines << original_title
|
580
|
+
if creators.exists?
|
581
|
+
item_lines << creators.pluck(:full_name).join("//")
|
582
|
+
else
|
583
|
+
item_lines << nil
|
584
|
+
end
|
585
|
+
if contributors.exists?
|
586
|
+
item_lines << contributors.pluck(:full_name).join("//")
|
587
|
+
else
|
588
|
+
item_lines << nil
|
589
|
+
end
|
590
|
+
if publishers.exists?
|
591
|
+
item_lines << publishers.pluck(:full_name).join("//")
|
592
|
+
else
|
593
|
+
item_lines << nil
|
594
|
+
end
|
595
|
+
item_lines << pub_date
|
596
|
+
item_lines << statement_of_responsibility
|
597
|
+
item_lines << price
|
598
|
+
item_lines << created_at
|
599
|
+
item_lines << updated_at
|
600
|
+
item_lines << manifestation_identifier
|
601
|
+
item_lines << access_address
|
602
|
+
item_lines << note
|
603
|
+
|
604
|
+
IdentifierType.order(:position).pluck(:name).each do |identifier_type|
|
605
|
+
if identifier_contents(identifier_type.to_sym).first
|
606
|
+
item_lines << identifier_contents(identifier_type.to_sym).first
|
607
|
+
else
|
608
|
+
item_lines << nil
|
587
609
|
end
|
588
|
-
|
589
|
-
|
590
|
-
|
610
|
+
end
|
611
|
+
if defined?(EnjuSubject)
|
612
|
+
SubjectHeadingType.order(:position).each do |subject_heading_type|
|
613
|
+
if subjects.exists?
|
614
|
+
item_lines << subjects.where(subject_heading_type: subject_heading_type).pluck(:term).join('//')
|
615
|
+
else
|
616
|
+
item_lines << nil
|
617
|
+
end
|
618
|
+
end
|
619
|
+
ClassificationType.order(:position).each do |classification_type|
|
620
|
+
if classifications.exists?
|
621
|
+
item_lines << classifications.where(classification_type: classification_type).pluck(:category).join('//')
|
622
|
+
else
|
623
|
+
item_lines << nil
|
624
|
+
end
|
625
|
+
end
|
626
|
+
end
|
627
|
+
|
628
|
+
item_lines << i.id
|
629
|
+
item_lines << i.item_identifier
|
630
|
+
item_lines << i.call_number
|
631
|
+
case options[:role].to_sym
|
632
|
+
when :Administrator, :Librarian
|
591
633
|
item_lines << i.price
|
592
|
-
|
593
|
-
|
634
|
+
end
|
635
|
+
item_lines << i.acquired_at
|
636
|
+
item_lines << i.accept.try(:created_at)
|
637
|
+
case options[:role].to_sym
|
638
|
+
when :Administrator, :Librarian
|
594
639
|
item_lines << i.bookstore.try(:name)
|
595
640
|
item_lines << i.budget_type.try(:name)
|
596
|
-
item_lines << i.circulation_status.try(:name)
|
597
|
-
item_lines << i.shelf.name
|
598
|
-
item_lines << i.shelf.library.name
|
599
|
-
item_lines << i.created_at
|
600
|
-
item_lines << i.updated_at
|
601
|
-
lines << item_lines
|
602
641
|
end
|
642
|
+
item_lines << i.circulation_status.try(:name)
|
643
|
+
item_lines << i.shelf.name
|
644
|
+
item_lines << i.shelf.library.name
|
645
|
+
item_lines << i.created_at
|
646
|
+
item_lines << i.updated_at
|
647
|
+
lines << item_lines
|
648
|
+
end
|
649
|
+
else
|
650
|
+
line = []
|
651
|
+
line << id
|
652
|
+
line << original_title
|
653
|
+
if creators.exists?
|
654
|
+
line << creators.pluck(:full_name).join("//")
|
603
655
|
else
|
604
|
-
line
|
605
|
-
|
606
|
-
|
607
|
-
line <<
|
608
|
-
|
609
|
-
line <<
|
610
|
-
|
611
|
-
|
612
|
-
line <<
|
613
|
-
|
614
|
-
line <<
|
615
|
-
|
616
|
-
|
656
|
+
line << nil
|
657
|
+
end
|
658
|
+
if contributors.exists?
|
659
|
+
line << contributors.pluck(:full_name).join("//")
|
660
|
+
else
|
661
|
+
line << nil
|
662
|
+
end
|
663
|
+
if publishers.exists?
|
664
|
+
line << publishers.pluck(:full_name).join("//")
|
665
|
+
else
|
666
|
+
line << nil
|
667
|
+
end
|
668
|
+
line << pub_date
|
669
|
+
line << statement_of_responsibility
|
670
|
+
line << price
|
671
|
+
line << created_at
|
672
|
+
line << updated_at
|
673
|
+
line << manifestation_identifier
|
674
|
+
line << access_address
|
675
|
+
line << note
|
676
|
+
|
677
|
+
IdentifierType.order(:position).pluck(:name).each do |identifier_type|
|
678
|
+
if identifier_contents(identifier_type.to_sym).first
|
679
|
+
line << identifier_contents(identifier_type.to_sym).first
|
680
|
+
else
|
681
|
+
line << nil
|
617
682
|
end
|
618
|
-
lines << line
|
619
683
|
end
|
684
|
+
if defined?(EnjuSubject)
|
685
|
+
SubjectHeadingType.order(:position).each do |subject_heading_type|
|
686
|
+
if subjects.exists?
|
687
|
+
line << subjects.where(subject_heading_type: subject_heading_type).pluck(:term).join('//')
|
688
|
+
else
|
689
|
+
line << nil
|
690
|
+
end
|
691
|
+
end
|
692
|
+
ClassificationType.order(:position).each do |classification_type|
|
693
|
+
if classifications.exists?
|
694
|
+
line << classifications.where(classification_type: classification_type).pluck(:category).join('//')
|
695
|
+
else
|
696
|
+
line << nil
|
697
|
+
end
|
698
|
+
end
|
699
|
+
end
|
700
|
+
|
701
|
+
lines << line
|
620
702
|
end
|
703
|
+
|
621
704
|
if options[:format] == :txt
|
622
705
|
lines.map{|i| i.to_csv(col_sep: "\t")}.join
|
623
706
|
else
|
@@ -625,9 +708,31 @@ class Manifestation < ActiveRecord::Base
|
|
625
708
|
end
|
626
709
|
end
|
627
710
|
|
711
|
+
def self.export(options = {format: :txt, role: :Guest})
|
712
|
+
file = ''
|
713
|
+
file += Manifestation.csv_header(options[:role], col_sep: "\t") if options[:format].to_sym == :txt
|
714
|
+
Manifestation.find_each do |manifestation|
|
715
|
+
file += manifestation.to_csv(options)
|
716
|
+
end
|
717
|
+
file
|
718
|
+
end
|
719
|
+
|
628
720
|
def root_series_statement
|
629
721
|
series_statements.where(root_manifestation_id: id).first
|
630
722
|
end
|
723
|
+
|
724
|
+
def isbn_characters
|
725
|
+
identifier_contents(:isbn).map{|i|
|
726
|
+
isbn10 = isbn13 = isbn10_dash = isbn13_dash = nil
|
727
|
+
isbn10 = Lisbn.new(i).isbn10
|
728
|
+
isbn13 = Lisbn.new(i).isbn13
|
729
|
+
isbn10_dash = Lisbn.new(isbn10).isbn_with_dash if isbn10
|
730
|
+
isbn13_dash = Lisbn.new(isbn13).isbn_with_dash if isbn13
|
731
|
+
[
|
732
|
+
isbn10, isbn13, isbn10_dash, isbn13_dash
|
733
|
+
]
|
734
|
+
}.flatten
|
735
|
+
end
|
631
736
|
end
|
632
737
|
|
633
738
|
# == Schema Information
|
data/app/models/picture_file.rb
CHANGED
@@ -23,7 +23,7 @@ class PictureFile < ActiveRecord::Base
|
|
23
23
|
default_scope { order('picture_files.position') }
|
24
24
|
# http://railsforum.com/viewtopic.php?id=11615
|
25
25
|
acts_as_list scope: 'picture_attachable_type=\'#{picture_attachable_type}\''
|
26
|
-
|
26
|
+
strip_attributes only: :picture_attachable_type
|
27
27
|
|
28
28
|
paginates_per 10
|
29
29
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
class ResourceExportFile < ActiveRecord::Base
|
2
2
|
include Statesman::Adapters::ActiveRecordQueries
|
3
3
|
include ExportFile
|
4
|
-
enju_export_file_model
|
5
4
|
|
6
5
|
if ENV['ENJU_STORAGE'] == 's3'
|
7
6
|
has_attached_file :resource_export, storage: :s3,
|
@@ -29,9 +28,12 @@ class ResourceExportFile < ActiveRecord::Base
|
|
29
28
|
|
30
29
|
def export!
|
31
30
|
transition_to!(:started)
|
31
|
+
role_name = user.try(:role).try(:name)
|
32
32
|
tempfile = Tempfile.new(['resource_export_file_', '.txt'])
|
33
|
-
|
34
|
-
|
33
|
+
tempfile.puts(Manifestation.csv_header(role_name, col_sep: "\t"))
|
34
|
+
Manifestation.find_each do |manifestation|
|
35
|
+
tempfile.puts(manifestation.to_csv(format: :txt, role: role_name))
|
36
|
+
end
|
35
37
|
tempfile.close
|
36
38
|
self.resource_export = File.new(tempfile.path, "r")
|
37
39
|
if save
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
1
|
class ResourceImportFile < ActiveRecord::Base
|
3
2
|
include Statesman::Adapters::ActiveRecordQueries
|
4
3
|
include ImportFile
|
@@ -34,7 +33,6 @@ class ResourceImportFile < ActiveRecord::Base
|
|
34
33
|
has_many :resource_import_results
|
35
34
|
has_many :resource_import_file_transitions
|
36
35
|
|
37
|
-
enju_import_file_model
|
38
36
|
attr_accessor :mode, :library_id
|
39
37
|
|
40
38
|
def state_machine
|
@@ -181,21 +179,21 @@ class ResourceImportFile < ActiveRecord::Base
|
|
181
179
|
end
|
182
180
|
import_result.manifestation = manifestation
|
183
181
|
|
184
|
-
if manifestation
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
182
|
+
if manifestation
|
183
|
+
if item_identifier.present? or row['shelf'].present? or row['call_number'].present?
|
184
|
+
import_result.item = create_item(row, manifestation)
|
185
|
+
else
|
186
|
+
if manifestation.fulltext_content?
|
187
|
+
item = create_item(row, manifestation)
|
188
|
+
item.circulation_status = CirculationStatus.where(name: 'Available On Shelf').first
|
189
|
+
begin
|
190
|
+
item.acquired_at = Time.zone.parse(row['acquired_at'].to_s.strip)
|
191
|
+
rescue ArgumentError
|
192
|
+
end
|
194
193
|
end
|
195
|
-
|
196
|
-
item.save!
|
197
|
-
manifestation.items << item
|
194
|
+
num[:failed] += 1
|
198
195
|
end
|
196
|
+
else
|
199
197
|
num[:failed] += 1
|
200
198
|
end
|
201
199
|
|
@@ -452,7 +450,8 @@ class ResourceImportFile < ActiveRecord::Base
|
|
452
450
|
dummy
|
453
451
|
)
|
454
452
|
if defined?(EnjuSubject)
|
455
|
-
header_columns +=
|
453
|
+
header_columns += ClassificationType.order(:position).pluck(:name).map{|c| "classification:#{c}"}
|
454
|
+
header_columns += SubjectHeadingType.order(:position).pluck(:name).map{|s| "subject:#{s}"}
|
456
455
|
end
|
457
456
|
header = file.first
|
458
457
|
ignored_columns = header - header_columns
|
@@ -469,52 +468,37 @@ class ResourceImportFile < ActiveRecord::Base
|
|
469
468
|
|
470
469
|
def import_subject(row)
|
471
470
|
subjects = []
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
v.each do |term|
|
480
|
-
subject = Subject.new(term: term)
|
481
|
-
subject.subject_heading_type = subject_heading_type
|
482
|
-
subject.subject_type = SubjectType.where(name: 'concept').first
|
483
|
-
subject.save!
|
484
|
-
subjects << subject
|
485
|
-
end
|
486
|
-
else
|
487
|
-
subject = Subject.new(term: v)
|
471
|
+
SubjectHeadingType.order(:position).pluck(:name).map{|s| "subject:#{s}"}.each do |column_name|
|
472
|
+
type = column_name.split(':').last
|
473
|
+
subject_list = row[column_name].to_s.split('//')
|
474
|
+
subject_list.map{|value|
|
475
|
+
subject_heading_type = SubjectHeadingType.where(name: type).first
|
476
|
+
next unless subject_heading_type
|
477
|
+
subject = Subject.new(term: value)
|
488
478
|
subject.subject_heading_type = subject_heading_type
|
479
|
+
# TODO: Subject typeの設定
|
489
480
|
subject.subject_type = SubjectType.where(name: 'concept').first
|
490
481
|
subject.save!
|
491
482
|
subjects << subject
|
492
|
-
|
493
|
-
|
483
|
+
}
|
484
|
+
end
|
494
485
|
subjects
|
495
486
|
end
|
496
487
|
|
497
488
|
def import_classification(row)
|
498
489
|
classifications = []
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
classification = Classification.new(category: category)
|
507
|
-
classification.classification_type = classification_type
|
508
|
-
classification.save!
|
509
|
-
classifications << classification
|
510
|
-
end
|
511
|
-
else
|
512
|
-
classification = Classification.new(category: v)
|
490
|
+
ClassificationType.order(:position).pluck(:name).map{|c| "classification:#{c}"}.each do |column_name|
|
491
|
+
type = column_name.split(':').last
|
492
|
+
classification_list = row[column_name].to_s.split('//')
|
493
|
+
classification_list.map{|value|
|
494
|
+
classification_type = ClassificationType.where(name: type).first
|
495
|
+
next unless classification_type
|
496
|
+
classification = Classification.new(category: value)
|
513
497
|
classification.classification_type = classification_type
|
514
498
|
classification.save!
|
515
499
|
classifications << classification
|
516
|
-
|
517
|
-
|
500
|
+
}
|
501
|
+
end
|
518
502
|
classifications
|
519
503
|
end
|
520
504
|
|
@@ -6,6 +6,8 @@ class SeriesStatement < ActiveRecord::Base
|
|
6
6
|
validates_presence_of :original_title
|
7
7
|
validates :root_manifestation_id, uniqueness: true, allow_nil: true
|
8
8
|
before_save :create_root_series_statement
|
9
|
+
after_save :reindex
|
10
|
+
after_destroy :reindex
|
9
11
|
|
10
12
|
acts_as_list
|
11
13
|
searchable do
|
@@ -19,10 +21,15 @@ class SeriesStatement < ActiveRecord::Base
|
|
19
21
|
end
|
20
22
|
|
21
23
|
attr_accessor :selected
|
22
|
-
|
24
|
+
strip_attributes only: :original_title
|
23
25
|
|
24
26
|
paginates_per 10
|
25
27
|
|
28
|
+
def reindex
|
29
|
+
manifestation.try(:index)
|
30
|
+
root_manifestation.try(:index)
|
31
|
+
end
|
32
|
+
|
26
33
|
def titles
|
27
34
|
[
|
28
35
|
original_title,
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class AgentImportFilePolicy < ApplicationPolicy
|
2
|
+
def index?
|
3
|
+
true if user.try(:has_role?, 'Librarian')
|
4
|
+
end
|
5
|
+
|
6
|
+
def show?
|
7
|
+
true if user.try(:has_role?, 'Librarian')
|
8
|
+
end
|
9
|
+
|
10
|
+
def create?
|
11
|
+
true if user.try(:has_role?, 'Librarian')
|
12
|
+
end
|
13
|
+
|
14
|
+
def update?
|
15
|
+
true if user.try(:has_role?, 'Librarian')
|
16
|
+
end
|
17
|
+
|
18
|
+
def destroy?
|
19
|
+
true if user.try(:has_role?, 'Librarian')
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class AgentImportResultPolicy < ApplicationPolicy
|
2
|
+
def index?
|
3
|
+
true if user.try(:has_role?, 'Librarian')
|
4
|
+
end
|
5
|
+
|
6
|
+
def show?
|
7
|
+
true if user.try(:has_role?, 'Librarian')
|
8
|
+
end
|
9
|
+
|
10
|
+
def create?
|
11
|
+
false
|
12
|
+
end
|
13
|
+
|
14
|
+
def update?
|
15
|
+
false
|
16
|
+
end
|
17
|
+
|
18
|
+
def destroy?
|
19
|
+
false
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class AgentMergeListPolicy < ApplicationPolicy
|
2
|
+
def index?
|
3
|
+
true if user.try(:has_role?, 'Librarian')
|
4
|
+
end
|
5
|
+
|
6
|
+
def show?
|
7
|
+
true if user.try(:has_role?, 'Librarian')
|
8
|
+
end
|
9
|
+
|
10
|
+
def create?
|
11
|
+
true if user.try(:has_role?, 'Librarian')
|
12
|
+
end
|
13
|
+
|
14
|
+
def edit?
|
15
|
+
true if user.try(:has_role?, 'Librarian')
|
16
|
+
end
|
17
|
+
|
18
|
+
def update?
|
19
|
+
true if user.try(:has_role?, 'Librarian')
|
20
|
+
end
|
21
|
+
|
22
|
+
def destroy?
|
23
|
+
true if user.try(:has_role?, 'Librarian')
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class AgentMergePolicy < ApplicationPolicy
|
2
|
+
def index?
|
3
|
+
true if user.try(:has_role?, 'Librarian')
|
4
|
+
end
|
5
|
+
|
6
|
+
def show?
|
7
|
+
true if user.try(:has_role?, 'Librarian')
|
8
|
+
end
|
9
|
+
|
10
|
+
def create?
|
11
|
+
true if user.try(:has_role?, 'Librarian')
|
12
|
+
end
|
13
|
+
|
14
|
+
def edit?
|
15
|
+
true if user.try(:has_role?, 'Librarian')
|
16
|
+
end
|
17
|
+
|
18
|
+
def update?
|
19
|
+
true if user.try(:has_role?, 'Librarian')
|
20
|
+
end
|
21
|
+
|
22
|
+
def destroy?
|
23
|
+
true if user.try(:has_role?, 'Librarian')
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class AgentPolicy < ApplicationPolicy
|
2
|
+
def index?
|
3
|
+
true
|
4
|
+
end
|
5
|
+
|
6
|
+
def show?
|
7
|
+
case user.try(:role).try(:name)
|
8
|
+
when 'Administrator'
|
9
|
+
true
|
10
|
+
when 'Librarian'
|
11
|
+
true if record.required_role_id <= 3
|
12
|
+
when 'User'
|
13
|
+
true if record.required_role_id <= 2
|
14
|
+
else
|
15
|
+
true if record.required_role_id <= 1
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def create?
|
20
|
+
true if user.try(:has_role?, 'Librarian')
|
21
|
+
end
|
22
|
+
|
23
|
+
def update?
|
24
|
+
true if user.try(:has_role?, 'Librarian')
|
25
|
+
end
|
26
|
+
|
27
|
+
def destroy?
|
28
|
+
true if user.try(:has_role?, 'Librarian')
|
29
|
+
end
|
30
|
+
end
|