enju_circulation 0.0.67 → 0.0.68
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.
- data/app/models/checkout.rb +1 -0
- data/app/views/baskets/index.html.erb +1 -1
- data/app/views/carrier_type_has_checkout_types/index.html.erb +1 -1
- data/app/views/checked_items/_checked_item.html.erb +1 -1
- data/app/views/checked_items/_checkout.html.erb +1 -1
- data/app/views/checkins/_checkin.html.erb +1 -1
- data/app/views/checkout_stat_has_manifestations/index.html.erb +1 -1
- data/app/views/checkout_stat_has_users/index.html.erb +1 -1
- data/app/views/checkout_types/index.html.erb +1 -1
- data/app/views/checkouts/_list.html.erb +1 -1
- data/app/views/circulation_statuses/index.html.erb +1 -1
- data/app/views/lending_policies/index.html.erb +1 -1
- data/app/views/manifestation_checkout_stats/index.html.erb +1 -1
- data/app/views/manifestation_checkout_stats/show.html.erb +1 -1
- data/app/views/manifestation_reserve_stats/index.html.erb +1 -1
- data/app/views/manifestation_reserve_stats/show.html.erb +1 -1
- data/app/views/reserve_stat_has_manifestations/index.html.erb +1 -1
- data/app/views/reserve_stat_has_users/index.html.erb +1 -1
- data/app/views/reserves/index.html.erb +1 -1
- data/app/views/use_restrictions/index.html.erb +1 -1
- data/app/views/user_checkout_stats/index.html.erb +1 -1
- data/app/views/user_checkout_stats/show.html.erb +1 -1
- data/app/views/user_group_has_checkout_types/index.html.erb +1 -1
- data/app/views/user_reserve_stats/index.html.erb +1 -1
- data/app/views/user_reserve_stats/show.html.erb +1 -1
- data/lib/enju_circulation/item.rb +123 -0
- data/lib/enju_circulation/version.rb +1 -1
- data/lib/enju_circulation.rb +2 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/solr/data/test/index/segments_1 +0 -0
- data/spec/dummy/solr/data/test/spellchecker/segments_1 +0 -0
- metadata +3 -2
data/app/models/checkout.rb
CHANGED
@@ -68,6 +68,7 @@ class Checkout < ActiveRecord::Base
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def get_new_due_date
|
71
|
+
return nil unless user
|
71
72
|
if self.item
|
72
73
|
if self.checkout_renewal_count <= self.item.checkout_status(user).checkout_renewal_limit
|
73
74
|
new_due_date = Time.zone.now.advance(:days => self.item.checkout_status(user).checkout_period).beginning_of_day
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<h1 class="title"><%= t('page.listing', :model => t('activerecord.models.basket')) -%></h1>
|
3
3
|
<div id="content_detail" class="ui-corner-all">
|
4
4
|
|
5
|
-
<table class="index">
|
5
|
+
<table class="table table-striped index">
|
6
6
|
<tr>
|
7
7
|
<th><%= t('activerecord.models.user') -%></th>
|
8
8
|
<th><%= t('activerecord.attributes.basket.note') -%></th>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<h1 class="title"><%= t('page.listing', :model => t('activerecord.models.carrier_type_has_checkout_type')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
|
5
|
-
<table class="index">
|
5
|
+
<table class="table table-striped index">
|
6
6
|
<tr>
|
7
7
|
<th><%= t('activerecord.models.carrier_type') -%></th>
|
8
8
|
<th><%= t('activerecord.models.checkout_type') -%></th>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<h1 class="title"><%= t('page.listing', :model => t('activerecord.models.checkout_stat_has_manifestation')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
|
5
|
-
<table class="index">
|
5
|
+
<table class="table table-striped index">
|
6
6
|
<tr>
|
7
7
|
<th><%= t('activerecord.models.manifestation_checkout_stat') -%></th>
|
8
8
|
<th><%= t('activerecord.models.manifestation') -%></th>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<h1 class="title"><%= t('page.listing', :model => t('activerecord.models.checkout_stat_has_user')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
|
5
|
-
<table class="index">
|
5
|
+
<table class="table table-striped index">
|
6
6
|
<tr>
|
7
7
|
<th><%= t('activerecord.models.user_checkout_stat') -%></th>
|
8
8
|
<th><%= t('activerecord.models.user') -%></th>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<h1 class="title"><%= t('page.listing', :model => t('activerecord.models.checkout_type')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
|
5
|
-
<table class="index">
|
5
|
+
<table class="table table-striped index">
|
6
6
|
<tr>
|
7
7
|
<th id="position"></th>
|
8
8
|
<th><%= t('activerecord.attributes.checkout_type.name') -%></th>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<h1 class="title"><%= t('page.listing', :model => t('activerecord.models.circulation_status')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
|
5
|
-
<table class="index">
|
5
|
+
<table class="table table-striped index">
|
6
6
|
<tr>
|
7
7
|
<th id="position"></th>
|
8
8
|
<th><%= t('activerecord.attributes.circulation_status.name') -%></th>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<h1 class="title"><%= t('page.listing', :model => t('activerecord.models.lending_policy')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
|
5
|
-
<table class="index">
|
5
|
+
<table class="table table-striped index">
|
6
6
|
<tr>
|
7
7
|
<th><%= t('activerecord.models.item') -%></th>
|
8
8
|
<th><%= t('activerecord.models.user_group') -%></th>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<h1 class="title"><%= t('page.listing', :model => t('activerecord.models.manifestation_checkout_stat')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
|
5
|
-
<table class="index">
|
5
|
+
<table class="table table-striped index">
|
6
6
|
<tr>
|
7
7
|
<th><%= t('activerecord.attributes.manifestation_checkout_stat.start_date') -%></th>
|
8
8
|
<th><%= t('activerecord.attributes.manifestation_checkout_stat.end_date') -%></th>
|
@@ -23,7 +23,7 @@
|
|
23
23
|
<%= @manifestation_checkout_stat.note -%>
|
24
24
|
</p>
|
25
25
|
|
26
|
-
<table class="index">
|
26
|
+
<table class="table table-striped index">
|
27
27
|
<tr>
|
28
28
|
<th><%= t('activerecord.models.manifestation') -%></th>
|
29
29
|
<th><%= t('activerecord.attributes.checkout_stat_has_manifestation.checkouts_count') -%></th>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<h1 class="title"><%= t('page.listing', :model => t('activerecord.models.manifestation_reserve_stat')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
|
5
|
-
<table class="index">
|
5
|
+
<table class="table table-striped index">
|
6
6
|
<tr>
|
7
7
|
<th><%= t('activerecord.attributes.manifestation_reserve_stat.start_date') -%></th>
|
8
8
|
<th><%= t('activerecord.attributes.manifestation_reserve_stat.end_date') -%></th>
|
@@ -23,7 +23,7 @@
|
|
23
23
|
<%= @manifestation_reserve_stat.note -%>
|
24
24
|
</p>
|
25
25
|
|
26
|
-
<table class="index">
|
26
|
+
<table class="table table-striped index">
|
27
27
|
<tr>
|
28
28
|
<th><%= t('activerecord.models.manifestation') -%></th>
|
29
29
|
<th><%= t('activerecord.attributes.reserve_stat_has_manifestation.reserves_count') -%></th>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<h1 class="title"><%= t('activerecord.models.reserve_stat_has_manifestation') -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
|
5
|
-
<table class="index">
|
5
|
+
<table class="table table-striped index">
|
6
6
|
<tr>
|
7
7
|
<th><%= t('activerecord.models.manifestation_reserve_stat') -%></th>
|
8
8
|
<th><%= t('activerecord.models.manifestation') -%></th>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<h1 class="title"><%= t('activerecord.models.reserve_stat_has_user') -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
|
5
|
-
<table class="index">
|
5
|
+
<table class="table table-striped index">
|
6
6
|
<tr>
|
7
7
|
<th><%= t('activerecord.models.user_reserve_stat') -%></th>
|
8
8
|
<th><%= t('activerecord.models.user') -%></th>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<div id="content_detail" class="ui-corner-all">
|
3
3
|
<h1 class="title"><%= t('page.listing', :model => t('activerecord.models.reserve')) -%></h1>
|
4
4
|
<div id="content_list">
|
5
|
-
<table class="index">
|
5
|
+
<table class="table table-striped index">
|
6
6
|
<tr>
|
7
7
|
<th style="width: 30px"><%= 'Id' -%></th>
|
8
8
|
<th><%= t('activerecord.models.user') -%></th>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<h1 class="title"><%= t('page.listing', :model => t('activerecord.models.use_restriction')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
|
5
|
-
<table class="index">
|
5
|
+
<table class="table table-striped index">
|
6
6
|
<tr>
|
7
7
|
<th id="position"></th>
|
8
8
|
<th><%= t('activerecord.attributes.use_restriction.name') -%></th>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<h1 class="title"><%= t('page.listing', :model => t('activerecord.models.user_checkout_stat')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
|
5
|
-
<table class="index">
|
5
|
+
<table class="table table-striped index">
|
6
6
|
<tr>
|
7
7
|
<th><%= t('activerecord.attributes.user_checkout_stat.start_date') -%></th>
|
8
8
|
<th><%= t('activerecord.attributes.user_checkout_stat.end_date') -%></th>
|
@@ -23,7 +23,7 @@
|
|
23
23
|
<%= @user_checkout_stat.note -%>
|
24
24
|
</p>
|
25
25
|
|
26
|
-
<table class="index">
|
26
|
+
<table class="table table-striped index">
|
27
27
|
<tr>
|
28
28
|
<th><%= t('activerecord.models.user') -%></th>
|
29
29
|
<th><%= t('activerecord.attributes.checkout_stat_has_user.checkouts_count') -%></th>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<h1 class="title"><%= t('page.listing', :model => t('activerecord.models.user_group_has_checkout_type')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
|
5
|
-
<table class="index">
|
5
|
+
<table class="table table-striped index">
|
6
6
|
<tr>
|
7
7
|
<th><%= t('activerecord.models.user_group') -%></th>
|
8
8
|
<th><%= t('activerecord.models.checkout_type') -%></th>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<h1 class="title"><%= t('page.listing', :model => t('activerecord.models.user_reserve_stat')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
|
5
|
-
<table class="index">
|
5
|
+
<table class="table table-striped index">
|
6
6
|
<tr>
|
7
7
|
<th><%= t('activerecord.attributes.user_reserve_stat.start_date') -%></th>
|
8
8
|
<th><%= t('activerecord.attributes.user_reserve_stat.end_date') -%></th>
|
@@ -0,0 +1,123 @@
|
|
1
|
+
module EnjuCirculation
|
2
|
+
module Item
|
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, includes(:circulation_status, :use_restriction).where(
|
31
|
+
'circulation_statuses.name' => FOR_CHECKOUT_CIRCULATION_STATUS,
|
32
|
+
'use_restrictions.name' => FOR_CHECKOUT_USE_RESTRICTION
|
33
|
+
).where('item_identifier IS NOT NULL')
|
34
|
+
scope :removed, includes(:circulation_status).where('circulation_statuses.name' => 'Removed')
|
35
|
+
has_many :checkouts
|
36
|
+
has_many :reserves
|
37
|
+
has_many :checked_items, :dependent => :destroy
|
38
|
+
has_many :baskets, :through => :checked_items
|
39
|
+
belongs_to :circulation_status, :validate => true
|
40
|
+
belongs_to :checkout_type
|
41
|
+
has_many :lending_policies, :dependent => :destroy
|
42
|
+
has_one :item_has_use_restriction, :dependent => :destroy
|
43
|
+
has_one :use_restriction, :through => :item_has_use_restriction
|
44
|
+
validates_associated :circulation_status, :checkout_type
|
45
|
+
validates_presence_of :circulation_status, :checkout_type
|
46
|
+
searchable do
|
47
|
+
integer :circulation_status_id
|
48
|
+
end
|
49
|
+
attr_accessible :item_has_use_restriction_attributes
|
50
|
+
accepts_nested_attributes_for :item_has_use_restriction
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
module InstanceMethods
|
55
|
+
def set_circulation_status
|
56
|
+
self.circulation_status = CirculationStatus.where(:name => 'In Process').first if self.circulation_status.nil?
|
57
|
+
end
|
58
|
+
|
59
|
+
def checkout_status(user)
|
60
|
+
return nil unless user
|
61
|
+
user.user_group.user_group_has_checkout_types.where(:checkout_type_id => self.checkout_type.id).first
|
62
|
+
end
|
63
|
+
|
64
|
+
def reserved?
|
65
|
+
return true if manifestation.next_reservation
|
66
|
+
false
|
67
|
+
end
|
68
|
+
|
69
|
+
def rent?
|
70
|
+
return true if self.checkouts.not_returned.select(:item_id).detect{|checkout| checkout.item_id == self.id}
|
71
|
+
false
|
72
|
+
end
|
73
|
+
|
74
|
+
def reserved_by_user?(user)
|
75
|
+
if manifestation.next_reservation
|
76
|
+
return true if manifestation.next_reservation.user == user
|
77
|
+
end
|
78
|
+
false
|
79
|
+
end
|
80
|
+
|
81
|
+
def available_for_checkout?
|
82
|
+
if circulation_status.name == 'On Loan'
|
83
|
+
false
|
84
|
+
else
|
85
|
+
manifestation.items.for_checkout.include?(self)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def checkout!(user)
|
90
|
+
self.circulation_status = CirculationStatus.where(:name => 'On Loan').first
|
91
|
+
if self.reserved_by_user?(user)
|
92
|
+
manifestation.next_reservation.update_attributes(:checked_out_at => Time.zone.now)
|
93
|
+
manifestation.next_reservation.sm_complete!
|
94
|
+
end
|
95
|
+
save!
|
96
|
+
end
|
97
|
+
|
98
|
+
def checkin!
|
99
|
+
self.circulation_status = CirculationStatus.where(:name => 'Available On Shelf').first
|
100
|
+
save(:validate => false)
|
101
|
+
end
|
102
|
+
|
103
|
+
def retain(librarian)
|
104
|
+
Item.transaction do
|
105
|
+
reservation = manifestation.next_reservation
|
106
|
+
unless reservation.nil?
|
107
|
+
reservation.item = self
|
108
|
+
reservation.sm_retain!
|
109
|
+
reservation.send_message(librarian)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def lending_rule(user)
|
115
|
+
lending_policies.where(:user_group_id => user.user_group.id).first
|
116
|
+
end
|
117
|
+
|
118
|
+
def not_for_loan?
|
119
|
+
!manifestation.items.for_checkout.include?(self)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
data/lib/enju_circulation.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "enju_circulation/engine"
|
2
2
|
require "enju_circulation/manifestation"
|
3
|
+
require "enju_circulation/item"
|
3
4
|
require "enju_circulation/user"
|
4
5
|
require "enju_circulation/controller"
|
5
6
|
|
@@ -8,4 +9,5 @@ end
|
|
8
9
|
|
9
10
|
ActionController::Base.send :include, EnjuCirculation::Controller
|
10
11
|
ActiveRecord::Base.send :include, EnjuCirculation::Manifestation
|
12
|
+
ActiveRecord::Base.send :include, EnjuCirculation::Item
|
11
13
|
ActiveRecord::Base.send :include, EnjuCirculation::User
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enju_circulation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.68
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -449,6 +449,7 @@ files:
|
|
449
449
|
- db/migrate/20120424103932_add_librarian_id_to_checked_item.rb
|
450
450
|
- lib/enju_circulation/controller.rb
|
451
451
|
- lib/enju_circulation/engine.rb
|
452
|
+
- lib/enju_circulation/item.rb
|
452
453
|
- lib/enju_circulation/manifestation.rb
|
453
454
|
- lib/enju_circulation/user.rb
|
454
455
|
- lib/enju_circulation/version.rb
|