enju_seed 0.3.6 → 0.4.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +9 -7
- data/Rakefile +16 -7
- data/app/controllers/profiles_controller.rb +33 -33
- data/app/controllers/roles_controller.rb +3 -2
- data/app/models/concerns/enju_seed/enju_user.rb +27 -31
- data/app/models/concerns/master_model.rb +2 -13
- data/app/models/identity.rb +3 -3
- data/app/models/profile.rb +14 -14
- data/app/models/role.rb +11 -27
- data/app/models/user_has_role.rb +6 -3
- data/app/policies/user_export_file_policy.rb +21 -0
- data/app/policies/user_import_file_policy.rb +21 -0
- data/app/policies/user_import_result_policy.rb +21 -0
- data/app/views/profiles/show.html.erb +1 -1
- data/app/views/roles/_form.html.erb +1 -1
- data/app/views/roles/show.html.erb +6 -1
- data/db/migrate/041_create_roles.rb +6 -7
- data/db/migrate/20100606065209_create_user_has_roles.rb +3 -3
- data/db/migrate/20130221154434_add_additional_attributes_to_user.rb +2 -2
- data/db/migrate/20140122054321_create_profiles.rb +5 -8
- data/db/migrate/20140811031145_add_expired_at_to_profile.rb +1 -1
- data/db/migrate/20141003181336_add_full_name_transcription_to_profile.rb +1 -1
- data/db/migrate/20141003182825_add_date_of_birth_to_profile.rb +1 -1
- data/db/migrate/20150421023923_create_identities.rb +4 -6
- data/db/migrate/20151126005552_add_provider_to_identity.rb +2 -2
- data/db/migrate/20170114174536_add_profile_id_to_user.rb +5 -0
- data/lib/enju_seed/engine.rb +2 -3
- data/lib/enju_seed/localized_name.rb +1 -3
- data/lib/enju_seed/version.rb +1 -1
- data/lib/enju_seed.rb +2 -3
- data/lib/tasks/enju_seed_tasks.rake +4 -8
- data/spec/controllers/my_accounts_controller_spec.rb +45 -56
- data/spec/controllers/profiles_controller_spec.rb +147 -152
- data/spec/controllers/roles_controller_spec.rb +35 -35
- data/spec/dummy/Rakefile +1 -1
- data/spec/dummy/app/models/user.rb +3 -3
- data/spec/dummy/bin/rails +1 -1
- data/spec/dummy/bin/setup +10 -19
- data/spec/dummy/config/application.rb +1 -6
- data/spec/dummy/config/database.yml +70 -10
- data/spec/dummy/config/environments/development.rb +1 -1
- data/spec/dummy/config/environments/production.rb +3 -8
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/config/initializers/assets.rb +4 -7
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -2
- data/spec/dummy/config/initializers/friendly_id.rb +75 -75
- data/spec/dummy/config/initializers/wrap_parameters.rb +2 -2
- data/spec/dummy/config/routes.rb +0 -4
- data/spec/dummy/config/secrets.yml +5 -15
- data/spec/dummy/config.ru +1 -2
- data/spec/dummy/db/migrate/001_create_agents.rb +7 -7
- data/spec/dummy/db/migrate/002_devise_create_users.rb +3 -4
- data/spec/dummy/db/migrate/005_create_manifestations.rb +4 -5
- data/spec/dummy/db/migrate/006_create_items.rb +3 -4
- data/spec/dummy/db/migrate/012_create_owns.rb +3 -5
- data/spec/dummy/db/migrate/015_create_creates.rb +3 -5
- data/spec/dummy/db/migrate/032_create_checkins.rb +1 -1
- data/spec/dummy/db/migrate/033_create_checkouts.rb +1 -1
- data/spec/dummy/db/migrate/035_create_reserves.rb +1 -1
- data/spec/dummy/db/migrate/047_create_produces.rb +3 -5
- data/spec/dummy/db/migrate/059_create_libraries.rb +8 -7
- data/spec/dummy/db/migrate/069_create_shelves.rb +3 -3
- data/spec/dummy/db/migrate/073_create_carrier_types.rb +2 -2
- data/spec/dummy/db/migrate/077_create_user_groups.rb +4 -4
- data/spec/dummy/db/migrate/080_create_library_groups.rb +6 -6
- data/spec/dummy/db/migrate/112_create_frequencies.rb +2 -2
- data/spec/dummy/db/migrate/117_create_form_of_works.rb +2 -2
- data/spec/dummy/db/migrate/120_create_baskets.rb +2 -2
- data/spec/dummy/db/migrate/121_create_checked_items.rb +1 -1
- data/spec/dummy/db/migrate/124_create_bookstores.rb +3 -3
- data/spec/dummy/db/migrate/125_create_donates.rb +3 -3
- data/spec/dummy/db/migrate/127_create_use_restrictions.rb +1 -1
- data/spec/dummy/db/migrate/129_create_item_has_use_restrictions.rb +1 -1
- data/spec/dummy/db/migrate/130_create_request_status_types.rb +3 -3
- data/spec/dummy/db/migrate/131_create_request_types.rb +3 -3
- data/spec/dummy/db/migrate/132_create_circulation_statuses.rb +1 -1
- data/spec/dummy/db/migrate/133_create_agent_merges.rb +2 -2
- data/spec/dummy/db/migrate/134_create_agent_merge_lists.rb +1 -1
- data/spec/dummy/db/migrate/20080830154109_create_realizes.rb +3 -5
- data/spec/dummy/db/migrate/20080830172106_create_exemplifies.rb +11 -0
- data/spec/dummy/db/migrate/20080905191442_create_agent_types.rb +2 -2
- data/spec/dummy/db/migrate/20081006090811_create_subscriptions.rb +5 -3
- data/spec/dummy/db/migrate/20081006093246_create_subscribes.rb +3 -4
- data/spec/dummy/db/migrate/20081023092436_create_search_engines.rb +6 -6
- data/spec/dummy/db/migrate/20081025083323_create_countries.rb +5 -5
- data/spec/dummy/db/migrate/20081025083905_create_languages.rb +6 -6
- data/spec/dummy/db/migrate/20081027150907_create_picture_files.rb +2 -2
- data/spec/dummy/db/migrate/20081028083142_create_agent_import_files.rb +1 -1
- data/spec/dummy/db/migrate/20081028083208_create_resource_import_files.rb +1 -1
- data/spec/dummy/db/migrate/20081030023412_create_checkout_types.rb +1 -1
- data/spec/dummy/db/migrate/20081030023518_create_user_group_has_checkout_types.rb +1 -1
- data/spec/dummy/db/migrate/20081030023615_create_carrier_type_has_checkout_types.rb +1 -1
- data/spec/dummy/db/migrate/20081212075554_create_checkout_stat_has_manifestations.rb +1 -1
- data/spec/dummy/db/migrate/20081212080038_create_manifestation_checkout_stats.rb +1 -1
- data/spec/dummy/db/migrate/20081215094302_create_user_checkout_stats.rb +1 -1
- data/spec/dummy/db/migrate/20081215094955_create_checkout_stat_has_users.rb +1 -1
- data/spec/dummy/db/migrate/20081216190517_create_reserve_stat_has_manifestations.rb +1 -1
- data/spec/dummy/db/migrate/20081216190724_create_manifestation_reserve_stats.rb +1 -1
- data/spec/dummy/db/migrate/20081220023628_create_user_reserve_stats.rb +1 -1
- data/spec/dummy/db/migrate/20081220034117_create_reserve_stat_has_users.rb +1 -1
- data/spec/dummy/db/migrate/20090321130448_add_completed_at_to_user_checkout_stat.rb +1 -1
- data/spec/dummy/db/migrate/20090705133942_add_attachments_picture_to_picture_file.rb +1 -1
- data/spec/dummy/db/migrate/20090705212043_add_attachments_attachment_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20090720091106_create_medium_of_performances.rb +2 -2
- data/spec/dummy/db/migrate/20090720091429_create_content_types.rb +2 -2
- data/spec/dummy/db/migrate/20090812151902_create_agent_relationship_types.rb +2 -2
- data/spec/dummy/db/migrate/20091012101112_add_dcndl_schema.rb +1 -1
- data/spec/dummy/db/migrate/20091025080447_create_licenses.rb +2 -2
- data/spec/dummy/db/migrate/20091214131723_create_series_statements.rb +1 -1
- data/spec/dummy/db/migrate/20100129142347_create_import_requests.rb +4 -7
- data/spec/dummy/db/migrate/20100211105551_add_admin_networks_to_library_group.rb +2 -2
- data/spec/dummy/db/migrate/20100223121519_rename_series_statement_title_to_original_title.rb +1 -1
- data/spec/dummy/db/migrate/20100314190054_add_opening_hour_to_library.rb +1 -1
- data/spec/dummy/db/migrate/20100321235924_add_series_statement_identifier_to_series_statement.rb +1 -1
- data/spec/dummy/db/migrate/20100525124311_create_manifestation_relationships.rb +4 -6
- data/spec/dummy/db/migrate/20100606073747_create_agent_relationships.rb +1 -1
- data/spec/dummy/db/migrate/20100607044753_create_manifestation_relationship_types.rb +2 -2
- data/spec/dummy/db/migrate/20100814091104_add_position_to_agent_relationship.rb +1 -1
- data/spec/dummy/db/migrate/20100925043847_create_resource_import_results.rb +1 -1
- data/spec/dummy/db/migrate/20100925074559_create_agent_import_results.rb +1 -1
- data/spec/dummy/db/migrate/20101212070145_add_acquired_at_to_item.rb +1 -1
- data/spec/dummy/db/migrate/20110222073537_add_url_to_library_group.rb +2 -2
- data/spec/dummy/db/migrate/20110301035123_add_pub_date_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20110301121550_add_birth_date_and_death_date_to_agent.rb +1 -1
- data/spec/dummy/db/migrate/20110301134521_add_expire_date_to_reserve.rb +1 -1
- data/spec/dummy/db/migrate/20110318183304_add_valid_period_for_new_user_to_user_group.rb +2 -2
- data/spec/dummy/db/migrate/20110328130826_add_current_checkout_count_to_user_group_has_checkout_type.rb +1 -1
- data/spec/dummy/db/migrate/20110603184217_add_edit_mode_to_resource_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20110619064807_add_edition_string_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20110620173525_add_bookstore_id_to_item.rb +1 -1
- data/spec/dummy/db/migrate/20110621093332_remove_expire_date_from_reserve.rb +1 -1
- data/spec/dummy/db/migrate/20110627034940_create_series_statement_merge_lists.rb +1 -1
- data/spec/dummy/db/migrate/20110627035057_create_series_statement_merges.rb +3 -3
- data/spec/dummy/db/migrate/20110627122938_add_number_of_day_to_notify_overdue_to_user_group.rb +1 -1
- data/spec/dummy/db/migrate/20110916091020_add_volume_number_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20110916103953_add_manifestaiton_id_to_series_statement.rb +1 -1
- data/spec/dummy/db/migrate/20110918162329_add_note_to_series_statement.rb +1 -1
- data/spec/dummy/db/migrate/20111124110059_create_create_types.rb +1 -1
- data/spec/dummy/db/migrate/20111124110319_create_realize_types.rb +1 -1
- data/spec/dummy/db/migrate/20111124110355_create_produce_types.rb +1 -1
- data/spec/dummy/db/migrate/20111124112131_add_create_type_to_create.rb +1 -1
- data/spec/dummy/db/migrate/20111129044509_add_pickup_location_to_reserve.rb +1 -1
- data/spec/dummy/db/migrate/20120105074911_add_isil_to_library.rb +1 -1
- data/spec/dummy/db/migrate/20120125152919_add_title_subseries_transcription_to_series_statement.rb +1 -1
- data/spec/dummy/db/migrate/20120129014038_create_budget_types.rb +1 -1
- data/spec/dummy/db/migrate/20120129020544_add_budget_type_id_to_item.rb +1 -1
- data/spec/dummy/db/migrate/20120319120638_add_content_type_id_to_manifestation.rb +2 -2
- data/spec/dummy/db/migrate/20120319173203_create_accepts.rb +4 -4
- data/spec/dummy/db/migrate/20120410104851_add_year_of_publication_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20120413072700_add_picture_meta_to_picture_file.rb +1 -1
- data/spec/dummy/db/migrate/20120413100352_add_fingerprint_to_picture_file.rb +1 -1
- data/spec/dummy/db/migrate/20120413161340_add_fingerprint_to_resource_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20120413161403_add_fingerprint_to_agent_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20120415164821_add_attachment_meta_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20120418081407_add_month_of_publication_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20120424103932_add_librarian_id_to_checked_item.rb +1 -1
- data/spec/dummy/db/migrate/20120510140958_add_closed_to_shelf.rb +2 -2
- data/spec/dummy/db/migrate/20120511072422_add_agent_identifier_to_agent.rb +1 -1
- data/spec/dummy/db/migrate/20120602141129_add_edit_mode_to_agent_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20121116031206_add_fulltext_content_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20130303124821_add_retained_at_to_reserve.rb +1 -1
- data/spec/dummy/db/migrate/20130304015019_add_postponed_at_to_reserve.rb +1 -1
- data/spec/dummy/db/migrate/20130412083556_add_latitude_and_longitude_to_library.rb +1 -1
- data/spec/dummy/db/migrate/20130416054135_add_circulation_status_id_to_item.rb +1 -1
- data/spec/dummy/db/migrate/20130421093852_add_periodical_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20130421155019_add_creator_string_to_series_statement.rb +1 -1
- data/spec/dummy/db/migrate/20130421164124_add_series_master_to_series_statement.rb +1 -1
- data/spec/dummy/db/migrate/20130429020822_add_root_manifestation_id_to_series_statement.rb +1 -1
- data/spec/dummy/db/migrate/20130506175303_create_identifier_types.rb +1 -1
- data/spec/dummy/db/migrate/20130506175834_create_identifiers.rb +2 -3
- data/spec/dummy/db/migrate/20130509185724_add_statement_of_responsibility_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20130519065638_add_lock_version_to_reserve.rb +1 -1
- data/spec/dummy/db/migrate/20130519065837_add_lock_version_to_checkin.rb +1 -1
- data/spec/dummy/db/migrate/20140110122216_create_user_import_files.rb +3 -3
- data/spec/dummy/db/migrate/20140110131010_create_user_import_results.rb +3 -3
- data/spec/dummy/db/migrate/20140518050147_create_reserve_transitions.rb +3 -3
- data/spec/dummy/db/migrate/20140519170214_create_resource_import_file_transitions.rb +3 -3
- data/spec/dummy/db/migrate/20140519171220_create_import_request_transitions.rb +3 -3
- data/spec/dummy/db/migrate/20140524020735_create_agent_import_file_transitions.rb +3 -3
- data/spec/dummy/db/migrate/20140524074813_create_user_import_file_transitions.rb +3 -2
- data/spec/dummy/db/migrate/20140528045518_create_user_checkout_stat_transitions.rb +4 -4
- data/spec/dummy/db/migrate/20140528045539_create_user_reserve_stat_transitions.rb +4 -4
- data/spec/dummy/db/migrate/20140528045600_create_manifestation_checkout_stat_transitions.rb +5 -5
- data/spec/dummy/db/migrate/20140528045617_create_manifestation_reserve_stat_transitions.rb +5 -5
- data/spec/dummy/db/migrate/20140529014410_create_item_transitions.rb +15 -0
- data/spec/dummy/db/migrate/20140614065404_create_resource_export_files.rb +1 -2
- data/spec/dummy/db/migrate/20140614141500_create_resource_export_file_transitions.rb +3 -3
- data/spec/dummy/db/migrate/20140628072217_add_user_encoding_to_user_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20140628073524_add_user_encoding_to_agent_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20140628073535_add_user_encoding_to_resource_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20140709113413_create_user_export_files.rb +2 -3
- data/spec/dummy/db/migrate/20140709113905_create_user_export_file_transitions.rb +2 -2
- data/spec/dummy/db/migrate/20140720140916_add_binding_item_identifier_to_item.rb +1 -1
- data/spec/dummy/db/migrate/20140720170714_add_default_library_id_to_user_import_file.rb +2 -2
- data/spec/dummy/db/migrate/20140720170735_add_default_user_group_id_to_user_import_file.rb +2 -2
- data/spec/dummy/db/migrate/20140721151416_add_default_shelf_id_to_resource_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20140802082007_add_manifestation_id_to_item.rb +2 -3
- data/spec/dummy/db/migrate/20140810061942_add_user_id_to_user_checkout_stat.rb +1 -1
- data/spec/dummy/db/migrate/20140810091231_add_checkout_icalendar_token_to_profile.rb +1 -1
- data/spec/dummy/db/migrate/20140810091417_add_save_checkout_history_to_profile.rb +1 -1
- data/spec/dummy/db/migrate/20140813182425_add_publication_place_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20140821151023_create_colors.rb +4 -2
- data/spec/dummy/db/migrate/20140823083524_add_extent_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20140823094847_add_dimensions_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20140823095740_rename_manifestation_periodical_to_serial.rb +1 -1
- data/spec/dummy/db/migrate/20141014065831_add_shelf_id_to_checkout.rb +1 -1
- data/spec/dummy/db/migrate/20141020120523_add_library_id_to_checkout.rb +1 -1
- data/spec/dummy/db/migrate/20141029131633_create_periodicals.rb +11 -0
- data/spec/dummy/db/migrate/20150106001709_create_demands.rb +1 -1
- data/spec/dummy/db/migrate/20150221063719_add_settings_to_library_group.rb +2 -2
- data/spec/dummy/db/migrate/20150302110310_add_attachment_id_to_manifestation.rb +7 -0
- data/spec/dummy/db/migrate/20150304183215_add_picture_id_to_picture_file.rb +7 -0
- data/spec/dummy/db/migrate/20150305025906_add_resource_import_id_to_resource_import_file.rb +7 -0
- data/spec/dummy/db/migrate/20150305030046_add_resource_export_id_to_resource_export_file.rb +8 -0
- data/spec/dummy/db/migrate/20150305031709_add_agent_import_id_to_agent_import_file.rb +7 -0
- data/spec/dummy/db/migrate/20150305105231_add_attachment_fingerprint_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20150420145354_add_attachment_to_carrier_type.rb +8 -0
- data/spec/dummy/db/migrate/20150420145420_add_attachment_to_content_type.rb +8 -0
- data/spec/dummy/db/migrate/20150924115059_create_withdraws.rb +4 -4
- data/spec/dummy/db/migrate/20151125004028_add_profile_id_to_agent.rb +1 -1
- data/spec/dummy/db/migrate/20151213070943_add_translation_table_to_library_group.rb +11 -5
- data/spec/dummy/db/migrate/20151213072705_add_footer_banner_to_library_group.rb +3 -20
- data/spec/dummy/db/migrate/20151216123621_create_doi_records.rb +12 -0
- data/spec/dummy/db/migrate/20160319144230_create_issn_records.rb +2 -1
- data/spec/dummy/db/migrate/20160506144040_create_isbn_records.rb +2 -1
- data/spec/dummy/db/migrate/20160513000929_create_agent_names.rb +18 -0
- data/spec/dummy/db/migrate/20160610093229_add_html_snippet_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20160627232219_add_most_recent_to_user_import_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20160627232316_add_most_recent_to_user_export_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20160703184619_add_most_recent_to_reserve_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20160703184650_add_most_recent_to_manifestation_checkout_stat_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20160703184723_add_most_recent_to_manifestation_reserve_stat_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20160703184747_add_most_recent_to_user_checkout_stat_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20160703184805_add_most_recent_to_user_reserve_stat_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20160801080612_add_most_recent_to_import_request_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20160801080619_add_most_recent_to_resource_import_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20160801080637_add_most_recent_to_resource_export_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20160801080643_add_most_recent_to_agent_import_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20160813191533_add_book_jacket_source_to_library_group.rb +5 -0
- data/spec/dummy/db/migrate/20160813191647_add_max_number_of_results_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20160813191733_add_family_name_first_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20160813191820_add_screenshot_generator_to_library_group.rb +5 -0
- data/spec/dummy/db/migrate/20160813192542_add_pub_year_facet_range_interval_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20160813203039_add_user_id_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20161111175127_add_attachment_data_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20161111193255_add_attachment_data_to_carrier_type.rb +5 -0
- data/spec/dummy/db/migrate/20161111193346_add_attachment_data_to_content_type.rb +5 -0
- data/spec/dummy/db/migrate/20161112122706_add_attachment_data_to_resource_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20161112122750_add_attachment_data_to_resource_export_file.rb +5 -0
- data/spec/dummy/db/migrate/20161112122814_add_attachment_data_to_agent_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20161114083857_add_image_data_to_picture_file.rb +5 -0
- data/spec/dummy/db/migrate/20161115184747_add_attachment_data_to_user_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20161115184756_add_attachment_data_to_user_export_file.rb +5 -0
- data/spec/dummy/db/schema.rb +401 -450
- data/spec/factories/profile.rb +8 -8
- data/spec/factories/user.rb +25 -22
- data/spec/factories/user_group.rb +1 -1
- data/spec/fixtures/libraries.yml +37 -37
- data/spec/fixtures/library_groups.yml +27 -19
- data/spec/fixtures/profiles.yml +27 -35
- data/spec/fixtures/roles.yml +12 -12
- data/spec/fixtures/user_groups.yml +20 -10
- data/spec/fixtures/user_has_roles.yml +2 -2
- data/spec/fixtures/users.yml +7 -0
- data/spec/models/profile_spec.rb +17 -18
- data/spec/models/role_spec.rb +17 -18
- data/spec/models/user_has_role_spec.rb +4 -5
- data/spec/models/user_spec.rb +14 -16
- data/spec/rails_helper.rb +4 -9
- data/spec/requests/profiles_spec.rb +3 -3
- data/spec/routing/profiles_routing_spec.rb +16 -18
- data/spec/routing/roles_routing_spec.rb +16 -18
- data/spec/routing/users_spec.rb +6 -7
- data/spec/spec_helper.rb +47 -49
- data/spec/support/controller_macros.rb +6 -6
- data/spec/views/my_accounts/show.html.erb_spec.rb +6 -6
- data/spec/views/profiles/edit.html.erb_spec.rb +7 -7
- data/spec/views/profiles/index.html.erb_spec.rb +3 -3
- data/spec/views/profiles/new.html.erb_spec.rb +5 -6
- data/spec/views/profiles/show.html.erb_spec.rb +4 -4
- metadata +297 -454
- data/db/migrate/20140610123439_drop_email_unique_constraint_enju_leaf_rc10.rb +0 -11
- data/lib/generators/enju_seed/setup/setup_generator.rb +0 -9
- data/lib/generators/enju_seed/setup/templates/db/fixtures/roles.yml +0 -38
- data/lib/generators/enju_seed/update/update_generator.rb +0 -9
- data/spec/dummy/app/models/application_record.rb +0 -3
- data/spec/dummy/bin/update +0 -29
- data/spec/dummy/bin/yarn +0 -11
- data/spec/dummy/config/cable.yml +0 -10
- data/spec/dummy/config/initializers/application_controller_renderer.rb +0 -8
- data/spec/dummy/config/puma.rb +0 -56
- data/spec/dummy/config/spring.rb +0 -6
- data/spec/dummy/config/webpack/development.js +0 -5
- data/spec/dummy/config/webpack/environment.js +0 -11
- data/spec/dummy/config/webpack/production.js +0 -5
- data/spec/dummy/config/webpack/test.js +0 -5
- data/spec/dummy/config/webpacker.yml +0 -95
- data/spec/dummy/db/migrate/149_create_message_templates.rb +0 -18
- data/spec/dummy/db/migrate/154_create_messages.rb +0 -23
- data/spec/dummy/db/migrate/20080819181903_create_message_requests.rb +0 -18
- data/spec/dummy/db/migrate/20090831220301_create_lending_policies.rb +0 -21
- data/spec/dummy/db/migrate/20110913115320_add_lft_and_rgt_to_message.rb +0 -11
- data/spec/dummy/db/migrate/20120125050502_add_depth_to_message.rb +0 -6
- data/spec/dummy/db/migrate/20120413170705_add_error_message_to_resource_import_file.rb +0 -5
- data/spec/dummy/db/migrate/20120413170720_add_error_message_to_agent_import_file.rb +0 -5
- data/spec/dummy/db/migrate/20140518111006_create_message_transitions.rb +0 -18
- data/spec/dummy/db/migrate/20140518135713_create_message_request_transitions.rb +0 -18
- data/spec/dummy/db/migrate/20140822114527_add_error_message_to_resource_import_result.rb +0 -5
- data/spec/dummy/db/migrate/20150117111136_add_foreign_key_to_items_referencing_manifestations.rb +0 -5
- data/spec/dummy/db/migrate/20150506105356_add_error_message_to_user_import_result.rb +0 -5
- data/spec/dummy/db/migrate/20160703185015_add_most_recent_to_message_transitions.rb +0 -9
- data/spec/dummy/db/migrate/20160703190209_add_foreign_key_on_manifestation_id_to_reserve.rb +0 -5
- data/spec/dummy/db/migrate/20160811102604_add_picture_width_to_picture_file.rb +0 -6
- data/spec/dummy/db/migrate/20160814165332_add_most_recent_to_message_request_transitions.rb +0 -9
- data/spec/dummy/db/migrate/20160820004638_add_attachment_attachment_to_carrier_types.rb +0 -11
- data/spec/dummy/db/migrate/20170116134107_create_issn_record_and_manifestations.rb +0 -11
- data/spec/dummy/db/migrate/20170116134120_create_isbn_record_and_manifestations.rb +0 -11
- data/spec/dummy/db/migrate/20170305064014_add_csv_charset_conversion_to_library_group.rb +0 -5
- data/spec/dummy/db/migrate/20171014084528_add_header_logo_to_library_group.rb +0 -5
- data/spec/dummy/db/migrate/20171119051258_set_not_null_to_manifestation_id_on_items.rb +0 -5
- data/spec/dummy/db/migrate/20171126133835_rename_login_banner_to_old_login_banner.rb +0 -5
- data/spec/dummy/db/migrate/20171126135238_add_foreign_key_to_library_group_id_on_library.rb +0 -5
- data/spec/dummy/db/migrate/20180102162311_add_header_logo_meta_to_library_group.rb +0 -5
- data/spec/dummy/db/migrate/20180107160726_add_constraints_to_most_recent_for_user_import_file_transitions.rb +0 -13
- data/spec/dummy/db/migrate/20180107160740_add_constraints_to_most_recent_for_user_export_file_transitions.rb +0 -13
- data/spec/dummy/db/migrate/20180107161311_add_constraints_to_most_recent_for_agent_import_file_transitions.rb +0 -13
- data/spec/dummy/db/migrate/20180107161331_add_constraints_to_most_recent_for_resource_import_file_transitions.rb +0 -13
- data/spec/dummy/db/migrate/20180107161347_add_constraints_to_most_recent_for_resource_export_file_transitions.rb +0 -13
- data/spec/dummy/db/migrate/20180107161410_add_constraints_to_most_recent_for_import_request_transitions.rb +0 -13
- data/spec/dummy/db/migrate/20180107162659_add_constraints_to_most_recent_for_message_transitions.rb +0 -13
- data/spec/dummy/db/migrate/20180107162711_add_constraints_to_most_recent_for_message_request_transitions.rb +0 -13
- data/spec/dummy/db/migrate/20181026064038_add_login_banner_to_library_group.rb +0 -6
- data/spec/dummy/db/migrate/20181030072731_add_not_null_to_position_on_carrier_type.rb +0 -14
- data/spec/dummy/db/migrate/20181030074920_add_not_null_to_position_on_library.rb +0 -14
- data/spec/dummy/db/migrate/20190208135957_create_active_storage_tables.active_storage.rb +0 -27
- data/spec/dummy/db/migrate/20190311154610_create_periodicals.rb +0 -10
- data/spec/dummy/db/migrate/20190314151124_add_full_name_translations_to_create.rb +0 -7
- data/spec/dummy/package.json +0 -5
- data/spec/fixtures/message_requests.yml +0 -26
- data/spec/fixtures/message_templates.yml +0 -98
- data/spec/fixtures/messages.yml +0 -56
- data/spec/system/profiles_spec.rb +0 -39
- data/spec/views/roles/edit.html.erb_spec.rb +0 -18
- data/spec/views/roles/index.html.erb_spec.rb +0 -14
- data/spec/views/roles/new.html.erb_spec.rb +0 -18
- data/spec/views/roles/show.html.erb_spec.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b5fffbc1a85f126c197b09fe20aa46de6d61fa3a
|
4
|
+
data.tar.gz: d6bb594aa98a2d6d93032321b2de745039da40f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89cad5681535a5c84a81bd18489e4ebe861d676545d4301ba91fcfcf6fb967a8c07303b63466164190b44571a1520e9c9c571c6b3b4627e43fc147d68c648f17
|
7
|
+
data.tar.gz: 84e0a347b30ba2afb9d2f8a55aaefc3896f160b6285536b881e2e3b016e2442b1da6f796ef21ece33feeb31ffcebe1dc0b38dd3fa11ab78dfa2b3367fcf8970a
|
data/README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# EnjuSeed
|
2
|
-
[![
|
3
|
-
[![
|
4
|
-
[![
|
2
|
+
[![Build Status](https://travis-ci.org/next-l/enju_seed.svg?branch=master)](https://travis-ci.org/next-l/enju_seed)
|
3
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/1af7690d4817559ccef9/maintainability)](https://codeclimate.com/github/next-l/enju_seed/maintainability)
|
4
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/1af7690d4817559ccef9/test_coverage)](https://codeclimate.com/github/next-l/enju_seed/test_coverage)
|
5
|
+
[![security](https://hakiri.io/github/next-l/enju_seed/master.svg)](https://hakiri.io/github/next-l/enju_seed/master)
|
5
6
|
|
6
|
-
|
7
|
+
## 製作者・貢献者 (Authors and contributors)
|
8
|
+
- [TANABE, Kosuke](https://github.com/nabeta) ([@nabeta](https://twitter.com/nabeta))
|
9
|
+
- [Project Next-L](http://www.next-l.jp) ([@ProjectNextL]([https://twitter.com/ProjectNextL))
|
7
10
|
|
8
|
-
##
|
9
|
-
|
10
|
-
* [Project Next-L](https://www.next-l.jp) ([@ProjectNextL](https://twitter.com/ProjectNextL))
|
11
|
+
## License
|
12
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -14,19 +14,28 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
14
14
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
15
|
end
|
16
16
|
|
17
|
-
APP_RAKEFILE = File.expand_path(
|
17
|
+
APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
|
18
18
|
load 'rails/tasks/engine.rake'
|
19
19
|
|
20
|
+
load 'rails/tasks/statistics.rake'
|
20
21
|
|
22
|
+
require 'bundler/gem_tasks'
|
21
23
|
|
22
|
-
|
24
|
+
require 'rake/testtask'
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = false
|
29
31
|
end
|
30
32
|
|
33
|
+
begin
|
34
|
+
require 'rspec/core/rake_task'
|
35
|
+
|
36
|
+
RSpec::Core::RakeTask.new(:spec)
|
37
|
+
rescue LoadError
|
38
|
+
# no rspec available
|
39
|
+
end
|
31
40
|
|
32
41
|
task default: :spec
|
@@ -1,5 +1,4 @@
|
|
1
1
|
class ProfilesController < ApplicationController
|
2
|
-
before_action :authenticate_user!
|
3
2
|
before_action :set_profile, only: [:show, :edit, :update, :destroy]
|
4
3
|
before_action :check_policy, only: [:index, :new, :create]
|
5
4
|
before_action :prepare_options, only: [:new, :edit]
|
@@ -8,7 +7,7 @@ class ProfilesController < ApplicationController
|
|
8
7
|
# GET /profiles.json
|
9
8
|
def index
|
10
9
|
if params[:username].present?
|
11
|
-
profile = User.
|
10
|
+
profile = User.where(username: params[:username]).first.try(:profile)
|
12
11
|
if profile
|
13
12
|
redirect_to profile
|
14
13
|
return
|
@@ -18,7 +17,7 @@ class ProfilesController < ApplicationController
|
|
18
17
|
@query = query.dup
|
19
18
|
@count = {}
|
20
19
|
|
21
|
-
sort = {sort_by: 'created_at', order: 'desc'}
|
20
|
+
sort = { sort_by: 'created_at', order: 'desc' }
|
22
21
|
case params[:sort_by]
|
23
22
|
when 'username'
|
24
23
|
sort[:sort_by] = 'username'
|
@@ -88,7 +87,7 @@ class ProfilesController < ApplicationController
|
|
88
87
|
else
|
89
88
|
@profile.reset_checkout_icalendar_token
|
90
89
|
end
|
91
|
-
render partial: 'feed_token', locals: {profile: @profile}
|
90
|
+
render partial: 'feed_token', locals: { profile: @profile }
|
92
91
|
return
|
93
92
|
end
|
94
93
|
end
|
@@ -96,9 +95,7 @@ class ProfilesController < ApplicationController
|
|
96
95
|
redirect_to edit_my_account_url
|
97
96
|
return
|
98
97
|
end
|
99
|
-
if @profile.user.try(:locked_at?)
|
100
|
-
@profile.user.locked = true
|
101
|
-
end
|
98
|
+
@profile.user.locked = true if @profile.user.try(:locked_at?)
|
102
99
|
end
|
103
100
|
|
104
101
|
# POST /profiles
|
@@ -106,9 +103,7 @@ class ProfilesController < ApplicationController
|
|
106
103
|
def create
|
107
104
|
if current_user.has_role?('Librarian')
|
108
105
|
@profile = Profile.new(profile_params)
|
109
|
-
if @profile.user
|
110
|
-
password = @profile.user.set_auto_generated_password
|
111
|
-
end
|
106
|
+
password = @profile.user.set_auto_generated_password if @profile.user
|
112
107
|
else
|
113
108
|
@profile = Profile.new(profile_params)
|
114
109
|
end
|
@@ -116,14 +111,14 @@ class ProfilesController < ApplicationController
|
|
116
111
|
respond_to do |format|
|
117
112
|
if @profile.save
|
118
113
|
if @profile.user
|
119
|
-
@profile.user.role = Role.
|
114
|
+
@profile.user.role = Role.where(name: 'User').first
|
120
115
|
flash[:temporary_password] = password
|
121
116
|
end
|
122
117
|
format.html { redirect_to @profile, notice: t('controller.successfully_created', model: t('activerecord.models.profile')) }
|
123
118
|
format.json { render json: @profile, status: :created, location: @profile }
|
124
119
|
else
|
125
120
|
prepare_options
|
126
|
-
format.html { render action:
|
121
|
+
format.html { render action: 'new' }
|
127
122
|
format.json { render json: @profile.errors, status: :unprocessable_entity }
|
128
123
|
end
|
129
124
|
end
|
@@ -132,9 +127,9 @@ class ProfilesController < ApplicationController
|
|
132
127
|
# PUT /profiles/1
|
133
128
|
# PUT /profiles/1.json
|
134
129
|
def update
|
135
|
-
@profile.
|
130
|
+
@profile.update_attributes(profile_update_params)
|
136
131
|
if @profile.user
|
137
|
-
if @profile.user.auto_generated_password ==
|
132
|
+
if @profile.user.auto_generated_password == '1'
|
138
133
|
password = @profile.user.set_auto_generated_password
|
139
134
|
end
|
140
135
|
end
|
@@ -146,7 +141,7 @@ class ProfilesController < ApplicationController
|
|
146
141
|
format.json { head :no_content }
|
147
142
|
else
|
148
143
|
prepare_options
|
149
|
-
format.html { render action:
|
144
|
+
format.html { render action: 'edit' }
|
150
145
|
format.json { render json: @profile.errors, status: :unprocessable_entity }
|
151
146
|
end
|
152
147
|
end
|
@@ -164,6 +159,7 @@ class ProfilesController < ApplicationController
|
|
164
159
|
end
|
165
160
|
|
166
161
|
private
|
162
|
+
|
167
163
|
def set_profile
|
168
164
|
@profile = Profile.find(params[:id])
|
169
165
|
authorize @profile
|
@@ -180,15 +176,17 @@ class ProfilesController < ApplicationController
|
|
180
176
|
:save_checkout_history, :checkout_icalendar_token, # EnjuCirculation
|
181
177
|
:save_search_history, # EnjuSearchLog
|
182
178
|
]
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
:
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
179
|
+
if current_user.has_role?('Librarian')
|
180
|
+
attrs += [
|
181
|
+
:library_id, :expired_at, :birth_date,
|
182
|
+
:user_group_id, :required_role_id, :note, :user_number, {
|
183
|
+
user_attributes: [
|
184
|
+
:id, :username, :email, :current_password, :locked,
|
185
|
+
{ user_has_role_attributes: [:id, :role_id] }
|
186
|
+
]
|
187
|
+
}
|
188
|
+
]
|
189
|
+
end
|
192
190
|
params.require(:profile).permit(*attrs)
|
193
191
|
end
|
194
192
|
|
@@ -199,15 +197,17 @@ class ProfilesController < ApplicationController
|
|
199
197
|
:save_checkout_history, :checkout_icalendar_token, # EnjuCirculation
|
200
198
|
:save_search_history, # EnjuSearchLog
|
201
199
|
]
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
:
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
200
|
+
if current_user.has_role?('Librarian')
|
201
|
+
attrs += [
|
202
|
+
:library_id, :expired_at, :birth_date,
|
203
|
+
:user_group_id, :required_role_id, :note, :user_number, {
|
204
|
+
user_attributes: [
|
205
|
+
:id, :email, :current_password, :auto_generated_password, :locked,
|
206
|
+
{ user_has_role_attributes: [:id, :role_id] }
|
207
|
+
]
|
208
|
+
}
|
209
|
+
]
|
210
|
+
end
|
211
211
|
params.require(:profile).permit(*attrs)
|
212
212
|
end
|
213
213
|
|
@@ -35,17 +35,18 @@ class RolesController < ApplicationController
|
|
35
35
|
end
|
36
36
|
|
37
37
|
respond_to do |format|
|
38
|
-
if @role.
|
38
|
+
if @role.update_attributes(role_params)
|
39
39
|
format.html { redirect_to @role, notice: t('controller.successfully_updated', model: t('activerecord.models.role')) }
|
40
40
|
format.json { head :no_content }
|
41
41
|
else
|
42
|
-
format.html { render action:
|
42
|
+
format.html { render action: 'edit' }
|
43
43
|
format.json { render json: @role.errors, status: :unprocessable_entity }
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
private
|
49
|
+
|
49
50
|
def set_role
|
50
51
|
@role = Role.find(params[:id])
|
51
52
|
authorize @role
|
@@ -6,26 +6,26 @@ module EnjuSeed
|
|
6
6
|
scope :administrators, -> { joins(:role).where('roles.name = ?', 'Administrator') }
|
7
7
|
scope :librarians, -> { joins(:role).where('roles.name = ? OR roles.name = ?', 'Administrator', 'Librarian') }
|
8
8
|
scope :suspended, -> { where('locked_at IS NOT NULL') }
|
9
|
-
has_one :profile
|
10
9
|
if defined?(EnjuBiblio)
|
11
10
|
has_many :import_requests
|
12
11
|
has_many :picture_files, as: :picture_attachable, dependent: :destroy
|
13
12
|
end
|
14
13
|
has_one :user_has_role, dependent: :destroy
|
15
14
|
has_one :role, through: :user_has_role
|
15
|
+
belongs_to :profile
|
16
16
|
accepts_nested_attributes_for :user_has_role
|
17
17
|
|
18
18
|
validates :username, presence: true, uniqueness: true, format: {
|
19
19
|
with: /\A[0-9A-Za-z][0-9A-Za-z_\-]*[0-9A-Za-z]\z/
|
20
20
|
}
|
21
|
-
validates :email, format: Devise
|
21
|
+
validates :email, format: Devise.email_regexp, allow_blank: true, uniqueness: true
|
22
22
|
validates_date :expired_at, allow_blank: true
|
23
23
|
|
24
24
|
with_options if: :password_required? do |v|
|
25
25
|
v.validates_presence_of :password
|
26
26
|
v.validates_confirmation_of :password
|
27
27
|
v.validates_length_of :password, allow_blank: true,
|
28
|
-
|
28
|
+
within: Devise.password_length
|
29
29
|
end
|
30
30
|
|
31
31
|
before_validation :set_lock_information
|
@@ -39,8 +39,8 @@ module EnjuSeed
|
|
39
39
|
strip_attributes only: :email, allow_empty: true
|
40
40
|
|
41
41
|
attr_accessor :password_not_verified,
|
42
|
-
|
43
|
-
|
42
|
+
:update_own_account, :auto_generated_password,
|
43
|
+
:locked, :current_password # , :agent_id
|
44
44
|
|
45
45
|
paginates_per 10
|
46
46
|
|
@@ -51,13 +51,13 @@ module EnjuSeed
|
|
51
51
|
# 有効期限切れのユーザを一括で使用不可にします。
|
52
52
|
def self.lock_expired_users
|
53
53
|
User.find_each do |user|
|
54
|
-
user.lock_access! if user.expired?
|
54
|
+
user.lock_access! if user.expired? && user.active_for_authentication?
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
# ユーザの情報をエクスポートします。
|
59
59
|
# @param [Hash] options
|
60
|
-
def self.export(options = {format: :
|
60
|
+
def self.export(options = { format: :txt })
|
61
61
|
header = %w(
|
62
62
|
username
|
63
63
|
full_name
|
@@ -76,14 +76,16 @@ module EnjuSeed
|
|
76
76
|
keyword_list
|
77
77
|
note
|
78
78
|
)
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
79
|
+
if defined? EnjuCirculation
|
80
|
+
header += %w(
|
81
|
+
checkout_icalendar_token
|
82
|
+
save_checkout_history
|
83
|
+
)
|
84
|
+
end
|
85
|
+
header << 'save_search_history' if defined? EnjuSearchLog
|
86
|
+
header << 'share_bookmarks' if defined? EnjuBookmark
|
85
87
|
lines = []
|
86
|
-
User.find_each.map
|
88
|
+
User.find_each.map do |u|
|
87
89
|
line = []
|
88
90
|
line << u.username
|
89
91
|
line << u.try(:profile).try(:full_name)
|
@@ -99,7 +101,7 @@ module EnjuSeed
|
|
99
101
|
line << u.created_at
|
100
102
|
line << u.updated_at
|
101
103
|
line << u.try(:profile).try(:expired_at)
|
102
|
-
line << u.try(:profile).try(:keyword_list).try(:split).try(:join,
|
104
|
+
line << u.try(:profile).try(:keyword_list).try(:split).try(:join, '//')
|
103
105
|
line << u.try(:profile).try(:note)
|
104
106
|
if defined? EnjuCirculation
|
105
107
|
line << u.try(:profile).try(:checkout_icalendar_token)
|
@@ -108,13 +110,11 @@ module EnjuSeed
|
|
108
110
|
if defined? EnjuSearchLog
|
109
111
|
line << u.try(:profile).try(:save_search_history)
|
110
112
|
end
|
111
|
-
if defined? EnjuBookmark
|
112
|
-
line << u.try(:profile).try(:share_bookmarks)
|
113
|
-
end
|
113
|
+
line << u.try(:profile).try(:share_bookmarks) if defined? EnjuBookmark
|
114
114
|
lines << line
|
115
|
-
|
116
|
-
if options[:format] == :
|
117
|
-
lines.map{|line| line.to_csv(col_sep: "\t")}.unshift(header.to_csv(col_sep: "\t")).join
|
115
|
+
end
|
116
|
+
if options[:format] == :txt
|
117
|
+
lines.map { |line| line.to_csv(col_sep: "\t") }.unshift(header.to_csv(col_sep: "\t")).join
|
118
118
|
else
|
119
119
|
lines
|
120
120
|
end
|
@@ -147,9 +147,9 @@ module EnjuSeed
|
|
147
147
|
|
148
148
|
# ユーザに使用不可の設定を反映させます。
|
149
149
|
def set_lock_information
|
150
|
-
if locked == '1'
|
150
|
+
if (locked == '1') && active_for_authentication?
|
151
151
|
lock_access!
|
152
|
-
elsif locked == '0'
|
152
|
+
elsif (locked == '0') && !active_for_authentication?
|
153
153
|
unlock_access!
|
154
154
|
end
|
155
155
|
end
|
@@ -176,7 +176,7 @@ module EnjuSeed
|
|
176
176
|
# @return [Object]
|
177
177
|
def check_role_before_destroy
|
178
178
|
if has_role?('Administrator')
|
179
|
-
if Role.
|
179
|
+
if Role.where(name: 'Administrator').first.users.count == 1
|
180
180
|
raise username + 'This is the last administrator in this system.'
|
181
181
|
end
|
182
182
|
end
|
@@ -209,7 +209,7 @@ module EnjuSeed
|
|
209
209
|
# @return [Boolean]
|
210
210
|
def last_librarian?
|
211
211
|
if has_role?('Librarian')
|
212
|
-
role = Role.
|
212
|
+
role = Role.where(name: 'Librarian').first
|
213
213
|
return true if role.users.count == 1
|
214
214
|
false
|
215
215
|
end
|
@@ -237,14 +237,12 @@ module EnjuSeed
|
|
237
237
|
errors[:base] << I18n.t('user.only_administrator_can_destroy')
|
238
238
|
end
|
239
239
|
# 最後の図書館員を削除しようとした
|
240
|
-
if last_librarian?
|
241
|
-
errors[:base] << I18n.t('user.last_librarian')
|
242
|
-
end
|
240
|
+
errors[:base] << I18n.t('user.last_librarian') if last_librarian?
|
243
241
|
end
|
244
242
|
|
245
243
|
# 最後の管理者を削除しようとした
|
246
244
|
if has_role?('Administrator')
|
247
|
-
if Role.
|
245
|
+
if Role.where(name: 'Administrator').first.users.count == 1
|
248
246
|
errors[:base] << I18n.t('user.last_administrator')
|
249
247
|
end
|
250
248
|
end
|
@@ -258,7 +256,6 @@ module EnjuSeed
|
|
258
256
|
end
|
259
257
|
end
|
260
258
|
|
261
|
-
|
262
259
|
# == Schema Information
|
263
260
|
#
|
264
261
|
# Table name: users
|
@@ -303,4 +300,3 @@ end
|
|
303
300
|
# save_search_history :boolean
|
304
301
|
# answer_feed_token :string(255)
|
305
302
|
#
|
306
|
-
|
@@ -3,14 +3,10 @@ module MasterModel
|
|
3
3
|
|
4
4
|
included do
|
5
5
|
acts_as_list
|
6
|
-
|
7
|
-
validates :name, presence: true
|
6
|
+
validates :name, presence: true, uniqueness: { case_sensitive: false }
|
8
7
|
validate :name do
|
9
8
|
valid_name?
|
10
9
|
end
|
11
|
-
validate :display_name do
|
12
|
-
valid_yaml?
|
13
|
-
end
|
14
10
|
validates :display_name, presence: true
|
15
11
|
before_validation :set_display_name, on: :create
|
16
12
|
strip_attributes only: :name
|
@@ -22,17 +18,10 @@ module MasterModel
|
|
22
18
|
end
|
23
19
|
|
24
20
|
private
|
21
|
+
|
25
22
|
def valid_name?
|
26
23
|
unless name =~ /\A[a-z][0-9a-z_]*[0-9a-z]\z/
|
27
24
|
errors.add(:name, I18n.t('page.only_lowercase_letters_and_numbers_are_allowed'))
|
28
25
|
end
|
29
26
|
end
|
30
|
-
|
31
|
-
def valid_yaml?
|
32
|
-
begin
|
33
|
-
YAML.load(display_name)
|
34
|
-
rescue Psych::SyntaxError
|
35
|
-
errors.add(:display_name, I18n.t('page.cannot_parse_yaml_header'))
|
36
|
-
end
|
37
|
-
end
|
38
27
|
end
|
data/app/models/identity.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
class Identity <
|
1
|
+
class Identity < ActiveRecord::Base
|
2
2
|
belongs_to :profile
|
3
|
-
validates :name, presence: true, uniqueness: {scope: :provider}
|
3
|
+
validates :name, presence: true, uniqueness: { scope: :provider }
|
4
4
|
validates :provider, presence: true
|
5
5
|
|
6
6
|
def self.find_for_oauth(auth)
|
@@ -19,5 +19,5 @@ end
|
|
19
19
|
# profile_id :integer
|
20
20
|
# created_at :datetime not null
|
21
21
|
# updated_at :datetime not null
|
22
|
-
# provider :string
|
22
|
+
# provider :string not null
|
23
23
|
#
|
data/app/models/profile.rb
CHANGED
@@ -1,19 +1,20 @@
|
|
1
|
-
class Profile <
|
1
|
+
class Profile < ActiveRecord::Base
|
2
|
+
enju_search_log_profile_model if defined?(EnjuSearchLog)
|
3
|
+
|
2
4
|
scope :administrators, -> { joins(user: :role).where('roles.name = ?', 'Administrator') }
|
3
5
|
scope :librarians, -> { joins(user: :role).where('roles.name = ? OR roles.name = ?', 'Administrator', 'Librarian') }
|
4
|
-
|
5
|
-
belongs_to :library
|
6
|
+
has_one :user
|
7
|
+
belongs_to :library, validate: true
|
6
8
|
belongs_to :user_group
|
7
|
-
belongs_to :required_role, class_name: 'Role', foreign_key: 'required_role_id'
|
9
|
+
belongs_to :required_role, class_name: 'Role', foreign_key: 'required_role_id' # , validate: true
|
8
10
|
has_many :identities
|
9
11
|
has_many :agents
|
10
12
|
accepts_nested_attributes_for :identities, allow_destroy: true, reject_if: :all_blank
|
11
13
|
|
12
14
|
validates_associated :user_group, :library
|
13
|
-
|
14
|
-
|
15
|
+
validates_associated :user
|
16
|
+
validates :user_group, :library, :locale, presence: true # , :user_number
|
15
17
|
validates :user_number, uniqueness: true, format: { with: /\A[0-9A-Za-z_]+\z/ }, allow_blank: true
|
16
|
-
validates :user_id, uniqueness: true, allow_blank: true
|
17
18
|
validates :birth_date, format: { with: /\A\d{4}-\d{1,2}-\d{1,2}\z/ }, allow_blank: true
|
18
19
|
|
19
20
|
strip_attributes only: :user_number
|
@@ -50,7 +51,7 @@ class Profile < ApplicationRecord
|
|
50
51
|
# 既定のユーザ権限を設定します。
|
51
52
|
# @return [void]
|
52
53
|
def set_role_and_agent
|
53
|
-
self.required_role = Role.
|
54
|
+
self.required_role = Role.where(name: 'Librarian').first unless required_role
|
54
55
|
self.locale = I18n.default_locale.to_s unless locale
|
55
56
|
end
|
56
57
|
|
@@ -77,18 +78,17 @@ end
|
|
77
78
|
#
|
78
79
|
# Table name: profiles
|
79
80
|
#
|
80
|
-
# id :
|
81
|
-
#
|
82
|
-
#
|
83
|
-
# library_id :integer
|
81
|
+
# id :uuid not null, primary key
|
82
|
+
# user_group_id :uuid
|
83
|
+
# library_id :uuid
|
84
84
|
# locale :string
|
85
85
|
# user_number :string
|
86
86
|
# full_name :text
|
87
87
|
# note :text
|
88
88
|
# keyword_list :text
|
89
89
|
# required_role_id :integer
|
90
|
-
# created_at :datetime
|
91
|
-
# updated_at :datetime
|
90
|
+
# created_at :datetime not null
|
91
|
+
# updated_at :datetime not null
|
92
92
|
# checkout_icalendar_token :string
|
93
93
|
# save_checkout_history :boolean default(FALSE), not null
|
94
94
|
# expired_at :datetime
|
data/app/models/role.rb
CHANGED
@@ -1,35 +1,19 @@
|
|
1
|
-
class Role <
|
1
|
+
class Role < ActiveRecord::Base
|
2
2
|
include MasterModel
|
3
3
|
validates :name, presence: true, format: { with: /\A[A-Za-z][a-z_,]*[a-z]\z/ }
|
4
4
|
has_many :user_has_roles
|
5
5
|
has_many :users, through: :user_has_roles
|
6
|
-
after_save :clear_all_cache
|
7
|
-
after_destroy :clear_all_cache
|
8
6
|
|
9
7
|
extend FriendlyId
|
10
8
|
friendly_id :name
|
11
|
-
|
12
|
-
def localized_name
|
13
|
-
display_name.localize
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.all_cache
|
17
|
-
if Rails.env == 'production'
|
18
|
-
Rails.cache.fetch('role_all'){ Role.select(:name).all }
|
19
|
-
else
|
20
|
-
Role.select(:name)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def clear_all_cache
|
25
|
-
Rails.cache.delete('role_all')
|
26
|
-
end
|
9
|
+
translates :display_name
|
27
10
|
|
28
11
|
def self.default_role
|
29
12
|
Role.find_by(name: 'Guest')
|
30
13
|
end
|
31
14
|
|
32
15
|
private
|
16
|
+
|
33
17
|
def valid_name?
|
34
18
|
true
|
35
19
|
end
|
@@ -39,12 +23,12 @@ end
|
|
39
23
|
#
|
40
24
|
# Table name: roles
|
41
25
|
#
|
42
|
-
# id
|
43
|
-
# name
|
44
|
-
#
|
45
|
-
# note
|
46
|
-
# created_at
|
47
|
-
# updated_at
|
48
|
-
# score
|
49
|
-
# position
|
26
|
+
# id :integer not null, primary key
|
27
|
+
# name :string not null
|
28
|
+
# display_name_translations :jsonb
|
29
|
+
# note :text
|
30
|
+
# created_at :datetime not null
|
31
|
+
# updated_at :datetime not null
|
32
|
+
# score :integer default(0), not null
|
33
|
+
# position :integer
|
50
34
|
#
|
data/app/models/user_has_role.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
-
class UserHasRole <
|
1
|
+
class UserHasRole < ActiveRecord::Base
|
2
2
|
belongs_to :user
|
3
3
|
belongs_to :role
|
4
4
|
accepts_nested_attributes_for :role
|
5
|
+
|
6
|
+
# validates_uniqueness_of :role_id, scope: :user_id
|
7
|
+
# validates_presence_of :role_id, :user_id
|
5
8
|
end
|
6
9
|
|
7
10
|
# == Schema Information
|
@@ -11,6 +14,6 @@ end
|
|
11
14
|
# id :integer not null, primary key
|
12
15
|
# user_id :integer not null
|
13
16
|
# role_id :integer not null
|
14
|
-
# created_at :datetime
|
15
|
-
# updated_at :datetime
|
17
|
+
# created_at :datetime not null
|
18
|
+
# updated_at :datetime not null
|
16
19
|
#
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class UserExportFilePolicy < ApplicationPolicy
|
2
|
+
def index?
|
3
|
+
true if user.try(:has_role?, 'Administrator')
|
4
|
+
end
|
5
|
+
|
6
|
+
def show?
|
7
|
+
true if user.try(:has_role?, 'Administrator')
|
8
|
+
end
|
9
|
+
|
10
|
+
def create?
|
11
|
+
true if user.try(:has_role?, 'Administrator')
|
12
|
+
end
|
13
|
+
|
14
|
+
def update?
|
15
|
+
true if user.try(:has_role?, 'Administrator')
|
16
|
+
end
|
17
|
+
|
18
|
+
def destroy?
|
19
|
+
true if user.try(:has_role?, 'Administrator')
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class UserImportFilePolicy < 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 UserImportResultPolicy < 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
|