enju_circulation 0.3.11 → 0.4.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -3
  3. data/app/controllers/checkins_controller.rb +2 -2
  4. data/app/controllers/checkouts_controller.rb +2 -2
  5. data/app/controllers/demands_controller.rb +1 -1
  6. data/app/controllers/manifestation_checkout_stats_controller.rb +2 -2
  7. data/app/controllers/manifestation_reserve_stats_controller.rb +2 -2
  8. data/app/controllers/reserves_controller.rb +2 -2
  9. data/app/controllers/user_checkout_stats_controller.rb +2 -2
  10. data/app/controllers/user_group_has_checkout_types_controller.rb +1 -1
  11. data/app/controllers/user_reserve_stats_controller.rb +2 -2
  12. data/app/helpers/items_helper.rb +3 -3
  13. data/app/models/checked_item.rb +7 -17
  14. data/app/models/checkin.rb +3 -2
  15. data/app/models/checkout.rb +2 -2
  16. data/app/models/checkout_stat_has_user.rb +1 -1
  17. data/app/models/checkout_type.rb +9 -7
  18. data/app/models/circulation_status.rb +9 -8
  19. data/app/models/concerns/enju_circulation/enju_item.rb +2 -46
  20. data/app/models/concerns/enju_circulation/enju_user_group.rb +0 -1
  21. data/app/models/concerns/enju_circulation/enju_withdraw.rb +1 -7
  22. data/app/models/manifestation_checkout_stat_transition.rb +1 -1
  23. data/app/models/manifestation_reserve_stat_transition.rb +1 -1
  24. data/app/models/reserve.rb +5 -5
  25. data/app/models/reserve_state_machine.rb +3 -2
  26. data/app/models/reserve_transition.rb +1 -1
  27. data/app/models/retain.rb +15 -0
  28. data/app/models/user_checkout_stat_transition.rb +1 -1
  29. data/app/models/user_group_has_checkout_type.rb +15 -37
  30. data/app/models/user_reserve_stat_transition.rb +1 -1
  31. data/app/views/carrier_type_has_checkout_types/_form.html.erb +2 -2
  32. data/app/views/carrier_type_has_checkout_types/index.html.erb +2 -2
  33. data/app/views/carrier_type_has_checkout_types/show.html.erb +2 -2
  34. data/app/views/carrier_types/_carrier_type_has_checkout_type_fields.html.erb +1 -1
  35. data/app/views/checked_items/new.html.erb +1 -1
  36. data/app/views/checkins/_checkin.html.erb +1 -1
  37. data/app/views/checkout_types/_form.html.erb +1 -1
  38. data/app/views/checkout_types/index.html.erb +1 -1
  39. data/app/views/checkout_types/show.html.erb +2 -2
  40. data/app/views/checkouts/_index_user.html.erb +1 -1
  41. data/app/views/checkouts/_list.html.erb +2 -9
  42. data/app/views/checkouts/index.atom.builder +1 -1
  43. data/app/views/checkouts/index.ics.erb +1 -1
  44. data/app/views/checkouts/index.rss.builder +1 -1
  45. data/app/views/checkouts/{index.text.ruby → index.txt.ruby} +0 -0
  46. data/app/views/circulation_statuses/_form.html.erb +1 -1
  47. data/app/views/circulation_statuses/index.html.erb +1 -1
  48. data/app/views/circulation_statuses/show.html.erb +1 -1
  49. data/app/views/item_has_use_restrictions/index.html.erb +1 -1
  50. data/app/views/item_has_use_restrictions/show.html.erb +1 -1
  51. data/app/views/manifestation_checkout_stats/_group_by_carrier_type.html.erb +3 -3
  52. data/app/views/manifestation_checkout_stats/_group_by_checkout_type.html.erb +3 -3
  53. data/app/views/manifestation_checkout_stats/{show.text.erb → show.txt.erb} +0 -0
  54. data/app/views/manifestation_reserve_stats/{show.text.erb → show.txt.erb} +0 -0
  55. data/app/views/manifestations/_circulation_status.html.erb +3 -3
  56. data/app/views/profiles/_submenu_checkout.html.erb +1 -1
  57. data/app/views/reserves/_new.html.erb +1 -1
  58. data/app/views/reserves/_new_user.html.erb +1 -1
  59. data/app/views/reserves/edit.html.erb +1 -1
  60. data/app/views/reserves/index.atom.builder +1 -1
  61. data/app/views/reserves/index.html.erb +1 -1
  62. data/app/views/reserves/index.rss.builder +1 -1
  63. data/app/views/reserves/{index.text.ruby → index.txt.ruby} +0 -0
  64. data/app/views/reserves/show.html.erb +1 -1
  65. data/app/views/use_restrictions/_form.html.erb +1 -1
  66. data/app/views/use_restrictions/index.html.erb +1 -1
  67. data/app/views/use_restrictions/show.html.erb +1 -1
  68. data/app/views/user_checkout_stats/{show.text.erb → show.txt.erb} +0 -0
  69. data/app/views/user_group_has_checkout_types/edit.html.erb +4 -4
  70. data/app/views/user_group_has_checkout_types/index.html.erb +2 -2
  71. data/app/views/user_group_has_checkout_types/new.html.erb +4 -4
  72. data/app/views/user_group_has_checkout_types/show.html.erb +4 -4
  73. data/app/views/user_groups/_user_group_has_checkout_type_fields.html.erb +2 -2
  74. data/app/views/user_reserve_stats/{show.text.erb → show.txt.erb} +0 -0
  75. data/config/locales/translation_en.yml +1 -14
  76. data/config/locales/translation_ja.yml +1 -14
  77. data/config/routes.rb +1 -2
  78. data/db/migrate/20110627122938_add_number_of_day_to_notify_overdue_to_user_group.rb +3 -3
  79. data/db/migrate/20190508160525_create_retains.rb +10 -0
  80. data/db/migrate/20190629134017_rename_user_group_has_checkout_type_due_date_before_to_due_date_after.rb +5 -0
  81. data/db/migrate/20190706052525_add_display_name_translations_to_circulation_status.rb +5 -0
  82. data/db/migrate/20190713114724_add_checkout_id_to_checkin.rb +5 -0
  83. data/db/migrate/20190814120827_add_display_name_translations_to_checkout_type.rb +5 -0
  84. data/lib/enju_circulation/version.rb +1 -1
  85. data/lib/generators/enju_circulation/setup/templates/db/fixtures/checkout_types.yml +3 -5
  86. data/lib/generators/enju_circulation/setup/templates/db/fixtures/circulation_statuses.yml +16 -48
  87. data/lib/tasks/enju_circulation_tasks.rake +7 -1
  88. data/spec/concerns/enju_accept_spec.rb +14 -14
  89. data/spec/controllers/accepts_controller_spec.rb +294 -0
  90. data/spec/controllers/baskets_controller_spec.rb +379 -0
  91. data/spec/controllers/checkins_controller_spec.rb +8 -130
  92. data/spec/controllers/checkouts_controller_spec.rb +5 -5
  93. data/spec/controllers/items_controller_spec.rb +23 -43
  94. data/spec/controllers/reserves_controller_spec.rb +9 -9
  95. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  96. data/spec/dummy/app/models/user.rb +1 -1
  97. data/spec/dummy/bin/bundle +1 -1
  98. data/spec/dummy/bin/setup +1 -3
  99. data/spec/dummy/bin/update +4 -2
  100. data/spec/dummy/bin/yarn +3 -3
  101. data/spec/dummy/config/database.yml +70 -9
  102. data/spec/dummy/config/initializers/assets.rb +1 -0
  103. data/spec/dummy/db/development.sqlite3 +0 -0
  104. data/spec/dummy/db/migrate/113_create_events.rb +2 -4
  105. data/spec/dummy/db/migrate/20081028093607_create_event_import_files.rb +2 -4
  106. data/spec/dummy/db/migrate/20090519203307_create_participates.rb +2 -4
  107. data/spec/dummy/db/migrate/20100925074639_create_event_import_results.rb +2 -2
  108. data/spec/dummy/db/migrate/20140720192418_add_default_library_id_to_event_import_file.rb +1 -1
  109. data/spec/dummy/db/migrate/20140812152348_create_event_export_files.rb +1 -1
  110. data/spec/dummy/db/migrate/20140814070854_add_default_event_category_id_to_event_import_file.rb +1 -1
  111. data/spec/dummy/db/migrate/20151128142913_create_places.rb +14 -0
  112. data/spec/dummy/db/migrate/20151201163718_add_place_id_to_event.rb +5 -0
  113. data/spec/dummy/db/migrate/20160703184258_add_most_recent_to_event_import_file_transitions.rb +9 -0
  114. data/spec/dummy/db/migrate/20160703184311_add_most_recent_to_event_export_file_transitions.rb +9 -0
  115. data/spec/dummy/db/migrate/20180107160726_add_constraints_to_most_recent_for_user_import_file_transitions.rb +1 -1
  116. data/spec/dummy/db/migrate/20180107160740_add_constraints_to_most_recent_for_user_export_file_transitions.rb +1 -1
  117. data/spec/dummy/db/migrate/20180107164558_add_constraints_to_most_recent_for_event_import_file_transitions.rb +13 -0
  118. data/spec/dummy/db/migrate/20180107164617_add_constraints_to_most_recent_for_event_export_file_transitions.rb +13 -0
  119. data/spec/dummy/db/migrate/20181119170645_add_foreign_key_to_events_referencing_event_categories.rb +5 -0
  120. data/spec/dummy/db/migrate/20190630113817_add_display_name_translations_to_library_group.rb +12 -0
  121. data/spec/dummy/db/migrate/20190630115523_add_login_banner_translations_to_library_group.rb +6 -0
  122. data/spec/dummy/db/migrate/20190630151446_add_display_name_translations_to_role.rb +5 -0
  123. data/spec/dummy/db/migrate/20190630153136_add_display_name_translations_to_event.rb +6 -0
  124. data/spec/dummy/db/migrate/20190712163038_add_display_name_translations_to_carrier_type.rb +21 -0
  125. data/spec/dummy/db/migrate/20190713114940_add_profile_id_to_user.rb +5 -0
  126. data/spec/dummy/db/migrate/20190713115451_add_full_name_translations_to_profile.rb +5 -0
  127. data/spec/dummy/db/schema.rb +221 -184
  128. data/spec/dummy/db/test.sqlite3 +0 -0
  129. data/spec/dummy/private/system/carrier_types/attachments/000/000/001/original/book.png +0 -0
  130. data/spec/dummy/private/system/carrier_types/attachments/000/000/001/thumb/book.png +0 -0
  131. data/spec/factories/accept.rb +1 -1
  132. data/spec/factories/item.rb +4 -4
  133. data/spec/factories/reserve.rb +1 -5
  134. data/spec/fixtures/carrier_types.yml +16 -15
  135. data/spec/fixtures/checkins.yml +2 -1
  136. data/spec/fixtures/checkout_stat_has_users.yml +1 -1
  137. data/spec/fixtures/checkout_types.yml +11 -10
  138. data/spec/fixtures/checkouts.yml +2 -2
  139. data/spec/fixtures/circulation_statuses.yml +26 -34
  140. data/spec/fixtures/content_types.yml +20 -31
  141. data/spec/fixtures/event_categories.yml +23 -23
  142. data/spec/fixtures/frequencies.yml +17 -25
  143. data/spec/fixtures/items.yml +1 -1
  144. data/spec/fixtures/libraries.yml +30 -31
  145. data/spec/fixtures/library_groups.yml +43 -20
  146. data/spec/fixtures/request_status_types.yml +14 -14
  147. data/spec/fixtures/request_types.yml +13 -13
  148. data/spec/fixtures/reserve_transitions.yml +1 -1
  149. data/spec/fixtures/reserves.yml +3 -3
  150. data/spec/fixtures/roles.yml +22 -5
  151. data/spec/fixtures/shelves.yml +16 -15
  152. data/spec/fixtures/user_group_has_checkout_types.yml +24 -24
  153. data/spec/fixtures/user_groups.yml +23 -3
  154. data/spec/helpers/items_helper_spec.rb +1 -1
  155. data/spec/models/checked_item_spec.rb +0 -11
  156. data/spec/models/checkin_spec.rb +2 -1
  157. data/spec/models/checkout_spec.rb +2 -2
  158. data/spec/models/checkout_stat_has_user_spec.rb +1 -1
  159. data/spec/models/checkout_type_spec.rb +8 -7
  160. data/spec/models/circulation_status_spec.rb +8 -7
  161. data/spec/models/item_spec.rb +6 -8
  162. data/spec/models/manifestation_spec.rb +15 -18
  163. data/spec/models/reserve_spec.rb +3 -3
  164. data/spec/models/resource_export_file_spec.rb +0 -15
  165. data/spec/models/retain_spec.rb +16 -0
  166. data/spec/models/user_group_has_checkout_type_spec.rb +15 -32
  167. data/spec/models/withdraw_spec.rb +4 -6
  168. data/spec/policies/manifestation_policy_spec.rb +2 -1
  169. data/spec/rails_helper.rb +10 -3
  170. data/spec/system/reserves_spec.rb +1 -1
  171. data/spec/views/items/index.html.erb_spec.rb +1 -4
  172. metadata +402 -452
  173. data/app/controllers/lending_policies_controller.rb +0 -106
  174. data/app/models/lending_policy.rb +0 -30
  175. data/app/views/lending_policies/_form.html.erb +0 -41
  176. data/app/views/lending_policies/edit.html.erb +0 -13
  177. data/app/views/lending_policies/index.html.erb +0 -42
  178. data/app/views/lending_policies/new.html.erb +0 -12
  179. data/app/views/lending_policies/show.html.erb +0 -50
  180. data/db/migrate/20090831220301_create_lending_policies.rb +0 -21
  181. data/spec/controllers/lending_policies_controller_spec.rb +0 -444
  182. data/spec/controllers/withdraws_controller_spec.rb +0 -26
  183. data/spec/dummy/config/locales/en.yml +0 -208
  184. data/spec/dummy/config/locales/ja.yml +0 -200
  185. data/spec/dummy/db/migrate/20190818075603_add_memo_to_manifestation.rb +0 -5
  186. data/spec/dummy/db/migrate/20190818075628_add_memo_to_item.rb +0 -5
  187. data/spec/dummy/db/migrate/20200425072340_create_manifestation_custom_properties.rb +0 -12
  188. data/spec/dummy/db/migrate/20200425072349_create_item_custom_properties.rb +0 -12
  189. data/spec/dummy/db/migrate/20200425074758_create_manifestation_custom_values.rb +0 -12
  190. data/spec/dummy/db/migrate/20200425074822_create_item_custom_values.rb +0 -12
  191. data/spec/fixtures/accepts.yml +0 -9
  192. data/spec/fixtures/bookstores.yml +0 -99
  193. data/spec/fixtures/budget_types.yml +0 -30
  194. data/spec/fixtures/exemplifies.yml +0 -168
  195. data/spec/fixtures/lending_policies.yml +0 -98
  196. data/spec/models/lending_policy_spec.rb +0 -23
  197. data/spec/system/items_spec.rb +0 -21
  198. data/spec/system/user_group_has_checkout_types.rb +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc1ce2cb589e9735098bc631b67af64bdeb3079231f89ba6dcc958edce5934b3
4
- data.tar.gz: e1ac4b066e1384274a988a0d925c4e9f88db5fae8d00b0665706561f0cc080a4
3
+ metadata.gz: ae2524b7384336afe28edefb0a5fd0ea8004c5ca9a56e87048df9047fade290b
4
+ data.tar.gz: c178fa1fb96decbd1e5b567055dda1e052e17e84da7e4101bdb2606f1c95e467
5
5
  SHA512:
6
- metadata.gz: 5776c625a4a3069c03e1b9dc503c6da7219521e77702e51729f4f7f9a6903e6bfd711cd51dfc6691b036a59bf9c161f17f4fb3944b6b02664fa780cdb80b3747
7
- data.tar.gz: fd45ef7eaa838fcdf1c4bcf50bd001699012ec9dd6f7711141c00f6660031d0e7620329b06d2516ba3f207ad9dbda8ea0916a9766431401a72005bbe98377150
6
+ metadata.gz: 5f6c642dbfabfcce25d17386a11b4c34fc8aee9589b2147604c7efd8e8314cfea7440d6774d23593380657da02cda3abba621991ff140336bab16318cb63251f
7
+ data.tar.gz: d2dcf749b0de72a7be4e976f16d15cd7f3397b228a23f3582b028f1a8a9849378e7c6688ebe64ab115fda2b40fa296d9e8019148fd184567a42cbd8787b1dad5
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # EnjuCirculation
2
- [![Travis CI](https://travis-ci.com/next-l/enju_circulation.svg?branch=1.3)](https://travis-ci.com/next-l/enju_circulation)
3
- [![Coverage Status](https://coveralls.io/repos/github/next-l/enju_circulation/badge.svg?branch=1.3)](https://coveralls.io/github/next-l/enju_circulation?branch=1.3)
4
- [![security](https://hakiri.io/github/next-l/enju_circulation/1.3.svg)](https://hakiri.io/github/next-l/enju_circulation/1.3)
2
+ [![CircleCI](https://circleci.com/gh/next-l/enju_circulation/tree/2.x.svg?style=svg)](https://circleci.com/gh/next-l/enju_circulation/tree/2.x)
3
+ [![Coverage Status](https://coveralls.io/repos/github/next-l/enju_circulation/badge.svg?branch=2.x)](https://coveralls.io/github/next-l/enju_circulation?branch=2.x)
5
4
 
6
5
  This project rocks and uses MIT-LICENSE.
7
6
 
@@ -77,12 +77,12 @@ class CheckinsController < ApplicationController
77
77
  end
78
78
  flash[:message] << message if message
79
79
  format.html { redirect_to checkins_url(basket_id: @checkin.basket_id) }
80
- format.json { render json: {result: @checkin, messages: flash[:message]}, status: :created, location: @checkin }
80
+ format.json { render json: @checkin, status: :created, location: @checkin }
81
81
  format.js { redirect_to checkins_url(basket_id: @basket.id, format: :js) }
82
82
  else
83
83
  @checkins = @basket.checkins.page(1)
84
84
  format.html { render action: "new" }
85
- format.json { render json: {messages: @checkin.errors}, status: :unprocessable_entity }
85
+ format.json { render json: @checkin.errors, status: :unprocessable_entity }
86
86
  format.js { render action: "index" }
87
87
  end
88
88
  end
@@ -21,7 +21,7 @@ class CheckoutsController < ApplicationController
21
21
  end
22
22
  end
23
23
 
24
- if ['text', 'rss'].include?(params[:format].to_s.downcase)
24
+ if ['txt', 'rss'].include?(params[:format].to_s.downcase)
25
25
  per_page = 500
26
26
  page = 1
27
27
  else
@@ -100,7 +100,7 @@ class CheckoutsController < ApplicationController
100
100
  format.json { render json: @checkouts }
101
101
  format.rss { render layout: false }
102
102
  format.ics
103
- format.text
103
+ format.txt
104
104
  format.atom
105
105
  end
106
106
  end
@@ -19,7 +19,7 @@ class DemandsController < ApplicationController
19
19
  respond_to do |format|
20
20
  format.html # show.html.erb
21
21
  format.json { render json: @demand }
22
- format.text
22
+ format.txt
23
23
  end
24
24
  end
25
25
 
@@ -17,7 +17,7 @@ class ManifestationCheckoutStatsController < ApplicationController
17
17
  # GET /manifestation_checkout_stats/1
18
18
  # GET /manifestation_checkout_stats/1.json
19
19
  def show
20
- if request.format.text?
20
+ if params[:format] == 'txt'
21
21
  per_page = 65534
22
22
  else
23
23
  per_page = CheckoutStatHasManifestation.default_per_page
@@ -52,7 +52,7 @@ class ManifestationCheckoutStatsController < ApplicationController
52
52
  respond_to do |format|
53
53
  format.html # show.html.erb
54
54
  format.json { render json: @manifestation_checkout_stat }
55
- format.text
55
+ format.txt
56
56
  format.js
57
57
  end
58
58
  end
@@ -18,7 +18,7 @@ class ManifestationReserveStatsController < ApplicationController
18
18
  # GET /manifestation_reserve_stats/1
19
19
  # GET /manifestation_reserve_stats/1.json
20
20
  def show
21
- if request.format.text?
21
+ if params[:format] == 'txt'
22
22
  per_page = 65534
23
23
  else
24
24
  per_page = ReserveStatHasManifestation.default_per_page
@@ -28,7 +28,7 @@ class ManifestationReserveStatsController < ApplicationController
28
28
  respond_to do |format|
29
29
  format.html # show.html.erb
30
30
  format.json { render json: @manifestation_reserve_stat }
31
- format.text
31
+ format.txt
32
32
  end
33
33
  end
34
34
 
@@ -34,7 +34,7 @@ class ReservesController < ApplicationController
34
34
  sort_column = :created_at
35
35
  order = :desc
36
36
  end
37
- if ['text', 'rss'].include?(params[:format].to_s.downcase)
37
+ if ['txt', 'rss'].include?(params[:format].to_s.downcase)
38
38
  per_page = 500
39
39
  page = 1
40
40
  else
@@ -105,7 +105,7 @@ class ReservesController < ApplicationController
105
105
  format.json { render json: @reserves }
106
106
  format.rss { render layout: false }
107
107
  format.atom
108
- format.text
108
+ format.txt
109
109
  end
110
110
  end
111
111
 
@@ -17,7 +17,7 @@ class UserCheckoutStatsController < ApplicationController
17
17
  # GET /user_checkout_stats/1
18
18
  # GET /user_checkout_stats/1.json
19
19
  def show
20
- if request.format.text?
20
+ if params[:format] == 'txt'
21
21
  per_page = 65534
22
22
  else
23
23
  per_page = CheckoutStatHasUser.default_per_page
@@ -27,7 +27,7 @@ class UserCheckoutStatsController < ApplicationController
27
27
  respond_to do |format|
28
28
  format.html # show.html.erb
29
29
  format.json { render json: @user_checkout_stat }
30
- format.text
30
+ format.txt
31
31
  end
32
32
  end
33
33
 
@@ -101,7 +101,7 @@ class UserGroupHasCheckoutTypesController < ApplicationController
101
101
  :user_group_id, :checkout_type_id,
102
102
  :checkout_limit, :checkout_period, :checkout_renewal_limit,
103
103
  :reservation_limit, :reservation_expired_period,
104
- :set_due_date_before_closing_day, :fixed_due_date, :note, :position,
104
+ :set_due_date_after_closing_day, :fixed_due_date, :note, :position,
105
105
  :user_group, :checkout_type
106
106
  )
107
107
  end
@@ -17,7 +17,7 @@ class UserReserveStatsController < ApplicationController
17
17
  # GET /user_reserve_stats/1
18
18
  # GET /user_reserve_stats/1.json
19
19
  def show
20
- if request.format.text?
20
+ if params[:format] == 'txt'
21
21
  per_page = 65534
22
22
  else
23
23
  per_page = ReserveStatHasUser.default_per_page
@@ -27,7 +27,7 @@ class UserReserveStatsController < ApplicationController
27
27
  respond_to do |format|
28
28
  format.html # show.html.erb
29
29
  format.json { render json: @user_reserve_stat }
30
- format.text
30
+ format.txt
31
31
  end
32
32
  end
33
33
 
@@ -1,16 +1,16 @@
1
1
  module ItemsHelper
2
2
  def circulation_status_facet(facet)
3
3
  string = ''
4
- circulation_status = CirculationStatus.where(name: facet.value).select([:name, :display_name]).first
4
+ circulation_status = CirculationStatus.where(name: facet.value).select([:name, :display_name_translations]).first
5
5
  if circulation_status
6
6
  # string << form_icon(circulation_status)
7
7
  current = true if params[:circulation_status] == circulation_status.name
8
8
  if current
9
9
  content_tag :strong do
10
- link_to("#{circulation_status.display_name.localize} (" + facet.count.to_s + ")", url_for(filtered_params.merge(circulation_status: circulation_status.name, page: nil, view: nil, only_path: true)))
10
+ link_to("#{circulation_status.display_name} (" + facet.count.to_s + ")", url_for(filtered_params.merge(circulation_status: circulation_status.name, page: nil, view: nil, only_path: true)))
11
11
  end
12
12
  else
13
- link_to("#{circulation_status.display_name.localize} (" + facet.count.to_s + ")", url_for(filtered_params.merge(circulation_status: circulation_status.name, page: nil, view: nil, only_path: true)))
13
+ link_to("#{circulation_status.display_name} (" + facet.count.to_s + ")", url_for(filtered_params.merge(circulation_status: circulation_status.name, page: nil, view: nil, only_path: true)))
14
14
  end
15
15
  end
16
16
  end
@@ -82,26 +82,16 @@ class CheckedItem < ApplicationRecord
82
82
  if due_date_string.present?
83
83
  self.due_date = Time.zone.parse(due_date_string).try(:end_of_day)
84
84
  else
85
- lending_rule = item.lending_rule(basket.user)
86
- return nil if lending_rule.nil?
87
-
88
- if lending_rule.fixed_due_date.blank?
89
- # self.due_date = item_checkout_type.checkout_period.days.since Time.zone.today
90
- self.due_date = lending_rule.loan_period.days.since(Time.zone.now).end_of_day
91
- else
92
- # self.due_date = item_checkout_type.fixed_due_date
93
- self.due_date = lending_rule.fixed_due_date.tomorrow.end_of_day
94
- end
85
+ due_date = item_checkout_type.checkout_period.days.since Time.zone.today
95
86
  # 返却期限日が閉館日の場合
96
- while item.shelf.library.closed?(due_date)
97
- if item_checkout_type.set_due_date_before_closing_day
98
- self.due_date = due_date.yesterday.end_of_day
99
- else
100
- self.due_date = due_date.tomorrow.end_of_day
101
- end
87
+ if item.shelf.library.closed?(due_date) && item_checkout_type.set_due_date_after_closing_day
88
+ self.due_date = due_date.tomorrow.end_of_day
89
+ else
90
+ self.due_date = due_date.end_of_day
102
91
  end
103
92
  end
104
- return due_date
93
+
94
+ self
105
95
  end
106
96
 
107
97
  def set_item
@@ -1,7 +1,7 @@
1
1
  class Checkin < ApplicationRecord
2
2
  default_scope { order('checkins.id DESC') }
3
3
  scope :on, lambda {|date| where('created_at >= ? AND created_at < ?', date.beginning_of_day, date.tomorrow.beginning_of_day)}
4
- has_one :checkout
4
+ has_one :checkout, dependent: :nullify
5
5
  belongs_to :item, touch: true
6
6
  belongs_to :librarian, class_name: 'User'
7
7
  belongs_to :basket
@@ -91,5 +91,6 @@ end
91
91
  # basket_id :integer
92
92
  # created_at :datetime
93
93
  # updated_at :datetime
94
- # lock_version :integer default("0"), not null
94
+ # lock_version :integer default(0), not null
95
+ # checkin_id :bigint
95
96
  #
@@ -174,8 +174,8 @@ end
174
174
  # librarian_id :integer
175
175
  # basket_id :integer
176
176
  # due_date :datetime
177
- # checkout_renewal_count :integer default("0"), not null
178
- # lock_version :integer default("0"), not null
177
+ # checkout_renewal_count :integer default(0), not null
178
+ # lock_version :integer default(0), not null
179
179
  # created_at :datetime
180
180
  # updated_at :datetime
181
181
  # shelf_id :integer
@@ -17,7 +17,7 @@ end
17
17
  # id :integer not null, primary key
18
18
  # user_checkout_stat_id :integer not null
19
19
  # user_id :integer not null
20
- # checkouts_count :integer default("0"), not null
20
+ # checkouts_count :integer default(0), not null
21
21
  # created_at :datetime
22
22
  # updated_at :datetime
23
23
  #
@@ -12,17 +12,19 @@ class CheckoutType < ApplicationRecord
12
12
  has_many :items
13
13
 
14
14
  paginates_per 10
15
+ translates :display_name
15
16
  end
16
17
 
17
18
  # == Schema Information
18
19
  #
19
20
  # Table name: checkout_types
20
21
  #
21
- # id :integer not null, primary key
22
- # name :string not null
23
- # display_name :text
24
- # note :text
25
- # position :integer
26
- # created_at :datetime
27
- # updated_at :datetime
22
+ # id :integer not null, primary key
23
+ # name :string not null
24
+ # display_name :text
25
+ # note :text
26
+ # position :integer
27
+ # created_at :datetime
28
+ # updated_at :datetime
29
+ # display_name_translations :jsonb not null
28
30
  #
@@ -2,9 +2,9 @@ class CirculationStatus < ApplicationRecord
2
2
  include MasterModel
3
3
  validates :name, presence: true, format: { with: /\A[0-9A-Za-z][0-9A-Za-z_\-\s,]*[0-9a-z]\Z/ }
4
4
 
5
- default_scope { order('circulation_statuses.position') }
6
5
  scope :available_for_checkout, -> { where(name: 'Available On Shelf') }
7
6
  has_many :items
7
+ translates :display_name
8
8
 
9
9
  private
10
10
 
@@ -17,11 +17,12 @@ end
17
17
  #
18
18
  # Table name: circulation_statuses
19
19
  #
20
- # id :integer not null, primary key
21
- # name :string not null
22
- # display_name :text
23
- # note :text
24
- # position :integer
25
- # created_at :datetime
26
- # updated_at :datetime
20
+ # id :integer not null, primary key
21
+ # name :string not null
22
+ # display_name :text
23
+ # note :text
24
+ # position :integer
25
+ # created_at :datetime
26
+ # updated_at :datetime
27
+ # display_name_translations :jsonb not null
27
28
  #
@@ -35,36 +35,24 @@ module EnjuCirculation
35
35
  has_many :reserves
36
36
  has_many :checked_items
37
37
  has_many :baskets, through: :checked_items
38
- belongs_to :circulation_status
38
+ belongs_to :circulation_status, validate: true
39
39
  belongs_to :checkout_type
40
- has_many :lending_policies, dependent: :destroy
41
40
  has_one :item_has_use_restriction, dependent: :destroy
42
41
  has_one :use_restriction, through: :item_has_use_restriction
42
+ validates_associated :circulation_status, :checkout_type
43
43
  validates :circulation_status, :checkout_type, presence: true
44
- validate :check_circulation_status
45
-
46
44
  searchable do
47
45
  string :circulation_status do
48
46
  circulation_status.name
49
47
  end
50
48
  end
51
49
  accepts_nested_attributes_for :item_has_use_restriction
52
-
53
- before_update :delete_lending_policy
54
50
  end
55
51
 
56
52
  def set_circulation_status
57
53
  self.circulation_status = CirculationStatus.find_by(name: 'In Process') if circulation_status.nil?
58
54
  end
59
55
 
60
- def check_circulation_status
61
- #circulation_status.name_will_change!
62
- #return unless circulation_status.name_change.first == 'Removed'
63
- return unless circulation_status.name == 'Removed'
64
- errors[:base] << I18n.t('activerecord.errors.models.item.attributes.circulation_status_id.is_rented') if rented?
65
- errors[:base] << I18n.t('activerecord.errors.models.item.attributes.circulation_status_id.is_reserved') if reserved?
66
- end
67
-
68
56
  def checkout_status(user)
69
57
  return nil unless user
70
58
  user.profile.user_group.user_group_has_checkout_types.find_by(checkout_type_id: checkout_type.id)
@@ -80,10 +68,6 @@ module EnjuCirculation
80
68
  false
81
69
  end
82
70
 
83
- def rented?
84
- rent?
85
- end
86
-
87
71
  def reserved_by_user?(user)
88
72
  if manifestation.next_reservation
89
73
  return true if manifestation.next_reservation.user == user
@@ -105,8 +89,6 @@ module EnjuCirculation
105
89
  manifestation.next_reservation.transition_to!(:completed)
106
90
  manifestation.reload
107
91
  end
108
-
109
- reload
110
92
  update!(circulation_status: CirculationStatus.find_by(name: 'On Loan'))
111
93
  end
112
94
 
@@ -135,36 +117,10 @@ module EnjuCirculation
135
117
  false
136
118
  end
137
119
 
138
- def lending_rule(user)
139
- policy = lending_policies.find_by(user_group_id: user.profile.user_group.id)
140
- if policy
141
- policy
142
- else
143
- create_lending_policy(user)
144
- end
145
- end
146
-
147
120
  def not_for_loan?
148
121
  !manifestation.items.for_checkout.include?(self)
149
122
  end
150
123
 
151
- def create_lending_policy(user)
152
- rule = user.profile.user_group.user_group_has_checkout_types.find_by(checkout_type_id: checkout_type_id)
153
- return nil unless rule
154
- LendingPolicy.create!(
155
- item_id: id,
156
- user_group_id: rule.user_group_id,
157
- fixed_due_date: rule.fixed_due_date,
158
- loan_period: rule.checkout_period,
159
- renewal: rule.checkout_renewal_limit
160
- )
161
- end
162
-
163
- def delete_lending_policy
164
- return nil unless changes[:checkout_type_id]
165
- lending_policies.delete_all
166
- end
167
-
168
124
  def next_reservation
169
125
  Reserve.waiting.find_by(item_id: id)
170
126
  end
@@ -5,7 +5,6 @@ module EnjuCirculation
5
5
  included do
6
6
  has_many :user_group_has_checkout_types, dependent: :destroy
7
7
  has_many :checkout_types, through: :user_group_has_checkout_types
8
- has_many :lending_policies
9
8
  accepts_nested_attributes_for :user_group_has_checkout_types, allow_destroy: true, reject_if: :all_blank
10
9
 
11
10
  validates :number_of_day_to_notify_due_date,
@@ -3,8 +3,7 @@ module EnjuCirculation
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- before_create :withdraw!
7
- validate :check_item
6
+ before_save :withdraw!, on: :create
8
7
  end
9
8
 
10
9
  def withdraw!
@@ -13,10 +12,5 @@ module EnjuCirculation
13
12
  item.use_restriction = UseRestriction.where(name: 'Not For Loan').first
14
13
  item.index!
15
14
  end
16
-
17
- def check_item
18
- errors.add(:item_id, :is_rented) if item.try(:rent?)
19
- errors.add(:item_id, :is_reserved) if item.try(:reserved?)
20
- end
21
15
  end
22
16
  end
@@ -12,7 +12,7 @@ end
12
12
  #
13
13
  # id :integer not null, primary key
14
14
  # to_state :string
15
- # metadata :text default("{}")
15
+ # metadata :text default({})
16
16
  # sort_key :integer
17
17
  # manifestation_checkout_stat_id :integer
18
18
  # created_at :datetime
@@ -12,7 +12,7 @@ end
12
12
  #
13
13
  # id :integer not null, primary key
14
14
  # to_state :string
15
- # metadata :text default("{}")
15
+ # metadata :text default({})
16
16
  # sort_key :integer
17
17
  # manifestation_reserve_stat_id :integer
18
18
  # created_at :datetime
@@ -2,7 +2,7 @@ class Reserve < ApplicationRecord
2
2
  include Statesman::Adapters::ActiveRecordQueries
3
3
  scope :hold, -> { where('item_id IS NOT NULL') }
4
4
  scope :not_hold, -> { where(item_id: nil) }
5
- scope :waiting, -> {not_in_state(:completed, :canceled, :expired).where('canceled_at IS NULL AND (expired_at > ? OR expired_at IS NULL)', Time.zone.now).order('reserves.id DESC')}
5
+ scope :waiting, -> {not_in_state(:completed, :expired, :retained).where('canceled_at IS NULL AND (expired_at > ? OR expired_at IS NULL)', Time.zone.now).order('reserves.id DESC')}
6
6
  scope :retained, -> {in_state(:retained).where('retained_at IS NOT NULL')}
7
7
  scope :completed, -> {in_state(:completed).where('checked_out_at IS NOT NULL')}
8
8
  scope :canceled, -> {in_state(:canceled).where('canceled_at IS NOT NULL')}
@@ -371,7 +371,7 @@ class Reserve < ApplicationRecord
371
371
  end
372
372
 
373
373
  def manifestation_must_include_item
374
- if manifestation && item && !completed?
374
+ if item_id.present? && !completed?
375
375
  errors[:base] << I18n.t('reserve.invalid_item') unless manifestation.items.include?(item)
376
376
  end
377
377
  end
@@ -404,10 +404,10 @@ end
404
404
  # canceled_at :datetime
405
405
  # expired_at :datetime
406
406
  # deleted_at :datetime
407
- # expiration_notice_to_patron :boolean default("0")
408
- # expiration_notice_to_library :boolean default("0")
407
+ # expiration_notice_to_patron :boolean default(FALSE)
408
+ # expiration_notice_to_library :boolean default(FALSE)
409
409
  # pickup_location_id :integer
410
410
  # retained_at :datetime
411
411
  # postponed_at :datetime
412
- # lock_version :integer default("0"), not null
412
+ # lock_version :integer default(0), not null
413
413
  #
@@ -14,15 +14,16 @@ class ReserveStateMachine
14
14
  transition from: :requested, to: [:retained, :canceled, :expired, :completed]
15
15
 
16
16
  after_transition(to: :requested) do |reserve|
17
- reserve.update(request_status_type: RequestStatusType.find_by(name: 'In Process'), item_id: nil, retained_at: nil)
17
+ reserve.update(request_status_type: RequestStatusType.where(name: 'In Process').first, item_id: nil, retained_at: nil)
18
18
  end
19
19
 
20
20
  after_transition(to: :retained) do |reserve|
21
21
  # TODO: 「取り置き中」の状態を正しく表す
22
- reserve.update(request_status_type: RequestStatusType.find_by(name: 'In Process'), retained_at: Time.zone.now)
22
+ reserve.update(request_status_type: RequestStatusType.where(name: 'In Process').first, retained_at: Time.zone.now)
23
23
  Reserve.transaction do
24
24
  if reserve.item
25
25
  other_reserves = reserve.item.reserves.waiting
26
+ other_reserves += reserve.item.reserves.in_state(:retained)
26
27
  other_reserves.each{|r|
27
28
  if r != reserve
28
29
  r.transition_to!(:postponed)
@@ -12,7 +12,7 @@ end
12
12
  #
13
13
  # id :integer not null, primary key
14
14
  # to_state :string
15
- # metadata :text default("{}")
15
+ # metadata :text default({})
16
16
  # sort_key :integer
17
17
  # reserve_id :integer
18
18
  # created_at :datetime
@@ -0,0 +1,15 @@
1
+ class Retain < ApplicationRecord
2
+ belongs_to :reserve
3
+ belongs_to :item
4
+ end
5
+
6
+ # == Schema Information
7
+ #
8
+ # Table name: retains
9
+ #
10
+ # id :bigint not null, primary key
11
+ # reserve_id :bigint not null
12
+ # item_id :bigint not null
13
+ # created_at :datetime not null
14
+ # updated_at :datetime not null
15
+ #
@@ -12,7 +12,7 @@ end
12
12
  #
13
13
  # id :integer not null, primary key
14
14
  # to_state :string
15
- # metadata :text default("{}")
15
+ # metadata :text default({})
16
16
  # sort_key :integer
17
17
  # user_checkout_stat_id :integer
18
18
  # created_at :datetime
@@ -13,31 +13,9 @@ class UserGroupHasCheckoutType < ApplicationRecord
13
13
  validates :checkout_renewal_limit, numericality: {only_integer: true, greater_than_or_equal_to: 0}
14
14
  validates :reservation_limit, numericality: {only_integer: true, greater_than_or_equal_to: 0}
15
15
  validates :reservation_expired_period, numericality: {only_integer: true, greater_than_or_equal_to: 0}
16
- after_update :update_lending_policy
17
16
 
18
17
  acts_as_list scope: :user_group_id
19
18
 
20
- def create_lending_policy
21
- checkout_type.items.find_each do |item|
22
- policy = LendingPolicy.where(item_id: item.id, user_group_id: user_group_id).select(:id).first
23
- unless policy
24
- sql = ['INSERT INTO lending_policies (item_id, user_group_id, loan_period, renewal, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?)', item.id, user_group_id, checkout_period, checkout_renewal_limit, Time.zone.now, Time.zone.now]
25
- ActiveRecord::Base.connection.execute(
26
- self.class.send(:sanitize_sql_array, sql)
27
- )
28
- end
29
- end
30
- end
31
-
32
- def update_lending_policy
33
- checkout_type.items.each do |item|
34
- sql = ['UPDATE lending_policies SET loan_period = ?, renewal = ?, updated_at = ? WHERE user_group_id = ? AND item_id = ?', checkout_period, checkout_renewal_limit, Time.zone.now, user_group_id, item.id]
35
- ActiveRecord::Base.connection.execute(
36
- self.class.send(:sanitize_sql_array, sql)
37
- )
38
- end
39
- end
40
-
41
19
  def self.update_current_checkout_count
42
20
  sql = [
43
21
  'SELECT count(checkouts.id) as current_checkout_count,
@@ -68,19 +46,19 @@ end
68
46
  #
69
47
  # Table name: user_group_has_checkout_types
70
48
  #
71
- # id :integer not null, primary key
72
- # user_group_id :integer not null
73
- # checkout_type_id :integer not null
74
- # checkout_limit :integer default("0"), not null
75
- # checkout_period :integer default("0"), not null
76
- # checkout_renewal_limit :integer default("0"), not null
77
- # reservation_limit :integer default("0"), not null
78
- # reservation_expired_period :integer default("7"), not null
79
- # set_due_date_before_closing_day :boolean default("0"), not null
80
- # fixed_due_date :datetime
81
- # note :text
82
- # position :integer
83
- # created_at :datetime
84
- # updated_at :datetime
85
- # current_checkout_count :integer
49
+ # id :integer not null, primary key
50
+ # user_group_id :integer not null
51
+ # checkout_type_id :integer not null
52
+ # checkout_limit :integer default(0), not null
53
+ # checkout_period :integer default(0), not null
54
+ # checkout_renewal_limit :integer default(0), not null
55
+ # reservation_limit :integer default(0), not null
56
+ # reservation_expired_period :integer default(7), not null
57
+ # set_due_date_after_closing_day :boolean default(FALSE), not null
58
+ # fixed_due_date :datetime
59
+ # note :text
60
+ # position :integer
61
+ # created_at :datetime
62
+ # updated_at :datetime
63
+ # current_checkout_count :integer
86
64
  #
@@ -12,7 +12,7 @@ end
12
12
  #
13
13
  # id :integer not null, primary key
14
14
  # to_state :string
15
- # metadata :text default("{}")
15
+ # metadata :text default({})
16
16
  # sort_key :integer
17
17
  # user_reserve_stat_id :integer
18
18
  # created_at :datetime