enju_circulation 0.1.2 → 0.2.0.beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +3 -3
  3. data/app/controllers/carrier_type_has_checkout_types_controller.rb +14 -4
  4. data/app/controllers/checked_items_controller.rb +13 -2
  5. data/app/controllers/checkins_controller.rb +13 -3
  6. data/app/controllers/checkout_types_controller.rb +12 -2
  7. data/app/controllers/checkouts_controller.rb +26 -25
  8. data/app/controllers/circulation_statuses_controller.rb +11 -1
  9. data/app/controllers/concerns/enju_circulation/controller.rb +12 -0
  10. data/app/controllers/demands_controller.rb +12 -2
  11. data/app/controllers/item_has_use_restrictions_controller.rb +13 -2
  12. data/app/controllers/lending_policies_controller.rb +18 -4
  13. data/app/controllers/manifestation_checkout_stats_controller.rb +14 -6
  14. data/app/controllers/manifestation_reserve_stats_controller.rb +15 -4
  15. data/app/controllers/reserves_controller.rb +17 -9
  16. data/app/controllers/use_restrictions_controller.rb +11 -1
  17. data/app/controllers/user_checkout_stats_controller.rb +14 -4
  18. data/app/controllers/user_group_has_checkout_types_controller.rb +12 -2
  19. data/app/controllers/user_reserve_stats_controller.rb +14 -4
  20. data/app/helpers/items_helper.rb +2 -2
  21. data/app/jobs/manifestation_checkout_stat_job.rb +7 -0
  22. data/app/jobs/manifestation_reserve_stat_job.rb +7 -0
  23. data/app/jobs/user_checkout_stat_job.rb +7 -0
  24. data/app/jobs/user_reserve_stat_job.rb +7 -0
  25. data/app/models/checked_item.rb +1 -1
  26. data/app/models/concerns/enju_circulation/enju_accept.rb +16 -0
  27. data/app/models/concerns/enju_circulation/enju_basket.rb +30 -0
  28. data/app/models/concerns/enju_circulation/enju_carrier_type.rb +11 -0
  29. data/app/models/concerns/enju_circulation/enju_item.rb +157 -0
  30. data/app/models/concerns/enju_circulation/enju_manifestation.rb +77 -0
  31. data/app/models/concerns/enju_circulation/enju_profile.rb +13 -0
  32. data/app/models/concerns/enju_circulation/enju_user.rb +50 -0
  33. data/app/models/concerns/enju_circulation/enju_user_group.rb +17 -0
  34. data/app/models/concerns/enju_circulation/enju_withdraw.rb +16 -0
  35. data/app/models/manifestation_checkout_stat_state_machine.rb +1 -1
  36. data/app/models/reserve.rb +7 -2
  37. data/app/policies/carrier_type_has_checkout_type_policy.rb +21 -0
  38. data/app/policies/checked_item_policy.rb +21 -0
  39. data/app/policies/checkin_policy.rb +21 -0
  40. data/app/policies/checkout_policy.rb +39 -0
  41. data/app/policies/checkout_type_policy.rb +23 -0
  42. data/app/policies/circulation_status_policy.rb +23 -0
  43. data/app/policies/demand_policy.rb +21 -0
  44. data/app/policies/item_has_use_restriction_policy.rb +21 -0
  45. data/app/policies/item_policy.rb +27 -0
  46. data/app/policies/lending_policy_policy.rb +21 -0
  47. data/app/policies/manifestation_checkout_stat_policy.rb +21 -0
  48. data/app/policies/manifestation_reserve_stat_policy.rb +21 -0
  49. data/app/policies/reserve_policy.rb +37 -0
  50. data/app/policies/use_restriction_policy.rb +23 -0
  51. data/app/policies/user_checkout_stat_policy.rb +21 -0
  52. data/app/policies/user_group_has_checkout_type_policy.rb +21 -0
  53. data/app/policies/user_reserve_stat_policy.rb +21 -0
  54. data/app/views/carrier_type_has_checkout_types/index.html.erb +3 -3
  55. data/app/views/carrier_type_has_checkout_types/show.html.erb +1 -1
  56. data/app/views/carrier_types/_carrier_type_has_checkout_type_fields.html.erb +5 -0
  57. data/app/views/carrier_types/_checkout_form.html.erb +2 -4
  58. data/app/views/checkout_types/index.html.erb +4 -4
  59. data/app/views/checkout_types/show.html.erb +2 -2
  60. data/app/views/checkouts/_index.html.erb +1 -1
  61. data/app/views/checkouts/_index_overdue.html.erb +4 -5
  62. data/app/views/checkouts/_index_user.html.erb +5 -5
  63. data/app/views/checkouts/_list.html.erb +2 -2
  64. data/app/views/checkouts/_reserved_facet.html.erb +2 -2
  65. data/app/views/checkouts/edit.html.erb +1 -1
  66. data/app/views/checkouts/index.html.erb +2 -2
  67. data/app/views/checkouts/index.rss.builder +2 -2
  68. data/app/views/checkouts/index.txt.erb +1 -1
  69. data/app/views/checkouts/show.html.erb +10 -6
  70. data/app/views/circulation_statuses/index.html.erb +4 -4
  71. data/app/views/circulation_statuses/show.html.erb +1 -1
  72. data/app/views/reserves/_state_facet.html.erb +2 -2
  73. data/app/views/reserves/index.html.erb +6 -4
  74. data/app/views/reserves/show.html.erb +1 -1
  75. data/app/views/use_restrictions/index.html.erb +4 -4
  76. data/app/views/use_restrictions/show.html.erb +1 -1
  77. data/app/views/user_group_has_checkout_types/index.html.erb +3 -3
  78. data/app/views/user_group_has_checkout_types/show.html.erb +1 -1
  79. data/app/views/user_groups/_checkout_form.html.erb +2 -16
  80. data/app/views/user_groups/_user_group_has_checkout_type_fields.html.erb +14 -0
  81. data/db/migrate/20160703184619_add_most_recent_to_reserve_transitions.rb +9 -0
  82. data/db/migrate/20160703184650_add_most_recent_to_manifestation_checkout_stat_transitions.rb +9 -0
  83. data/db/migrate/20160703184723_add_most_recent_to_manifestation_reserve_stat_transitions.rb +9 -0
  84. data/db/migrate/20160703184747_add_most_recent_to_user_checkout_stat_transitions.rb +9 -0
  85. data/db/migrate/20160703184805_add_most_recent_to_user_reserve_stat_transitions.rb +9 -0
  86. data/db/migrate/20160703190209_add_foreign_key_on_manifestation_id_to_reserve.rb +5 -0
  87. data/lib/enju_circulation/version.rb +1 -1
  88. data/lib/enju_circulation.rb +0 -20
  89. data/lib/generators/enju_circulation/setup/setup_generator.rb +16 -4
  90. data/lib/tasks/enju_circulation_tasks.rake +1 -1
  91. data/spec/controllers/carrier_type_has_checkout_types_controller_spec.rb +13 -13
  92. data/spec/controllers/checked_items_controller_spec.rb +6 -6
  93. data/spec/controllers/checkins_controller_spec.rb +6 -6
  94. data/spec/controllers/checkout_types_controller_spec.rb +11 -11
  95. data/spec/controllers/checkouts_controller_spec.rb +72 -71
  96. data/spec/controllers/circulation_statuses_controller_spec.rb +12 -12
  97. data/spec/controllers/item_has_use_restrictions_controller_spec.rb +11 -11
  98. data/spec/controllers/lending_policies_controller_spec.rb +14 -14
  99. data/spec/controllers/manifestation_checkout_stats_controller_spec.rb +6 -6
  100. data/spec/controllers/manifestation_reserve_stats_controller_spec.rb +6 -6
  101. data/spec/controllers/reserves_controller_spec.rb +5 -5
  102. data/spec/controllers/use_restrictions_controller_spec.rb +14 -14
  103. data/spec/controllers/user_checkout_stats_controller_spec.rb +8 -8
  104. data/spec/controllers/user_group_has_checkout_types_controller_spec.rb +11 -11
  105. data/spec/controllers/user_reserve_stats_controller_spec.rb +8 -8
  106. data/spec/dummy/app/assets/javascripts/application.js +1 -0
  107. data/spec/dummy/app/controllers/application_controller.rb +8 -4
  108. data/spec/dummy/app/models/user.rb +3 -5
  109. data/spec/dummy/config/application.rb +6 -37
  110. data/spec/dummy/config/environments/development.rb +22 -18
  111. data/spec/dummy/config/environments/production.rb +46 -34
  112. data/spec/dummy/config/environments/test.rb +19 -14
  113. data/spec/dummy/config/initializers/enju_leaf.rb +5 -0
  114. data/spec/dummy/db/migrate/20150924115059_create_withdraws.rb +13 -0
  115. data/spec/dummy/db/migrate/20151213070943_add_translation_table_to_library_group.rb +13 -0
  116. data/spec/dummy/db/migrate/20151213072705_add_footer_banner_to_library_group.rb +9 -0
  117. data/spec/dummy/db/schema.rb +30 -2
  118. data/spec/fixtures/profiles.yml +1 -1
  119. data/spec/models/manifestation_checkout_stat_spec.rb +3 -4
  120. data/spec/models/manifestation_reserve_stat_spec.rb +1 -1
  121. data/spec/models/user_checkout_stat_spec.rb +1 -1
  122. data/spec/models/user_reserve_stat_spec.rb +1 -1
  123. data/spec/support/devise.rb +2 -2
  124. data/spec/views/checkout_types/index.html.erb_spec.rb +1 -0
  125. data/spec/views/checkout_types/show.html.erb_spec.rb +1 -0
  126. data/spec/views/checkouts/index.html.erb_spec.rb +1 -3
  127. data/spec/views/checkouts/show.html.erb_spec.rb +5 -4
  128. data/spec/views/profiles/show.html.erb_spec.rb +2 -1
  129. data/spec/views/reserves/index.html.erb_spec.rb +3 -0
  130. data/spec/views/use_restrictions/index.html.erb_spec.rb +1 -0
  131. data/spec/views/use_restrictions/show.html.erb_spec.rb +1 -0
  132. metadata +147 -38
  133. data/app/models/enju_circulation/ability.rb +0 -114
  134. data/app/views/circulation_statuses/show.mobile.erb +0 -24
  135. data/app/workers/manifestation_checkout_stat_queue.rb +0 -7
  136. data/app/workers/manifestation_reserve_stat_queue.rb +0 -7
  137. data/app/workers/user_checkout_stat_queue.rb +0 -7
  138. data/app/workers/user_reserve_stat_queue.rb +0 -7
  139. data/lib/enju_circulation/accept.rb +0 -23
  140. data/lib/enju_circulation/basket.rb +0 -37
  141. data/lib/enju_circulation/carrier_type.rb +0 -15
  142. data/lib/enju_circulation/controller.rb +0 -21
  143. data/lib/enju_circulation/item.rb +0 -166
  144. data/lib/enju_circulation/manifestation.rb +0 -84
  145. data/lib/enju_circulation/profile.rb +0 -23
  146. data/lib/enju_circulation/user.rb +0 -61
  147. data/lib/enju_circulation/user_group.rb +0 -21
  148. data/lib/enju_circulation/withdraw.rb +0 -23
  149. data/spec/dummy/app/models/ability.rb +0 -111
  150. data/spec/dummy/app/models/local_agent.rb +0 -13
  151. data/spec/dummy/config/application.yml +0 -42
@@ -1,37 +0,0 @@
1
- module EnjuCirculation
2
- module EnjuBasket
3
- def self.included(base)
4
- base.extend ClassMethods
5
- end
6
-
7
- module ClassMethods
8
- def enju_circulation_basket_model
9
- include InstanceMethods
10
- has_many :checked_items, dependent: :destroy
11
- has_many :items, through: :checked_items
12
- has_many :checkouts
13
- has_many :checkins
14
- end
15
- end
16
-
17
- module InstanceMethods
18
- def basket_checkout(librarian)
19
- return nil if checked_items.size == 0
20
- Item.transaction do
21
- checked_items.each do |checked_item|
22
- checkout = user.checkouts.new
23
- checkout.librarian = librarian
24
- checkout.item = checked_item.item
25
- checkout.basket = self
26
- checkout.library = librarian.profile.library
27
- checkout.shelf = checked_item.item.shelf
28
- checkout.due_date = checked_item.due_date
29
- checked_item.item.checkout!(user)
30
- checkout.save!
31
- end
32
- CheckedItem.destroy_all(basket_id: id)
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,15 +0,0 @@
1
- module EnjuCirculation
2
- module EnjuCarrierType
3
- def self.included(base)
4
- base.extend ClassMethods
5
- end
6
-
7
- module ClassMethods
8
- def enju_circulation_carrier_type_model
9
- has_many :carrier_type_has_checkout_types, dependent: :destroy
10
- has_many :checkout_types, through: :carrier_type_has_checkout_types
11
- accepts_nested_attributes_for :carrier_type_has_checkout_types, allow_destroy: true, reject_if: :all_blank
12
- end
13
- end
14
- end
15
- end
@@ -1,21 +0,0 @@
1
- module EnjuCirculation
2
- module Controller
3
- def self.included(base)
4
- base.extend(ClassMethods)
5
- end
6
-
7
- module ClassMethods
8
- def enju_circulation
9
- include InstanceMethods
10
- end
11
- end
12
-
13
- module InstanceMethods
14
- private
15
-
16
- def get_checkout_type
17
- @checkout_type = CheckoutType.find(params[:checkout_type_id]) if params[:checkout_type_id]
18
- end
19
- end
20
- end
21
- end
@@ -1,166 +0,0 @@
1
- module EnjuCirculation
2
- module EnjuItem
3
- def self.included(base)
4
- base.extend ClassMethods
5
- end
6
-
7
- module ClassMethods
8
- FOR_CHECKOUT_CIRCULATION_STATUS = [
9
- 'Available On Shelf',
10
- 'On Loan',
11
- 'Waiting To Be Reshelved'
12
- ]
13
- FOR_CHECKOUT_USE_RESTRICTION = [
14
- 'Available For Supply Without Return',
15
- 'Limited Circulation, Long Loan Period',
16
- 'Limited Circulation, Short Loan Period',
17
- 'No Reproduction',
18
- 'Overnight Only',
19
- 'Renewals Not Permitted',
20
- 'Supervision Required',
21
- 'Term Loan',
22
- 'User Signature Required',
23
- 'Limited Circulation, Normal Loan Period'
24
- ]
25
-
26
- def enju_circulation_item_model
27
- include InstanceMethods
28
- has_many :reserves, :foreign_key => :manifestation_id
29
-
30
- scope :for_checkout, ->(identifier_conditions = 'item_identifier IS NOT NULL') {
31
- includes(:circulation_status, :use_restriction).where(
32
- 'circulation_statuses.name' => FOR_CHECKOUT_CIRCULATION_STATUS,
33
- 'use_restrictions.name' => FOR_CHECKOUT_USE_RESTRICTION
34
- ).where(identifier_conditions)
35
- }
36
- scope :removed, -> { includes(:circulation_status).where('circulation_statuses.name' => 'Removed') }
37
- has_many :checkouts
38
- has_many :reserves
39
- has_many :checked_items
40
- has_many :baskets, :through => :checked_items
41
- belongs_to :circulation_status, :validate => true
42
- belongs_to :checkout_type
43
- has_many :lending_policies, :dependent => :destroy
44
- has_one :item_has_use_restriction, :dependent => :destroy
45
- has_one :use_restriction, :through => :item_has_use_restriction
46
- validates_associated :circulation_status, :checkout_type
47
- validates_presence_of :circulation_status, :checkout_type
48
- searchable do
49
- string :circulation_status do
50
- circulation_status.name
51
- end
52
- end
53
- accepts_nested_attributes_for :item_has_use_restriction
54
-
55
- before_update :delete_lending_policy
56
- end
57
- end
58
-
59
- module InstanceMethods
60
- def set_circulation_status
61
- self.circulation_status = CirculationStatus.where(:name => 'In Process').first if self.circulation_status.nil?
62
- end
63
-
64
- def checkout_status(user)
65
- return nil unless user
66
- user.profile.user_group.user_group_has_checkout_types.where(:checkout_type_id => self.checkout_type.id).first
67
- end
68
-
69
- def reserved?
70
- return true if manifestation.next_reservation
71
- false
72
- end
73
-
74
- def rent?
75
- return true if self.checkouts.not_returned.select(:item_id).detect{|checkout| checkout.item_id == self.id}
76
- false
77
- end
78
-
79
- def reserved_by_user?(user)
80
- if manifestation.next_reservation
81
- return true if manifestation.next_reservation.user == user
82
- end
83
- false
84
- end
85
-
86
- def available_for_checkout?
87
- if circulation_status.name == 'On Loan'
88
- false
89
- else
90
- manifestation.items.for_checkout.include?(self)
91
- end
92
- end
93
-
94
- def checkout!(user)
95
- self.circulation_status = CirculationStatus.where(name: 'On Loan').first
96
- if reserved_by_user?(user)
97
- manifestation.next_reservation.update_attributes(checked_out_at: Time.zone.now)
98
- manifestation.next_reservation.transition_to!(:completed)
99
- end
100
- save!
101
- end
102
-
103
- def checkin!
104
- self.circulation_status = CirculationStatus.where(name: 'Available On Shelf').first
105
- save(validate: false)
106
- end
107
-
108
- def retain(librarian)
109
- self.class.transaction do
110
- reservation = manifestation.next_reservation
111
- unless reservation.nil?
112
- reservation.item = self
113
- reservation.transition_to!(:retained)
114
- reservation.send_message(librarian)
115
- end
116
- end
117
- end
118
-
119
- def retained?
120
- if manifestation.next_reservation.try(:current_state) == 'retained' and manifestation.next_reservation.item == self
121
- return true
122
- else
123
- false
124
- end
125
- end
126
-
127
- def lending_rule(user)
128
- policy = lending_policies.where(user_group_id: user.profile.user_group.id).first
129
- if policy
130
- policy
131
- else
132
- create_lending_policy(user)
133
- end
134
- end
135
-
136
- def not_for_loan?
137
- !manifestation.items.for_checkout.include?(self)
138
- end
139
-
140
- def create_lending_policy(user)
141
- rule = user.profile.user_group.user_group_has_checkout_types.where(checkout_type_id: checkout_type_id).first
142
- return nil unless rule
143
- LendingPolicy.create!(
144
- item_id: id,
145
- user_group_id: rule.user_group_id,
146
- fixed_due_date: rule.fixed_due_date,
147
- loan_period: rule.checkout_period,
148
- renewal: rule.checkout_renewal_limit
149
- )
150
- end
151
-
152
- def delete_lending_policy
153
- return nil unless changes[:checkout_type_id]
154
- lending_policies.delete_all
155
- end
156
-
157
- def next_reservation
158
- Reserve.waiting.where(:item_id => id).first
159
- end
160
-
161
- def latest_checkout
162
- checkouts.order('checkouts.id').first
163
- end
164
- end
165
- end
166
- end
@@ -1,84 +0,0 @@
1
- module EnjuCirculation
2
- module EnjuManifestation
3
- def self.included(base)
4
- base.extend ClassMethods
5
- end
6
-
7
- module ClassMethods
8
- def enju_circulation_manifestation_model
9
- include InstanceMethods
10
- has_many :reserves, :foreign_key => :manifestation_id
11
-
12
- searchable do
13
- boolean :reservable do
14
- items.for_checkout.exists?
15
- end
16
- end
17
- end
18
- end
19
-
20
- module InstanceMethods
21
- def next_reservation
22
- self.reserves.waiting.order('reserves.created_at ASC').readonly(false).first
23
- end
24
-
25
- def available_checkout_types(user)
26
- if user
27
- user.profile.user_group.user_group_has_checkout_types.available_for_carrier_type(self.carrier_type)
28
- end
29
- end
30
-
31
- def is_reservable_by?(user)
32
- return false if items.for_checkout.empty?
33
- unless user.has_role?('Librarian')
34
- unless items.size == (items.size - user.checkouts.overdue(Time.zone.now).collect(&:item).size)
35
- return false
36
- end
37
- end
38
- true
39
- end
40
-
41
- def is_reserved_by?(user)
42
- return nil unless user
43
- reserve = Reserve.waiting.where(:user_id => user.id, :manifestation_id => id).first
44
- if reserve
45
- reserve
46
- else
47
- false
48
- end
49
- end
50
-
51
- def is_reserved?
52
- if self.reserves.present?
53
- true
54
- else
55
- false
56
- end
57
- end
58
-
59
- def checkouts(start_date, end_date)
60
- Checkout.completed(start_date, end_date).where(:item_id => self.items.collect(&:id))
61
- end
62
-
63
- def checkout_period(user)
64
- if available_checkout_types(user)
65
- available_checkout_types(user).collect(&:checkout_period).max || 0
66
- end
67
- end
68
-
69
- def reservation_expired_period(user)
70
- if available_checkout_types(user)
71
- available_checkout_types(user).collect(&:reservation_expired_period).max || 0
72
- end
73
- end
74
-
75
- def is_checked_out_by?(user)
76
- if items.size > items.size - user.checkouts.not_returned.collect(&:item).size
77
- true
78
- else
79
- false
80
- end
81
- end
82
- end
83
- end
84
- end
@@ -1,23 +0,0 @@
1
- module EnjuCirculation
2
- module EnjuProfile
3
- def self.included(base)
4
- base.extend ClassMethods
5
- end
6
-
7
- module ClassMethods
8
- def enju_circulation_profile_model
9
- include InstanceMethods
10
- end
11
- end
12
-
13
- module InstanceMethods
14
- def reset_checkout_icalendar_token
15
- self.checkout_icalendar_token = SecureRandom.hex(16)
16
- end
17
-
18
- def delete_checkout_icalendar_token
19
- self.checkout_icalendar_token = nil
20
- end
21
- end
22
- end
23
- end
@@ -1,61 +0,0 @@
1
- module EnjuCirculation
2
- module EnjuUser
3
- def self.included(base)
4
- base.extend ClassMethods
5
- end
6
-
7
- module ClassMethods
8
- def enju_circulation_user_model
9
- include InstanceMethods
10
- #attr_accessible :save_checkout_history, :checkout_icalendar_token
11
- #attr_accessible :save_checkout_history, :checkout_icalendar_token,
12
- # :as => :admin
13
-
14
- has_many :checkouts, :dependent => :nullify
15
- has_many :reserves, :dependent => :destroy
16
- has_many :reserved_manifestations, :through => :reserves, :source => :manifestation
17
- has_many :checkout_stat_has_users
18
- has_many :user_checkout_stats, :through => :checkout_stat_has_users
19
- has_many :reserve_stat_has_users
20
- has_many :user_reserve_stats, :through => :reserve_stat_has_users
21
- has_many :baskets, :dependent => :destroy
22
-
23
- before_destroy :check_item_before_destroy
24
- end
25
- end
26
-
27
- module InstanceMethods
28
- def check_item_before_destroy
29
- # TODO: 貸出記録を残す場合
30
- if checkouts.size > 0
31
- raise 'This user has items still checked out.'
32
- end
33
- end
34
-
35
- def checked_item_count
36
- checkout_count = {}
37
- CheckoutType.all.each do |checkout_type|
38
- # 資料種別ごとの貸出中の冊数を計算
39
- checkout_count[:"#{checkout_type.name}"] = self.checkouts.count_by_sql(["
40
- SELECT count(item_id) FROM checkouts
41
- WHERE item_id IN (
42
- SELECT id FROM items
43
- WHERE checkout_type_id = ?
44
- )
45
- AND user_id = ? AND checkin_id IS NULL", checkout_type.id, self.id]
46
- )
47
- end
48
- return checkout_count
49
- end
50
-
51
- def reached_reservation_limit?(manifestation)
52
- return true if profile.user_group.user_group_has_checkout_types.available_for_carrier_type(manifestation.carrier_type).where(:user_group_id => profile.user_group.id).collect(&:reservation_limit).max.to_i <= reserves.waiting.size
53
- false
54
- end
55
-
56
- def has_overdue?(day = 1)
57
- true if checkouts.where(checkin_id: nil).where(Checkout.arel_table[:due_date].lt day.days.ago).count >= 1
58
- end
59
- end
60
- end
61
- end
@@ -1,21 +0,0 @@
1
- module EnjuCirculation
2
- module EnjuUserGroup
3
- def self.included(base)
4
- base.extend ClassMethods
5
- end
6
-
7
- module ClassMethods
8
- def enju_circulation_user_group_model
9
- has_many :user_group_has_checkout_types, dependent: :destroy
10
- has_many :checkout_types, through: :user_group_has_checkout_types
11
- has_many :lending_policies
12
- accepts_nested_attributes_for :user_group_has_checkout_types, :allow_destroy => true, :reject_if => :all_blank
13
-
14
- validates_numericality_of :number_of_day_to_notify_due_date,
15
- :number_of_day_to_notify_overdue,
16
- :number_of_time_to_notify_overdue,
17
- :greater_than_or_equal_to => 0
18
- end
19
- end
20
- end
21
- end
@@ -1,23 +0,0 @@
1
- module EnjuCirculation
2
- module EnjuWithdraw
3
- def self.included(base)
4
- base.extend ClassMethods
5
- end
6
-
7
- module ClassMethods
8
- def enju_circulation_withdraw_model
9
- include InstanceMethods
10
- before_save :withdraw!, on: :create
11
- end
12
- end
13
-
14
- module InstanceMethods
15
- def withdraw!
16
- circulation_status = CirculationStatus.where(name: 'Removed').first
17
- item.update_column(:circulation_status_id, circulation_status.id) if circulation_status
18
- item.use_restriction = UseRestriction.where(name: 'Not For Loan').first
19
- item.index!
20
- end
21
- end
22
- end
23
- end
@@ -1,111 +0,0 @@
1
- #module EnjuCirculation
2
- class Ability
3
- include CanCan::Ability
4
-
5
- def initialize(user, ip_address = nil)
6
- case user.try(:role).try(:name)
7
- when 'Administrator'
8
- can [:destroy, :delete], Manifestation do |manifestation|
9
- manifestation.items.empty? and !manifestation.periodical_master? and !manifestation.is_reserved?
10
- end
11
- can :manage, [
12
- Basket,
13
- CarrierTypeHasCheckoutType,
14
- CheckedItem,
15
- Checkin,
16
- CheckoutStatHasManifestation,
17
- CheckoutStatHasUser,
18
- CheckoutType,
19
- ItemHasUseRestriction,
20
- ManifestationCheckoutStat,
21
- ManifestationReserveStat,
22
- Reserve,
23
- ReserveStatHasManifestation,
24
- ReserveStatHasUser,
25
- UserCheckoutStat,
26
- UserGroupHasCheckoutType,
27
- UserReserveStat
28
- ]
29
- can [:read, :create, :update, :remove_all], Checkout
30
- can [:destroy, :delete], Checkout do |checkout|
31
- checkout.checkin
32
- end
33
- can [:read, :update], [
34
- CirculationStatus,
35
- LendingPolicy,
36
- UseRestriction
37
- ]
38
- can [:destroy, :delete], LendingPolicy
39
- can :read, [Item, Manifestation]
40
- when 'Librarian'
41
- can [:destroy, :delete], Item do |item|
42
- item.checkouts.not_returned.empty?
43
- end
44
- can [:destroy, :delete], Manifestation do |manifestation|
45
- manifestation.items.empty? and !manifestation.periodical_master? and !manifestation.is_reserved?
46
- end
47
- can :manage, [
48
- Basket,
49
- CheckedItem,
50
- Checkin,
51
- ManifestationCheckoutStat,
52
- ManifestationReserveStat,
53
- Reserve
54
- ]
55
- can [:read, :create, :update, :remove_all], Checkout
56
- can [:destroy, :delete], Checkout do |checkout|
57
- checkout.checkin
58
- end
59
- can [:read, :create, :update], UserCheckoutStat
60
- can [:read, :create, :update], UserReserveStat
61
- can :read, [
62
- CarrierTypeHasCheckoutType,
63
- CheckoutType,
64
- CheckoutStatHasManifestation,
65
- CheckoutStatHasUser,
66
- CirculationStatus,
67
- ItemHasUseRestriction,
68
- LendingPolicy,
69
- ReserveStatHasManifestation,
70
- ReserveStatHasUser,
71
- UseRestriction,
72
- UserGroupHasCheckoutType
73
- ]
74
- can :read, [Item, Manifestation]
75
- when 'User'
76
- can [:index, :create, :remove_all], Checkout
77
- can [:show, :update], Checkout do |checkout|
78
- checkout.user == user
79
- end
80
- can [:destroy, :delete], Checkout do |checkout|
81
- checkout.user == user && checkout.checkin
82
- end
83
- can :index, Reserve
84
- can :create, Reserve do |reserve|
85
- user.user_number.present?
86
- end
87
- can [:show, :update, :destroy, :delete], Reserve do |reserve|
88
- reserve.user == user
89
- end
90
- can :read, [
91
- CirculationStatus,
92
- ManifestationCheckoutStat,
93
- ManifestationReserveStat,
94
- UserCheckoutStat,
95
- UserReserveStat,
96
- ]
97
- can :read, [Item, Manifestation]
98
- else
99
- can :index, Checkout
100
- can :read, [
101
- CirculationStatus,
102
- ManifestationCheckoutStat,
103
- ManifestationReserveStat,
104
- UserCheckoutStat,
105
- UserReserveStat
106
- ]
107
- can :read, [Item, Manifestation]
108
- end
109
- end
110
- end
111
- #end
@@ -1,13 +0,0 @@
1
- class LocalAgent
2
- def initialize(user)
3
- @user = user
4
- end
5
-
6
- def id
7
- end
8
-
9
- def full_name
10
- # TODO: 外部サービスから取得
11
- @user.email
12
- end
13
- end
@@ -1,42 +0,0 @@
1
- defaults: &defaults
2
- enju:
3
- web_hostname: localhost
4
- web_port_number: 3000
5
-
6
- family_name_first: true
7
- max_number_of_results: 500
8
- write_search_log_to_file: true
9
- csv_charset_conversion: true
10
-
11
- # Choose a locale from 'ca', 'de', 'fr', 'jp', 'uk', 'us'
12
- #AMAZON_AWS_HOSTNAME = 'ecs.amazonaws.com'
13
- amazon:
14
- aws_hostname: ecs.amazonaws.jp
15
- hostname: www.amazon.co.jp
16
- access_key: REPLACE_WITH_YOUR_AMAZON_ACCESS_KEY
17
- secret_access_key: REPLACE_WITH_YOUR_AMAZON_SECRET_ACCESS_KEY
18
-
19
- # :google, :amazon
20
- book_jacket:
21
- source: :google
22
- unknown_resource:
23
-
24
- # :mozshot, :simpleapi, :heartrails, :thumbalizr
25
- screenshot:
26
- generator: :mozshot
27
-
28
- uploaded_file:
29
- storage: :local
30
-
31
- manifestation:
32
- facet:
33
- pub_year_range_interval: 10
34
-
35
- development:
36
- <<: *defaults
37
-
38
- test:
39
- <<: *defaults
40
-
41
- production:
42
- <<: *defaults