enju_circulation 0.0.69 → 0.0.70
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/checkouts_controller.rb +65 -25
- data/app/models/checkin.rb +1 -1
- data/app/models/checkout.rb +33 -12
- 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/checkouts/_index.html.erb +3 -0
- data/app/views/checkouts/_index_overdue.html.erb +1 -0
- data/app/views/checkouts/_index_user.html.erb +1 -0
- data/app/views/checkouts/_list.html.erb +1 -1
- data/app/views/checkouts/_reserved_facet.html.erb +14 -0
- data/app/views/checkouts/edit.html.erb +1 -1
- data/app/views/checkouts/show.html.erb +1 -1
- data/app/views/lending_policies/show.html.erb +1 -1
- data/app/views/reserves/index.html.erb +1 -1
- data/app/views/reserves/show.html.erb +1 -1
- data/config/locales/translation_en.yml +1 -0
- data/config/locales/translation_ja.yml +1 -0
- data/lib/enju_circulation/version.rb +1 -1
- data/spec/controllers/checkouts_controller_spec.rb +2 -2
- 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
- data/spec/fixtures/checkouts.yml +10 -10
- metadata +3 -2
@@ -31,39 +31,79 @@ class CheckoutsController < ApplicationController
|
|
31
31
|
end
|
32
32
|
|
33
33
|
unless icalendar_user
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
search = Checkout.search
|
35
|
+
if @user
|
36
|
+
user = @user
|
37
|
+
if current_user.try(:has_role?, 'Librarian')
|
38
|
+
search.build do
|
39
|
+
with(:username).equal_to user.username
|
40
|
+
with(:checked_in_at).equal_to nil unless user.save_checkout_history
|
41
|
+
end
|
37
42
|
else
|
38
|
-
if
|
39
|
-
|
43
|
+
if current_user == user
|
44
|
+
redirect_to checkouts_url(:format => params[:format])
|
45
|
+
return
|
40
46
|
else
|
41
|
-
|
42
|
-
|
43
|
-
date = params[:days_overdue].to_i.days.ago.beginning_of_day
|
44
|
-
else
|
45
|
-
date = 1.days.ago.beginning_of_day
|
46
|
-
end
|
47
|
-
@checkouts = Checkout.overdue(date).order('checkouts.id DESC').page(params[:page]).per_page(per_page)
|
48
|
-
else
|
49
|
-
@checkouts = Checkout.not_returned.order('checkouts.id DESC').page(params[:page]).per_page(per_page)
|
50
|
-
end
|
47
|
+
access_denied
|
48
|
+
return
|
51
49
|
end
|
52
50
|
end
|
53
51
|
else
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
52
|
+
unless current_user.try(:has_role?, 'Librarian')
|
53
|
+
search.build do
|
54
|
+
with(:username).equal_to current_user.username
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
search.build do
|
59
|
+
with(:checked_in_at).equal_to nil
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
if current_user.try(:has_role?, 'Librarian')
|
64
|
+
if @item
|
65
|
+
item = @item
|
66
|
+
search.build do
|
67
|
+
with(:item_identifier).equal_to item.item_identifier
|
64
68
|
end
|
65
69
|
end
|
70
|
+
else
|
71
|
+
if @item
|
72
|
+
access_denied; return
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
if params[:view] == 'overdue'
|
77
|
+
if params[:days_overdue]
|
78
|
+
date = params[:days_overdue].to_i.days.ago.beginning_of_day
|
79
|
+
else
|
80
|
+
date = 1.days.ago.beginning_of_day
|
81
|
+
end
|
82
|
+
search.build do
|
83
|
+
with(:due_date).less_than date
|
84
|
+
with(:checked_in_at).equal_to nil
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
if params[:reserved].present?
|
89
|
+
if params[:reserved] == 'true'
|
90
|
+
@reserved = reserved = true
|
91
|
+
elsif params[:reserved] == 'false'
|
92
|
+
@reserved = reserved = false
|
93
|
+
end
|
94
|
+
search.build do
|
95
|
+
with(:reserved).equal_to reserved
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
search.build do
|
100
|
+
order_by :created_at, :desc
|
101
|
+
facet :reserved
|
66
102
|
end
|
103
|
+
page = params[:page] || 1
|
104
|
+
search.query.paginate(page.to_i, Checkout.per_page)
|
105
|
+
@checkouts = search.execute!.results
|
106
|
+
@checkouts_facet = search.facet(:reserved).rows
|
67
107
|
end
|
68
108
|
|
69
109
|
@days_overdue = params[:days_overdue] ||= 1
|
data/app/models/checkin.rb
CHANGED
@@ -32,7 +32,7 @@ class Checkin < ActiveRecord::Base
|
|
32
32
|
message = ''
|
33
33
|
Checkin.transaction do
|
34
34
|
checkouts = Checkout.not_returned.where(:item_id => item_id).select(
|
35
|
-
[:id, :item_id, :user_id, :basket_id, :due_date, :lock_version]
|
35
|
+
[:id, :item_id, :user_id, :basket_id, :due_date, :lock_version, :created_at]
|
36
36
|
)
|
37
37
|
item.checkin!
|
38
38
|
checkouts.each do |checkout|
|
data/app/models/checkout.rb
CHANGED
@@ -23,6 +23,26 @@ class Checkout < ActiveRecord::Base
|
|
23
23
|
validate :is_not_checked?, :on => :create
|
24
24
|
validates_date :due_date
|
25
25
|
|
26
|
+
searchable do
|
27
|
+
string :username do
|
28
|
+
user.try(:username)
|
29
|
+
end
|
30
|
+
string :user_number do
|
31
|
+
user.try(:user_number)
|
32
|
+
end
|
33
|
+
string :item_identifier do
|
34
|
+
item.item_identifier
|
35
|
+
end
|
36
|
+
time :due_date
|
37
|
+
time :created_at
|
38
|
+
time :checked_in_at do
|
39
|
+
checkin.try(:created_at)
|
40
|
+
end
|
41
|
+
boolean :reserved do
|
42
|
+
reserved?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
26
46
|
def self.per_page
|
27
47
|
10
|
28
48
|
end
|
@@ -35,20 +55,21 @@ class Checkout < ActiveRecord::Base
|
|
35
55
|
end
|
36
56
|
|
37
57
|
def checkout_renewable?
|
38
|
-
return false if
|
39
|
-
if
|
40
|
-
return false if
|
41
|
-
return false if
|
58
|
+
return false if overdue?
|
59
|
+
if item
|
60
|
+
return false if over_checkout_renewal_limit?
|
61
|
+
return false if reserved?
|
42
62
|
end
|
43
63
|
true
|
44
64
|
end
|
45
65
|
|
46
66
|
def reserved?
|
47
|
-
return true if
|
67
|
+
return true if item.try(:reserved?)
|
68
|
+
false
|
48
69
|
end
|
49
70
|
|
50
71
|
def over_checkout_renewal_limit?
|
51
|
-
return true if
|
72
|
+
return true if item.checkout_status(user).checkout_renewal_limit <= checkout_renewal_count
|
52
73
|
end
|
53
74
|
|
54
75
|
def overdue?
|
@@ -60,7 +81,7 @@ class Checkout < ActiveRecord::Base
|
|
60
81
|
end
|
61
82
|
|
62
83
|
def is_today_due_date?
|
63
|
-
if Time.zone.now.beginning_of_day ==
|
84
|
+
if Time.zone.now.beginning_of_day == due_date.beginning_of_day
|
64
85
|
return true
|
65
86
|
else
|
66
87
|
return false
|
@@ -69,17 +90,17 @@ class Checkout < ActiveRecord::Base
|
|
69
90
|
|
70
91
|
def get_new_due_date
|
71
92
|
return nil unless user
|
72
|
-
if
|
73
|
-
if
|
74
|
-
new_due_date = Time.zone.now.advance(:days =>
|
93
|
+
if item
|
94
|
+
if checkout_renewal_count <= item.checkout_status(user).checkout_renewal_limit
|
95
|
+
new_due_date = Time.zone.now.advance(:days => item.checkout_status(user).checkout_period).beginning_of_day
|
75
96
|
else
|
76
|
-
new_due_date =
|
97
|
+
new_due_date = due_date
|
77
98
|
end
|
78
99
|
end
|
79
100
|
end
|
80
101
|
|
81
102
|
def self.manifestations_count(start_date, end_date, manifestation)
|
82
|
-
|
103
|
+
completed(start_date, end_date).where(:item_id => manifestation.items.pluck('items.id')).count
|
83
104
|
end
|
84
105
|
|
85
106
|
def self.send_due_date_notification
|
@@ -12,7 +12,7 @@
|
|
12
12
|
<%= render 'manifestations/show_index', :manifestation => checked_item.item.manifestation -%>
|
13
13
|
</td>
|
14
14
|
<td><%= link_to checked_item.item.item_identifier, checked_item.item -%></td>
|
15
|
-
<td><%= l(checked_item.due_date, :
|
15
|
+
<td><%= l(checked_item.due_date, :formats => :only_date) -%></td>
|
16
16
|
<td><%= link_to t('page.destroy'), checked_item, :data => {:confirm => t('page.are_you_sure')}, :method => :delete -%></td>
|
17
17
|
</tr>
|
18
18
|
<%- end -%>
|
@@ -14,7 +14,7 @@
|
|
14
14
|
<%= render 'manifestations/holding', :manifestation => checkout.item.manifestation -%>
|
15
15
|
</td>
|
16
16
|
<td><%= link_to checkout.item.item_identifier, checkout.item -%></td>
|
17
|
-
<td><%= l(checkout.due_date, :
|
17
|
+
<td><%= l(checkout.due_date, :formats => :only_date) -%></td>
|
18
18
|
</tr>
|
19
19
|
<%- end -%>
|
20
20
|
</table>
|
@@ -15,6 +15,9 @@
|
|
15
15
|
<ul>
|
16
16
|
<li><%= link_to t('checkout.my_checkout'), user_checkouts_path(current_user) -%></li>
|
17
17
|
<li><%= link_to t('page.overdue'), checkouts_path(:view => 'overdue') -%></li>
|
18
|
+
</ul>
|
19
|
+
<%= render 'reserved_facet' %>
|
20
|
+
<ul>
|
18
21
|
<li>
|
19
22
|
<%= link_to 'RSS', checkouts_path(:format => :rss) -%>
|
20
23
|
<%= link_to (image_tag 'icons/feed.png', :size => '16x16', :alt => 'RSS', :class => 'icon'), checkouts_path(:format => :rss) -%>
|
@@ -24,6 +24,7 @@
|
|
24
24
|
<ul>
|
25
25
|
<li><%= link_to t('page.back_to', :model => t('activerecord.models.checkout')), checkouts_path -%></li>
|
26
26
|
</ul>
|
27
|
+
<%= render 'reserved_facet' %>
|
27
28
|
<p>
|
28
29
|
<%= link_to (image_tag 'icons/feed.png', :size => '16x16', :alt => 'RSS', :class => 'icon'), checkouts_path(:format => :rss, :view => 'overdue') -%>
|
29
30
|
(<%= link_to 'RSS', checkouts_path(:format => :rss, :view => 'overdue') -%>)
|
@@ -21,7 +21,7 @@
|
|
21
21
|
(<%= link_to checkout.item.item_identifier, checkout.item -%>)
|
22
22
|
</td>
|
23
23
|
<td>
|
24
|
-
<%= l(checkout.due_date, :
|
24
|
+
<%= l(checkout.due_date, :formats => :only_date) -%>
|
25
25
|
<br />
|
26
26
|
<% if checkout.checkin %>
|
27
27
|
<strong><%= t('checkout.returned') %></strong>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<h4><%= t('checkout.reserved') %></h4>
|
2
|
+
<ul>
|
3
|
+
<%- @checkouts_facet.each do |facet| -%>
|
4
|
+
<% facet.value ? facet_reserved = true : facet_reserved = false %>
|
5
|
+
<li>
|
6
|
+
<%- if @reserved == facet_reserved -%><strong><%- end -%>
|
7
|
+
<%= link_to "#{localized_boolean(facet.value)} (#{facet.count})", url_for(params.merge(:page => nil, :reserved => facet.value.to_s, :view => nil, :only_path => true)) -%>
|
8
|
+
<%- if @reserved == facet_reserved -%></strong><%- end -%>
|
9
|
+
</li>
|
10
|
+
<%- end -%>
|
11
|
+
<%- unless @reserved.nil? -%>
|
12
|
+
<li><%= link_to t('page.remove_this_facet'), url_for(params.merge(:reserved => nil, :page => nil, :view => nil, :only_path => true)) -%></li>
|
13
|
+
<%- end -%>
|
14
|
+
</ul>
|
@@ -7,7 +7,7 @@
|
|
7
7
|
<h3><%= t('checkout.renewal') -%></h3>
|
8
8
|
<%- if @checkout.checkout_renewable? -%>
|
9
9
|
<%= form_for(@checkout) do |f| -%>
|
10
|
-
<%= t('checkout.new_due_date') -%>: <%= l(@new_due_date, :
|
10
|
+
<%= t('checkout.new_due_date') -%>: <%= l(@new_due_date, :formats => :only_date) if @new_due_date -%>
|
11
11
|
<%= f.hidden_field :due_date, :value => @new_due_date -%>
|
12
12
|
<br />
|
13
13
|
<%= f.submit %>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
</p>
|
11
11
|
<p>
|
12
12
|
<strong><%= t('activerecord.attributes.checkout.due_date') -%></strong><br />
|
13
|
-
<%= l(@checkout.due_date, :
|
13
|
+
<%= l(@checkout.due_date, :formats => :only_date) if @checkout.due_date -%>
|
14
14
|
</p>
|
15
15
|
<%- if can? :destroy, @checkout -%>
|
16
16
|
<p>
|
@@ -21,7 +21,7 @@
|
|
21
21
|
|
22
22
|
<p>
|
23
23
|
<strong><%= t('activerecord.attributes.lending_policy.fixed_due_date') -%>:</strong>
|
24
|
-
<%= l(@lending_policy.fixed_due_date, :
|
24
|
+
<%= l(@lending_policy.fixed_due_date, :formats => :only_date) if @lending_policy.fixed_due_date -%>
|
25
25
|
</p>
|
26
26
|
|
27
27
|
<p>
|
@@ -22,7 +22,7 @@
|
|
22
22
|
<%= render 'title', :reserve => reserve -%>
|
23
23
|
</td>
|
24
24
|
<td><%= i18n_state(reserve.state) -%></td>
|
25
|
-
<td><%= l(reserve.expired_at, :
|
25
|
+
<td><%= l(reserve.expired_at, :formats => :only_date) -%></td>
|
26
26
|
<%- if can? :destroy, reserve -%>
|
27
27
|
<td>
|
28
28
|
<%= link_to t('page.edit'), edit_reserve_path(reserve) -%>
|
@@ -33,7 +33,7 @@
|
|
33
33
|
|
34
34
|
<p>
|
35
35
|
<strong><%= t('activerecord.attributes.reserve.expired_at') -%>:</strong>
|
36
|
-
<%= l(@reserve.expired_at, :
|
36
|
+
<%= l(@reserve.expired_at, :formats => :only_date) if @reserve.expired_at -%>
|
37
37
|
</p>
|
38
38
|
|
39
39
|
<p>
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe CheckoutsController do
|
4
4
|
fixtures :all
|
5
5
|
|
6
|
-
describe "GET index" do
|
6
|
+
describe "GET index", :solr => true do
|
7
7
|
before(:each) do
|
8
8
|
FactoryGirl.create(:admin)
|
9
9
|
end
|
@@ -13,7 +13,7 @@ describe CheckoutsController do
|
|
13
13
|
|
14
14
|
it "assigns all checkouts as @checkouts" do
|
15
15
|
get :index
|
16
|
-
assigns(:checkouts).should eq
|
16
|
+
assigns(:checkouts).should eq Checkout.not_returned.order('checkouts.id DESC').page(1)
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should get other user's index" do
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
Binary file
|
Binary file
|
data/spec/fixtures/checkouts.yml
CHANGED
@@ -41,7 +41,7 @@ checkout_00004:
|
|
41
41
|
librarian_id: 1
|
42
42
|
checkout_renewal_count: 0
|
43
43
|
due_date: <%= 2.day.from_now.beginning_of_day %>
|
44
|
-
created_at: 2007-09-08 01:39:
|
44
|
+
created_at: 2007-09-08 01:39:04.210081 +09:00
|
45
45
|
basket_id: 3
|
46
46
|
checkout_00005:
|
47
47
|
item_id: 5
|
@@ -52,7 +52,7 @@ checkout_00005:
|
|
52
52
|
librarian_id: 1
|
53
53
|
checkout_renewal_count: 0
|
54
54
|
due_date: <%= 2.day.from_now.beginning_of_day %>
|
55
|
-
created_at: 2007-09-08 01:39:
|
55
|
+
created_at: 2007-09-08 01:39:05.210081 +09:00
|
56
56
|
basket_id: 4
|
57
57
|
checkout_00006:
|
58
58
|
item_id: 7
|
@@ -63,7 +63,7 @@ checkout_00006:
|
|
63
63
|
librarian_id: 2
|
64
64
|
checkout_renewal_count: 0
|
65
65
|
due_date: 2010-09-15 00:00:00 +09:00
|
66
|
-
created_at: 2007-09-08 01:39:
|
66
|
+
created_at: 2007-09-08 01:39:06.210081 +09:00
|
67
67
|
checkout_00007:
|
68
68
|
item_id: 7
|
69
69
|
updated_at: 2007-09-09 21:15:11.648996 +09:00
|
@@ -73,7 +73,7 @@ checkout_00007:
|
|
73
73
|
librarian_id: 1
|
74
74
|
checkout_renewal_count: 0
|
75
75
|
due_date: <%= 2.day.from_now.beginning_of_day %>
|
76
|
-
created_at: 2007-09-08 01:39:
|
76
|
+
created_at: 2007-09-08 01:39:07.210081 +09:00
|
77
77
|
basket_id: 5
|
78
78
|
checkout_00008:
|
79
79
|
item_id: 8
|
@@ -84,7 +84,7 @@ checkout_00008:
|
|
84
84
|
librarian_id: 1
|
85
85
|
checkout_renewal_count: 0
|
86
86
|
due_date: <%= 2.day.from_now.beginning_of_day %>
|
87
|
-
created_at: 2007-09-08 01:39:
|
87
|
+
created_at: 2007-09-08 01:39:08.210081 +09:00
|
88
88
|
basket_id: 6
|
89
89
|
checkout_00009:
|
90
90
|
item_id: 9
|
@@ -95,7 +95,7 @@ checkout_00009:
|
|
95
95
|
librarian_id: 1
|
96
96
|
checkout_renewal_count: 1
|
97
97
|
due_date: <%= 2.day.from_now.beginning_of_day %>
|
98
|
-
created_at: 2007-09-08 01:39:
|
98
|
+
created_at: 2007-09-08 01:39:09.210081 +09:00
|
99
99
|
basket_id: 7
|
100
100
|
checkout_00010:
|
101
101
|
item_id: 13
|
@@ -106,7 +106,7 @@ checkout_00010:
|
|
106
106
|
librarian_id: 1
|
107
107
|
checkout_renewal_count: 1
|
108
108
|
due_date: <%= 2.day.from_now.beginning_of_day %>
|
109
|
-
created_at: 2007-09-08 01:39:
|
109
|
+
created_at: 2007-09-08 01:39:10.210081 +09:00
|
110
110
|
basket_id: 7
|
111
111
|
checkout_00011:
|
112
112
|
item_id: 14
|
@@ -117,7 +117,7 @@ checkout_00011:
|
|
117
117
|
librarian_id: 1
|
118
118
|
checkout_renewal_count: 1
|
119
119
|
due_date: <%= 180.days.ago.beginning_of_day %>
|
120
|
-
created_at: 2007-09-08 01:39:
|
120
|
+
created_at: 2007-09-08 01:39:11.210081 +09:00
|
121
121
|
basket_id: 7
|
122
122
|
checkout_00012:
|
123
123
|
item_id: 6
|
@@ -128,7 +128,7 @@ checkout_00012:
|
|
128
128
|
librarian_id: 1
|
129
129
|
checkout_renewal_count: 1
|
130
130
|
due_date: <%= 180.days.ago.beginning_of_day %>
|
131
|
-
created_at: 2007-09-08 01:39:
|
131
|
+
created_at: 2007-09-08 01:39:12.210081 +09:00
|
132
132
|
basket_id: 8
|
133
133
|
checkin_id: 5
|
134
134
|
checkout_00013:
|
@@ -140,7 +140,7 @@ checkout_00013:
|
|
140
140
|
librarian_id: 1
|
141
141
|
checkout_renewal_count: 1
|
142
142
|
due_date: <%= 180.days.ago.beginning_of_day %>
|
143
|
-
created_at: 2007-09-08 01:39:
|
143
|
+
created_at: 2007-09-08 01:39:13.210081 +09:00
|
144
144
|
basket_id: 8
|
145
145
|
checkin_id: 4
|
146
146
|
# == Schema Information
|
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.70
|
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-07-
|
12
|
+
date: 2012-07-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -332,6 +332,7 @@ files:
|
|
332
332
|
- app/views/checkouts/_index_overdue.html.erb
|
333
333
|
- app/views/checkouts/_index_user.html.erb
|
334
334
|
- app/views/checkouts/_list.html.erb
|
335
|
+
- app/views/checkouts/_reserved_facet.html.erb
|
335
336
|
- app/views/checkouts/edit.html.erb
|
336
337
|
- app/views/checkouts/index.atom.builder
|
337
338
|
- app/views/checkouts/index.csv.erb
|