enju_leaf 1.1.0.rc12 → 1.1.0.rc13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/enju.css +0 -1
- data/app/controllers/my_accounts_controller.rb +26 -18
- data/app/controllers/page_controller.rb +6 -6
- data/app/controllers/profiles_controller.rb +155 -0
- data/app/controllers/roles_controller.rb +5 -5
- data/app/controllers/user_export_files_controller.rb +100 -0
- data/app/controllers/user_groups_controller.rb +11 -11
- data/app/controllers/user_import_files_controller.rb +22 -11
- data/app/controllers/user_import_results_controller.rb +1 -1
- data/app/mailers/notifier.rb +7 -7
- data/app/models/enju_leaf/ability.rb +14 -13
- data/app/models/profile.rb +63 -16
- data/app/models/role.rb +2 -2
- data/app/models/user_export_file.rb +52 -0
- data/app/models/user_export_file_state_machine.rb +15 -0
- data/app/models/user_export_file_transition.rb +20 -0
- data/app/models/user_group.rb +3 -3
- data/app/models/user_has_role.rb +2 -2
- data/app/models/user_import_file.rb +139 -53
- data/app/views/kaminari/_first_page.html.erb +1 -1
- data/app/views/kaminari/_last_page.html.erb +1 -1
- data/app/views/kaminari/_next_page.html.erb +1 -1
- data/app/views/kaminari/_page.html.erb +1 -1
- data/app/views/kaminari/_prev_page.html.erb +1 -1
- data/app/views/kaminari/enju_leaf_mobile/_next_page.html.erb +1 -1
- data/app/views/kaminari/enju_leaf_mobile/_page.html.erb +1 -1
- data/app/views/kaminari/enju_leaf_mobile/_prev_page.html.erb +1 -1
- data/app/views/layouts/application.html.erb +4 -4
- data/app/views/my_accounts/_edit_credential.html.erb +67 -59
- data/app/views/my_accounts/edit.html.erb +6 -46
- data/app/views/my_accounts/show.html.erb +8 -8
- data/app/views/page/_add.html.erb +2 -2
- data/app/views/page/_footer.html.erb +3 -2
- data/app/views/page/_footer.mobile.erb +1 -1
- data/app/views/page/_header.html.erb +4 -4
- data/app/views/page/_include.html.erb +1 -1
- data/app/views/page/_index.html.erb +8 -8
- data/app/views/page/_index.mobile.erb +4 -4
- data/app/views/page/_menu.html.erb +9 -6
- data/app/views/page/_msie_acceralator.html.erb +1 -1
- data/app/views/page/_position.html.erb +2 -2
- data/app/views/page/_search_form.html.erb +2 -2
- data/app/views/page/_search_form.mobile.erb +2 -2
- data/app/views/page/_select_locale.html.erb +2 -2
- data/app/views/page/about.en.html.erb +2 -2
- data/app/views/page/about.ja.html.erb +2 -2
- data/app/views/page/advanced_search.html.erb +8 -8
- data/app/views/page/configuration.html.erb +5 -3
- data/app/views/page/export.html.erb +7 -17
- data/app/views/page/import.html.erb +1 -4
- data/app/views/page/index.html.erb +2 -2
- data/app/views/page/msie_acceralator.builder +1 -1
- data/app/views/page/opensearch.builder +2 -2
- data/app/views/profiles/_edit_credential.html.erb +78 -0
- data/app/views/profiles/_edit_profile.html.erb +42 -0
- data/app/views/{users → profiles}/_form.html.erb +0 -0
- data/app/views/{users → profiles}/_show.html.erb +0 -0
- data/app/views/profiles/edit.html.erb +36 -0
- data/app/views/profiles/index.html.erb +61 -0
- data/app/views/{users → profiles}/new.html.erb +34 -36
- data/app/views/{users → profiles}/show.html.erb +24 -22
- data/app/views/{users → profiles}/show.mobile.erb +0 -0
- data/app/views/roles/_form.html.erb +1 -1
- data/app/views/roles/edit.html.erb +1 -1
- data/app/views/roles/index.html.erb +2 -2
- data/app/views/roles/new.html.erb +1 -1
- data/app/views/roles/show.html.erb +1 -1
- data/app/views/user_export_files/_form.html.erb +22 -0
- data/app/views/user_export_files/edit.html.erb +6 -0
- data/app/views/user_export_files/index.html.erb +44 -0
- data/app/views/user_export_files/new.html.erb +16 -0
- data/app/views/user_export_files/show.html.erb +31 -0
- data/app/views/user_groups/_form.html.erb +5 -5
- data/app/views/user_groups/edit.html.erb +1 -1
- data/app/views/user_groups/index.html.erb +14 -8
- data/app/views/user_groups/new.html.erb +1 -1
- data/app/views/user_groups/show.html.erb +3 -3
- data/app/views/user_import_files/index.html.erb +11 -10
- data/app/views/user_import_files/new.html.erb +15 -3
- data/app/views/user_import_files/show.html.erb +13 -3
- data/app/views/user_import_results/index.html.erb +7 -7
- data/app/views/user_import_results/{index.tsv.erb → index.txt.erb} +1 -1
- data/app/views/user_import_results/show.html.erb +2 -2
- data/app/workers/user_export_file_queue.rb +7 -0
- data/config/initializers/mime_types.rb +1 -1
- data/config/locales/devise.en.yml +19 -18
- data/config/locales/devise.ja.yml +45 -42
- data/config/locales/en.yml +214 -0
- data/config/locales/ja.yml +10 -6
- data/config/locales/translation_en.yml +34 -5
- data/config/locales/translation_ja.yml +35 -6
- data/config/routes.rb +4 -7
- data/db/migrate/20130221154434_add_additional_attributes_to_user.rb +0 -9
- data/db/migrate/20140122054321_create_profiles.rb +1 -1
- data/db/migrate/20140709113413_create_user_export_files.rb +11 -0
- data/db/migrate/20140709113905_create_user_export_file_transitions.rb +14 -0
- data/db/migrate/20140720170714_add_default_library_id_to_user_import_file.rb +5 -0
- data/db/migrate/20140720170735_add_default_user_group_id_to_user_import_file.rb +5 -0
- data/db/migrate/20140811031145_add_expired_at_to_profile.rb +5 -0
- data/lib/enju_leaf/calculate_stat.rb +9 -0
- data/lib/enju_leaf/controller.rb +1 -1
- data/lib/enju_leaf/export_file.rb +26 -0
- data/lib/enju_leaf/import_file.rb +25 -0
- data/lib/enju_leaf/master_model.rb +15 -6
- data/lib/enju_leaf/url_validator.rb +4 -2
- data/lib/enju_leaf/user.rb +74 -68
- data/lib/enju_leaf/version.rb +1 -1
- data/lib/enju_leaf.rb +23 -24
- data/lib/generators/enju_leaf/quick_install/quick_install_generator.rb +2 -1
- data/lib/generators/enju_leaf/setup/setup_generator.rb +6 -0
- data/lib/generators/enju_leaf/setup/templates/db/fixtures/user_groups.yml +1 -1
- data/lib/generators/enju_leaf/setup/templates/db/seeds.rb +5 -4
- data/lib/tasks/enju_leaf_tasks.rake +18 -9
- data/lib/tasks/profile.rb +15 -0
- data/spec/controllers/my_accounts_controller_spec.rb +61 -43
- data/spec/controllers/page_controller_spec.rb +20 -20
- data/spec/controllers/profiles_controller_spec.rb +530 -0
- data/spec/controllers/roles_controller_spec.rb +19 -19
- data/spec/controllers/user_export_files_controller_spec.rb +297 -0
- data/spec/controllers/user_groups_controller_spec.rb +48 -48
- data/spec/controllers/user_import_files_controller_spec.rb +45 -41
- data/spec/controllers/user_import_results_controller_spec.rb +9 -9
- data/spec/dummy/app/models/user.rb +3 -0
- data/spec/dummy/config/application.rb +3 -1
- data/spec/dummy/config/environments/test.rb +2 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/{001_create_patrons.rb → 001_create_agents.rb} +1 -2
- data/spec/dummy/db/migrate/005_create_manifestations.rb +5 -17
- data/spec/dummy/db/migrate/006_create_items.rb +2 -3
- data/spec/dummy/db/migrate/032_create_checkins.rb +17 -0
- data/spec/dummy/db/migrate/033_create_checkouts.rb +25 -0
- data/spec/dummy/db/migrate/035_create_reserves.rb +27 -0
- data/spec/dummy/db/migrate/055_create_bookmarks.rb +22 -0
- data/spec/dummy/db/migrate/059_create_libraries.rb +5 -1
- data/spec/dummy/db/migrate/069_create_shelves.rb +5 -1
- data/spec/dummy/db/migrate/080_create_library_groups.rb +0 -2
- data/spec/dummy/db/migrate/113_create_events.rb +23 -0
- data/spec/dummy/db/migrate/114_create_event_categories.rb +16 -0
- data/spec/dummy/db/migrate/121_create_checked_items.rb +17 -0
- data/spec/dummy/db/migrate/127_create_use_restrictions.rb +16 -0
- data/spec/dummy/db/migrate/129_create_item_has_use_restrictions.rb +16 -0
- data/spec/dummy/db/migrate/130_create_request_status_types.rb +5 -1
- data/spec/dummy/db/migrate/131_create_request_types.rb +5 -1
- data/spec/dummy/db/migrate/132_create_circulation_statuses.rb +16 -0
- data/spec/dummy/db/migrate/149_create_message_templates.rb +18 -0
- data/spec/dummy/db/migrate/154_create_messages.rb +23 -0
- data/spec/dummy/db/migrate/20080819181903_create_message_requests.rb +18 -0
- data/spec/dummy/db/migrate/{20080905191442_create_patron_types.rb → 20080905191442_create_agent_types.rb} +1 -1
- data/spec/dummy/db/migrate/{20081028083142_create_patron_import_files.rb → 20081028083142_create_agent_import_files.rb} +2 -4
- data/spec/dummy/db/migrate/20081028083208_create_resource_import_files.rb +1 -3
- data/spec/dummy/db/migrate/20081030023412_create_checkout_types.rb +17 -0
- data/spec/dummy/db/migrate/20081030023518_create_user_group_has_checkout_types.rb +25 -0
- data/spec/dummy/db/migrate/20081030023615_create_carrier_type_has_checkout_types.rb +18 -0
- data/spec/dummy/db/migrate/20081212075554_create_checkout_stat_has_manifestations.rb +17 -0
- data/spec/dummy/db/migrate/20081212080038_create_manifestation_checkout_stats.rb +16 -0
- data/spec/dummy/db/migrate/20081212151614_create_bookmark_stats.rb +16 -0
- data/spec/dummy/db/migrate/20081212151820_create_bookmark_stat_has_manifestations.rb +13 -0
- data/spec/dummy/db/migrate/20081215094302_create_user_checkout_stats.rb +16 -0
- data/spec/dummy/db/migrate/20081215094955_create_checkout_stat_has_users.rb +17 -0
- data/spec/dummy/db/migrate/20081216190517_create_reserve_stat_has_manifestations.rb +17 -0
- data/spec/dummy/db/migrate/20081216190724_create_manifestation_reserve_stats.rb +16 -0
- data/spec/dummy/db/migrate/20081220023628_create_user_reserve_stats.rb +16 -0
- data/spec/dummy/db/migrate/20081220034117_create_reserve_stat_has_users.rb +17 -0
- data/spec/dummy/db/migrate/20090321130448_add_completed_at_to_user_checkout_stat.rb +27 -0
- data/spec/dummy/db/migrate/{20090812151902_create_patron_relationship_types.rb → 20090812151902_create_agent_relationship_types.rb} +1 -1
- data/spec/dummy/db/migrate/20090831220301_create_lending_policies.rb +21 -0
- data/spec/dummy/db/migrate/20100129142347_create_import_requests.rb +0 -1
- data/spec/dummy/db/migrate/20100222124420_add_allow_bookmark_external_url_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20100525171356_acts_as_taggable_on_migration.rb +30 -0
- data/spec/dummy/db/migrate/{20100606073747_create_patron_relationships.rb → 20100606073747_create_agent_relationships.rb} +1 -1
- data/spec/dummy/db/migrate/{20100814091104_add_position_to_patron_relationship.rb → 20100814091104_add_position_to_agent_relationship.rb} +1 -1
- data/spec/dummy/db/migrate/{20100925074559_create_patron_import_results.rb → 20100925074559_create_agent_import_results.rb} +1 -1
- data/spec/dummy/db/migrate/{20110301121550_add_birth_date_and_death_date_to_patron.rb → 20110301121550_add_birth_date_and_death_date_to_agent.rb} +1 -1
- data/spec/dummy/db/migrate/20110301134521_add_expire_date_to_reserve.rb +9 -0
- data/spec/dummy/db/migrate/20110328130826_add_current_checkout_count_to_user_group_has_checkout_type.rb +9 -0
- data/spec/dummy/db/migrate/20110618091240_add_periodical_to_series_statement.rb +1 -1
- data/spec/dummy/db/migrate/20110621093332_remove_expire_date_from_reserve.rb +9 -0
- data/spec/dummy/db/migrate/20110913115320_add_lft_and_rgt_to_message.rb +11 -0
- data/spec/dummy/db/migrate/20111020063828_remove_dsbl_from_library_group.rb +11 -0
- data/spec/dummy/db/migrate/20111217234412_add_save_checkout_history_to_user.rb +5 -0
- data/spec/dummy/db/migrate/20111218002349_add_checkout_icalendar_token_to_user.rb +6 -0
- data/spec/dummy/db/migrate/20111231145823_add_share_bookmarks_to_user.rb +5 -0
- data/spec/dummy/db/migrate/20120125050502_add_depth_to_message.rb +6 -0
- data/spec/dummy/db/migrate/{20120413161403_add_fingerprint_to_patron_import_file.rb → 20120413161403_add_fingerprint_to_agent_import_file.rb} +1 -1
- data/spec/dummy/db/migrate/{20120413170720_add_error_message_to_patron_import_file.rb → 20120413170720_add_error_message_to_agent_import_file.rb} +1 -1
- data/spec/dummy/db/migrate/20120418121539_add_save_search_history_to_user.rb +5 -0
- data/spec/dummy/db/migrate/20120424103932_add_librarian_id_to_checked_item.rb +5 -0
- data/spec/dummy/db/migrate/{20120511072422_add_patron_identifier_to_patron.rb → 20120511072422_add_agent_identifier_to_agent.rb} +1 -1
- data/spec/dummy/db/migrate/{20120602141129_add_edit_mode_to_patron_import_file.rb → 20120602141129_add_edit_mode_to_agent_import_file.rb} +1 -1
- data/spec/dummy/db/migrate/20130303104849_add_state_index_to_reserve.rb +5 -0
- data/spec/dummy/db/migrate/20130303124821_add_retained_at_to_reserve.rb +5 -0
- data/spec/dummy/db/migrate/20130304015019_add_postponed_at_to_reserve.rb +5 -0
- data/spec/dummy/db/migrate/20130416054135_add_circulation_status_id_to_item.rb +8 -0
- data/spec/dummy/db/migrate/20130421155019_add_creator_string_to_series_statement.rb +7 -0
- data/spec/dummy/db/migrate/20130421164124_add_series_master_to_series_statement.rb +5 -0
- data/spec/dummy/db/migrate/20130509185724_add_statement_of_responsibility_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20130519065638_add_lock_version_to_reserve.rb +5 -0
- data/spec/dummy/db/migrate/20130519065837_add_lock_version_to_checkin.rb +5 -0
- data/spec/dummy/db/migrate/20140518050147_create_reserve_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140518111006_create_message_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140518135713_create_message_request_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140519170214_create_resource_import_file_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140519171220_create_import_request_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140524020735_create_agent_import_file_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140524135607_create_bookmark_stat_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140524142813_add_taggings_count_to_tag.rb +5 -0
- data/spec/dummy/db/migrate/20140528045518_create_user_checkout_stat_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140528045539_create_user_reserve_stat_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140528045600_create_manifestation_checkout_stat_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140528045617_create_manifestation_reserve_stat_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140529014410_create_item_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140614065404_create_resource_export_files.rb +11 -0
- data/spec/dummy/db/migrate/20140614141500_create_resource_export_file_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140628073524_add_user_encoding_to_agent_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20140628073535_add_user_encoding_to_resource_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20140810061942_add_user_id_to_stat.rb +12 -0
- data/spec/dummy/db/migrate/20140810091231_add_checkout_icalendar_token_to_profile.rb +6 -0
- data/spec/dummy/db/migrate/20140810091417_add_save_checkout_history_to_profile.rb +5 -0
- data/spec/dummy/db/migrate/20140811132912_add_save_search_history_to_profile.rb +5 -0
- data/spec/dummy/db/migrate/20140812093836_add_share_bookmarks_to_profile.rb +5 -0
- data/spec/dummy/db/schema.rb +632 -57
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/private/system/user_import_files/user_imports/980/190/963/original/user_delete_file.tsv +4 -0
- data/spec/dummy/private/system/user_import_files/user_imports/980/190/963/original/user_import_file_sample.tsv +7 -7
- data/spec/dummy/public/system/user_export_files/user_exports/000/000/003/original/user_export_file_20140815-3963-1s1td26.txt +8 -0
- data/spec/dummy/public/system/user_export_files/user_exports/000/000/003/original/user_export_file_20140815-69229-i0rcty.txt +8 -0
- data/spec/dummy/public/system/user_export_files/user_exports/000/000/003/original/user_export_file_20140816-21120-1w731r8.txt +8 -0
- data/spec/dummy/public/system/user_export_files/user_exports/000/000/004/original/user_export_file_20140711-28652-1dj3e98.txt +148 -0
- data/spec/dummy/public/system/user_export_files/user_exports/000/000/004/original/user_export_file_20140711-29117-13jb6ol.txt +148 -0
- data/spec/dummy/public/system/user_export_files/user_exports/000/000/004/original/user_export_file_20140721-65743-1tnagd4.txt +8 -0
- data/spec/dummy/public/system/user_export_files/user_exports/000/000/004/original/user_export_file_20140815-3963-1kk8o87.txt +8 -0
- data/spec/dummy/public/system/user_export_files/user_exports/000/000/004/original/user_export_file_20140815-69229-188nwub.txt +8 -0
- data/spec/dummy/public/system/user_export_files/user_exports/000/000/004/original/user_export_file_20140816-21120-twzfb6.txt +8 -0
- data/spec/dummy/solr/default/data/index/_4h.fdt +0 -0
- data/spec/dummy/solr/default/data/index/{_3h.fdx → _4h.fdx} +0 -0
- data/spec/dummy/solr/default/data/index/{_3h.fnm → _4h.fnm} +0 -0
- data/spec/dummy/solr/default/data/index/{_3h.nvd → _4h.nvd} +0 -0
- data/spec/dummy/solr/default/data/index/{_3h.nvm → _4h.nvm} +0 -0
- data/spec/dummy/solr/default/data/index/{_3h.si → _4h.si} +0 -0
- data/spec/dummy/solr/default/data/index/_4h_Lucene41_0.doc +0 -0
- data/spec/dummy/solr/default/data/index/_4h_Lucene41_0.pos +0 -0
- data/spec/dummy/solr/default/data/index/_4h_Lucene41_0.tim +0 -0
- data/spec/dummy/solr/default/data/index/_4h_Lucene41_0.tip +0 -0
- data/spec/dummy/solr/default/data/index/segments.gen +0 -0
- data/spec/dummy/solr/default/data/index/segments_97 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000320 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000321 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000322 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000323 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000324 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000325 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000326 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000327 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000328 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000329 +0 -0
- data/spec/dummy/tmp/cache/4F7/F90/default_role +0 -0
- data/spec/dummy/tmp/cache/ACB/B20/manifestation_search_total +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/154f7b83f2da0e86effbe25f32135177 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/1b984bdbd3204a51a82d0e01a1569e2d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/3054c50144654f9c7e57bb0639a276e9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/3bd7a263237ba366f64d938fe5303757 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/62899096da1a3e67660f3b88068be8c9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/65b2e4f67eab21b30217e29075f433b2 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/87d24a3f43f175d4d17babe9203c79a7 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d38d8658b30de1d068603968227680d4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/cache/stdout +246 -279
- data/spec/dummy/tmp/pids/redis-test.pid +1 -1
- data/spec/factories/profile.rb +9 -0
- data/spec/factories/user.rb +0 -13
- data/spec/fixtures/agent_import_files.yml +0 -3
- data/spec/fixtures/agents.yml +54 -54
- data/spec/fixtures/baskets.yml +4 -4
- data/spec/fixtures/carrier_type_has_checkout_types.yml +30 -0
- data/spec/fixtures/checked_items.yml +34 -0
- data/spec/fixtures/checkins.yml +54 -0
- data/spec/fixtures/checkout_stat_has_manifestations.yml +23 -0
- data/spec/fixtures/checkout_stat_has_users.yml +23 -0
- data/spec/fixtures/checkout_types.yml +33 -0
- data/spec/fixtures/checkouts.yml +162 -0
- data/spec/fixtures/circulation_statuses.yml +119 -0
- data/spec/fixtures/event_categories.yml +55 -0
- data/spec/fixtures/events.yml +142 -0
- data/spec/fixtures/exemplifies.yml +12 -0
- data/spec/fixtures/import_requests.yml +0 -2
- data/spec/fixtures/item_has_use_restrictions.yml +60 -0
- data/spec/fixtures/items.yml +101 -11
- data/spec/fixtures/lending_policies.yml +98 -0
- data/spec/fixtures/libraries.yml +26 -25
- data/spec/fixtures/library_groups.yml +6 -8
- data/spec/fixtures/manifestation_checkout_stats.yml +30 -0
- data/spec/fixtures/manifestation_reserve_stats.yml +30 -0
- data/spec/fixtures/manifestations.yml +69 -207
- data/spec/fixtures/message_requests.yml +27 -0
- data/spec/fixtures/message_templates.yml +105 -0
- data/spec/fixtures/profiles.yml +98 -0
- data/spec/fixtures/request_status_types.yml +63 -0
- data/spec/fixtures/request_types.yml +55 -0
- data/spec/fixtures/reserve_stat_has_manifestations.yml +23 -0
- data/spec/fixtures/reserve_stat_has_users.yml +23 -0
- data/spec/fixtures/reserve_transitions.yml +88 -0
- data/spec/fixtures/reserves.yml +162 -0
- data/spec/fixtures/resource_import_files.yml +0 -3
- data/spec/fixtures/roles.yml +0 -4
- data/spec/fixtures/shelves.yml +2 -3
- data/spec/fixtures/use_restrictions.yml +92 -0
- data/spec/fixtures/user_checkout_stats.yml +30 -0
- data/spec/fixtures/user_export_files.yml +26 -0
- data/spec/fixtures/user_group_has_checkout_types.yml +110 -0
- data/spec/fixtures/user_import_files.yml +2 -0
- data/spec/fixtures/user_reserve_stats.yml +30 -0
- data/spec/fixtures/users.yml +1 -101
- data/spec/models/profile_spec.rb +66 -0
- data/spec/models/user_export_file_spec.rb +31 -0
- data/spec/models/user_import_file_spec.rb +42 -20
- data/spec/models/user_spec.rb +1 -18
- data/spec/requests/{users_spec.rb → profiles_spec.rb} +3 -3
- data/spec/routing/accounts_spec.rb +1 -1
- data/spec/routing/profiles_routing_spec.rb +35 -0
- data/spec/support/resque.rb +1 -0
- data/spec/views/{users → profiles}/edit.html.erb_spec.rb +5 -7
- data/spec/views/{users → profiles}/index.html.erb_spec.rb +3 -3
- data/spec/views/{users → profiles}/new.html.erb_spec.rb +5 -5
- data/spec/views/profiles/show.html.erb_spec.rb +20 -0
- data/vendor/assets/javascripts/jquery.colorbox.js +4 -3
- data/vendor/assets/stylesheets/colorbox.css +1 -1
- metadata +416 -132
- data/app/controllers/users_controller.rb +0 -195
- data/app/models/user_sweeper.rb +0 -18
- data/app/views/users/_edit_credential.html.erb +0 -79
- data/app/views/users/edit.html.erb +0 -76
- data/app/views/users/index.html.erb +0 -56
- data/lib/enju_leaf/expire_editable_fragment.rb +0 -30
- data/lib/enju_leaf/expire_fragment_cache.rb +0 -17
- data/spec/controllers/users_controller_spec.rb +0 -539
- data/spec/dummy/db/migrate/20110916053430_rename_manifestation_number_list_to_number_string.rb +0 -13
- data/spec/dummy/db/migrate/20120415060308_rename_resource_import_file_imported_at_to_executed_at.rb +0 -9
- data/spec/dummy/db/migrate/20120415060323_rename_patron_import_file_imported_at_to_executed_at.rb +0 -9
- data/spec/dummy/db/migrate/20121119153944_add_manifestation_id_to_item.rb +0 -5
- data/spec/dummy/solr/default/data/index/_3h.fdt +0 -0
- data/spec/dummy/solr/default/data/index/_3h_Lucene41_0.doc +0 -0
- data/spec/dummy/solr/default/data/index/_3h_Lucene41_0.pos +0 -0
- data/spec/dummy/solr/default/data/index/_3h_Lucene41_0.tim +0 -0
- data/spec/dummy/solr/default/data/index/_3h_Lucene41_0.tip +0 -0
- data/spec/dummy/solr/default/data/index/segments_71 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000242 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000243 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000244 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000245 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000246 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000247 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000248 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000249 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000250 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000251 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/3f8d795856d1fdf902b0be679120571a +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5998e66e374537d52eed3fe1ca5f2bfc +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5ea4a1824e1d67da6c4fb9aeef9f49f4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/87f0cb69a0df1355e33cce3949919d5a +0 -0
- data/spec/routing/users_routing_spec.rb +0 -35
- data/spec/views/users/show.html.erb_spec.rb +0 -15
@@ -6,12 +6,12 @@ module EnjuLeaf
|
|
6
6
|
|
7
7
|
case user.try(:role).try(:name)
|
8
8
|
when 'Administrator'
|
9
|
-
can :index,
|
10
|
-
can [:read, :create, :update], User
|
11
|
-
can :destroy,
|
12
|
-
if
|
9
|
+
can :index, Profile
|
10
|
+
can [:read, :create, :update], [User, Profile]
|
11
|
+
can :destroy, Profile do |profile|
|
12
|
+
if profile != user.profile and profile.user.id != 1
|
13
13
|
if defined?(EnjuCirculation)
|
14
|
-
true if
|
14
|
+
true if profile.user.checkouts.not_returned.empty?
|
15
15
|
else
|
16
16
|
true
|
17
17
|
end
|
@@ -19,12 +19,13 @@ module EnjuLeaf
|
|
19
19
|
end
|
20
20
|
can [:read, :create, :update], UserGroup
|
21
21
|
can :destroy, UserGroup do |user_group|
|
22
|
-
user_group.
|
22
|
+
user_group.profiles.empty?
|
23
23
|
end
|
24
24
|
can :manage, [
|
25
25
|
UserHasRole
|
26
26
|
]
|
27
27
|
can :manage, [
|
28
|
+
UserExportFile,
|
28
29
|
UserImportFile
|
29
30
|
] if LibraryGroup.site_config.network_access_allowed?(ip_address)
|
30
31
|
can :update, [
|
@@ -35,11 +36,11 @@ module EnjuLeaf
|
|
35
36
|
UserImportResult
|
36
37
|
] if LibraryGroup.site_config.network_access_allowed?(ip_address)
|
37
38
|
when 'Librarian'
|
38
|
-
can [:read, :create, :update],
|
39
|
-
can :destroy,
|
40
|
-
if
|
39
|
+
can [:read, :create, :update], Profile
|
40
|
+
can :destroy, Profile do |profile|
|
41
|
+
if profile.user.role.name == 'User' and profile != user.profile
|
41
42
|
if defined?(EnjuCirculation)
|
42
|
-
true if
|
43
|
+
true if profile.user.checkouts.not_returned.empty?
|
43
44
|
else
|
44
45
|
true
|
45
46
|
end
|
@@ -56,9 +57,9 @@ module EnjuLeaf
|
|
56
57
|
UserImportResult
|
57
58
|
] if LibraryGroup.site_config.network_access_allowed?(ip_address)
|
58
59
|
when 'User'
|
59
|
-
can :show,
|
60
|
-
can :update,
|
61
|
-
|
60
|
+
can :show, Profile
|
61
|
+
can :update, Profile do |profile|
|
62
|
+
profile == user.profile
|
62
63
|
end
|
63
64
|
can :read, [
|
64
65
|
UserGroup
|
data/app/models/profile.rb
CHANGED
@@ -1,16 +1,61 @@
|
|
1
1
|
class Profile < ActiveRecord::Base
|
2
|
+
attr_accessible :full_name, :keyword_list, :locale
|
3
|
+
attr_accessible :full_name, :user_number, :library_id, :keyword_list, :note,
|
4
|
+
:user_group_id, :user_id, :locale, :required_role_id, :expired_at,
|
5
|
+
:user_attributes,
|
6
|
+
:save_checkout_history,
|
7
|
+
as: :admin
|
8
|
+
|
9
|
+
enju_circulation_profile_model if defined?(EnjuCirculation)
|
10
|
+
enju_search_log_profile_model if defined?(EnjuSearchLog)
|
11
|
+
|
2
12
|
belongs_to :user
|
3
|
-
belongs_to :library, :
|
13
|
+
belongs_to :library, validate: true
|
4
14
|
belongs_to :user_group
|
5
|
-
belongs_to :required_role, :
|
15
|
+
belongs_to :required_role, class_name: 'Role', foreign_key: 'required_role_id' #, validate: true
|
6
16
|
|
7
|
-
validates_associated :user_group, :library
|
17
|
+
validates_associated :user_group, :library
|
18
|
+
validates_associated :user
|
8
19
|
validates_presence_of :user_group, :library, :locale #, :user_number
|
9
|
-
validates :user_number, :
|
20
|
+
validates :user_number, uniqueness: true, format: {with: /\A[0-9A-Za-z_]+\Z/}, allow_blank: true
|
10
21
|
|
11
22
|
searchable do
|
12
23
|
text :user_number, :full_name, :note
|
13
24
|
string :user_number
|
25
|
+
text :username do
|
26
|
+
user.try(:username)
|
27
|
+
end
|
28
|
+
text :email do
|
29
|
+
user.try(:email)
|
30
|
+
end
|
31
|
+
string :username do
|
32
|
+
user.try(:username)
|
33
|
+
end
|
34
|
+
string :email do
|
35
|
+
user.try(:email)
|
36
|
+
end
|
37
|
+
time :created_at
|
38
|
+
time :updated_at
|
39
|
+
boolean :active do
|
40
|
+
user.try(:active_for_authentication?)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
before_validation :set_role_and_agent, on: :create
|
45
|
+
before_save :set_expired_at
|
46
|
+
accepts_nested_attributes_for :user
|
47
|
+
|
48
|
+
def set_role_and_agent
|
49
|
+
self.required_role = Role.where(name: 'Librarian').first
|
50
|
+
self.locale = I18n.default_locale.to_s unless locale
|
51
|
+
end
|
52
|
+
|
53
|
+
def set_expired_at
|
54
|
+
if expired_at.blank?
|
55
|
+
if user_group.valid_period_for_new_user > 0
|
56
|
+
self.expired_at = user_group.valid_period_for_new_user.days.from_now.end_of_day
|
57
|
+
end
|
58
|
+
end
|
14
59
|
end
|
15
60
|
end
|
16
61
|
|
@@ -18,16 +63,18 @@ end
|
|
18
63
|
#
|
19
64
|
# Table name: profiles
|
20
65
|
#
|
21
|
-
# id
|
22
|
-
# user_id
|
23
|
-
# user_group_id
|
24
|
-
# library_id
|
25
|
-
# locale
|
26
|
-
# user_number
|
27
|
-
# full_name
|
28
|
-
# note
|
29
|
-
# keyword_list
|
30
|
-
# required_role_id
|
31
|
-
# created_at
|
32
|
-
# updated_at
|
66
|
+
# id :integer not null, primary key
|
67
|
+
# user_id :integer
|
68
|
+
# user_group_id :integer
|
69
|
+
# library_id :integer
|
70
|
+
# locale :string(255)
|
71
|
+
# user_number :string(255)
|
72
|
+
# full_name :text
|
73
|
+
# note :text
|
74
|
+
# keyword_list :text
|
75
|
+
# required_role_id :integer
|
76
|
+
# created_at :datetime not null
|
77
|
+
# updated_at :datetime not null
|
78
|
+
# checkout_icalendar_token :string(255)
|
79
|
+
# save_checkout_history :boolean default(FALSE), not null
|
33
80
|
#
|
data/app/models/role.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
class Role < ActiveRecord::Base
|
2
2
|
attr_accessible :name, :display_name, :note
|
3
3
|
include MasterModel
|
4
|
-
default_scope :
|
4
|
+
default_scope order: "roles.position"
|
5
5
|
has_many :user_has_roles
|
6
|
-
has_many :users, :
|
6
|
+
has_many :users, through: :user_has_roles
|
7
7
|
after_save :clear_all_cache
|
8
8
|
after_destroy :clear_all_cache
|
9
9
|
|
@@ -0,0 +1,52 @@
|
|
1
|
+
class UserExportFile < ActiveRecord::Base
|
2
|
+
include Statesman::Adapters::ActiveRecordModel
|
3
|
+
include ExportFile
|
4
|
+
enju_export_file_model
|
5
|
+
has_attached_file :user_export
|
6
|
+
validates_attachment_content_type :user_export, :content_type => /\Atext\/plain\Z/
|
7
|
+
|
8
|
+
has_many :user_export_file_transitions
|
9
|
+
|
10
|
+
def state_machine
|
11
|
+
UserExportFileStateMachine.new(self, transition_class: UserExportFileTransition)
|
12
|
+
end
|
13
|
+
|
14
|
+
delegate :can_transition_to?, :transition_to!, :transition_to, :current_state,
|
15
|
+
to: :state_machine
|
16
|
+
|
17
|
+
def export!
|
18
|
+
transition_to!(:started)
|
19
|
+
tempfile = Tempfile.new(['user_export_file_', '.txt'])
|
20
|
+
file = User.export(format: :txt)
|
21
|
+
tempfile.puts(file)
|
22
|
+
tempfile.close
|
23
|
+
self.user_export = File.new(tempfile.path, "r")
|
24
|
+
if save
|
25
|
+
send_message
|
26
|
+
end
|
27
|
+
transition_to!(:completed)
|
28
|
+
rescue => e
|
29
|
+
transition_to!(:failed)
|
30
|
+
raise e
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
def self.transition_class
|
35
|
+
UserExportFileTransition
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# == Schema Information
|
40
|
+
#
|
41
|
+
# Table name: user_export_files
|
42
|
+
#
|
43
|
+
# id :integer not null, primary key
|
44
|
+
# user_id :integer
|
45
|
+
# user_export_file_name :string(255)
|
46
|
+
# user_export_content_type :string(255)
|
47
|
+
# user_export_file_size :integer
|
48
|
+
# user_export_updated_at :datetime
|
49
|
+
# executed_at :datetime
|
50
|
+
# created_at :datetime not null
|
51
|
+
# updated_at :datetime not null
|
52
|
+
#
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class UserExportFileStateMachine
|
2
|
+
include Statesman::Machine
|
3
|
+
|
4
|
+
state :pending, initial: true
|
5
|
+
state :started
|
6
|
+
state :completed
|
7
|
+
state :failed
|
8
|
+
|
9
|
+
transition from: :pending, to: :started
|
10
|
+
transition from: :started, to: [:completed, :failed]
|
11
|
+
|
12
|
+
after_transition(from: :pending, to: :started) do |user_export_file|
|
13
|
+
user_export_file.update_column(:executed_at, Time.zone.now)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class UserExportFileTransition < ActiveRecord::Base
|
2
|
+
include Statesman::Adapters::ActiveRecordTransition
|
3
|
+
|
4
|
+
|
5
|
+
belongs_to :user_export_file, inverse_of: :user_export_file_transitions
|
6
|
+
attr_accessible :to_state, :sort_key, :metadata
|
7
|
+
end
|
8
|
+
|
9
|
+
# == Schema Information
|
10
|
+
#
|
11
|
+
# Table name: user_export_file_transitions
|
12
|
+
#
|
13
|
+
# id :integer not null, primary key
|
14
|
+
# to_state :string(255)
|
15
|
+
# metadata :text default("{}")
|
16
|
+
# sort_key :integer
|
17
|
+
# user_export_file_id :integer
|
18
|
+
# created_at :datetime not null
|
19
|
+
# updated_at :datetime not null
|
20
|
+
#
|
data/app/models/user_group.rb
CHANGED
@@ -7,12 +7,12 @@ class UserGroup < ActiveRecord::Base
|
|
7
7
|
:number_of_time_to_notify_overdue
|
8
8
|
|
9
9
|
include MasterModel
|
10
|
-
default_scope :
|
11
|
-
has_many :
|
10
|
+
default_scope order: "user_groups.position"
|
11
|
+
has_many :profiles
|
12
12
|
|
13
13
|
validates_numericality_of :valid_period_for_new_user,
|
14
14
|
:greater_than_or_equal_to => 0,
|
15
|
-
:
|
15
|
+
allow_blank: true
|
16
16
|
|
17
17
|
paginates_per 10
|
18
18
|
|
data/app/models/user_has_role.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
class UserHasRole < ActiveRecord::Base
|
2
2
|
attr_accessible :user_id, :role_id
|
3
|
-
attr_accessible :user_id, :role_id, :
|
3
|
+
attr_accessible :user_id, :role_id, as: :admin
|
4
4
|
belongs_to :user
|
5
5
|
belongs_to :role
|
6
6
|
accepts_nested_attributes_for :role
|
7
7
|
|
8
|
-
# validates_uniqueness_of :role_id, :
|
8
|
+
# validates_uniqueness_of :role_id, scope: :user_id
|
9
9
|
# validates_presence_of :role_id, :user_id
|
10
10
|
end
|
11
11
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
class UserImportFile < ActiveRecord::Base
|
2
|
-
attr_accessible :user_import, :edit_mode, :user_encoding, :mode
|
2
|
+
attr_accessible :user_import, :edit_mode, :user_encoding, :mode,
|
3
|
+
:default_user_group_id, :default_library_id
|
3
4
|
include Statesman::Adapters::ActiveRecordModel
|
4
5
|
include ImportFile
|
5
6
|
default_scope {order('user_import_files.id DESC')}
|
@@ -12,7 +13,7 @@ class UserImportFile < ActiveRecord::Base
|
|
12
13
|
:s3_permissions => :private
|
13
14
|
else
|
14
15
|
has_attached_file :user_import,
|
15
|
-
:
|
16
|
+
path: ":rails_root/private/system/:class/:attachment/:id_partition/:style/:filename"
|
16
17
|
end
|
17
18
|
validates_attachment_content_type :user_import, :content_type => [
|
18
19
|
'text/csv',
|
@@ -22,7 +23,9 @@ class UserImportFile < ActiveRecord::Base
|
|
22
23
|
'application/vnd.ms-excel'
|
23
24
|
]
|
24
25
|
validates_attachment_presence :user_import
|
25
|
-
belongs_to :user, :
|
26
|
+
belongs_to :user, validate: true
|
27
|
+
belongs_to :default_user_group, class_name: 'UserGroup'
|
28
|
+
belongs_to :default_library, class_name: 'Library'
|
26
29
|
has_many :user_import_results
|
27
30
|
|
28
31
|
has_many :user_import_file_transitions
|
@@ -40,7 +43,7 @@ class UserImportFile < ActiveRecord::Base
|
|
40
43
|
def import
|
41
44
|
transition_to!(:started)
|
42
45
|
num = {:user_imported => 0, :user_found => 0, :failed => 0}
|
43
|
-
rows = open_import_file(create_import_temp_file)
|
46
|
+
rows = open_import_file(create_import_temp_file(user_import))
|
44
47
|
row_num = 1
|
45
48
|
|
46
49
|
field = rows.first
|
@@ -52,7 +55,7 @@ class UserImportFile < ActiveRecord::Base
|
|
52
55
|
row_num += 1
|
53
56
|
next if row['dummy'].to_s.strip.present?
|
54
57
|
import_result = UserImportResult.create!(
|
55
|
-
:user_import_file_id => id, :
|
58
|
+
:user_import_file_id => id, body: row.fields.join("\t")
|
56
59
|
)
|
57
60
|
|
58
61
|
username = row['username']
|
@@ -63,7 +66,7 @@ class UserImportFile < ActiveRecord::Base
|
|
63
66
|
num[:user_found] += 1
|
64
67
|
else
|
65
68
|
new_user = User.new
|
66
|
-
new_user.role = Role.where(:
|
69
|
+
new_user.role = Role.where(name: row['role']).first
|
67
70
|
if new_user.role
|
68
71
|
unless user.has_role?(new_user.role.name)
|
69
72
|
num[:failed] += 1
|
@@ -74,42 +77,29 @@ class UserImportFile < ActiveRecord::Base
|
|
74
77
|
end
|
75
78
|
new_user.operator = user
|
76
79
|
new_user.username = username
|
77
|
-
new_user.
|
78
|
-
|
79
|
-
|
80
|
-
end
|
81
|
-
new_user.user_number = row['user_number']
|
82
|
-
if row['expired_at'].present?
|
83
|
-
new_user.expired_at = Time.zone.parse(row['expired_at']).end_of_day
|
84
|
-
end
|
85
|
-
new_user.note = row['note']
|
86
|
-
|
87
|
-
if I18n.available_locales.include?(row['locale'].to_s.to_sym)
|
88
|
-
new_user.locale = row['locale']
|
89
|
-
end
|
90
|
-
|
91
|
-
library = Library.where(:name => row['library'].to_s.strip).first || Library.web
|
92
|
-
new_user.library = library
|
93
|
-
|
94
|
-
if row['password'].present?
|
95
|
-
new_user.password = row['password']
|
96
|
-
else
|
97
|
-
new_user.set_auto_generated_password
|
98
|
-
end
|
80
|
+
new_user.assign_attributes(set_user_params(new_user, row), as: :admin)
|
81
|
+
profile = Profile.new
|
82
|
+
profile.assign_attributes(set_profile_params(row), as: :admin)
|
99
83
|
|
100
84
|
if new_user.save
|
101
|
-
|
102
|
-
|
103
|
-
|
85
|
+
new_user.profile = profile
|
86
|
+
if profile.save
|
87
|
+
num[:user_imported] += 1
|
88
|
+
import_result.user = new_user
|
89
|
+
import_result.save!
|
90
|
+
else
|
91
|
+
num[:failed] += 1
|
92
|
+
end
|
104
93
|
else
|
105
94
|
num[:failed] += 1
|
106
95
|
end
|
107
96
|
end
|
108
97
|
end
|
109
98
|
|
99
|
+
Sunspot.commit
|
110
100
|
rows.close
|
111
101
|
transition_to!(:completed)
|
112
|
-
|
102
|
+
send_message
|
113
103
|
num
|
114
104
|
rescue => e
|
115
105
|
self.error_message = "line #{row_num}: #{e.message}"
|
@@ -119,8 +109,42 @@ class UserImportFile < ActiveRecord::Base
|
|
119
109
|
|
120
110
|
def modify
|
121
111
|
transition_to!(:started)
|
122
|
-
|
112
|
+
num = {:user_updated => 0, :user_not_found => 0, :failed => 0}
|
113
|
+
rows = open_import_file(create_import_temp_file(user_import))
|
123
114
|
row_num = 1
|
115
|
+
|
116
|
+
field = rows.first
|
117
|
+
if [field['username']].reject{|f| f.to_s.strip == ""}.empty?
|
118
|
+
raise "username column is not found"
|
119
|
+
end
|
120
|
+
|
121
|
+
rows.each do |row|
|
122
|
+
row_num += 1
|
123
|
+
next if row['dummy'].to_s.strip.present?
|
124
|
+
import_result = UserImportResult.create!(
|
125
|
+
:user_import_file_id => id, body: row.fields.join("\t")
|
126
|
+
)
|
127
|
+
|
128
|
+
username = row['username']
|
129
|
+
new_user = User.where(:username => username).first
|
130
|
+
if new_user
|
131
|
+
new_user.assign_attributes(set_user_params(new_user, row), as: :admin)
|
132
|
+
if new_user.save
|
133
|
+
num[:user_updated] += 1
|
134
|
+
import_result.user = new_user
|
135
|
+
import_result.save!
|
136
|
+
else
|
137
|
+
num[:failed] += 1
|
138
|
+
end
|
139
|
+
else
|
140
|
+
num[:user_not_found] += 1
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
rows.close
|
145
|
+
transition_to!(:completed)
|
146
|
+
Sunspot.commit
|
147
|
+
num
|
124
148
|
rescue => e
|
125
149
|
self.error_message = "line #{row_num}: #{e.message}"
|
126
150
|
transition_to!(:failed)
|
@@ -130,7 +154,7 @@ class UserImportFile < ActiveRecord::Base
|
|
130
154
|
def remove
|
131
155
|
transition_to!(:started)
|
132
156
|
row_num = 1
|
133
|
-
rows = open_import_file(create_import_temp_file)
|
157
|
+
rows = open_import_file(create_import_temp_file(user_import))
|
134
158
|
|
135
159
|
field = rows.first
|
136
160
|
if [field['username']].reject{|field| field.to_s.strip == ""}.empty?
|
@@ -155,27 +179,30 @@ class UserImportFile < ActiveRecord::Base
|
|
155
179
|
UserImportFileTransition
|
156
180
|
end
|
157
181
|
|
158
|
-
def create_import_temp_file
|
159
|
-
tempfile = Tempfile.new(self.class.name.underscore)
|
160
|
-
if Setting.uploaded_file.storage == :s3
|
161
|
-
uploaded_file_path = user_import.expiring_url(10)
|
162
|
-
else
|
163
|
-
uploaded_file_path = user_import.path
|
164
|
-
end
|
165
|
-
open(uploaded_file_path){|f|
|
166
|
-
f.each{|line|
|
167
|
-
tempfile.puts(convert_encoding(line))
|
168
|
-
}
|
169
|
-
}
|
170
|
-
tempfile.close
|
171
|
-
tempfile
|
172
|
-
end
|
173
|
-
|
174
182
|
def open_import_file(tempfile)
|
175
|
-
file = CSV.open(tempfile.path, 'r:utf-8', :
|
183
|
+
file = CSV.open(tempfile.path, 'r:utf-8', col_sep: "\t")
|
184
|
+
header_columns = %w(
|
185
|
+
username role email password user_group user_number expired_at
|
186
|
+
keyword_list note locale library dummy
|
187
|
+
)
|
188
|
+
if defined?(EnjuCirculation)
|
189
|
+
header_columns += %w(checkout_icalendar_token save_checkout_history)
|
190
|
+
end
|
191
|
+
if defined?(EnjuSearchLog)
|
192
|
+
header_columns += %w(save_search_history)
|
193
|
+
end
|
194
|
+
if defined?(EnjuBookmark)
|
195
|
+
header_columns += %w(share_bookmarks)
|
196
|
+
end
|
197
|
+
|
176
198
|
header = file.first
|
177
|
-
|
178
|
-
|
199
|
+
ignored_columns = header - header_columns
|
200
|
+
unless ignored_columns.empty?
|
201
|
+
self.error_message = I18n.t('import.following_column_were_ignored', column: ignored_columns.join(', '))
|
202
|
+
save!
|
203
|
+
end
|
204
|
+
rows = CSV.open(tempfile.path, 'r:utf-8', headers: header, col_sep: "\t")
|
205
|
+
UserImportResult.create!(:user_import_file_id => self.id, body: header.join("\t"))
|
179
206
|
tempfile.close(true)
|
180
207
|
file.close
|
181
208
|
rows
|
@@ -188,6 +215,63 @@ class UserImportFile < ActiveRecord::Base
|
|
188
215
|
rescue
|
189
216
|
Rails.logger.info "#{Time.zone.now} importing resources failed!"
|
190
217
|
end
|
218
|
+
|
219
|
+
private
|
220
|
+
def set_user_params(new_user, row)
|
221
|
+
params = {}
|
222
|
+
profile_params = {}
|
223
|
+
params[:email] = row['email'] if row['email'].present?
|
224
|
+
|
225
|
+
if row['password'].present?
|
226
|
+
params[:password] = row['password']
|
227
|
+
else
|
228
|
+
params[:password] = Devise.friendly_token[0..7]
|
229
|
+
end
|
230
|
+
params
|
231
|
+
end
|
232
|
+
|
233
|
+
def set_profile_params(row)
|
234
|
+
params = {}
|
235
|
+
user_group = UserGroup.where(name: row['user_group']).first
|
236
|
+
unless user_group
|
237
|
+
user_group = default_user_group
|
238
|
+
end
|
239
|
+
params[:user_group_id] = user_group.id if user_group
|
240
|
+
|
241
|
+
params[:user_number] = row['user_number']
|
242
|
+
|
243
|
+
if row['expired_at'].present?
|
244
|
+
params[:expired_at] = Time.zone.parse(row['expired_at']).end_of_day
|
245
|
+
end
|
246
|
+
|
247
|
+
if row['keyword_list'].present?
|
248
|
+
params[:keyword_list] = row['keyword_list'].split('//').join('\n')
|
249
|
+
end
|
250
|
+
|
251
|
+
params[:note] = row['note']
|
252
|
+
|
253
|
+
if I18n.available_locales.include?(row['locale'].to_s.to_sym)
|
254
|
+
params[:locale] = row['locale']
|
255
|
+
end
|
256
|
+
|
257
|
+
library = Library.where(name: row['library'].to_s.strip).first
|
258
|
+
unless library
|
259
|
+
library = default_library || Library.web
|
260
|
+
end
|
261
|
+
params[:library_id] = library.id if library
|
262
|
+
|
263
|
+
if defined?(EnjuCirculation)
|
264
|
+
params[:checkout_icalendar_token] = row['checkout_icalendar_token'] if row['checkout_icalendar_token'].present?
|
265
|
+
params[:save_checkout_history] = row['save_checkout_history'] if row['save_checkout_history'].present?
|
266
|
+
end
|
267
|
+
if defined?(EnjuSearchLog)
|
268
|
+
params[:save_search_history] = row['save_search_history'] if row['save_search_history'].present?
|
269
|
+
end
|
270
|
+
if defined?(EnjuBookmark)
|
271
|
+
params[:share_bookmarks] = row['share_bookmarks'] if row['share_bookmarks'].present?
|
272
|
+
end
|
273
|
+
params
|
274
|
+
end
|
191
275
|
end
|
192
276
|
|
193
277
|
# == Schema Information
|
@@ -208,4 +292,6 @@ end
|
|
208
292
|
# created_at :datetime not null
|
209
293
|
# updated_at :datetime not null
|
210
294
|
# user_encoding :string(255)
|
295
|
+
# default_library_id :integer
|
296
|
+
# default_user_group_id :integer
|
211
297
|
#
|
@@ -6,4 +6,4 @@
|
|
6
6
|
per_page: number of items to fetch per page
|
7
7
|
remote: data-remote
|
8
8
|
-%>
|
9
|
-
<%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, :
|
9
|
+
<%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, rel: 'next', remote: remote %>
|
@@ -8,5 +8,5 @@
|
|
8
8
|
remote: data-remote
|
9
9
|
-%>
|
10
10
|
<% if page.current? %><span class="current"><% end %>
|
11
|
-
<%= link_to_unless page.current?, page, url, opts = {:
|
11
|
+
<%= link_to_unless page.current?, page, url, opts = {remote: remote, rel: page.next? ? 'next' : page.prev? ? 'prev' : nil} %>
|
12
12
|
<% if page.current? %></span><% end %>
|
@@ -6,4 +6,4 @@
|
|
6
6
|
per_page: number of items to fetch per page
|
7
7
|
remote: data-remote
|
8
8
|
-%>
|
9
|
-
<%= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, :
|
9
|
+
<%= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, rel: 'prev', remote: remote %>
|
@@ -8,6 +8,6 @@
|
|
8
8
|
-%>
|
9
9
|
<% unless current_page.last? %>
|
10
10
|
<li class="next_page mobile_pagination ui-block-c">
|
11
|
-
<%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, :
|
11
|
+
<%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, rel: 'next', remote: remote %>
|
12
12
|
</li>
|
13
13
|
<% end %>
|
@@ -8,5 +8,5 @@
|
|
8
8
|
remote: data-remote
|
9
9
|
-%>
|
10
10
|
<li class="page<%= ' active' if page.current? %> mobile_pagination ui-block-b">
|
11
|
-
<%= link_to "#{page} / #{total_pages}", url, opts = {:
|
11
|
+
<%= link_to "#{page} / #{total_pages}", url, opts = {remote: remote, rel: page.next? ? 'next' : page.prev? ? 'prev' : nil} %>
|
12
12
|
</li>
|
@@ -8,6 +8,6 @@
|
|
8
8
|
-%>
|
9
9
|
<% unless current_page.first? %>
|
10
10
|
<li class="prev mobile_pagination ui-block-a">
|
11
|
-
<%= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, :
|
11
|
+
<%= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, rel: 'prev', remote: remote %>
|
12
12
|
</li>
|
13
13
|
<% end %>
|
@@ -5,11 +5,11 @@
|
|
5
5
|
<%= render 'page/include' %>
|
6
6
|
<title><%= title(controller.controller_name) %></title>
|
7
7
|
<%- if controller.controller_name == 'manifestations' and controller.action_name == 'index' -%>
|
8
|
-
<%= auto_discovery_link_tag(:rss, url_for(params.merge(:
|
9
|
-
<%= auto_discovery_link_tag(:atom, url_for(params.merge(:
|
8
|
+
<%= auto_discovery_link_tag(:rss, url_for(params.merge(format: 'rss', page: nil, commit: nil, only_path: true)), title: (t('manifestation.library_group_manifestation', library_group_name: @library_group.display_name.localize) + " (RSS)")) %>
|
9
|
+
<%= auto_discovery_link_tag(:atom, url_for(params.merge(format: 'atom', page: nil, commit: nil, only_path: true)), title: (t('manifestation.library_group_manifestation', library_group_name: @library_group.display_name.localize) + " (Atom)")) %>
|
10
10
|
<% if defined?(EnjuNews) %>
|
11
|
-
<%= auto_discovery_link_tag(:rss, news_posts_url(:
|
12
|
-
<%= auto_discovery_link_tag(:atom, news_posts_url(:
|
11
|
+
<%= auto_discovery_link_tag(:rss, news_posts_url(format: :rss, locale: @locale), title: (t('news_post.library_group_news_post', library_group_name: @library_group.display_name.localize) + " (RSS)")) %>
|
12
|
+
<%= auto_discovery_link_tag(:atom, news_posts_url(format: :atom, locale: @locale), title: (t('news_post.library_group_news_post', library_group_name: @library_group.display_name.localize) + " (Atom)")) %>
|
13
13
|
<% end %>
|
14
14
|
<% end %>
|
15
15
|
<%= book_jacket_header(Setting.book_jacket.source) %>
|