enju_circulation 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/reserves_controller.rb +6 -0
  3. data/app/controllers/user_group_has_checkout_types_controller.rb +1 -1
  4. data/app/jobs/manifestation_checkout_stat_job.rb +1 -1
  5. data/app/jobs/manifestation_reserve_stat_job.rb +1 -1
  6. data/app/jobs/user_checkout_stat_job.rb +1 -1
  7. data/app/jobs/user_reserve_stat_job.rb +1 -1
  8. data/app/models/carrier_type_has_checkout_type.rb +1 -1
  9. data/app/models/checked_item.rb +2 -2
  10. data/app/models/checkin.rb +1 -1
  11. data/app/models/checkout.rb +1 -1
  12. data/app/models/checkout_stat_has_manifestation.rb +1 -1
  13. data/app/models/checkout_stat_has_user.rb +1 -1
  14. data/app/models/checkout_type.rb +1 -1
  15. data/app/models/circulation_status.rb +1 -1
  16. data/app/models/demand.rb +1 -1
  17. data/app/models/item_has_use_restriction.rb +1 -1
  18. data/app/models/lending_policy.rb +1 -1
  19. data/app/models/manifestation_checkout_stat.rb +1 -1
  20. data/app/models/manifestation_checkout_stat_transition.rb +1 -1
  21. data/app/models/manifestation_reserve_stat.rb +1 -1
  22. data/app/models/manifestation_reserve_stat_transition.rb +1 -1
  23. data/app/models/reserve.rb +1 -1
  24. data/app/models/reserve_stat_has_manifestation.rb +1 -1
  25. data/app/models/reserve_stat_has_user.rb +1 -1
  26. data/app/models/reserve_transition.rb +1 -1
  27. data/app/models/use_restriction.rb +1 -1
  28. data/app/models/user_checkout_stat.rb +1 -1
  29. data/app/models/user_checkout_stat_transition.rb +1 -1
  30. data/app/models/user_group_has_checkout_type.rb +1 -1
  31. data/app/models/user_reserve_stat.rb +1 -1
  32. data/app/models/user_reserve_stat_transition.rb +1 -1
  33. data/app/views/checkouts/_index_overdue.html.erb +4 -4
  34. data/app/views/checkouts/_list.html.erb +2 -4
  35. data/app/views/checkouts/edit.html.erb +9 -0
  36. data/app/views/reserves/_state_facet.html.erb +2 -2
  37. data/app/views/reserves/index.html.erb +10 -10
  38. data/app/views/reserves/index.txt.ruby +22 -0
  39. data/app/views/user_group_has_checkout_types/edit.html.erb +2 -2
  40. data/app/views/user_group_has_checkout_types/new.html.erb +2 -2
  41. data/app/views/user_group_has_checkout_types/show.html.erb +2 -2
  42. data/app/views/user_groups/_user_group_has_checkout_type_fields.html.erb +2 -2
  43. data/config/locales/translation_en.yml +1 -1
  44. data/config/locales/translation_ja.yml +1 -1
  45. data/db/migrate/20110627122938_add_number_of_day_to_notify_overdue_to_user_group.rb +2 -2
  46. data/lib/enju_circulation/version.rb +1 -1
  47. data/lib/generators/enju_circulation/setup/templates/db/fixtures/circulation_statuses.yml +1 -1
  48. data/spec/concerns/enju_accept_spec.rb +11 -11
  49. data/spec/controllers/items_controller_spec.rb +62 -0
  50. data/spec/dummy/app/assets/images/icons/book.png +0 -0
  51. data/spec/dummy/app/jobs/application_job.rb +7 -0
  52. data/spec/dummy/app/models/application_record.rb +3 -0
  53. data/spec/dummy/app/models/user.rb +2 -1
  54. data/spec/dummy/config/application.rb +1 -1
  55. data/spec/dummy/db/migrate/005_create_manifestations.rb +3 -3
  56. data/spec/dummy/db/migrate/20081025083323_create_countries.rb +5 -4
  57. data/spec/dummy/db/migrate/20081025083905_create_languages.rb +1 -0
  58. data/spec/dummy/db/migrate/20100606065209_create_user_has_roles.rb +2 -4
  59. data/spec/dummy/db/migrate/20120125152919_add_title_subseries_transcription_to_series_statement.rb +1 -0
  60. data/spec/dummy/db/migrate/20120129020544_add_budget_type_id_to_item.rb +1 -0
  61. data/spec/dummy/db/migrate/20120319120638_add_content_type_id_to_manifestation.rb +1 -0
  62. data/spec/dummy/db/migrate/20140122054321_create_profiles.rb +4 -5
  63. data/spec/dummy/db/migrate/20180107161311_add_constraints_to_most_recent_for_agent_import_file_transitions.rb +1 -1
  64. data/spec/dummy/db/migrate/20180107161331_add_constraints_to_most_recent_for_resource_import_file_transitions.rb +1 -1
  65. data/spec/dummy/db/migrate/20180107161347_add_constraints_to_most_recent_for_resource_export_file_transitions.rb +1 -1
  66. data/spec/dummy/db/migrate/20180107161410_add_constraints_to_most_recent_for_import_request_transitions.rb +1 -1
  67. data/spec/dummy/db/schema.rb +6 -4
  68. data/spec/dummy/private/system/carrier_types/attachments/000/000/001/original/book.png +0 -0
  69. data/spec/dummy/private/system/carrier_types/attachments/000/000/001/thumb/book.png +0 -0
  70. data/spec/dummy/private/system/resource_export_files/resource_exports/000/000/001/original/resource_export_file_20190804-29715-1ca6cab.txt +150 -0
  71. data/spec/dummy/private/system/resource_export_files/resource_exports/000/000/001/original/resource_export_file_20190804-30258-1menuu9.txt +150 -0
  72. data/spec/dummy/private/system/resource_export_files/resource_exports/000/000/001/original/resource_export_file_20190804-30590-jfx9wk.txt +150 -0
  73. data/spec/dummy/private/system/resource_export_files/resource_exports/000/000/001/original/resource_export_file_20190804-31207-1f5iuud.txt +148 -0
  74. data/spec/factories/accept.rb +1 -1
  75. data/spec/factories/item.rb +3 -3
  76. data/spec/factories/profile.rb +1 -1
  77. data/spec/fixtures/accepts.yml +9 -0
  78. data/spec/fixtures/carrier_types.yml +27 -24
  79. data/spec/fixtures/circulation_statuses.yml +1 -1
  80. data/spec/fixtures/items.yml +11 -0
  81. data/spec/helpers/items_helper_spec.rb +1 -1
  82. data/spec/models/item_spec.rb +47 -0
  83. data/spec/models/manifestation_spec.rb +38 -0
  84. data/spec/models/resource_export_file_spec.rb +42 -0
  85. data/spec/policies/manifestation_policy_spec.rb +16 -0
  86. data/spec/rails_helper.rb +1 -0
  87. data/spec/system/checkouts_spec.rb +33 -0
  88. data/spec/system/reserves_spec.rb +15 -0
  89. data/spec/views/checkouts/edit.html.erb_spec.rb +1 -1
  90. data/spec/views/items/index.html.erb_spec.rb +35 -0
  91. data/spec/views/manifestations/show.html.erb_spec.rb +24 -0
  92. data/spec/views/reserves/index.html.erb_spec.rb +1 -1
  93. metadata +412 -356
  94. data/app/views/reserves/index.txt.erb +0 -4
  95. data/spec/support/resque.rb +0 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b38f62123745a87848e27bea905ec42fc17e30df0fc0ba9853cf7fe98db6d79b
4
- data.tar.gz: f951bd48af2901ffca4a3a1499f0bbe88595498ceeecdd185909aa0580cdffd6
3
+ metadata.gz: 7b0b9972d6bbdc83978dfe89ade80938501efaf2b3ebb5276b8c8735bb72dfc1
4
+ data.tar.gz: '094bb7364db3cd6210ae9f3c6746ba6111d85e700c790ae442b186a63d6299ff'
5
5
  SHA512:
6
- metadata.gz: c0d8649b6101178444596fde67c8574651881d8794bbd0656461fcef65a0fdce66bb67354089842be21412c673c2b1cf98a9ec0d39607ef811f6be8836d23b4e
7
- data.tar.gz: f6345684a0fc171f5c78b1d41ff764a47fd4b02e97825c16afa5118eccc7e7498ff6b3b0822374203f60557e6c2c5a2315e77b33f6c5806429f736e0462dd1b7
6
+ metadata.gz: 55f809ad8fc660f27838d8fc0b39fc7a02ada4bca1a3a6b80a6f394dd38993d0918900733722692dac2537c0e15eb0275912979d795e8669212a9cbb6a7eea95
7
+ data.tar.gz: d2fd2702f0df03077ed417236d32c5b42c446c6c0c09545af9a61e9b9bb400aa111efd6b57d45db34b9a77757ddac7791f362b140bcb3f71cdca744b564692fc
@@ -296,4 +296,10 @@ class ReservesController < ApplicationController
296
296
  def prepare_options
297
297
  @libraries = Library.real.order(:position)
298
298
  end
299
+
300
+ def filtered_params
301
+ params.permit([:user_id, :reserved_from, :reserved_until, :query, :sort_by, :state])
302
+ end
303
+
304
+ helper_method :filtered_params
299
305
  end
@@ -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
@@ -1,4 +1,4 @@
1
- class ManifestationCheckoutStatJob < ActiveJob::Base
1
+ class ManifestationCheckoutStatJob < ApplicationJob
2
2
  queue_as :enju_leaf
3
3
 
4
4
  def perform(manifestation_checkout_stat)
@@ -1,4 +1,4 @@
1
- class ManifestationReserveStatJob < ActiveJob::Base
1
+ class ManifestationReserveStatJob < ApplicationJob
2
2
  queue_as :enju_leaf
3
3
 
4
4
  def perform(manifestation_reserve_stat)
@@ -1,4 +1,4 @@
1
- class UserCheckoutStatJob < ActiveJob::Base
1
+ class UserCheckoutStatJob < ApplicationJob
2
2
  queue_as :enju_leaf
3
3
 
4
4
  def perform(user_checkout_stat)
@@ -1,4 +1,4 @@
1
- class UserReserveStatJob < ActiveJob::Base
1
+ class UserReserveStatJob < ApplicationJob
2
2
  queue_as :enju_leaf
3
3
 
4
4
  def perform(user_reserve_stat)
@@ -1,4 +1,4 @@
1
- class CarrierTypeHasCheckoutType < ActiveRecord::Base
1
+ class CarrierTypeHasCheckoutType < ApplicationRecord
2
2
  scope :available_for_carrier_type, lambda {|carrier_type| includes(:carrier_type).where('carrier_types.name = ?', carrier_type.name)}
3
3
  scope :available_for_user_group, lambda {|user_group| includes(checkout_type: :user_groups).where('user_groups.name = ?', user_group.name)}
4
4
 
@@ -1,4 +1,4 @@
1
- class CheckedItem < ActiveRecord::Base
1
+ class CheckedItem < ApplicationRecord
2
2
  belongs_to :item
3
3
  belongs_to :basket
4
4
  belongs_to :librarian, class_name: 'User', optional: true
@@ -94,7 +94,7 @@ class CheckedItem < ActiveRecord::Base
94
94
  end
95
95
  # 返却期限日が閉館日の場合
96
96
  while item.shelf.library.closed?(due_date)
97
- if item_checkout_type.set_due_date_before_closing_day
97
+ if item_checkout_type.set_due_date_after_closing_day
98
98
  self.due_date = due_date.yesterday.end_of_day
99
99
  else
100
100
  self.due_date = due_date.tomorrow.end_of_day
@@ -1,4 +1,4 @@
1
- class Checkin < ActiveRecord::Base
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
4
  has_one :checkout
@@ -1,4 +1,4 @@
1
- class Checkout < ActiveRecord::Base
1
+ class Checkout < ApplicationRecord
2
2
  scope :not_returned, -> { where(checkin_id: nil) }
3
3
  scope :returned, -> { where('checkin_id IS NOT NULL') }
4
4
  scope :overdue, lambda {|date| where('checkin_id IS NULL AND due_date < ?', date)}
@@ -1,4 +1,4 @@
1
- class CheckoutStatHasManifestation < ActiveRecord::Base
1
+ class CheckoutStatHasManifestation < ApplicationRecord
2
2
  # attr_accessible :manifestation_checkout_stat_id, :manifestation_id,
3
3
  # as: :admin
4
4
  belongs_to :manifestation_checkout_stat
@@ -1,4 +1,4 @@
1
- class CheckoutStatHasUser < ActiveRecord::Base
1
+ class CheckoutStatHasUser < ApplicationRecord
2
2
  # attr_accessible :user_checkout_stat_id, :user_id,
3
3
  # as: :admin
4
4
  belongs_to :user_checkout_stat
@@ -1,4 +1,4 @@
1
- class CheckoutType < ActiveRecord::Base
1
+ class CheckoutType < ApplicationRecord
2
2
  include MasterModel
3
3
  scope :available_for_carrier_type, lambda {|carrier_type| includes(:carrier_types).where('carrier_types.name = ?', carrier_type.name).order('carrier_types.position')}
4
4
  scope :available_for_user_group, lambda {|user_group| includes(:user_groups).where('user_groups.name = ?', user_group.name).order('user_group.position')}
@@ -1,4 +1,4 @@
1
- class CirculationStatus < ActiveRecord::Base
1
+ 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
 
data/app/models/demand.rb CHANGED
@@ -1,4 +1,4 @@
1
- class Demand < ActiveRecord::Base
1
+ class Demand < ApplicationRecord
2
2
  belongs_to :user
3
3
  belongs_to :item
4
4
  belongs_to :message
@@ -1,4 +1,4 @@
1
- class ItemHasUseRestriction < ActiveRecord::Base
1
+ class ItemHasUseRestriction < ApplicationRecord
2
2
  belongs_to :item, validate: true
3
3
  belongs_to :use_restriction, validate: true
4
4
  accepts_nested_attributes_for :use_restriction
@@ -1,4 +1,4 @@
1
- class LendingPolicy < ActiveRecord::Base
1
+ class LendingPolicy < ApplicationRecord
2
2
  default_scope { order('lending_policies.position') }
3
3
  belongs_to :item
4
4
  belongs_to :user_group
@@ -1,4 +1,4 @@
1
- class ManifestationCheckoutStat < ActiveRecord::Base
1
+ class ManifestationCheckoutStat < ApplicationRecord
2
2
  include Statesman::Adapters::ActiveRecordQueries
3
3
  include CalculateStat
4
4
  default_scope {order('manifestation_checkout_stats.id DESC')}
@@ -1,4 +1,4 @@
1
- class ManifestationCheckoutStatTransition < ActiveRecord::Base
1
+ class ManifestationCheckoutStatTransition < ApplicationRecord
2
2
  include Statesman::Adapters::ActiveRecordTransition
3
3
 
4
4
 
@@ -1,4 +1,4 @@
1
- class ManifestationReserveStat < ActiveRecord::Base
1
+ class ManifestationReserveStat < ApplicationRecord
2
2
  include Statesman::Adapters::ActiveRecordQueries
3
3
  include CalculateStat
4
4
  default_scope {order('manifestation_reserve_stats.id DESC')}
@@ -1,4 +1,4 @@
1
- class ManifestationReserveStatTransition < ActiveRecord::Base
1
+ class ManifestationReserveStatTransition < ApplicationRecord
2
2
  include Statesman::Adapters::ActiveRecordTransition
3
3
 
4
4
 
@@ -1,4 +1,4 @@
1
- class Reserve < ActiveRecord::Base
1
+ 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) }
@@ -1,4 +1,4 @@
1
- class ReserveStatHasManifestation < ActiveRecord::Base
1
+ class ReserveStatHasManifestation < ApplicationRecord
2
2
  belongs_to :manifestation_reserve_stat
3
3
  belongs_to :manifestation
4
4
 
@@ -1,4 +1,4 @@
1
- class ReserveStatHasUser < ActiveRecord::Base
1
+ class ReserveStatHasUser < ApplicationRecord
2
2
  # attr_accessible
3
3
  # attr_accessible :user_reserve_stat_id, :user_id,
4
4
  # as: :admin
@@ -1,4 +1,4 @@
1
- class ReserveTransition < ActiveRecord::Base
1
+ class ReserveTransition < ApplicationRecord
2
2
  include Statesman::Adapters::ActiveRecordTransition
3
3
 
4
4
 
@@ -1,4 +1,4 @@
1
- class UseRestriction < ActiveRecord::Base
1
+ class UseRestriction < 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
 
@@ -1,4 +1,4 @@
1
- class UserCheckoutStat < ActiveRecord::Base
1
+ class UserCheckoutStat < ApplicationRecord
2
2
  include Statesman::Adapters::ActiveRecordQueries
3
3
  include CalculateStat
4
4
  default_scope {order('user_checkout_stats.id DESC')}
@@ -1,4 +1,4 @@
1
- class UserCheckoutStatTransition < ActiveRecord::Base
1
+ class UserCheckoutStatTransition < ApplicationRecord
2
2
  include Statesman::Adapters::ActiveRecordTransition
3
3
 
4
4
 
@@ -1,4 +1,4 @@
1
- class UserGroupHasCheckoutType < ActiveRecord::Base
1
+ class UserGroupHasCheckoutType < ApplicationRecord
2
2
  scope :available_for_item, lambda{|item| where(checkout_type_id: item.checkout_type.id)}
3
3
  scope :available_for_carrier_type, lambda{|carrier_type| includes(checkout_type: :carrier_types).where('carrier_types.id' => carrier_type.id)}
4
4
 
@@ -1,4 +1,4 @@
1
- class UserReserveStat < ActiveRecord::Base
1
+ class UserReserveStat < ApplicationRecord
2
2
  include Statesman::Adapters::ActiveRecordQueries
3
3
  include CalculateStat
4
4
  default_scope {order('user_reserve_stats.id DESC')}
@@ -1,4 +1,4 @@
1
- class UserReserveStatTransition < ActiveRecord::Base
1
+ class UserReserveStatTransition < ApplicationRecord
2
2
  include Statesman::Adapters::ActiveRecordTransition
3
3
 
4
4
 
@@ -27,12 +27,12 @@
27
27
  <h4><%= t('page.other_format') %></h4>
28
28
  <ul>
29
29
  <li>
30
- <%= link_to 'RSS', checkouts_path(format: :rss, days_overdue: 1) -%>
31
- <%= link_to image_tag('icons/feed.png', size: '16x16', class: 'enju_icon', alt: 'RSS'), checkouts_path(format: :rss, days_overdue: 1) -%>
30
+ <%= link_to 'RSS', url_for(filtered_params.merge(format: :rss, days_overdue: params[:days_overdue])) -%>
31
+ <%= link_to image_tag('icons/feed.png', size: '16x16', class: 'enju_icon', alt: 'RSS'), url_for(filtered_params.merge(format: :rss, days_overdue: params[:days_overdue])) -%>
32
32
  </li>
33
33
  <li>
34
- <%= link_to 'TSV', checkouts_path(format: :txt, days_overdue: 1, locale: @locale.to_s) -%>
35
- <%= link_to image_tag('icons/page_white_excel.png', size: '16x16', class: 'enju_icon', alt: 'TSV'), checkouts_path(format: :txt, days_overdue: 1, locale: @locale.to_s) -%>
34
+ <%= link_to 'TSV', url_for(filtered_params.merge(format: :txt, days_overdue: params[:days_overdue], locale: @locale.to_s)) -%>
35
+ <%= link_to image_tag('icons/page_white_excel.png', size: '16x16', class: 'enju_icon', alt: 'TSV'), url_for(filtered_params.merge(format: :txt, days_overdue: params[:days_overdue], locale: @locale.to_s)) -%>
36
36
  </li>
37
37
  </ul>
38
38
  </div>
@@ -3,7 +3,6 @@
3
3
  <th><%= t('activerecord.models.user') %></th>
4
4
  <th class="checked_item_title"><%= t('page.title') %></th>
5
5
  <th><%= t('activerecord.attributes.checkout.due_date') %></th>
6
- <th></th>
7
6
  </tr>
8
7
 
9
8
  <%- checkouts.each_with_index do |checkout, i| %>
@@ -28,12 +27,11 @@
28
27
  </td>
29
28
  <td>
30
29
  <%= l(checkout.due_date, format: :only_date) -%>
31
- <br />
32
30
  <% if checkout.checkin %>
31
+ <br />
33
32
  <strong><%= t('checkout.returned') %></strong>
34
33
  <% end %>
35
- </td>
36
- <td>
34
+ <br />
37
35
  <%- if policy(checkout).update? -%>
38
36
  <% unless checkout.checkin %>
39
37
  <%= link_to t('checkout.extend'), edit_checkout_path(checkout) -%>
@@ -4,6 +4,15 @@
4
4
 
5
5
  <%= render 'manifestations/title', manifestation: @checkout.item.manifestation if @checkout.item -%>
6
6
 
7
+ <h3><%= t('item.current_checkout') %></h3>
8
+
9
+ <ul>
10
+ <li><%= t('activerecord.attributes.user.username') %>:
11
+ <%= @checkout.user.username %></li>
12
+ <li><%= t('activerecord.attributes.profile.user_number') %>:
13
+ <%= @checkout.user.profile.user_number %></li>
14
+ </ul>
15
+
7
16
  <h3><%= t('checkout.renewal') -%></h3>
8
17
  <%- if @checkout.renewable? -%>
9
18
  <%= form_for(@checkout) do |f| -%>
@@ -4,12 +4,12 @@
4
4
  <% @state_facet.each do |state| %>
5
5
  <li>
6
6
  <% if state.value == params[:state].to_s.downcase %><strong><% end %>
7
- <%= link_to "#{i18n_state(state.value)} (#{state.count})", url_for(params.permit.merge(state: state.value, page: nil, view: nil, only_path: true)) %>
7
+ <%= link_to "#{i18n_state(state.value)} (#{state.count})", url_for(filtered_params.merge(state: state.value, page: nil, view: nil, only_path: true)) %>
8
8
  <% if state.value == params[:state].to_s.downcase %></strong><% end %>
9
9
  </li>
10
10
  <% end %>
11
11
  <%- if params[:state] -%>
12
- <li><%= link_to t('page.remove_this_facet'), url_for(params.permit.merge(state: nil, page: nil, view: nil, only_path: true)) -%></li>
12
+ <li><%= link_to t('page.remove_this_facet'), url_for(filtered_params.merge(state: nil, page: nil, view: nil, only_path: true)) -%></li>
13
13
  <%- end -%>
14
14
  </ul>
15
15
  <%- end -%>
@@ -21,12 +21,12 @@
21
21
  <%- if @sort_by == :created_at -%>
22
22
  <strong><%= t('activerecord.attributes.reserve.created_at') -%></strong>
23
23
  <%- else -%>
24
- <%= link_to t('activerecord.attributes.reserve.created_at'), url_for(params.permit.merge(sort_by: nil, only_path: true)) -%>
24
+ <%= link_to t('activerecord.attributes.reserve.created_at'), url_for(filtered_params.merge(sort_by: nil, only_path: true)) -%>
25
25
  <% end %>
26
26
  <%- if @sort_by == :title -%>
27
27
  <strong><%= t('page.title') -%></strong>
28
28
  <%- else -%>
29
- <%= link_to t('page.title'), url_for(params.permit.merge(sort_by: 'title', only_path: true)) -%>
29
+ <%= link_to t('page.title'), url_for(filtered_params.merge(sort_by: 'title', only_path: true)) -%>
30
30
  <%- end -%>
31
31
  </p>
32
32
 
@@ -103,15 +103,15 @@
103
103
 
104
104
  <p>
105
105
  <%- if @user -%>
106
- <%= link_to image_tag('icons/feed.png', size: '16x16', class: 'enju_icon', alt: t('page.feed')), reserves_path(user_id: @user.username, format: :rss) -%>
107
- (<%= link_to 'RSS', reserves_path(user_id: @user.username, format: :rss) -%>)
108
- <%= link_to image_tag('icons/page_white_excel.png', size: '16x16', class: 'enju_icon', alt: 'TSV'), reserves_path(user_id: @user.username, format: :txt, locale: @locale.to_s) -%>
109
- (<%= link_to 'TSV', reserves_path(user_id: @user.username, format: :txt, locale: @locale.to_s) -%>)
106
+ <%= link_to image_tag('icons/feed.png', size: '16x16', class: 'enju_icon', alt: t('page.feed')), url_for(filtered_params.merge(user_id: @user.username, format: :rss)) -%>
107
+ (<%= link_to 'RSS', url_for(filtered_params.merge(user_id: @user.username, format: :rss)) -%>)
108
+ <%= link_to image_tag('icons/page_white_excel.png', size: '16x16', class: 'enju_icon', alt: 'TSV'), url_for(filtered_params.merge(user_id: @user.username, format: :txt, locale: @locale.to_s)) -%>
109
+ (<%= link_to 'TSV', url_for(filtered_params.merge(user_id: @user.username, format: :txt, locale: @locale.to_s)) -%>)
110
110
  <%- else -%>
111
- <%= link_to image_tag('icons/feed.png', size: '16x16', class: 'enju_icon', alt: t('page.feed')), reserves_path(format: :rss) -%>
112
- (<%= link_to 'RSS', reserves_path(format: :rss) -%>)
113
- <%= link_to image_tag('icons/page_white_excel.png', size: '16x16', class: 'enju_icon', alt: 'TSV'), reserves_path(format: :txt, locale: @locale.to_s) -%>
114
- (<%= link_to 'TSV', reserves_path(format: :txt, locale: @locale.to_s) -%>)
111
+ <%= link_to image_tag('icons/feed.png', size: '16x16', class: 'enju_icon', alt: t('page.feed')), url_for(filtered_params.merge(format: :rss)) -%>
112
+ (<%= link_to 'RSS', url_for(filtered_params.merge(format: :rss)) -%>)
113
+ <%= link_to image_tag('icons/page_white_excel.png', size: '16x16', class: 'enju_icon', alt: 'TSV'), url_for(filtered_params.merge(format: :txt, locale: @locale.to_s)) -%>
114
+ (<%= link_to 'TSV', url_for(filtered_params.merge(format: :txt, locale: @locale.to_s)) -%>)
115
115
  <%- end -%>
116
116
  </p>
117
117
  </div>
@@ -0,0 +1,22 @@
1
+ CSV.generate(col_sep: "\t", row_sep: "\r\n") do |csv|
2
+ csv << %w(id state maniestation_id title creator publisher pub_date isbn item_identifier call_number user_number username library created_at expired_at)
3
+ @reserves.each do |reserve|
4
+ csv << [
5
+ reserve.id,
6
+ reserve.current_state,
7
+ reserve.manifestation_id,
8
+ reserve.manifestation.original_title,
9
+ reserve.manifestation.creators.pluck(:full_name).join('//'),
10
+ reserve.manifestation.publishers.pluck(:full_name).join('//'),
11
+ reserve.manifestation.pub_date,
12
+ reserve.manifestation.identifier_contents(:isbn).join('//'),
13
+ reserve.item.try(:item_identifier),
14
+ reserve.item.try(:call_number),
15
+ reserve.user.profile.try(:user_number),
16
+ reserve.user.try(:username),
17
+ reserve.pickup_location.try(:name),
18
+ reserve.created_at,
19
+ reserve.updated_at
20
+ ]
21
+ end
22
+ end
@@ -34,8 +34,8 @@
34
34
  </div>
35
35
 
36
36
  <div class="field">
37
- <%= f.label :set_due_date_before_closing_day -%>
38
- <%= f.check_box :set_due_date_before_closing_day -%>
37
+ <%= f.label :set_due_date_after_closing_day -%>
38
+ <%= f.check_box :set_due_date_after_closing_day -%>
39
39
  </div>
40
40
 
41
41
  <div class="field">
@@ -34,8 +34,8 @@
34
34
  </div>
35
35
 
36
36
  <div class="field">
37
- <%= f.label :set_due_date_before_closing_day -%>
38
- <%= f.check_box :set_due_date_before_closing_day -%>
37
+ <%= f.label :set_due_date_after_closing_day -%>
38
+ <%= f.check_box :set_due_date_after_closing_day -%>
39
39
  </div>
40
40
 
41
41
  <div class="field">
@@ -39,8 +39,8 @@
39
39
  </p>
40
40
 
41
41
  <p>
42
- <strong><%= t('activerecord.attributes.user_group_has_checkout_type.set_due_date_before_closing_day') -%>:</strong>
43
- <%= localized_boolean(@user_group_has_checkout_type.set_due_date_before_closing_day) -%>
42
+ <strong><%= t('activerecord.attributes.user_group_has_checkout_type.set_due_date_after_closing_day') -%>:</strong>
43
+ <%= localized_boolean(@user_group_has_checkout_type.set_due_date_after_closing_day) -%>
44
44
  </p>
45
45
 
46
46
  <p>
@@ -8,7 +8,7 @@
8
8
  <br />
9
9
  <%= f.label :reservation_limit -%>
10
10
  <%= f.text_field :reservation_limit, class: 'resource_integer' %>
11
- <%= f.label :set_due_date_before_closing_day -%>
12
- <%= f.check_box :set_due_date_before_closing_day %>
11
+ <%= f.label :set_due_date_after_closing_day -%>
12
+ <%= f.check_box :set_due_date_after_closing_day %>
13
13
  <%= link_to_remove_association t('page.remove'), f, data: {confirm: t('page.are_you_sure')} %>
14
14
  </div>
@@ -72,7 +72,7 @@ en:
72
72
  checkout_renewal_limit: Checkout renewal limit
73
73
  reservation_limit: Reservation limit
74
74
  reservation_expired_period: Reservation expired period
75
- set_due_date_before_closing_day: Set due date before the closing day
75
+ set_due_date_after_closing_day: Set due date before the closing day
76
76
  fixed_due_date: Fixed due date
77
77
  note: Note
78
78
  position: Position
@@ -70,7 +70,7 @@ ja:
70
70
  checkout_renewal_limit: 貸出更新回数の上限
71
71
  reservation_limit: 予約数の上限
72
72
  reservation_expired_period: 予約の期限切れまでの期間
73
- set_due_date_before_closing_day: 返却日を閉館日の前日にする
73
+ set_due_date_after_closing_day: 返却日を閉館日の翌日にする
74
74
  fixed_due_date: 固定貸出期限
75
75
  note: 注記
76
76
  position: 位置
@@ -1,7 +1,7 @@
1
1
  class AddNumberOfDayToNotifyOverdueToUserGroup < ActiveRecord::Migration[4.2]
2
2
  def self.up
3
- add_column :user_groups, :number_of_day_to_notify_overdue, :integer, default: 1, null: false
4
- add_column :user_groups, :number_of_day_to_notify_due_date, :integer, default: 7, null: false
3
+ add_column :user_groups, :number_of_day_to_notify_overdue, :integer, default: 7, null: false
4
+ add_column :user_groups, :number_of_day_to_notify_due_date, :integer, default: 3, null: false
5
5
  add_column :user_groups, :number_of_time_to_notify_overdue, :integer, default: 3, null: false
6
6
  end
7
7
 
@@ -1,3 +1,3 @@
1
1
  module EnjuCirculation
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
@@ -10,7 +10,7 @@ circulation_status_00001:
10
10
  circulation_status_00002:
11
11
  name: Available On Shelf
12
12
  display_name: |-
13
- en: Available on Shelf
13
+ en: Available On Shelf
14
14
  ja: 在架(利用可能)
15
15
  id: 2
16
16
  note: ""
@@ -1,29 +1,29 @@
1
1
  require 'rails_helper'
2
2
 
3
- class MyAccept < Accept
4
- include EnjuCirculation::EnjuAccept
5
- end
6
-
7
3
  describe EnjuCirculation::EnjuAccept do
8
4
  fixtures :all
9
5
 
10
6
  it "should successfully accept" do
11
- accept = MyAccept.new(FactoryBot.attributes_for(:accept))
12
- expect(accept.item).to be_truthy
13
- expect(accept.item.circulation_status.name).to eq "In Process"
7
+ accept = Accept.new(FactoryBot.attributes_for(:accept))
8
+ accept.item = FactoryBot.create(:item)
14
9
  accept.save!
15
10
  expect(accept.item.circulation_status.name).to eq "Available On Shelf"
16
11
  expect(accept.item.use_restriction.name).to eq "Limited Circulation, Normal Loan Period"
17
12
  end
18
13
 
19
14
  it "should reflect to items list", solr: true do
20
- FactoryBot.create(:item)
21
- FactoryBot.create(:item)
22
- FactoryBot.create(:item)
15
+ Item.reindex
16
+
17
+ 3.times do
18
+ FactoryBot.create(:item, circulation_status: CirculationStatus.find_by(name: 'In Process'))
19
+ end
20
+
23
21
  result = Item.search.build { facet :circulation_status }.execute
24
22
  inprocess_count = result.facet(:circulation_status).rows.find{|e| e.value == "In Process" }.count
25
23
  onshelf_count = result.facet(:circulation_status).rows.find{|e| e.value == "Available On Shelf" }.try(:count) || 0
26
- accept = MyAccept.new(FactoryBot.attributes_for(:accept))
24
+
25
+ accept = Accept.new(FactoryBot.attributes_for(:accept))
26
+ accept.item = FactoryBot.create(:item)
27
27
  accept.save!
28
28
  result = Item.search.build { facet :circulation_status }.execute
29
29
  expect(result.facet(:circulation_status).rows.find{|e| e.value == "In Process" }.count).to eq inprocess_count
@@ -0,0 +1,62 @@
1
+ require 'rails_helper'
2
+
3
+ describe ItemsController do
4
+ fixtures :all
5
+
6
+ describe 'POST create' do
7
+ before(:each) do
8
+ manifestation = FactoryBot.create(:manifestation)
9
+ @attrs = FactoryBot.attributes_for(:item, manifestation_id: manifestation.id)
10
+ @invalid_attrs = { item_identifier: '無効なID', manifestation_id: manifestation.id }
11
+ end
12
+
13
+ describe 'When logged in as Administrator' do
14
+ login_fixture_admin
15
+
16
+ describe 'with valid params' do
17
+ it 'should create reserved item' do
18
+ post :create, params: { item: { circulation_status_id: 1, manifestation_id: 2 } }
19
+ expect(assigns(:item)).to be_valid
20
+
21
+ expect(response).to redirect_to item_url(assigns(:item))
22
+ flash[:message].should eq I18n.t('item.this_item_is_reserved')
23
+ assigns(:item).manifestation.should eq Manifestation.find(2)
24
+ assigns(:item).should be_retained
25
+ end
26
+
27
+ it "should create another item with already retained" do
28
+ reserve = FactoryBot.create(:reserve)
29
+ reserve.transition_to!(:requested)
30
+ post :create, params: { item: FactoryBot.attributes_for(:item, manifestation_id: reserve.manifestation.id) }
31
+ expect(assigns(:item)).to be_valid
32
+ expect(response).to redirect_to item_url(assigns(:item))
33
+ post :create, params: { item: FactoryBot.attributes_for(:item, manifestation_id: reserve.manifestation.id) }
34
+ expect(assigns(:item)).to be_valid
35
+ expect(response).to redirect_to item_url(assigns(:item))
36
+ end
37
+
38
+ it 'should create a lending policy' do
39
+ old_lending_policy_count = LendingPolicy.count
40
+ post :create, params: { item: @attrs }
41
+ LendingPolicy.count.should eq old_lending_policy_count
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ describe 'DELETE destroy' do
48
+ describe 'When logged in as Administrator' do
49
+ login_fixture_admin
50
+
51
+ it 'should not destroy item if not checked in' do
52
+ delete :destroy, params: { id: 1 }
53
+ expect(response).to be_forbidden
54
+ end
55
+
56
+ it 'should not destroy a removed item' do
57
+ delete :destroy, params: { id: 26 }
58
+ expect(response).to be_forbidden
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,7 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ # Automatically retry jobs that encountered a deadlock
3
+ # retry_on ActiveRecord::Deadlocked
4
+
5
+ # Most jobs are safe to ignore if the underlying records are no longer available
6
+ # discard_on ActiveJob::DeserializationError
7
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -1,4 +1,4 @@
1
- class User < ActiveRecord::Base
1
+ class User < ApplicationRecord
2
2
  # Include default devise modules. Others available are:
3
3
  # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
4
4
  devise :database_authenticatable, #:registerable,
@@ -9,6 +9,7 @@ class User < ActiveRecord::Base
9
9
  include EnjuCirculation::EnjuUser
10
10
  end
11
11
 
12
+ Accept.include(EnjuCirculation::EnjuAccept)
12
13
  Basket.include(EnjuCirculation::EnjuBasket)
13
14
  Manifestation.include(EnjuCirculation::EnjuManifestation)
14
15
  Item.include(EnjuCirculation::EnjuItem)