enju_circulation 0.1.0.pre40 → 0.1.0.pre41
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +8 -1
- data/app/controllers/checked_items_controller.rb +1 -1
- data/app/controllers/checkout_types_controller.rb +0 -7
- data/app/controllers/checkouts_controller.rb +1 -1
- data/app/controllers/manifestation_checkout_stats_controller.rb +22 -8
- data/app/controllers/reserves_controller.rb +17 -5
- data/app/models/carrier_type_has_checkout_type.rb +2 -3
- data/app/models/checked_item.rb +2 -3
- data/app/models/checkin.rb +2 -3
- data/app/models/checkout.rb +6 -2
- data/app/models/checkout_stat_has_manifestation.rb +2 -3
- data/app/models/checkout_stat_has_user.rb +2 -3
- data/app/models/checkout_type.rb +2 -3
- data/app/models/circulation_status.rb +2 -3
- data/app/models/item_has_use_restriction.rb +2 -3
- data/app/models/lending_policy.rb +2 -3
- data/app/models/manifestation_checkout_stat.rb +3 -3
- data/app/models/manifestation_checkout_stat_state_machine.rb +1 -1
- data/app/models/manifestation_checkout_stat_transition.rb +2 -2
- data/app/models/manifestation_reserve_stat.rb +3 -3
- data/app/models/manifestation_reserve_stat_transition.rb +2 -2
- data/app/models/reserve.rb +14 -11
- data/app/models/reserve_stat_has_manifestation.rb +2 -3
- data/app/models/reserve_stat_has_user.rb +2 -3
- data/app/models/reserve_transition.rb +2 -2
- data/app/models/use_restriction.rb +2 -3
- data/app/models/user_checkout_stat.rb +2 -2
- data/app/models/user_checkout_stat_transition.rb +2 -2
- data/app/models/user_group_has_checkout_type.rb +6 -7
- data/app/models/user_reserve_stat.rb +2 -2
- data/app/models/user_reserve_stat_transition.rb +2 -2
- data/app/views/checkouts/_list.html.erb +5 -0
- data/app/views/checkouts/index.rss.builder +3 -3
- data/app/views/manifestation_checkout_stats/_group_by_carrier_type.html.erb +53 -0
- data/app/views/manifestation_checkout_stats/_group_by_checkout_type.html.erb +54 -0
- data/app/views/manifestation_checkout_stats/show.html.erb +6 -38
- data/app/views/reserves/_new.html.erb +6 -1
- data/app/views/reserves/_new_user.html.erb +6 -1
- data/app/views/reserves/edit.html.erb +5 -0
- data/app/views/reserves/index.html.erb +2 -0
- data/app/views/reserves/index.rss.builder +2 -2
- data/app/views/reserves/show.html.erb +5 -0
- data/config/locales/translation_en.yml +2 -0
- data/config/locales/translation_ja.yml +2 -0
- data/db/migrate/20111129044509_add_pickup_location_to_reserve.rb +6 -0
- data/db/migrate/20140518050147_create_reserve_transitions.rb +5 -1
- data/db/migrate/20140528045518_create_user_checkout_stat_transitions.rb +5 -1
- data/db/migrate/20140528045539_create_user_reserve_stat_transitions.rb +5 -1
- data/db/migrate/20140528045600_create_manifestation_checkout_stat_transitions.rb +5 -1
- data/db/migrate/20140528045617_create_manifestation_reserve_stat_transitions.rb +5 -1
- data/db/migrate/20141014065831_add_shelf_id_to_checkout.rb +6 -0
- data/db/migrate/20141020120523_add_library_id_to_checkout.rb +6 -0
- data/lib/enju_circulation/accept.rb +22 -0
- data/lib/enju_circulation/basket.rb +37 -0
- data/lib/enju_circulation/item.rb +14 -8
- data/lib/enju_circulation/profile.rb +1 -1
- data/lib/enju_circulation/version.rb +1 -1
- data/lib/enju_circulation.rb +4 -0
- data/lib/tasks/checkout.rb +7 -0
- data/lib/tasks/enju_circulation_tasks.rake +10 -2
- data/spec/controllers/manifestation_checkout_stats_controller_spec.rb +2 -0
- data/spec/dummy/config/database.yml +23 -18
- data/spec/dummy/db/migrate/20140518111006_create_message_transitions.rb +5 -1
- data/spec/dummy/db/migrate/20140518135713_create_message_request_transitions.rb +5 -1
- data/spec/dummy/db/migrate/20140519170214_create_resource_import_file_transitions.rb +5 -1
- data/spec/dummy/db/migrate/20140519171220_create_import_request_transitions.rb +5 -1
- data/spec/dummy/db/migrate/20140524020735_create_agent_import_file_transitions.rb +5 -1
- data/spec/dummy/db/migrate/20140614141500_create_resource_export_file_transitions.rb +5 -1
- data/spec/dummy/db/schema.rb +561 -555
- data/spec/fixtures/carrier_type_has_checkout_types.yml +2 -3
- data/spec/fixtures/checked_items.yml +6 -7
- data/spec/fixtures/checkins.yml +2 -3
- data/spec/fixtures/checkout_stat_has_manifestations.yml +2 -3
- data/spec/fixtures/checkout_stat_has_users.yml +2 -3
- data/spec/fixtures/checkout_types.yml +2 -3
- data/spec/fixtures/checkouts.yml +17 -15
- data/spec/fixtures/circulation_statuses.yml +2 -3
- data/spec/fixtures/item_has_use_restrictions.yml +2 -3
- data/spec/fixtures/lending_policies.yml +2 -3
- data/spec/fixtures/manifestation_checkout_stats.yml +2 -2
- data/spec/fixtures/manifestation_reserve_stats.yml +2 -2
- data/spec/fixtures/manifestations.yml +114 -114
- data/spec/fixtures/reserve_stat_has_manifestations.yml +2 -3
- data/spec/fixtures/reserve_stat_has_users.yml +2 -3
- data/spec/fixtures/reserve_transitions.yml +2 -2
- data/spec/fixtures/reserves.yml +20 -19
- data/spec/fixtures/use_restrictions.yml +2 -3
- data/spec/fixtures/user_checkout_stats.yml +2 -2
- data/spec/fixtures/user_group_has_checkout_types.yml +2 -3
- data/spec/fixtures/user_reserve_stats.yml +2 -2
- data/spec/fixtures/users.yml +1 -1
- data/spec/models/basket_spec.rb +15 -2
- data/spec/models/carrier_type_has_checkout_type_spec.rb +2 -3
- data/spec/models/checked_item_spec.rb +2 -3
- data/spec/models/checkin_spec.rb +2 -3
- data/spec/models/checkout_spec.rb +4 -2
- data/spec/models/checkout_stat_has_manifestation_spec.rb +2 -3
- data/spec/models/checkout_stat_has_user_spec.rb +2 -3
- data/spec/models/checkout_type_spec.rb +2 -3
- data/spec/models/circulation_status_spec.rb +2 -3
- data/spec/models/lending_policy_spec.rb +2 -3
- data/spec/models/manifestation_checkout_stat_spec.rb +5 -4
- data/spec/models/manifestation_reserve_stat_spec.rb +2 -2
- data/spec/models/reserve_spec.rb +3 -2
- data/spec/models/reserve_stat_has_manifestation_spec.rb +2 -3
- data/spec/models/reserve_stat_has_user_spec.rb +2 -3
- data/spec/models/user_checkout_stat_spec.rb +2 -2
- data/spec/models/user_group_has_checkout_type_spec.rb +2 -3
- data/spec/models/user_reserve_stat_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -0
- metadata +44 -8
@@ -0,0 +1,53 @@
|
|
1
|
+
<table class="table table-striped index">
|
2
|
+
<tr>
|
3
|
+
<th>
|
4
|
+
<%= t('activerecord.models.library') %>
|
5
|
+
-
|
6
|
+
<%= t('activerecord.models.shelf') %>
|
7
|
+
</th>
|
8
|
+
<% CarrierType.order(:position).each do |carrier_type| %>
|
9
|
+
<th><%= carrier_type.display_name.localize %></th>
|
10
|
+
<% end %>
|
11
|
+
<th><%= t('page.total') %></th>
|
12
|
+
</tr>
|
13
|
+
<% (Shelf.order(:position) << nil).each do |shelf| %>
|
14
|
+
<tr>
|
15
|
+
<td>
|
16
|
+
<% if shelf %>
|
17
|
+
<strong>
|
18
|
+
<%= shelf.library.display_name.localize %>
|
19
|
+
-
|
20
|
+
<%= shelf.display_name.localize %>
|
21
|
+
</strong>
|
22
|
+
<% else %>
|
23
|
+
<strong><%= t('page.unknown') %></strong>
|
24
|
+
<% end %>
|
25
|
+
</td>
|
26
|
+
<% CarrierType.order(:position).each do |carrier_type| %>
|
27
|
+
<td>
|
28
|
+
<% if shelf %>
|
29
|
+
<%= @carrier_type_results[[shelf.id, carrier_type.id]] %>
|
30
|
+
<% else %>
|
31
|
+
<%= @carrier_type_results[[nil, carrier_type.id]] %>
|
32
|
+
<% end %>
|
33
|
+
</td>
|
34
|
+
<% end %>
|
35
|
+
<td>
|
36
|
+
<% if shelf %>
|
37
|
+
<%= @carrier_type_results.select{|r| r[0] == shelf.id}.sum{|k, v| v} %>
|
38
|
+
<% else %>
|
39
|
+
<%= @carrier_type_results.select{|r| r[0].nil?}.sum{|k, v| v} %>
|
40
|
+
<% end %>
|
41
|
+
</td>
|
42
|
+
</tr>
|
43
|
+
<% end %>
|
44
|
+
<tr>
|
45
|
+
<td><strong><%= t('page.total') %></strong></td>
|
46
|
+
<% CarrierType.order(:position).each do |carrier_type| %>
|
47
|
+
<td>
|
48
|
+
<%= @carrier_type_results.select{|r| r[1] == carrier_type.id}.sum{|k, v| v} %>
|
49
|
+
</td>
|
50
|
+
<% end %>
|
51
|
+
<td><%= @carrier_type_results.sum{|k, v| v} %></td>
|
52
|
+
</tr>
|
53
|
+
</table>
|
@@ -0,0 +1,54 @@
|
|
1
|
+
<table class="table table-striped index">
|
2
|
+
<tr>
|
3
|
+
<th>
|
4
|
+
<%= t('activerecord.models.library') %>
|
5
|
+
-
|
6
|
+
<%= t('activerecord.models.shelf') %>
|
7
|
+
</th>
|
8
|
+
<% CheckoutType.order(:position).each do |checkout_type| %>
|
9
|
+
<th><%= checkout_type.display_name.localize %></th>
|
10
|
+
<% end %>
|
11
|
+
<th><%= t('page.total') %></th>
|
12
|
+
</tr>
|
13
|
+
<% (Shelf.order(:position) << nil).each do |shelf| %>
|
14
|
+
<tr>
|
15
|
+
<td>
|
16
|
+
<% if shelf %>
|
17
|
+
<strong>
|
18
|
+
<%= shelf.library.display_name.localize %>
|
19
|
+
-
|
20
|
+
<%= shelf.display_name.localize %>
|
21
|
+
</strong>
|
22
|
+
<% else %>
|
23
|
+
<strong><%= t('page.unknown') %></strong>
|
24
|
+
<% end %>
|
25
|
+
</td>
|
26
|
+
<% CheckoutType.order(:position).each do |checkout_type| %>
|
27
|
+
<td>
|
28
|
+
<% if shelf %>
|
29
|
+
<%= @checkout_type_results[[shelf.id, checkout_type.id]] %>
|
30
|
+
<% else %>
|
31
|
+
<%= @checkout_type_results[[nil, checkout_type.id]] %>
|
32
|
+
<% end %>
|
33
|
+
</td>
|
34
|
+
<% end %>
|
35
|
+
<td>
|
36
|
+
<% if shelf %>
|
37
|
+
<%= @checkout_type_results.select{|r| r[0] == shelf.id}.sum{|k, v| v} %>
|
38
|
+
<% else %>
|
39
|
+
<%= @checkout_type_results.select{|r| r[0].nil?}.sum{|k, v| v} %>
|
40
|
+
<% end %>
|
41
|
+
</td>
|
42
|
+
</tr>
|
43
|
+
<% end %>
|
44
|
+
<tr>
|
45
|
+
<td><strong><%= t('page.total') %></strong></td>
|
46
|
+
<% CheckoutType.order(:position).each do |checkout_type| %>
|
47
|
+
<td>
|
48
|
+
<%= @checkout_type_results.select{|r| r[1] == checkout_type.id}.sum{|k, v| v} %>
|
49
|
+
</td>
|
50
|
+
<% end %>
|
51
|
+
<td><%= @checkout_type_results.sum{|k, v| v} %></td>
|
52
|
+
</tr>
|
53
|
+
</table>
|
54
|
+
|
@@ -26,48 +26,16 @@
|
|
26
26
|
<div id="tabs">
|
27
27
|
<ul>
|
28
28
|
<li title="active" class="selected"><a href="#tab1"><em><%= t('statistic.by_carrier_type') -%></em></a></li>
|
29
|
-
<li><a href="#tab2"><em><%= t('statistic.
|
29
|
+
<li><a href="#tab2"><em><%= t('statistic.by_checkout_type') -%></em></a></li>
|
30
|
+
<li><a href="#tab3"><em><%= t('statistic.by_manifestation') -%></em></a></li>
|
30
31
|
</ul>
|
31
32
|
<div id="tab1">
|
32
|
-
|
33
|
-
<tr>
|
34
|
-
<th></th>
|
35
|
-
<% CarrierType.order(:position).each do |carrier_type| %>
|
36
|
-
<th><%= carrier_type.display_name.localize %></th>
|
37
|
-
<% end %>
|
38
|
-
</tr>
|
39
|
-
<% Shelf.order(:library_id, :position).each do |shelf| %>
|
40
|
-
<tr>
|
41
|
-
<td><strong><%= shelf.display_name.localize %></strong></td>
|
42
|
-
<% results = Checkout.where(
|
43
|
-
Checkout.arel_table[:created_at].gteq @manifestation_checkout_stat.start_date
|
44
|
-
).where(
|
45
|
-
Checkout.arel_table[:created_at].lt @manifestation_checkout_stat.end_date
|
46
|
-
).joins(item: [:shelf, :manifestation]).group(:carrier_type_id).merge(
|
47
|
-
Manifestation.where(carrier_type_id: CarrierType.pluck(:id))
|
48
|
-
).merge(Shelf.where(id: shelf.id)).order('manifestations.carrier_type_id').count(:id) %>
|
49
|
-
<% CarrierType.order(:position).each do |carrier_type| %>
|
50
|
-
<td>
|
51
|
-
<% results.each do |carrier_type_id, count| %>
|
52
|
-
<%= count if carrier_type_id == carrier_type.id %>
|
53
|
-
<% end %>
|
54
|
-
</td>
|
55
|
-
<% end %>
|
56
|
-
</tr>
|
57
|
-
<% end %>
|
58
|
-
<tr>
|
59
|
-
<td><strong><%= t('page.total') %></strong></td>
|
60
|
-
<% CarrierType.order(:position).each do |carrier_type| %>
|
61
|
-
<td>
|
62
|
-
<% @breakdown.each do |carrier_type_id, count| %>
|
63
|
-
<%= count if carrier_type_id == carrier_type.id %>
|
64
|
-
<% end %>
|
65
|
-
</td>
|
66
|
-
<% end %>
|
67
|
-
</tr>
|
68
|
-
</table>
|
33
|
+
<%= render 'group_by_carrier_type' %>
|
69
34
|
</div>
|
70
35
|
<div id="tab2">
|
36
|
+
<%= render 'group_by_checkout_type' %>
|
37
|
+
</div>
|
38
|
+
<div id="tab3">
|
71
39
|
<div id="group_by_manifestation">
|
72
40
|
<%= render 'group_by_manifestation', stats: @stats %>
|
73
41
|
</div>
|
@@ -20,6 +20,11 @@
|
|
20
20
|
<%= f.text_field :expired_at, value: @reserve.expired_at.try(:strftime, "%Y-%m-%d"), class: 'date_field', placeholder: "#{t('page.example')}: 2011-04-12"-%>
|
21
21
|
</div>
|
22
22
|
|
23
|
+
<div class="field">
|
24
|
+
<%= f.label :pickup_location_id %>
|
25
|
+
<%= f.select :pickup_location_id, @libraries.map{|l| [l.display_name.localize, l.id]} %>
|
26
|
+
</div>
|
27
|
+
|
23
28
|
<% if current_user.has_role?('Librarian') %>
|
24
29
|
<div class="field">
|
25
30
|
<%= f.label t('activerecord.attributes.profile.user_number') -%><br />
|
@@ -42,7 +47,7 @@
|
|
42
47
|
<ul>
|
43
48
|
<li><%= link_to t('page.listing', model: t('activerecord.models.reserve')), reserves_path -%></li>
|
44
49
|
<%- if @reserve.manifestation -%>
|
45
|
-
<li><%= link_to t('page.showing', model: t('activerecord.models.manifestation')), @reserve.manifestation -%></li>
|
50
|
+
<li><%= link_to t('page.showing', model: t('activerecord.models.manifestation')), manifestation_path(@reserve.manifestation) -%></li>
|
46
51
|
<%- end -%>
|
47
52
|
</ul>
|
48
53
|
</div>
|
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
<div class="field">
|
24
24
|
<%= f.label t('activerecord.models.user') -%>
|
25
|
-
<%= link_to @reserve.user.username, @reserve.user.profile -%>
|
25
|
+
<%= link_to @reserve.user.username, profile_path(@reserve.user.profile) -%>
|
26
26
|
(<%= @reserve.user.profile.user_number %>)
|
27
27
|
<%= f.hidden_field :user_number, value: @user.profile.user_number -%>
|
28
28
|
</div>
|
@@ -32,6 +32,11 @@
|
|
32
32
|
<%= f.text_field :expired_at, value: @reserve.expired_at.try(:strftime, "%Y-%m-%d"), class: 'date_field', placeholder: "#{t('page.example')}: 2011-04-12"-%>
|
33
33
|
</div>
|
34
34
|
|
35
|
+
<div class="field">
|
36
|
+
<%= f.label :pickup_location_id %>
|
37
|
+
<%= f.select :pickup_location_id, @libraries.map{|l| [l.display_name.localize, l.id]} %>
|
38
|
+
</div>
|
39
|
+
|
35
40
|
<div class="actions">
|
36
41
|
<%= f.submit %>
|
37
42
|
</div>
|
@@ -33,6 +33,11 @@
|
|
33
33
|
<%= f.text_field :expired_at, value: @reserve.expired_at.try(:strftime, "%Y-%m-%d"), class: 'date_field', placeholder: "#{t('page.example')}: 2011-04-12"-%>
|
34
34
|
</div>
|
35
35
|
|
36
|
+
<div class="field">
|
37
|
+
<%= f.label :pickup_location_id %>
|
38
|
+
<%= f.select :pickup_location_id, @libraries.map{|l| [l.display_name.localize, l.id]} %>
|
39
|
+
</div>
|
40
|
+
|
36
41
|
<p>
|
37
42
|
<strong><%= t('activerecord.attributes.reserve.state') -%>:</strong>
|
38
43
|
<%= i18n_state(@reserve.current_state) -%>
|
@@ -50,6 +50,8 @@
|
|
50
50
|
<%= t('activerecord.attributes.reserve.created_at') %>: <%= l(reserve.created_at, format: :short) -%>
|
51
51
|
<br />
|
52
52
|
<%= t('activerecord.attributes.reserve.expired_at') %>: <%= l(reserve.expired_at, format: :short) -%>
|
53
|
+
<br />
|
54
|
+
<%= t('activerecord.attributes.reserve.pickup_location_id') %>: <%= link_to reserve.pickup_location.display_name.localize, reserve.pickup_location if reserve.pickup_location %>
|
53
55
|
</td>
|
54
56
|
<td>
|
55
57
|
<%= i18n_state(reserve.current_state) -%>
|
@@ -20,12 +20,12 @@ xml.rss('version' => "2.0",
|
|
20
20
|
xml.tag! "atom:link", rel: 'self', href: reserves_url(format: :rss)
|
21
21
|
xml.tag! "atom:link", rel: 'alternate', href: reserves_url
|
22
22
|
end
|
23
|
-
#xml.tag! "atom:link", rel: 'search', :
|
23
|
+
#xml.tag! "atom:link", rel: 'search', type: 'application/opensearchdescription+xml', href: "http://#{request.host_with_port}/page/opensearch"
|
24
24
|
unless params[:query].blank?
|
25
25
|
xml.tag! "opensearch:totalResults", @count[:query_result]
|
26
26
|
xml.tag! "opensearch:startIndex", @reserves.offset + 1
|
27
27
|
xml.tag! "opensearch:itemsPerPage", @reserves.per_page
|
28
|
-
#xml.tag! "opensearch:Query", :
|
28
|
+
#xml.tag! "opensearch:Query", role: 'request', searchTerms: params[:query], startPage: (params[:page] || 1)
|
29
29
|
end
|
30
30
|
@reserves.each do |reserve|
|
31
31
|
xml.item do
|
@@ -21,6 +21,11 @@
|
|
21
21
|
<%= i18n_state(@reserve.current_state) -%>
|
22
22
|
</p>
|
23
23
|
|
24
|
+
<p>
|
25
|
+
<strong><%= t('activerecord.attributes.reserve.pickup_location_id') -%>:</strong>
|
26
|
+
<%= link_to @reserve.pickup_location.display_name.localize, @reserve.pickup_location if @reserve.pickup_location -%>
|
27
|
+
</p>
|
28
|
+
|
24
29
|
<p>
|
25
30
|
<strong><%= t('activerecord.attributes.item.item_identifier') -%>:</strong>
|
26
31
|
<%= link_to @reserve.item.item_identifier, @reserve.item if @reserve.item -%>
|
@@ -48,6 +48,7 @@ en:
|
|
48
48
|
state: State
|
49
49
|
force_retaining: Force retaining
|
50
50
|
item_identifier: Item identifier
|
51
|
+
pickup_location_id: Pickup location
|
51
52
|
checkout_type:
|
52
53
|
name: Name
|
53
54
|
display_name: Display name
|
@@ -196,4 +197,5 @@ en:
|
|
196
197
|
successfully_created: "%{model} task was created successfully. When the task is completed, its status on the list will be updated to 'completed' and you can check the results by following the 'show' link."
|
197
198
|
breakdown: Brakedown
|
198
199
|
by_carrier_type: By carrier type
|
200
|
+
by_checkout_type: By checkout type
|
199
201
|
by_manifestation: By manifestation
|
@@ -46,6 +46,7 @@ ja:
|
|
46
46
|
state: 状態
|
47
47
|
force_retaining: 強制的に取り置きを行う
|
48
48
|
item_identifier: 個別資料ID
|
49
|
+
pickup_location_id: 受取館
|
49
50
|
checkout_type:
|
50
51
|
name: 名前
|
51
52
|
display_name: 表示名
|
@@ -194,4 +195,5 @@ ja:
|
|
194
195
|
successfully_created: "%{model}のタスクは正常に作成されました。タスクが完了すると「%{model}の一覧」の状態が「完了」となり、「表示」リンクをたどることで結果を確認できるようになります。"
|
195
196
|
breakdown: 内訳
|
196
197
|
by_carrier_type: 資料の形態別
|
198
|
+
by_checkout_type: 貸出区分別
|
197
199
|
by_manifestation: 書誌別
|
@@ -2,7 +2,11 @@ class CreateReserveTransitions < ActiveRecord::Migration
|
|
2
2
|
def change
|
3
3
|
create_table :reserve_transitions do |t|
|
4
4
|
t.string :to_state
|
5
|
-
|
5
|
+
if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
|
6
|
+
t.text :metadata
|
7
|
+
else
|
8
|
+
t.text :metadata, default: "{}"
|
9
|
+
end
|
6
10
|
t.integer :sort_key
|
7
11
|
t.integer :reserve_id
|
8
12
|
t.timestamps
|
@@ -2,7 +2,11 @@ class CreateUserCheckoutStatTransitions < ActiveRecord::Migration
|
|
2
2
|
def change
|
3
3
|
create_table :user_checkout_stat_transitions do |t|
|
4
4
|
t.string :to_state
|
5
|
-
|
5
|
+
if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
|
6
|
+
t.text :metadata
|
7
|
+
else
|
8
|
+
t.text :metadata, default: "{}"
|
9
|
+
end
|
6
10
|
t.integer :sort_key
|
7
11
|
t.integer :user_checkout_stat_id
|
8
12
|
t.timestamps
|
@@ -2,7 +2,11 @@ class CreateUserReserveStatTransitions < ActiveRecord::Migration
|
|
2
2
|
def change
|
3
3
|
create_table :user_reserve_stat_transitions do |t|
|
4
4
|
t.string :to_state
|
5
|
-
|
5
|
+
if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
|
6
|
+
t.text :metadata
|
7
|
+
else
|
8
|
+
t.text :metadata, default: "{}"
|
9
|
+
end
|
6
10
|
t.integer :sort_key
|
7
11
|
t.integer :user_reserve_stat_id
|
8
12
|
t.timestamps
|
@@ -2,7 +2,11 @@ class CreateManifestationCheckoutStatTransitions < ActiveRecord::Migration
|
|
2
2
|
def change
|
3
3
|
create_table :manifestation_checkout_stat_transitions do |t|
|
4
4
|
t.string :to_state
|
5
|
-
|
5
|
+
if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
|
6
|
+
t.text :metadata
|
7
|
+
else
|
8
|
+
t.text :metadata, default: "{}"
|
9
|
+
end
|
6
10
|
t.integer :sort_key
|
7
11
|
t.integer :manifestation_checkout_stat_id
|
8
12
|
t.timestamps
|
@@ -2,7 +2,11 @@ class CreateManifestationReserveStatTransitions < ActiveRecord::Migration
|
|
2
2
|
def change
|
3
3
|
create_table :manifestation_reserve_stat_transitions do |t|
|
4
4
|
t.string :to_state
|
5
|
-
|
5
|
+
if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
|
6
|
+
t.text :metadata
|
7
|
+
else
|
8
|
+
t.text :metadata, default: "{}"
|
9
|
+
end
|
6
10
|
t.integer :sort_key
|
7
11
|
t.integer :manifestation_reserve_stat_id
|
8
12
|
t.timestamps
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module EnjuCirculation
|
2
|
+
module EnjuAccept
|
3
|
+
def self.included(base)
|
4
|
+
base.extend ClassMethods
|
5
|
+
end
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
def enju_circulation_accept_model
|
9
|
+
include InstanceMethods
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module InstanceMethods
|
14
|
+
def accept!
|
15
|
+
circulation_status = CirculationStatus.where(name: 'Available On Shelf').first
|
16
|
+
item.update_column(:circulation_status_id, circulation_status.id) if circulation_status
|
17
|
+
use_restriction = UseRestriction.where(name: 'Limited Circulation, Normal Loan Period').first
|
18
|
+
item.use_restriction = use_restriction if use_restriction
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,37 @@
|
|
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
|
@@ -90,17 +90,17 @@ module EnjuCirculation
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def checkout!(user)
|
93
|
-
self.circulation_status = CirculationStatus.where(:
|
94
|
-
if
|
95
|
-
manifestation.next_reservation.update_attributes(:
|
93
|
+
self.circulation_status = CirculationStatus.where(name: 'On Loan').first
|
94
|
+
if reserved_by_user?(user)
|
95
|
+
manifestation.next_reservation.update_attributes(checked_out_at: Time.zone.now)
|
96
96
|
manifestation.next_reservation.sm_complete!
|
97
97
|
end
|
98
98
|
save!
|
99
99
|
end
|
100
100
|
|
101
101
|
def checkin!
|
102
|
-
self.circulation_status = CirculationStatus.where(:
|
103
|
-
save(:
|
102
|
+
self.circulation_status = CirculationStatus.where(name: 'Available On Shelf').first
|
103
|
+
save(validate: false)
|
104
104
|
end
|
105
105
|
|
106
106
|
def retain(librarian)
|
@@ -123,16 +123,22 @@ module EnjuCirculation
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def lending_rule(user)
|
126
|
-
lending_policies.where(:
|
126
|
+
lending_policies.where(user_group_id: user.profile.user_group.id).first
|
127
127
|
end
|
128
128
|
|
129
129
|
def not_for_loan?
|
130
130
|
!manifestation.items.for_checkout.include?(self)
|
131
131
|
end
|
132
132
|
|
133
|
-
|
133
|
+
def create_lending_policy
|
134
134
|
UserGroupHasCheckoutType.available_for_item(self).each do |rule|
|
135
|
-
LendingPolicy.create!(
|
135
|
+
LendingPolicy.create!(
|
136
|
+
item_id: id,
|
137
|
+
user_group_id: rule.user_group_id,
|
138
|
+
fixed_due_date: rule.fixed_due_date,
|
139
|
+
loan_period: rule.checkout_period,
|
140
|
+
renewal: rule.checkout_renewal_limit
|
141
|
+
)
|
136
142
|
end
|
137
143
|
end
|
138
144
|
|
data/lib/enju_circulation.rb
CHANGED
@@ -4,6 +4,8 @@ require "enju_circulation/item"
|
|
4
4
|
require "enju_circulation/user"
|
5
5
|
require "enju_circulation/user_group"
|
6
6
|
require "enju_circulation/profile"
|
7
|
+
require "enju_circulation/accept"
|
8
|
+
require "enju_circulation/basket"
|
7
9
|
require "enju_circulation/controller"
|
8
10
|
require "enju_circulation/helper"
|
9
11
|
|
@@ -16,4 +18,6 @@ ActiveRecord::Base.send :include, EnjuCirculation::EnjuItem
|
|
16
18
|
ActiveRecord::Base.send :include, EnjuCirculation::EnjuUser
|
17
19
|
ActiveRecord::Base.send :include, EnjuCirculation::EnjuUserGroup
|
18
20
|
ActiveRecord::Base.send :include, EnjuCirculation::EnjuProfile
|
21
|
+
ActiveRecord::Base.send :include, EnjuCirculation::EnjuAccept
|
22
|
+
ActiveRecord::Base.send :include, EnjuCirculation::EnjuBasket
|
19
23
|
ActionView::Base.send :include, EnjuCirculation::ManifestationsHelper
|
@@ -0,0 +1,7 @@
|
|
1
|
+
def update_checkout
|
2
|
+
Checkout.find_each do |checkout|
|
3
|
+
checkout.update_column(:shelf_id, checkout.item.try(:shelf_id)) if checkout.shelf_id.nil?
|
4
|
+
checkout.update_column(:library_id, checkout.librarian.try(:profile).try(:library_id)) if checkout.library_id.nil?
|
5
|
+
|
6
|
+
end
|
7
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'active_record/fixtures'
|
2
|
-
require 'tasks/
|
2
|
+
require 'tasks/checkout'
|
3
3
|
require 'tasks/circulation_status'
|
4
|
+
require 'tasks/reserve'
|
4
5
|
require 'tasks/use_restriction'
|
5
6
|
|
6
7
|
namespace :enju_circulation do
|
@@ -20,7 +21,7 @@ namespace :enju_circulation do
|
|
20
21
|
task :stat => :environment do
|
21
22
|
UserCheckoutStat.calculate_stat
|
22
23
|
UserReserveStat.calculate_stat
|
23
|
-
ManifestationCheckoutStat.calculate_stat
|
24
|
+
#ManifestationCheckoutStat.calculate_stat
|
24
25
|
ManifestationReserveStat.calculate_stat
|
25
26
|
end
|
26
27
|
|
@@ -45,4 +46,11 @@ namespace :enju_circulation do
|
|
45
46
|
end
|
46
47
|
puts 'enju_circulation: The upgrade completed successfully.'
|
47
48
|
end
|
49
|
+
|
50
|
+
desc "migrate old checkout records"
|
51
|
+
task :migrate_old_checkout => :environment do
|
52
|
+
Checkout.transaction do
|
53
|
+
update_checkout
|
54
|
+
end
|
55
|
+
end
|
48
56
|
end
|
@@ -174,6 +174,7 @@ describe ManifestationCheckoutStatsController do
|
|
174
174
|
it "assigns a newly created manifestation_checkout_stat as @manifestation_checkout_stat" do
|
175
175
|
post :create, :manifestation_checkout_stat => @attrs
|
176
176
|
assigns(:manifestation_checkout_stat).should be_valid
|
177
|
+
assigns(:manifestation_checkout_stat).current_state.should eq 'completed'
|
177
178
|
end
|
178
179
|
|
179
180
|
it "redirects to the created manifestation_checkout_stat" do
|
@@ -186,6 +187,7 @@ describe ManifestationCheckoutStatsController do
|
|
186
187
|
it "assigns a newly created but unsaved manifestation_checkout_stat as @manifestation_checkout_stat" do
|
187
188
|
post :create, :manifestation_checkout_stat => @invalid_attrs
|
188
189
|
assigns(:manifestation_checkout_stat).should_not be_valid
|
190
|
+
assigns(:manifestation_checkout_stat).current_state.should eq 'pending'
|
189
191
|
end
|
190
192
|
|
191
193
|
it "re-renders the 'new' template" do
|
@@ -1,25 +1,30 @@
|
|
1
|
-
|
2
|
-
# gem install sqlite3
|
3
|
-
#
|
4
|
-
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
-
# gem 'sqlite3'
|
6
|
-
development:
|
1
|
+
sqlite: &sqlite
|
7
2
|
adapter: sqlite3
|
8
|
-
database: db
|
3
|
+
database: db/<%= Rails.env %>.sqlite3
|
4
|
+
|
5
|
+
mysql: &mysql
|
6
|
+
adapter: mysql2
|
7
|
+
username: root
|
8
|
+
password:
|
9
|
+
database: enju_<%= Rails.env %>
|
10
|
+
|
11
|
+
postgresql: &postgresql
|
12
|
+
adapter: postgresql
|
13
|
+
username: postgres
|
14
|
+
password:
|
15
|
+
database: enju_<%= Rails.env %>
|
16
|
+
|
17
|
+
defaults: &defaults
|
9
18
|
pool: 5
|
10
19
|
timeout: 5000
|
20
|
+
host: localhost
|
21
|
+
<<: *<%= ENV['DB'] || "sqlite" %>
|
22
|
+
|
23
|
+
development:
|
24
|
+
<<: *defaults
|
11
25
|
|
12
|
-
# Warning: The database defined as "test" will be erased and
|
13
|
-
# re-generated from your development database when you run "rake".
|
14
|
-
# Do not set this db to the same as development or production.
|
15
26
|
test:
|
16
|
-
|
17
|
-
database: db/test.sqlite3
|
18
|
-
pool: 5
|
19
|
-
timeout: 5000
|
27
|
+
<<: *defaults
|
20
28
|
|
21
29
|
production:
|
22
|
-
|
23
|
-
database: db/production.sqlite3
|
24
|
-
pool: 5
|
25
|
-
timeout: 5000
|
30
|
+
<<: *defaults
|
@@ -2,7 +2,11 @@ class CreateMessageTransitions < ActiveRecord::Migration
|
|
2
2
|
def change
|
3
3
|
create_table :message_transitions do |t|
|
4
4
|
t.string :to_state
|
5
|
-
|
5
|
+
if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
|
6
|
+
t.text :metadata
|
7
|
+
else
|
8
|
+
t.text :metadata, default: "{}"
|
9
|
+
end
|
6
10
|
t.integer :sort_key
|
7
11
|
t.integer :message_id
|
8
12
|
t.timestamps
|