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.
Files changed (367) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/enju.css +0 -1
  3. data/app/controllers/my_accounts_controller.rb +26 -18
  4. data/app/controllers/page_controller.rb +6 -6
  5. data/app/controllers/profiles_controller.rb +155 -0
  6. data/app/controllers/roles_controller.rb +5 -5
  7. data/app/controllers/user_export_files_controller.rb +100 -0
  8. data/app/controllers/user_groups_controller.rb +11 -11
  9. data/app/controllers/user_import_files_controller.rb +22 -11
  10. data/app/controllers/user_import_results_controller.rb +1 -1
  11. data/app/mailers/notifier.rb +7 -7
  12. data/app/models/enju_leaf/ability.rb +14 -13
  13. data/app/models/profile.rb +63 -16
  14. data/app/models/role.rb +2 -2
  15. data/app/models/user_export_file.rb +52 -0
  16. data/app/models/user_export_file_state_machine.rb +15 -0
  17. data/app/models/user_export_file_transition.rb +20 -0
  18. data/app/models/user_group.rb +3 -3
  19. data/app/models/user_has_role.rb +2 -2
  20. data/app/models/user_import_file.rb +139 -53
  21. data/app/views/kaminari/_first_page.html.erb +1 -1
  22. data/app/views/kaminari/_last_page.html.erb +1 -1
  23. data/app/views/kaminari/_next_page.html.erb +1 -1
  24. data/app/views/kaminari/_page.html.erb +1 -1
  25. data/app/views/kaminari/_prev_page.html.erb +1 -1
  26. data/app/views/kaminari/enju_leaf_mobile/_next_page.html.erb +1 -1
  27. data/app/views/kaminari/enju_leaf_mobile/_page.html.erb +1 -1
  28. data/app/views/kaminari/enju_leaf_mobile/_prev_page.html.erb +1 -1
  29. data/app/views/layouts/application.html.erb +4 -4
  30. data/app/views/my_accounts/_edit_credential.html.erb +67 -59
  31. data/app/views/my_accounts/edit.html.erb +6 -46
  32. data/app/views/my_accounts/show.html.erb +8 -8
  33. data/app/views/page/_add.html.erb +2 -2
  34. data/app/views/page/_footer.html.erb +3 -2
  35. data/app/views/page/_footer.mobile.erb +1 -1
  36. data/app/views/page/_header.html.erb +4 -4
  37. data/app/views/page/_include.html.erb +1 -1
  38. data/app/views/page/_index.html.erb +8 -8
  39. data/app/views/page/_index.mobile.erb +4 -4
  40. data/app/views/page/_menu.html.erb +9 -6
  41. data/app/views/page/_msie_acceralator.html.erb +1 -1
  42. data/app/views/page/_position.html.erb +2 -2
  43. data/app/views/page/_search_form.html.erb +2 -2
  44. data/app/views/page/_search_form.mobile.erb +2 -2
  45. data/app/views/page/_select_locale.html.erb +2 -2
  46. data/app/views/page/about.en.html.erb +2 -2
  47. data/app/views/page/about.ja.html.erb +2 -2
  48. data/app/views/page/advanced_search.html.erb +8 -8
  49. data/app/views/page/configuration.html.erb +5 -3
  50. data/app/views/page/export.html.erb +7 -17
  51. data/app/views/page/import.html.erb +1 -4
  52. data/app/views/page/index.html.erb +2 -2
  53. data/app/views/page/msie_acceralator.builder +1 -1
  54. data/app/views/page/opensearch.builder +2 -2
  55. data/app/views/profiles/_edit_credential.html.erb +78 -0
  56. data/app/views/profiles/_edit_profile.html.erb +42 -0
  57. data/app/views/{users → profiles}/_form.html.erb +0 -0
  58. data/app/views/{users → profiles}/_show.html.erb +0 -0
  59. data/app/views/profiles/edit.html.erb +36 -0
  60. data/app/views/profiles/index.html.erb +61 -0
  61. data/app/views/{users → profiles}/new.html.erb +34 -36
  62. data/app/views/{users → profiles}/show.html.erb +24 -22
  63. data/app/views/{users → profiles}/show.mobile.erb +0 -0
  64. data/app/views/roles/_form.html.erb +1 -1
  65. data/app/views/roles/edit.html.erb +1 -1
  66. data/app/views/roles/index.html.erb +2 -2
  67. data/app/views/roles/new.html.erb +1 -1
  68. data/app/views/roles/show.html.erb +1 -1
  69. data/app/views/user_export_files/_form.html.erb +22 -0
  70. data/app/views/user_export_files/edit.html.erb +6 -0
  71. data/app/views/user_export_files/index.html.erb +44 -0
  72. data/app/views/user_export_files/new.html.erb +16 -0
  73. data/app/views/user_export_files/show.html.erb +31 -0
  74. data/app/views/user_groups/_form.html.erb +5 -5
  75. data/app/views/user_groups/edit.html.erb +1 -1
  76. data/app/views/user_groups/index.html.erb +14 -8
  77. data/app/views/user_groups/new.html.erb +1 -1
  78. data/app/views/user_groups/show.html.erb +3 -3
  79. data/app/views/user_import_files/index.html.erb +11 -10
  80. data/app/views/user_import_files/new.html.erb +15 -3
  81. data/app/views/user_import_files/show.html.erb +13 -3
  82. data/app/views/user_import_results/index.html.erb +7 -7
  83. data/app/views/user_import_results/{index.tsv.erb → index.txt.erb} +1 -1
  84. data/app/views/user_import_results/show.html.erb +2 -2
  85. data/app/workers/user_export_file_queue.rb +7 -0
  86. data/config/initializers/mime_types.rb +1 -1
  87. data/config/locales/devise.en.yml +19 -18
  88. data/config/locales/devise.ja.yml +45 -42
  89. data/config/locales/en.yml +214 -0
  90. data/config/locales/ja.yml +10 -6
  91. data/config/locales/translation_en.yml +34 -5
  92. data/config/locales/translation_ja.yml +35 -6
  93. data/config/routes.rb +4 -7
  94. data/db/migrate/20130221154434_add_additional_attributes_to_user.rb +0 -9
  95. data/db/migrate/20140122054321_create_profiles.rb +1 -1
  96. data/db/migrate/20140709113413_create_user_export_files.rb +11 -0
  97. data/db/migrate/20140709113905_create_user_export_file_transitions.rb +14 -0
  98. data/db/migrate/20140720170714_add_default_library_id_to_user_import_file.rb +5 -0
  99. data/db/migrate/20140720170735_add_default_user_group_id_to_user_import_file.rb +5 -0
  100. data/db/migrate/20140811031145_add_expired_at_to_profile.rb +5 -0
  101. data/lib/enju_leaf/calculate_stat.rb +9 -0
  102. data/lib/enju_leaf/controller.rb +1 -1
  103. data/lib/enju_leaf/export_file.rb +26 -0
  104. data/lib/enju_leaf/import_file.rb +25 -0
  105. data/lib/enju_leaf/master_model.rb +15 -6
  106. data/lib/enju_leaf/url_validator.rb +4 -2
  107. data/lib/enju_leaf/user.rb +74 -68
  108. data/lib/enju_leaf/version.rb +1 -1
  109. data/lib/enju_leaf.rb +23 -24
  110. data/lib/generators/enju_leaf/quick_install/quick_install_generator.rb +2 -1
  111. data/lib/generators/enju_leaf/setup/setup_generator.rb +6 -0
  112. data/lib/generators/enju_leaf/setup/templates/db/fixtures/user_groups.yml +1 -1
  113. data/lib/generators/enju_leaf/setup/templates/db/seeds.rb +5 -4
  114. data/lib/tasks/enju_leaf_tasks.rake +18 -9
  115. data/lib/tasks/profile.rb +15 -0
  116. data/spec/controllers/my_accounts_controller_spec.rb +61 -43
  117. data/spec/controllers/page_controller_spec.rb +20 -20
  118. data/spec/controllers/profiles_controller_spec.rb +530 -0
  119. data/spec/controllers/roles_controller_spec.rb +19 -19
  120. data/spec/controllers/user_export_files_controller_spec.rb +297 -0
  121. data/spec/controllers/user_groups_controller_spec.rb +48 -48
  122. data/spec/controllers/user_import_files_controller_spec.rb +45 -41
  123. data/spec/controllers/user_import_results_controller_spec.rb +9 -9
  124. data/spec/dummy/app/models/user.rb +3 -0
  125. data/spec/dummy/config/application.rb +3 -1
  126. data/spec/dummy/config/environments/test.rb +2 -0
  127. data/spec/dummy/db/development.sqlite3 +0 -0
  128. data/spec/dummy/db/migrate/{001_create_patrons.rb → 001_create_agents.rb} +1 -2
  129. data/spec/dummy/db/migrate/005_create_manifestations.rb +5 -17
  130. data/spec/dummy/db/migrate/006_create_items.rb +2 -3
  131. data/spec/dummy/db/migrate/032_create_checkins.rb +17 -0
  132. data/spec/dummy/db/migrate/033_create_checkouts.rb +25 -0
  133. data/spec/dummy/db/migrate/035_create_reserves.rb +27 -0
  134. data/spec/dummy/db/migrate/055_create_bookmarks.rb +22 -0
  135. data/spec/dummy/db/migrate/059_create_libraries.rb +5 -1
  136. data/spec/dummy/db/migrate/069_create_shelves.rb +5 -1
  137. data/spec/dummy/db/migrate/080_create_library_groups.rb +0 -2
  138. data/spec/dummy/db/migrate/113_create_events.rb +23 -0
  139. data/spec/dummy/db/migrate/114_create_event_categories.rb +16 -0
  140. data/spec/dummy/db/migrate/121_create_checked_items.rb +17 -0
  141. data/spec/dummy/db/migrate/127_create_use_restrictions.rb +16 -0
  142. data/spec/dummy/db/migrate/129_create_item_has_use_restrictions.rb +16 -0
  143. data/spec/dummy/db/migrate/130_create_request_status_types.rb +5 -1
  144. data/spec/dummy/db/migrate/131_create_request_types.rb +5 -1
  145. data/spec/dummy/db/migrate/132_create_circulation_statuses.rb +16 -0
  146. data/spec/dummy/db/migrate/149_create_message_templates.rb +18 -0
  147. data/spec/dummy/db/migrate/154_create_messages.rb +23 -0
  148. data/spec/dummy/db/migrate/20080819181903_create_message_requests.rb +18 -0
  149. data/spec/dummy/db/migrate/{20080905191442_create_patron_types.rb → 20080905191442_create_agent_types.rb} +1 -1
  150. data/spec/dummy/db/migrate/{20081028083142_create_patron_import_files.rb → 20081028083142_create_agent_import_files.rb} +2 -4
  151. data/spec/dummy/db/migrate/20081028083208_create_resource_import_files.rb +1 -3
  152. data/spec/dummy/db/migrate/20081030023412_create_checkout_types.rb +17 -0
  153. data/spec/dummy/db/migrate/20081030023518_create_user_group_has_checkout_types.rb +25 -0
  154. data/spec/dummy/db/migrate/20081030023615_create_carrier_type_has_checkout_types.rb +18 -0
  155. data/spec/dummy/db/migrate/20081212075554_create_checkout_stat_has_manifestations.rb +17 -0
  156. data/spec/dummy/db/migrate/20081212080038_create_manifestation_checkout_stats.rb +16 -0
  157. data/spec/dummy/db/migrate/20081212151614_create_bookmark_stats.rb +16 -0
  158. data/spec/dummy/db/migrate/20081212151820_create_bookmark_stat_has_manifestations.rb +13 -0
  159. data/spec/dummy/db/migrate/20081215094302_create_user_checkout_stats.rb +16 -0
  160. data/spec/dummy/db/migrate/20081215094955_create_checkout_stat_has_users.rb +17 -0
  161. data/spec/dummy/db/migrate/20081216190517_create_reserve_stat_has_manifestations.rb +17 -0
  162. data/spec/dummy/db/migrate/20081216190724_create_manifestation_reserve_stats.rb +16 -0
  163. data/spec/dummy/db/migrate/20081220023628_create_user_reserve_stats.rb +16 -0
  164. data/spec/dummy/db/migrate/20081220034117_create_reserve_stat_has_users.rb +17 -0
  165. data/spec/dummy/db/migrate/20090321130448_add_completed_at_to_user_checkout_stat.rb +27 -0
  166. data/spec/dummy/db/migrate/{20090812151902_create_patron_relationship_types.rb → 20090812151902_create_agent_relationship_types.rb} +1 -1
  167. data/spec/dummy/db/migrate/20090831220301_create_lending_policies.rb +21 -0
  168. data/spec/dummy/db/migrate/20100129142347_create_import_requests.rb +0 -1
  169. data/spec/dummy/db/migrate/20100222124420_add_allow_bookmark_external_url_to_library_group.rb +9 -0
  170. data/spec/dummy/db/migrate/20100525171356_acts_as_taggable_on_migration.rb +30 -0
  171. data/spec/dummy/db/migrate/{20100606073747_create_patron_relationships.rb → 20100606073747_create_agent_relationships.rb} +1 -1
  172. data/spec/dummy/db/migrate/{20100814091104_add_position_to_patron_relationship.rb → 20100814091104_add_position_to_agent_relationship.rb} +1 -1
  173. data/spec/dummy/db/migrate/{20100925074559_create_patron_import_results.rb → 20100925074559_create_agent_import_results.rb} +1 -1
  174. 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
  175. data/spec/dummy/db/migrate/20110301134521_add_expire_date_to_reserve.rb +9 -0
  176. data/spec/dummy/db/migrate/20110328130826_add_current_checkout_count_to_user_group_has_checkout_type.rb +9 -0
  177. data/spec/dummy/db/migrate/20110618091240_add_periodical_to_series_statement.rb +1 -1
  178. data/spec/dummy/db/migrate/20110621093332_remove_expire_date_from_reserve.rb +9 -0
  179. data/spec/dummy/db/migrate/20110913115320_add_lft_and_rgt_to_message.rb +11 -0
  180. data/spec/dummy/db/migrate/20111020063828_remove_dsbl_from_library_group.rb +11 -0
  181. data/spec/dummy/db/migrate/20111217234412_add_save_checkout_history_to_user.rb +5 -0
  182. data/spec/dummy/db/migrate/20111218002349_add_checkout_icalendar_token_to_user.rb +6 -0
  183. data/spec/dummy/db/migrate/20111231145823_add_share_bookmarks_to_user.rb +5 -0
  184. data/spec/dummy/db/migrate/20120125050502_add_depth_to_message.rb +6 -0
  185. data/spec/dummy/db/migrate/{20120413161403_add_fingerprint_to_patron_import_file.rb → 20120413161403_add_fingerprint_to_agent_import_file.rb} +1 -1
  186. 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
  187. data/spec/dummy/db/migrate/20120418121539_add_save_search_history_to_user.rb +5 -0
  188. data/spec/dummy/db/migrate/20120424103932_add_librarian_id_to_checked_item.rb +5 -0
  189. data/spec/dummy/db/migrate/{20120511072422_add_patron_identifier_to_patron.rb → 20120511072422_add_agent_identifier_to_agent.rb} +1 -1
  190. 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
  191. data/spec/dummy/db/migrate/20130303104849_add_state_index_to_reserve.rb +5 -0
  192. data/spec/dummy/db/migrate/20130303124821_add_retained_at_to_reserve.rb +5 -0
  193. data/spec/dummy/db/migrate/20130304015019_add_postponed_at_to_reserve.rb +5 -0
  194. data/spec/dummy/db/migrate/20130416054135_add_circulation_status_id_to_item.rb +8 -0
  195. data/spec/dummy/db/migrate/20130421155019_add_creator_string_to_series_statement.rb +7 -0
  196. data/spec/dummy/db/migrate/20130421164124_add_series_master_to_series_statement.rb +5 -0
  197. data/spec/dummy/db/migrate/20130509185724_add_statement_of_responsibility_to_manifestation.rb +5 -0
  198. data/spec/dummy/db/migrate/20130519065638_add_lock_version_to_reserve.rb +5 -0
  199. data/spec/dummy/db/migrate/20130519065837_add_lock_version_to_checkin.rb +5 -0
  200. data/spec/dummy/db/migrate/20140518050147_create_reserve_transitions.rb +14 -0
  201. data/spec/dummy/db/migrate/20140518111006_create_message_transitions.rb +14 -0
  202. data/spec/dummy/db/migrate/20140518135713_create_message_request_transitions.rb +14 -0
  203. data/spec/dummy/db/migrate/20140519170214_create_resource_import_file_transitions.rb +14 -0
  204. data/spec/dummy/db/migrate/20140519171220_create_import_request_transitions.rb +14 -0
  205. data/spec/dummy/db/migrate/20140524020735_create_agent_import_file_transitions.rb +14 -0
  206. data/spec/dummy/db/migrate/20140524135607_create_bookmark_stat_transitions.rb +14 -0
  207. data/spec/dummy/db/migrate/20140524142813_add_taggings_count_to_tag.rb +5 -0
  208. data/spec/dummy/db/migrate/20140528045518_create_user_checkout_stat_transitions.rb +14 -0
  209. data/spec/dummy/db/migrate/20140528045539_create_user_reserve_stat_transitions.rb +14 -0
  210. data/spec/dummy/db/migrate/20140528045600_create_manifestation_checkout_stat_transitions.rb +14 -0
  211. data/spec/dummy/db/migrate/20140528045617_create_manifestation_reserve_stat_transitions.rb +14 -0
  212. data/spec/dummy/db/migrate/20140529014410_create_item_transitions.rb +14 -0
  213. data/spec/dummy/db/migrate/20140614065404_create_resource_export_files.rb +11 -0
  214. data/spec/dummy/db/migrate/20140614141500_create_resource_export_file_transitions.rb +14 -0
  215. data/spec/dummy/db/migrate/20140628073524_add_user_encoding_to_agent_import_file.rb +5 -0
  216. data/spec/dummy/db/migrate/20140628073535_add_user_encoding_to_resource_import_file.rb +5 -0
  217. data/spec/dummy/db/migrate/20140810061942_add_user_id_to_stat.rb +12 -0
  218. data/spec/dummy/db/migrate/20140810091231_add_checkout_icalendar_token_to_profile.rb +6 -0
  219. data/spec/dummy/db/migrate/20140810091417_add_save_checkout_history_to_profile.rb +5 -0
  220. data/spec/dummy/db/migrate/20140811132912_add_save_search_history_to_profile.rb +5 -0
  221. data/spec/dummy/db/migrate/20140812093836_add_share_bookmarks_to_profile.rb +5 -0
  222. data/spec/dummy/db/schema.rb +632 -57
  223. data/spec/dummy/db/test.sqlite3 +0 -0
  224. data/spec/dummy/private/system/user_import_files/user_imports/980/190/963/original/user_delete_file.tsv +4 -0
  225. data/spec/dummy/private/system/user_import_files/user_imports/980/190/963/original/user_import_file_sample.tsv +7 -7
  226. data/spec/dummy/public/system/user_export_files/user_exports/000/000/003/original/user_export_file_20140815-3963-1s1td26.txt +8 -0
  227. data/spec/dummy/public/system/user_export_files/user_exports/000/000/003/original/user_export_file_20140815-69229-i0rcty.txt +8 -0
  228. data/spec/dummy/public/system/user_export_files/user_exports/000/000/003/original/user_export_file_20140816-21120-1w731r8.txt +8 -0
  229. data/spec/dummy/public/system/user_export_files/user_exports/000/000/004/original/user_export_file_20140711-28652-1dj3e98.txt +148 -0
  230. data/spec/dummy/public/system/user_export_files/user_exports/000/000/004/original/user_export_file_20140711-29117-13jb6ol.txt +148 -0
  231. data/spec/dummy/public/system/user_export_files/user_exports/000/000/004/original/user_export_file_20140721-65743-1tnagd4.txt +8 -0
  232. data/spec/dummy/public/system/user_export_files/user_exports/000/000/004/original/user_export_file_20140815-3963-1kk8o87.txt +8 -0
  233. data/spec/dummy/public/system/user_export_files/user_exports/000/000/004/original/user_export_file_20140815-69229-188nwub.txt +8 -0
  234. data/spec/dummy/public/system/user_export_files/user_exports/000/000/004/original/user_export_file_20140816-21120-twzfb6.txt +8 -0
  235. data/spec/dummy/solr/default/data/index/_4h.fdt +0 -0
  236. data/spec/dummy/solr/default/data/index/{_3h.fdx → _4h.fdx} +0 -0
  237. data/spec/dummy/solr/default/data/index/{_3h.fnm → _4h.fnm} +0 -0
  238. data/spec/dummy/solr/default/data/index/{_3h.nvd → _4h.nvd} +0 -0
  239. data/spec/dummy/solr/default/data/index/{_3h.nvm → _4h.nvm} +0 -0
  240. data/spec/dummy/solr/default/data/index/{_3h.si → _4h.si} +0 -0
  241. data/spec/dummy/solr/default/data/index/_4h_Lucene41_0.doc +0 -0
  242. data/spec/dummy/solr/default/data/index/_4h_Lucene41_0.pos +0 -0
  243. data/spec/dummy/solr/default/data/index/_4h_Lucene41_0.tim +0 -0
  244. data/spec/dummy/solr/default/data/index/_4h_Lucene41_0.tip +0 -0
  245. data/spec/dummy/solr/default/data/index/segments.gen +0 -0
  246. data/spec/dummy/solr/default/data/index/segments_97 +0 -0
  247. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000320 +0 -0
  248. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000321 +0 -0
  249. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000322 +0 -0
  250. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000323 +0 -0
  251. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000324 +0 -0
  252. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000325 +0 -0
  253. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000326 +0 -0
  254. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000327 +0 -0
  255. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000328 +0 -0
  256. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000329 +0 -0
  257. data/spec/dummy/tmp/cache/4F7/F90/default_role +0 -0
  258. data/spec/dummy/tmp/cache/ACB/B20/manifestation_search_total +0 -0
  259. data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  260. data/spec/dummy/tmp/cache/assets/test/sprockets/154f7b83f2da0e86effbe25f32135177 +0 -0
  261. data/spec/dummy/tmp/cache/assets/test/sprockets/1b984bdbd3204a51a82d0e01a1569e2d +0 -0
  262. data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  263. data/spec/dummy/tmp/cache/assets/test/sprockets/3054c50144654f9c7e57bb0639a276e9 +0 -0
  264. data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  265. data/spec/dummy/tmp/cache/assets/test/sprockets/3bd7a263237ba366f64d938fe5303757 +0 -0
  266. data/spec/dummy/tmp/cache/assets/test/sprockets/62899096da1a3e67660f3b88068be8c9 +0 -0
  267. data/spec/dummy/tmp/cache/assets/test/sprockets/65b2e4f67eab21b30217e29075f433b2 +0 -0
  268. data/spec/dummy/tmp/cache/assets/test/sprockets/87d24a3f43f175d4d17babe9203c79a7 +0 -0
  269. data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  270. data/spec/dummy/tmp/cache/assets/test/sprockets/d38d8658b30de1d068603968227680d4 +0 -0
  271. data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  272. data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  273. data/spec/dummy/tmp/cache/stdout +246 -279
  274. data/spec/dummy/tmp/pids/redis-test.pid +1 -1
  275. data/spec/factories/profile.rb +9 -0
  276. data/spec/factories/user.rb +0 -13
  277. data/spec/fixtures/agent_import_files.yml +0 -3
  278. data/spec/fixtures/agents.yml +54 -54
  279. data/spec/fixtures/baskets.yml +4 -4
  280. data/spec/fixtures/carrier_type_has_checkout_types.yml +30 -0
  281. data/spec/fixtures/checked_items.yml +34 -0
  282. data/spec/fixtures/checkins.yml +54 -0
  283. data/spec/fixtures/checkout_stat_has_manifestations.yml +23 -0
  284. data/spec/fixtures/checkout_stat_has_users.yml +23 -0
  285. data/spec/fixtures/checkout_types.yml +33 -0
  286. data/spec/fixtures/checkouts.yml +162 -0
  287. data/spec/fixtures/circulation_statuses.yml +119 -0
  288. data/spec/fixtures/event_categories.yml +55 -0
  289. data/spec/fixtures/events.yml +142 -0
  290. data/spec/fixtures/exemplifies.yml +12 -0
  291. data/spec/fixtures/import_requests.yml +0 -2
  292. data/spec/fixtures/item_has_use_restrictions.yml +60 -0
  293. data/spec/fixtures/items.yml +101 -11
  294. data/spec/fixtures/lending_policies.yml +98 -0
  295. data/spec/fixtures/libraries.yml +26 -25
  296. data/spec/fixtures/library_groups.yml +6 -8
  297. data/spec/fixtures/manifestation_checkout_stats.yml +30 -0
  298. data/spec/fixtures/manifestation_reserve_stats.yml +30 -0
  299. data/spec/fixtures/manifestations.yml +69 -207
  300. data/spec/fixtures/message_requests.yml +27 -0
  301. data/spec/fixtures/message_templates.yml +105 -0
  302. data/spec/fixtures/profiles.yml +98 -0
  303. data/spec/fixtures/request_status_types.yml +63 -0
  304. data/spec/fixtures/request_types.yml +55 -0
  305. data/spec/fixtures/reserve_stat_has_manifestations.yml +23 -0
  306. data/spec/fixtures/reserve_stat_has_users.yml +23 -0
  307. data/spec/fixtures/reserve_transitions.yml +88 -0
  308. data/spec/fixtures/reserves.yml +162 -0
  309. data/spec/fixtures/resource_import_files.yml +0 -3
  310. data/spec/fixtures/roles.yml +0 -4
  311. data/spec/fixtures/shelves.yml +2 -3
  312. data/spec/fixtures/use_restrictions.yml +92 -0
  313. data/spec/fixtures/user_checkout_stats.yml +30 -0
  314. data/spec/fixtures/user_export_files.yml +26 -0
  315. data/spec/fixtures/user_group_has_checkout_types.yml +110 -0
  316. data/spec/fixtures/user_import_files.yml +2 -0
  317. data/spec/fixtures/user_reserve_stats.yml +30 -0
  318. data/spec/fixtures/users.yml +1 -101
  319. data/spec/models/profile_spec.rb +66 -0
  320. data/spec/models/user_export_file_spec.rb +31 -0
  321. data/spec/models/user_import_file_spec.rb +42 -20
  322. data/spec/models/user_spec.rb +1 -18
  323. data/spec/requests/{users_spec.rb → profiles_spec.rb} +3 -3
  324. data/spec/routing/accounts_spec.rb +1 -1
  325. data/spec/routing/profiles_routing_spec.rb +35 -0
  326. data/spec/support/resque.rb +1 -0
  327. data/spec/views/{users → profiles}/edit.html.erb_spec.rb +5 -7
  328. data/spec/views/{users → profiles}/index.html.erb_spec.rb +3 -3
  329. data/spec/views/{users → profiles}/new.html.erb_spec.rb +5 -5
  330. data/spec/views/profiles/show.html.erb_spec.rb +20 -0
  331. data/vendor/assets/javascripts/jquery.colorbox.js +4 -3
  332. data/vendor/assets/stylesheets/colorbox.css +1 -1
  333. metadata +416 -132
  334. data/app/controllers/users_controller.rb +0 -195
  335. data/app/models/user_sweeper.rb +0 -18
  336. data/app/views/users/_edit_credential.html.erb +0 -79
  337. data/app/views/users/edit.html.erb +0 -76
  338. data/app/views/users/index.html.erb +0 -56
  339. data/lib/enju_leaf/expire_editable_fragment.rb +0 -30
  340. data/lib/enju_leaf/expire_fragment_cache.rb +0 -17
  341. data/spec/controllers/users_controller_spec.rb +0 -539
  342. data/spec/dummy/db/migrate/20110916053430_rename_manifestation_number_list_to_number_string.rb +0 -13
  343. data/spec/dummy/db/migrate/20120415060308_rename_resource_import_file_imported_at_to_executed_at.rb +0 -9
  344. data/spec/dummy/db/migrate/20120415060323_rename_patron_import_file_imported_at_to_executed_at.rb +0 -9
  345. data/spec/dummy/db/migrate/20121119153944_add_manifestation_id_to_item.rb +0 -5
  346. data/spec/dummy/solr/default/data/index/_3h.fdt +0 -0
  347. data/spec/dummy/solr/default/data/index/_3h_Lucene41_0.doc +0 -0
  348. data/spec/dummy/solr/default/data/index/_3h_Lucene41_0.pos +0 -0
  349. data/spec/dummy/solr/default/data/index/_3h_Lucene41_0.tim +0 -0
  350. data/spec/dummy/solr/default/data/index/_3h_Lucene41_0.tip +0 -0
  351. data/spec/dummy/solr/default/data/index/segments_71 +0 -0
  352. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000242 +0 -0
  353. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000243 +0 -0
  354. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000244 +0 -0
  355. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000245 +0 -0
  356. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000246 +0 -0
  357. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000247 +0 -0
  358. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000248 +0 -0
  359. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000249 +0 -0
  360. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000250 +0 -0
  361. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000251 +0 -0
  362. data/spec/dummy/tmp/cache/assets/test/sprockets/3f8d795856d1fdf902b0be679120571a +0 -0
  363. data/spec/dummy/tmp/cache/assets/test/sprockets/5998e66e374537d52eed3fe1ca5f2bfc +0 -0
  364. data/spec/dummy/tmp/cache/assets/test/sprockets/5ea4a1824e1d67da6c4fb9aeef9f49f4 +0 -0
  365. data/spec/dummy/tmp/cache/assets/test/sprockets/87f0cb69a0df1355e33cce3949919d5a +0 -0
  366. data/spec/routing/users_routing_spec.rb +0 -35
  367. data/spec/views/users/show.html.erb_spec.rb +0 -15
@@ -0,0 +1,14 @@
1
+ class CreateUserExportFileTransitions < ActiveRecord::Migration
2
+ def change
3
+ create_table :user_export_file_transitions do |t|
4
+ t.string :to_state
5
+ t.text :metadata, default: "{}"
6
+ t.integer :sort_key
7
+ t.integer :user_export_file_id
8
+ t.timestamps
9
+ end
10
+
11
+ add_index :user_export_file_transitions, :user_export_file_id, name: "index_user_export_file_transitions_on_file_id"
12
+ add_index :user_export_file_transitions, [:sort_key, :user_export_file_id], unique: true, name: "index_user_export_file_transitions_on_sort_key_and_file_id"
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ class AddDefaultLibraryIdToUserImportFile < ActiveRecord::Migration
2
+ def change
3
+ add_column :user_import_files, :default_library_id, :integer
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddDefaultUserGroupIdToUserImportFile < ActiveRecord::Migration
2
+ def change
3
+ add_column :user_import_files, :default_user_group_id, :integer
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddExpiredAtToProfile < ActiveRecord::Migration
2
+ def change
3
+ add_column :profiles, :expired_at, :datetime
4
+ end
5
+ end
@@ -26,5 +26,14 @@ module CalculateStat
26
26
  end
27
27
  end
28
28
  end
29
+
30
+ def send_message
31
+ sender = User.find(1)
32
+ message_template = MessageTemplate.localized_template('counting_completed', user.profile.locale)
33
+ request = MessageRequest.new
34
+ request.assign_attributes({:sender => sender, :receiver => user, :message_template => message_template}, as: :admin)
35
+ request.save_message_body
36
+ request.transition_to!(:sent)
37
+ end
29
38
  end
30
39
  end
@@ -11,7 +11,7 @@ module EnjuLeaf
11
11
  rescue_from CanCan::AccessDenied, :with => :render_403
12
12
  #rescue_from ActiveRecord::RecordNotFound, :with => :render_404
13
13
  rescue_from Errno::ECONNREFUSED, :with => :render_500
14
- rescue_from ActionView::MissingTemplate, :with => :render_404_invalid_format
14
+ #rescue_from ActionView::MissingTemplate, :with => :render_404_invalid_format
15
15
  end
16
16
  end
17
17
 
@@ -0,0 +1,26 @@
1
+ module ExportFile
2
+ def self.included(base)
3
+ base.extend ClassMethods
4
+ end
5
+
6
+ module ClassMethods
7
+ def enju_export_file_model
8
+ include InstanceMethods
9
+ belongs_to :user
10
+ validates :user, presence: true
11
+ attr_accessible :mode
12
+ attr_accessor :mode
13
+ end
14
+ end
15
+
16
+ module InstanceMethods
17
+ def send_message
18
+ sender = User.find(1)
19
+ message_template = MessageTemplate.localized_template('export_completed', user.profile.locale)
20
+ request = MessageRequest.new
21
+ request.assign_attributes({:sender => sender, :receiver => user, :message_template => message_template}, as: :admin)
22
+ request.save_message_body
23
+ request.transition_to!(:sent)
24
+ end
25
+ end
26
+ end
@@ -49,6 +49,15 @@ module ImportFile
49
49
  end
50
50
  end
51
51
 
52
+ def send_message
53
+ sender = User.find(1)
54
+ message_template = MessageTemplate.localized_template('import_completed', user.profile.locale)
55
+ request = MessageRequest.new
56
+ request.assign_attributes({:sender => sender, :receiver => user, :message_template => message_template}, as: :admin)
57
+ request.save_message_body
58
+ request.transition_to!(:sent)
59
+ end
60
+
52
61
  private
53
62
  def nkf_encode(line)
54
63
  case user_encoding
@@ -65,5 +74,21 @@ module ImportFile
65
74
  end
66
75
  string = NKF.nkf("#{output_encoding} -Lu", line)
67
76
  end
77
+
78
+ def create_import_temp_file(attachment)
79
+ tempfile = Tempfile.new(self.class.name.underscore)
80
+ if Setting.uploaded_file.storage == :s3
81
+ uploaded_file_path = attachment.expiring_url(10)
82
+ else
83
+ uploaded_file_path = attachment.path
84
+ end
85
+ open(uploaded_file_path){|f|
86
+ f.each{|line|
87
+ tempfile.puts(convert_encoding(line))
88
+ }
89
+ }
90
+ tempfile.close
91
+ tempfile
92
+ end
68
93
  end
69
94
  end
@@ -4,18 +4,27 @@ module MasterModel
4
4
  base.send :include, InstanceMethods
5
5
  base.class_eval do
6
6
  acts_as_list
7
- validates_uniqueness_of :name, :case_sensitive => false,
8
- :message => I18n.t('Only lowercase letters and numbers are allowed.')
9
- validates :name, :presence => true, :format => {:with => /\A[0-9A-Za-z][0-9A-Za-z_\-\s]*[0-9a-z]\Z/}
10
- validates :display_name, :presence => true
11
- before_validation :set_display_name, :on => :create
7
+ validates_uniqueness_of :name, case_sensitive: false
8
+ validates :name, presence: true
9
+ validate :name do
10
+ valid_format?
11
+ end
12
+ validates :display_name, presence: true
13
+ before_validation :set_display_name, on: :create
12
14
  normalize_attributes :name
13
15
  end
14
16
  end
15
17
 
16
18
  module InstanceMethods
17
19
  def set_display_name
18
- self.display_name = "#{I18n.locale}: #{self.name}" if self.display_name.blank?
20
+ self.display_name = "#{I18n.locale}: #{name}" if display_name.blank?
21
+ end
22
+
23
+ private
24
+ def valid_format?
25
+ unless name =~ /\A[A-Za-z][0-9A-Za-z_\s]*[0-9a-z]\Z/
26
+ errors.add(:name, I18n.t('page.only_lowercase_letters_and_numbers_are_allowed'))
27
+ end
19
28
  end
20
29
  end
21
30
  end
@@ -1,10 +1,12 @@
1
1
  class UrlValidator < ActiveModel::EachValidator
2
2
  def validate_each(record, attribute, value)
3
- url = ::Addressable::URI.parse(value)
4
- if url
3
+ if value =~ /\Ahttps?:\/\/[^\n]+\z/i
4
+ url = ::Addressable::URI.parse(value)
5
5
  unless ['http', 'https'].include?(url.scheme)
6
6
  record.errors.add(attribute.to_sym)
7
7
  end
8
+ else
9
+ record.errors.add(attribute.to_sym)
8
10
  end
9
11
  end
10
12
  end
@@ -10,35 +10,35 @@ module EnjuLeaf
10
10
 
11
11
  # Setup accessible (or protected) attributes for your model
12
12
  attr_accessible :email, :password, :password_confirmation, :current_password,
13
- :remember_me, :email_confirmation, :library_id, :locale,
14
- :keyword_list, :auto_generated_password
13
+ :remember_me, :email_confirmation,
14
+ :auto_generated_password,
15
+ :profile_attributes
15
16
  attr_accessible :email, :password, :password_confirmation, :username,
16
- :current_password, :user_number, :remember_me,
17
- :email_confirmation, :note, :user_group_id, :library_id, :locale,
18
- :expired_at, :locked, :required_role_id, :role_id,
19
- :keyword_list, :user_has_role_attributes, :auto_generated_password,
17
+ :current_password, :remember_me,
18
+ :email_confirmation,
19
+ :expired_at, :locked, :role_id,
20
+ :user_has_role_attributes, :auto_generated_password,
21
+ :profile_attributes,
20
22
  :as => :admin
21
23
 
22
24
  scope :administrators, where('roles.name = ?', 'Administrator').includes(:role)
23
25
  scope :librarians, where('roles.name = ? OR roles.name = ?', 'Administrator', 'Librarian').includes(:role)
24
26
  scope :suspended, where('locked_at IS NOT NULL')
25
- #has_one :agent, :dependent => :destroy
27
+ has_one :profile, :dependent => :destroy
26
28
  if defined?(EnjuBiblio)
27
29
  has_many :import_requests
28
30
  has_many :picture_files, :as => :picture_attachable, :dependent => :destroy
29
31
  end
30
32
  has_one :user_has_role, :dependent => :destroy
31
33
  has_one :role, :through => :user_has_role
32
- belongs_to :library, :validate => true
33
34
  belongs_to :user_group
34
- belongs_to :required_role, :class_name => 'Role', :foreign_key => 'required_role_id' #, :validate => true
35
- has_many :export_files if defined?(EnjuExport)
36
- #has_one :agent_import_result
35
+ belongs_to :library
36
+ belongs_to :required_role, class_name: 'Role', foreign_key: 'required_role_id'
37
37
  accepts_nested_attributes_for :user_has_role
38
+ accepts_nested_attributes_for :profile
38
39
 
39
- validates :username, :presence => true, :uniqueness => true, :format => {:with => /\A[0-9A-Za-z][0-9A-Za-z_\-]*[0-9A-Za-z]\Z/}, :allow_blank => true
40
- validates_uniqueness_of :email, :allow_blank => true
41
- validates :email, :format => Devise::email_regexp, :allow_blank => true
40
+ validates :username, :presence => true, :uniqueness => true, :format => {:with => /\A[0-9A-Za-z][0-9A-Za-z_\-]*[0-9A-Za-z]\Z/}
41
+ validates :email, :format => Devise::email_regexp, :allow_blank => true, :uniqueness => true
42
42
  validates_date :expired_at, :allow_blank => true
43
43
 
44
44
  with_options :if => :password_required? do |v|
@@ -49,47 +49,20 @@ module EnjuLeaf
49
49
  end
50
50
 
51
51
  validates_presence_of :email, :email_confirmation, :on => :create, :if => proc{|user| !user.operator.try(:has_role?, 'Librarian')}
52
- validates_associated :user_group, :library #, :agent
53
- validates_presence_of :user_group, :library, :locale #, :user_number
54
- validates :user_number, :uniqueness => true, :format => {:with => /\A[0-9A-Za-z_]+\Z/}, :allow_blank => true
55
- validates_confirmation_of :email, :on => :create, :if => proc{|user| !user.operator.try(:has_role?, 'Librarian')}
52
+ validates_confirmation_of :email, :on => :create #, :if => proc{|user| !user.operator.try(:has_role?, 'Librarian')}
56
53
 
57
- before_validation :set_role_and_agent, :on => :create
58
54
  before_validation :set_lock_information
59
55
  before_destroy :check_role_before_destroy
60
56
  before_save :check_expiration
61
- before_create :set_expired_at
62
- after_destroy :remove_from_index
63
57
  after_create :set_confirmation
64
58
 
65
59
  extend FriendlyId
66
60
  friendly_id :username
67
61
  #has_paper_trail
68
- normalize_attributes :username, :user_number
62
+ normalize_attributes :username
69
63
  normalize_attributes :email, :with => :strip
70
64
 
71
- searchable do
72
- text :username, :email, :note, :user_number
73
- text :name do
74
- #agent.name if agent
75
- end
76
- string :username
77
- string :email
78
- string :user_number
79
- integer :required_role_id
80
- time :created_at
81
- time :updated_at
82
- boolean :active do
83
- active_for_authentication?
84
- end
85
- time :confirmed_at
86
- end
87
-
88
- attr_accessor :first_name, :middle_name, :last_name, :full_name,
89
- :first_name_transcription, :middle_name_transcription,
90
- :last_name_transcription, :full_name_transcription,
91
- :zip_code, :address, :telephone_number, :fax_number, :address_note,
92
- :operator, :password_not_verified,
65
+ attr_accessor :operator, :password_not_verified,
93
66
  :update_own_account, :auto_generated_password,
94
67
  :locked, :current_password #, :agent_id
95
68
 
@@ -100,6 +73,63 @@ module EnjuLeaf
100
73
  user.lock_access! if user.expired? and user.active_for_authentication?
101
74
  end
102
75
  end
76
+
77
+ def export(options = {format: :txt})
78
+ header = %w(
79
+ username
80
+ email
81
+ user_number
82
+ role
83
+ user_group
84
+ library
85
+ locale
86
+ created_at
87
+ updated_at
88
+ expired_at
89
+ keyword_list
90
+ note
91
+ checkout_icalendar_token
92
+ save_checkout_history
93
+ save_search_history
94
+ share_bookmarks
95
+ ).join("\t")
96
+ users = User.all.map{|u|
97
+ lines = []
98
+ lines << u.username
99
+ lines << u.email
100
+ lines << u.profile.user_number
101
+ lines << u.role.name
102
+ lines << u.profile.user_group.try(:name)
103
+ lines << u.profile.library.try(:name)
104
+ lines << u.profile.locale
105
+ lines << u.created_at
106
+ lines << u.updated_at
107
+ lines << u.expired_at
108
+ lines << u.profile.keyword_list.try(:split).try(:join, "//")
109
+ lines << u.profile.note
110
+ if defined?(EnjuCirculation)
111
+ lines << u.profile.try(:checkout_icalendar_token)
112
+ lines << u.profile.try(:save_checkout_history)
113
+ else
114
+ lines << nil
115
+ end
116
+ if defined?(EnjuSearchLog)
117
+ lines << u.try(:save_search_history)
118
+ else
119
+ lines << nil
120
+ end
121
+ if defined?(EnjuBookmark)
122
+ lines << u.try(:share_bookmarks)
123
+ else
124
+ lines << nil
125
+ end
126
+ }
127
+ if options[:format] == :txt
128
+ users.map{|u| u.join("\t")}.unshift(header).join("\r\n")
129
+ else
130
+ users
131
+ end
132
+ end
103
133
  end
104
134
  end
105
135
 
@@ -121,14 +151,6 @@ module EnjuLeaf
121
151
  end
122
152
  end
123
153
 
124
- def set_role_and_agent
125
- self.required_role = Role.where(:name => 'Librarian').first
126
- self.locale = I18n.default_locale.to_s unless locale
127
- #unless self.agent
128
- # self.agent = Agent.create(:full_name => self.username) if self.username
129
- #end
130
- end
131
-
132
154
  def set_lock_information
133
155
  if locked == '1' and self.active_for_authentication?
134
156
  lock_access!
@@ -188,14 +210,6 @@ module EnjuLeaf
188
210
  end
189
211
  end
190
212
 
191
- def set_expired_at
192
- if expired_at.blank?
193
- if user_group.valid_period_for_new_user > 0
194
- self.expired_at = user_group.valid_period_for_new_user.days.from_now.end_of_day
195
- end
196
- end
197
- end
198
-
199
213
  def deletable_by(current_user)
200
214
  if defined?(EnjuCirculation)
201
215
  # 未返却の資料のあるユーザを削除しようとした
@@ -228,14 +242,6 @@ module EnjuLeaf
228
242
  false
229
243
  end
230
244
  end
231
-
232
- def patron
233
- LocalPatron.new({:username => username})
234
- end
235
-
236
- def full_name
237
- username
238
- end
239
245
  end
240
246
  end
241
247
  end
@@ -1,3 +1,3 @@
1
1
  module EnjuLeaf
2
- VERSION = "1.1.0.rc12"
2
+ VERSION = "1.1.0.rc13"
3
3
  end
data/lib/enju_leaf.rb CHANGED
@@ -6,9 +6,8 @@ require "enju_leaf/helper"
6
6
  require "enju_leaf/calculate_stat"
7
7
  require "enju_leaf/bookmark_url"
8
8
  require "enju_leaf/calculate_stat"
9
- require "enju_leaf/expire_editable_fragment"
10
- require "enju_leaf/expire_fragment_cache"
11
9
  require "enju_leaf/import_file"
10
+ require "enju_leaf/export_file"
12
11
  require "enju_leaf/localized_name"
13
12
  require "enju_leaf/master_model"
14
13
  require "enju_leaf/url_validator"
@@ -36,17 +35,17 @@ module EnjuLeaf
36
35
  return if performed?
37
36
  if user_signed_in?
38
37
  respond_to do |format|
39
- format.html {render :template => 'page/403', :status => 403}
40
- format.mobile {render :template => 'page/403', :status => 403}
41
- format.xml {render :template => 'page/403', :status => 403}
42
- format.json { render :text => '{"error": "forbidden"}' }
38
+ format.html {render template: 'page/403', status: 403}
39
+ format.mobile {render template: 'page/403', status: 403}
40
+ format.xml {render template: 'page/403', status: 403}
41
+ format.json { render text: '{"error": "forbidden"}' }
43
42
  end
44
43
  else
45
44
  respond_to do |format|
46
45
  format.html {redirect_to new_user_session_url}
47
46
  format.mobile {redirect_to new_user_session_url}
48
- format.xml {render :template => 'page/403', :status => 403}
49
- format.json { render :text => '{"error": "forbidden"}' }
47
+ format.xml {render template: 'page/403', status: 403}
48
+ format.json { render text: '{"error": "forbidden"}' }
50
49
  end
51
50
  end
52
51
  end
@@ -54,16 +53,16 @@ module EnjuLeaf
54
53
  def render_404
55
54
  return if performed?
56
55
  respond_to do |format|
57
- format.html {render :template => 'page/404', :status => 404}
58
- format.mobile {render :template => 'page/404', :status => 404}
59
- format.xml {render :template => 'page/404', :status => 404}
60
- format.json { render :text => '{"error": "not_found"}' }
56
+ format.html {render template: 'page/404', status: 404}
57
+ format.mobile {render template: 'page/404', status: 404}
58
+ format.xml {render template: 'page/404', status: 404}
59
+ format.json { render text: '{"error": "not_found"}' }
61
60
  end
62
61
  end
63
62
 
64
63
  def render_404_invalid_format
65
64
  return if performed?
66
- render :file => "#{Rails.root}/public/404", :formats => [:html]
65
+ render file: "#{Rails.root}/public/404", formats: [:html]
67
66
  end
68
67
 
69
68
  def render_500
@@ -71,10 +70,10 @@ module EnjuLeaf
71
70
  return if performed?
72
71
  #flash[:notice] = t('page.connection_failed')
73
72
  respond_to do |format|
74
- format.html {render :file => "#{Rails.root.to_s}/public/500", :layout => false, :status => 500}
75
- format.mobile {render :file => "#{Rails.root.to_s}/public/500", :layout => false, :status => 500}
76
- format.xml {render :template => 'page/500', :status => 500}
77
- format.json { render :text => '{"error": "server_error"}' }
73
+ format.html {render file: "#{Rails.root.to_s}/public/500", layout: false, status: 500}
74
+ format.mobile {render file: "#{Rails.root.to_s}/public/500", layout: false, status: 500}
75
+ format.xml {render template: 'page/500', status: 500}
76
+ format.json { render text: '{"error": "server_error"}' }
78
77
  end
79
78
  end
80
79
 
@@ -85,7 +84,7 @@ module EnjuLeaf
85
84
  end
86
85
  end
87
86
  if user_signed_in?
88
- locale = params[:locale] || session[:locale] || current_user.locale.try(:to_sym)
87
+ locale = params[:locale] || session[:locale] || current_user.profile.try(:locale).try(:to_sym)
89
88
  else
90
89
  locale = params[:locale] || session[:locale]
91
90
  end
@@ -99,16 +98,16 @@ module EnjuLeaf
99
98
  end
100
99
 
101
100
  def default_url_options(options={})
102
- {:locale => nil}
101
+ {locale: nil}
103
102
  end
104
103
 
105
104
  def set_available_languages
106
105
  if Rails.env == 'production'
107
106
  @available_languages = Rails.cache.fetch('available_languages'){
108
- Language.where(:iso_639_1 => I18n.available_locales.map{|l| l.to_s}).select([:id, :iso_639_1, :name, :native_name, :display_name, :position]).all
107
+ Language.where(iso_639_1: I18n.available_locales.map{|l| l.to_s}).select([:id, :iso_639_1, :name, :native_name, :display_name, :position]).all
109
108
  }
110
109
  else
111
- @available_languages = Language.where(:iso_639_1 => I18n.available_locales.map{|l| l.to_s})
110
+ @available_languages = Language.where(iso_639_1: I18n.available_locales.map{|l| l.to_s})
112
111
  end
113
112
  end
114
113
 
@@ -125,7 +124,7 @@ module EnjuLeaf
125
124
  end
126
125
 
127
126
  def get_user
128
- @user = User.where(:username => params[:user_id]).first if params[:user_id]
127
+ @user = User.where(username: params[:user_id]).first if params[:user_id]
129
128
  #authorize! :show, @user if @user
130
129
  end
131
130
 
@@ -183,7 +182,7 @@ module EnjuLeaf
183
182
  language = params[:language]
184
183
  if defined?(EnjuSubject)
185
184
  subject = params[:subject]
186
- subject_by_term = Subject.where(:term => params[:subject]).first
185
+ subject_by_term = Subject.where(term: params[:subject]).first
187
186
  @subject_by_term = subject_by_term
188
187
  end
189
188
 
@@ -284,7 +283,7 @@ module EnjuLeaf
284
283
  if ['higher', 'lower'].include?(direction)
285
284
  resource.send("move_#{direction}")
286
285
  if redirect
287
- redirect_to url_for(:controller => resource.class.to_s.pluralize.underscore)
286
+ redirect_to url_for(controller: resource.class.to_s.pluralize.underscore)
288
287
  return
289
288
  end
290
289
  end
@@ -29,7 +29,8 @@ class EnjuLeaf::QuickInstallGenerator < Rails::Generators::Base
29
29
  rake("sunspot:solr:run", :env => environment)
30
30
  else
31
31
  rake("sunspot:solr:start", :env => environment)
32
- rake("enju_leaf:create_initial_index", :env => environment)
32
+ sleep 5
33
+ rake("environment sunspot:reindex", :env => environment)
33
34
  rake("sunspot:solr:stop", :env => environment)
34
35
  end
35
36
  end
@@ -8,6 +8,12 @@ class EnjuLeaf::SetupGenerator < Rails::Generators::Base
8
8
  copy_file("config/application.yml", "config/application.yml")
9
9
  copy_file("config/resque.yml", "config/resque.yml")
10
10
  copy_file("config/schedule.rb", "config/schedule.rb")
11
+ inject_into_file 'config/application.rb', :after => /# config.i18n.default_locale = :de$\n/ do
12
+ <<"EOS"
13
+ config.i18n.available_locales = [:en, :ja]
14
+ config.i18n.enforce_available_locales = true
15
+ EOS
16
+ end
11
17
  gsub_file 'config/application.rb', /# config.i18n.default_locale = :de$/,
12
18
  "config.i18n.default_locale = :ja"
13
19
  gsub_file 'config/application.rb', /# config.time_zone = 'Central Time \(US & Canada\)'$/,
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  user_group_00001:
3
- name: "First group"
3
+ name: "first_group"
4
4
  display_name: "First group"
5
5
  id: 1
6
6
  note: ""
@@ -16,7 +16,7 @@ Sunspot.session = Sunspot::Rails::StubSessionProxy.new(Sunspot.session)
16
16
  system_user = User.new
17
17
  system_user.username = 'system'
18
18
  system_user.password = SecureRandom.urlsafe_base64(32)
19
- system_user.email = system_user.email_confirmation = LibraryGroup.first.email
19
+ system_user.email = system_user.email_confirmation = 'root@library.example.jp'
20
20
  system_user.save!
21
21
  system_user.role = Role.where(:name => 'Administrator').first
22
22
  system_user.index
@@ -27,9 +27,10 @@ user.email = email
27
27
  user.email_confirmation = email
28
28
  user.password = password
29
29
  user.password_confirmation = password
30
- user.library = Library.real.first
31
- user.locale = I18n.default_locale.to_s
32
- user.user_number = '0'
30
+ user.profile = Profile.new
31
+ user.profile.library = Library.real.first
32
+ user.profile.locale = I18n.default_locale.to_s
33
+ user.profile.user_number = '0'
33
34
  user.operator = user
34
35
  user.save!
35
36
  #user.confirm!
@@ -1,4 +1,6 @@
1
1
  require 'active_record/fixtures'
2
+ require 'tasks/profile'
3
+
2
4
  namespace :enju_leaf do
3
5
  desc "create initial records for enju_leaf"
4
6
  task :setup => :environment do
@@ -12,17 +14,24 @@ namespace :enju_leaf do
12
14
  puts 'initial fixture files loaded.'
13
15
  end
14
16
 
15
- desc "create initial index"
16
- task :create_initial_index => :environment do
17
- Library.reindex
18
- Shelf.reindex
19
- User.reindex
20
-
21
- puts 'indexing completed.'
22
- end
23
-
24
17
  desc "import users from a TSV file"
25
18
  task :user_import => :environment do
26
19
  UserImportFile.import
27
20
  end
21
+
22
+ desc "upgrade enju_leaf"
23
+ task :upgrade => :environment do
24
+ version = EnjuLeaf::VERSION.split('.')
25
+ if version[0..2] == ["1", "1" ,"0"]
26
+ if version[3] == 'rc13'
27
+ Rake::Task['enju_biblio:upgrade'].invoke
28
+ Rake::Task['enju_circulation:upgrade'].invoke
29
+ Rake::Task['enju_message:upgrade'].invoke
30
+ Profile.transaction do
31
+ update_profile
32
+ end
33
+ end
34
+ end
35
+ puts 'enju_leaf: The upgrade completed successfully.'
36
+ end
28
37
  end
@@ -0,0 +1,15 @@
1
+ def update_profile
2
+ User.find_each do |user|
3
+ next if user.profile
4
+ profile = Profile.new
5
+ profile.user = user
6
+ profile.user_group = user.user_group
7
+ profile.library = user.library
8
+ profile.required_role = user.required_role
9
+ profile.user_number = user.user_number
10
+ profile.keyword_list = user.keyword_list
11
+ profile.locale = user.locale
12
+ profile.note = user.note
13
+ profile.save
14
+ end
15
+ end