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
@@ -0,0 +1,21 @@
1
+ class ItemHasUseRestrictionPolicy < ApplicationPolicy
2
+ def index?
3
+ user.try(:has_role?, 'Librarian')
4
+ end
5
+
6
+ def show?
7
+ user.try(:has_role?, 'Librarian')
8
+ end
9
+
10
+ def create?
11
+ user.try(:has_role?, 'Administrator')
12
+ end
13
+
14
+ def update?
15
+ user.try(:has_role?, 'Administrator')
16
+ end
17
+
18
+ def destroy?
19
+ user.try(:has_role?, 'Administrator')
20
+ end
21
+ end
@@ -0,0 +1,27 @@
1
+ class ItemPolicy < ApplicationPolicy
2
+ def index?
3
+ true
4
+ end
5
+
6
+ def show?
7
+ true
8
+ end
9
+
10
+ def create?
11
+ true if user.try(:has_role?, 'Librarian')
12
+ end
13
+
14
+ def edit?
15
+ true if user.try(:has_role?, 'Librarian')
16
+ end
17
+
18
+ def update?
19
+ true if user.try(:has_role?, 'Librarian')
20
+ end
21
+
22
+ def destroy?
23
+ if user.try(:has_role?, 'Librarian')
24
+ record.removable?
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,21 @@
1
+ class LendingPolicyPolicy < ApplicationPolicy
2
+ def index?
3
+ user.try(:has_role?, 'Librarian')
4
+ end
5
+
6
+ def show?
7
+ user.try(:has_role?, 'Librarian')
8
+ end
9
+
10
+ def create?
11
+ false
12
+ end
13
+
14
+ def update?
15
+ user.try(:has_role?, 'Administrator')
16
+ end
17
+
18
+ def destroy?
19
+ user.try(:has_role?, 'Administrator')
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ class ManifestationCheckoutStatPolicy < ApplicationPolicy
2
+ def index?
3
+ true
4
+ end
5
+
6
+ def show?
7
+ true
8
+ end
9
+
10
+ def create?
11
+ user.try(:has_role?, 'Librarian')
12
+ end
13
+
14
+ def update?
15
+ user.try(:has_role?, 'Librarian')
16
+ end
17
+
18
+ def destroy?
19
+ user.try(:has_role?, 'Librarian')
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ class ManifestationReserveStatPolicy < ApplicationPolicy
2
+ def index?
3
+ true
4
+ end
5
+
6
+ def show?
7
+ true
8
+ end
9
+
10
+ def create?
11
+ user.try(:has_role?, 'Librarian')
12
+ end
13
+
14
+ def update?
15
+ user.try(:has_role?, 'Librarian')
16
+ end
17
+
18
+ def destroy?
19
+ user.try(:has_role?, 'Librarian')
20
+ end
21
+ end
@@ -0,0 +1,37 @@
1
+ class ReservePolicy < ApplicationPolicy
2
+ def index?
3
+ user.try(:has_role?, 'User')
4
+ end
5
+
6
+ def show?
7
+ if user.try(:has_role?, 'Librarian')
8
+ true
9
+ elsif user and user == record.user
10
+ true
11
+ end
12
+ end
13
+
14
+ def create?
15
+ if user.try(:has_role?, 'Librarian')
16
+ true
17
+ elsif user.try(:has_role?, 'User')
18
+ true if user.profile.user_number.try(:present?)
19
+ end
20
+ end
21
+
22
+ def update?
23
+ if user.try(:has_role?, 'Librarian')
24
+ true
25
+ elsif user and user == record.user
26
+ true
27
+ end
28
+ end
29
+
30
+ def destroy?
31
+ if user.try(:has_role?, 'Librarian')
32
+ true
33
+ elsif user and user == record.user
34
+ true
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,23 @@
1
+ class UseRestrictionPolicy < ApplicationPolicy
2
+ def index?
3
+ true if user.try(:has_role?, 'Librarian')
4
+ end
5
+
6
+ def show?
7
+ true if user.try(:has_role?, 'Librarian')
8
+ end
9
+
10
+ def create?
11
+ false
12
+ end
13
+
14
+ def update?
15
+ if user.try(:has_role?, 'Administrator')
16
+ true
17
+ end
18
+ end
19
+
20
+ def destroy?
21
+ false
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ class UserCheckoutStatPolicy < ApplicationPolicy
2
+ def index?
3
+ user.try(:has_role?, 'Librarian')
4
+ end
5
+
6
+ def show?
7
+ user.try(:has_role?, 'Librarian')
8
+ end
9
+
10
+ def create?
11
+ user.try(:has_role?, 'Librarian')
12
+ end
13
+
14
+ def update?
15
+ user.try(:has_role?, 'Librarian')
16
+ end
17
+
18
+ def destroy?
19
+ user.try(:has_role?, 'Administrator')
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ class UserGroupHasCheckoutTypePolicy < ApplicationPolicy
2
+ def index?
3
+ user.try(:has_role?, 'Librarian')
4
+ end
5
+
6
+ def show?
7
+ user.try(:has_role?, 'Librarian')
8
+ end
9
+
10
+ def create?
11
+ user.try(:has_role?, 'Administrator')
12
+ end
13
+
14
+ def update?
15
+ user.try(:has_role?, 'Administrator')
16
+ end
17
+
18
+ def destroy?
19
+ user.try(:has_role?, 'Administrator')
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ class UserReserveStatPolicy < ApplicationPolicy
2
+ def index?
3
+ user.try(:has_role?, 'Librarian')
4
+ end
5
+
6
+ def show?
7
+ user.try(:has_role?, 'Librarian')
8
+ end
9
+
10
+ def create?
11
+ user.try(:has_role?, 'Librarian')
12
+ end
13
+
14
+ def update?
15
+ user.try(:has_role?, 'Librarian')
16
+ end
17
+
18
+ def destroy?
19
+ user.try(:has_role?, 'Administrator')
20
+ end
21
+ end
@@ -17,10 +17,10 @@
17
17
  <td><%= carrier_type_has_checkout_type.note -%></td>
18
18
  <td>
19
19
  <%= link_to t('page.show'), carrier_type_has_checkout_type -%>
20
- <%- if can? :update, carrier_type_has_checkout_type -%>
20
+ <%- if policy(carrier_type_has_checkout_type).update? -%>
21
21
  <%= link_to t('page.edit'), edit_carrier_type_has_checkout_type_path(carrier_type_has_checkout_type) -%>
22
22
  <% end %>
23
- <%- if can? :delete, carrier_type_has_checkout_type -%>
23
+ <%- if policy(carrier_type_has_checkout_type).destroy? -%>
24
24
  <%= link_to t('page.destroy'), carrier_type_has_checkout_type, data: {confirm: t('page.are_you_sure')}, method: :delete -%>
25
25
  <% end %>
26
26
  </td>
@@ -33,7 +33,7 @@
33
33
 
34
34
  <div id="submenu" class="ui-corner-all ui-widget-content">
35
35
  <ul>
36
- <%- if can? :create, CarrierTypeHasCheckoutType -%>
36
+ <%- if policy(CarrierTypeHasCheckoutType).create? -%>
37
37
  <li><%= link_to t('page.new', model: t('activerecord.models.carrier_type_has_checkout_type')), new_carrier_type_has_checkout_type_path -%></li>
38
38
  <% end %>
39
39
  </ul>
@@ -23,7 +23,7 @@
23
23
 
24
24
  <div id="submenu" class="ui-corner-all ui-widget-content">
25
25
  <ul>
26
- <% if can?(:update, @carrier_type_has_checkout_type) %>
26
+ <% if policy(@carrier_type_has_checkout_type).update? %>
27
27
  <li><%= link_to t('page.edit'), edit_carrier_type_has_checkout_type_path(@carrier_type_has_checkout_type) -%></li>
28
28
  <% end %>
29
29
  <li><%= back_to_index(flash[:page_info]) -%></li>
@@ -0,0 +1,5 @@
1
+ <div class="nested-fields">
2
+ <%= f.label :checkout_type_id -%>
3
+ <%= f.select(:checkout_type_id, @checkout_types.collect{|c| [c.display_name.localize, c.id]}) %>
4
+ <%= f.link_to_remove t('page.remove'), data: {confirm: t('page.are_you_sure')} %>
5
+ </div>
@@ -1,9 +1,7 @@
1
1
  <div class="field">
2
2
  <%= f.label t('activerecord.models.carrier_type_has_checkout_type') %><br />
3
3
  <%= f.fields_for :carrier_type_has_checkout_types do |checkout_form| %>
4
- <%= checkout_form.label :checkout_type_id -%>
5
- <%= checkout_form.select(:checkout_type_id, @checkout_types.collect{|c| [c.display_name.localize, c.id]}) %>
6
- <%= checkout_form.link_to_remove t('page.remove'), confirm: t('page.are_you_sure') %>
4
+ <%= render 'carrier_type_has_checkout_type_fields', f: checkout_form %>
7
5
  <% end %>
8
- <p><%= f.link_to_add t('page.add'), :carrier_type_has_checkout_types %></p>
6
+ <p><%= link_to_add_association t('page.add'), f, :carrier_type_has_checkout_types %></p>
9
7
  </div>
@@ -17,7 +17,7 @@
17
17
  <%- @checkout_types.each do |checkout_type| -%>
18
18
  <tr class="line<%= cycle("0", "1") -%>">
19
19
  <td>
20
- <%- if can? :update, checkout_type -%>
20
+ <%- if policy(checkout_type).update? -%>
21
21
  <%= move_position(checkout_type) -%>
22
22
  <%- end -%>
23
23
  </td>
@@ -28,10 +28,10 @@
28
28
  <%= checkout_type.note %>
29
29
  </td>
30
30
  <td>
31
- <%- if can? :update, checkout_type -%>
31
+ <%- if policy(checkout_type).update? -%>
32
32
  <%= link_to t('page.edit'), edit_checkout_type_path(checkout_type) -%>
33
33
  <% end %>
34
- <%- if can? :delete, checkout_type -%>
34
+ <%- if policy(checkout_type).destroy? -%>
35
35
  <%= link_to t('page.destroy'), checkout_type_path(checkout_type), data: {confirm: t('page.are_you_sure')}, method: :delete -%>
36
36
  <%- end -%>
37
37
  </td>
@@ -44,7 +44,7 @@
44
44
 
45
45
  <div id="submenu" class="ui-corner-all ui-widget-content">
46
46
  <ul>
47
- <%- if can? :create, CheckoutType -%>
47
+ <%- if policy(CheckoutType).create? -%>
48
48
  <li><%= link_to t('page.new', model: t('activerecord.models.checkout_type')), new_checkout_type_path -%></li>
49
49
  <%- end -%>
50
50
  </ul>
@@ -31,11 +31,11 @@
31
31
 
32
32
  <div id="submenu" class="ui-corner-all ui-widget-content">
33
33
  <ul>
34
- <%- if can? :update, @checkout_type -%>
34
+ <%- if policy(@checkout_type).update? -%>
35
35
  <li><%= link_to t('page.edit'), edit_checkout_type_path(@checkout_type) -%></li>
36
36
  <%- end -%>
37
37
  <li><%= back_to_index(flash[:page_info]) -%></li>
38
- <%- if can? :create, UserGroupHasCheckoutType -%>
38
+ <%- if policy(UserGroupHasCheckoutType).create? -%>
39
39
  <li><%= link_to t('page.new', model: t('activerecord.models.user_group_has_checkout_type')), new_checkout_type_user_group_has_checkout_type_path(@checkout_type) -%></li>
40
40
  <%- end -%>
41
41
  </ul>
@@ -14,7 +14,7 @@
14
14
  <div id="submenu" class="ui-corner-all ui-widget-content">
15
15
  <ul>
16
16
  <li><%= link_to t('checkout.my_checkout'), checkouts_path(user_id: current_user.username) -%></li>
17
- <li><%= link_to t('page.overdue'), checkouts_path(view: 'overdue') -%></li>
17
+ <li><%= link_to t('page.overdue'), checkouts_path(days_overdue: 1) -%></li>
18
18
  </ul>
19
19
  <%= render 'reserved_facet' %>
20
20
  <h4><%= t('page.other_format') %></h4>
@@ -6,7 +6,6 @@
6
6
  <p>
7
7
  <%= t('checkout.number_of_day_overdue') -%>:
8
8
  <%= text_field_tag 'days_overdue', h(@days_overdue), class: 'resource_integer' -%>
9
- <%= hidden_field_tag 'view', 'overdue' -%>
10
9
  <%= submit_tag t('page.search') -%>
11
10
  </p>
12
11
  <%- end -%>
@@ -28,12 +27,12 @@
28
27
  <h4><%= t('page.other_format') %></h4>
29
28
  <ul>
30
29
  <li>
31
- <%= link_to 'RSS', checkouts_path(format: :rss, view: 'overdue') -%>
32
- <%= link_to (image_tag 'icons/feed.png', size: '16x16', alt: 'RSS', class: 'icon'), checkouts_path(format: :rss, view: 'overdue') -%>
30
+ <%= link_to 'RSS', checkouts_path(format: :rss, days_overdue: 1) -%>
31
+ <%= link_to (image_tag 'icons/feed.png', size: '16x16', alt: 'RSS', class: 'icon'), checkouts_path(format: :rss, days_overdue: 1) -%>
33
32
  </li>
34
33
  <li>
35
- <%= link_to 'TSV', checkouts_path(format: :txt, view: 'overdue', locale: @locale.to_s) -%>
36
- <%= link_to (image_tag 'icons/page_white_excel.png', size: '16x16', alt: 'TSV', class: 'icon'), checkouts_path(format: :txt, view: 'overdue', locale: @locale.to_s) -%>
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', alt: 'TSV', class: 'icon'), checkouts_path(format: :txt, days_overdue: 1, locale: @locale.to_s) -%>
37
36
  </li>
38
37
  </ul>
39
38
  </div>
@@ -33,14 +33,14 @@
33
33
  <%= link_to (image_tag 'icons/date.png', size: '16x16', alt: 'iCalendar', class: 'icon'), checkouts_path(user_id: user.username, format: :ics) -%>
34
34
  </li>
35
35
  <% end %>
36
- <%- if params[:view] == 'overdue' -%>
36
+ <%- if params[:days_overdue].present? -%>
37
37
  <li>
38
- <%= link_to 'RSS', checkouts_path(user_id: user.username, format: :rss, view: 'overdue') -%>
39
- <%= link_to (image_tag 'icons/feed.png', size: '16x16', alt: 'RSS', class: 'icon'), checkouts_path(user_id: user.username, format: :rss, view: 'overdue') -%>
38
+ <%= link_to 'RSS', checkouts_path(user_id: user.username, format: :rss, days_overdue: 1) -%>
39
+ <%= link_to (image_tag 'icons/feed.png', size: '16x16', alt: 'RSS', class: 'icon'), checkouts_path(user_id: user.username, format: :rss, days_overdue: 1) -%>
40
40
  </li>
41
41
  <li>
42
- <%= link_to 'TSV', checkouts_path(user_id: user.username, format: :txt, view: 'overdue', locale: @locale.to_s) -%>
43
- <%= link_to (image_tag 'icons/page_white_excel.png', size: '16x16', alt: 'TSV', class: 'icon'), checkouts_path(user_id: user.username, format: :txt, view: 'overdue', locale: @locale.to_s) -%>
42
+ <%= link_to 'TSV', checkouts_path(user_id: user.username, format: :txt, days_overdue: 1, locale: @locale.to_s) -%>
43
+ <%= link_to (image_tag 'icons/page_white_excel.png', size: '16x16', alt: 'TSV', class: 'icon'), checkouts_path(user_id: user.username, format: :txt, days_overdue: 1, locale: @locale.to_s) -%>
44
44
  </li>
45
45
  <%- else -%>
46
46
  <li>
@@ -34,12 +34,12 @@
34
34
  <% end %>
35
35
  </td>
36
36
  <td>
37
- <%- if can? :update, checkout -%>
37
+ <%- if policy(checkout).update? -%>
38
38
  <% unless checkout.checkin %>
39
39
  <%= link_to t('checkout.extend'), edit_checkout_path(checkout) -%>
40
40
  <% end %>
41
41
  <%- end -%>
42
- <%- if can? :delete, checkout -%>
42
+ <%- if policy(checkout).destroy? -%>
43
43
  <%= link_to t('page.destroy'), checkout, data: {confirm: t('page.are_you_sure')}, method: :delete -%>
44
44
  <%- end -%>
45
45
  </td>
@@ -4,11 +4,11 @@
4
4
  <% facet.value ? facet_reserved = true : facet_reserved = false %>
5
5
  <li>
6
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)) -%>
7
+ <%= link_to "#{localized_boolean(facet.value)} (#{facet.count})", url_for(params.permit.merge(page: nil, reserved: facet.value.to_s, view: nil, only_path: true)) -%>
8
8
  <%- if @reserved == facet_reserved -%></strong><%- end -%>
9
9
  </li>
10
10
  <%- end -%>
11
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>
12
+ <li><%= link_to t('page.remove_this_facet'), url_for(params.permit.merge(reserved: nil, page: nil, view: nil, only_path: true)) -%></li>
13
13
  <%- end -%>
14
14
  </ul>
@@ -45,7 +45,7 @@
45
45
  <ul>
46
46
  <li><%= link_to t('page.show'), @checkout -%></li>
47
47
  <% if @checkout.user %>
48
- <li><%= link_to t('page.back'), checkouts_path(user_id: @checkout.user.username) -%></li>
48
+ <li><%= link_to t('page.back'), :back -%></li>
49
49
  <% end %>
50
50
  </ul>
51
51
  </div>
@@ -4,14 +4,14 @@
4
4
  <% elsif @item %>
5
5
  <%= render 'index_item', item: @item -%>
6
6
  <% else %>
7
- <%- if params[:view] == 'overdue' -%>
7
+ <%- if params[:days_overdue].present? -%>
8
8
  <%= render 'index_overdue' -%>
9
9
  <%- else -%>
10
10
  <%= render 'index' -%>
11
11
  <% end %>
12
12
  <% end %>
13
13
  <% else %>
14
- <%- if params[:view] == 'overdue' -%>
14
+ <%- if params[:days_overdue].present? -%>
15
15
  <%= render 'index_overdue' -%>
16
16
  <%- else -%>
17
17
  <%= render 'index_user', user: current_user -%>
@@ -6,12 +6,12 @@ xml.rss('version' => "2.0",
6
6
  if @user
7
7
  xml.title t('checkout.user_checkout', login_name: @user.username)
8
8
  xml.link checkouts_url(user_id: @user.username)
9
- xml.tag! "atom:link", rel: 'self', href: "#{request.protocol}#{request.host_with_port}#{url_for(params.merge(format: :rss, only_path: true))}"
9
+ xml.tag! "atom:link", rel: 'self', href: "#{request.protocol}#{request.host_with_port}#{url_for(params.permit.merge(format: :rss, only_path: true))}"
10
10
  xml.tag! "atom:link", rel: 'alternate', href: checkouts_url(user_id: @user.username)
11
11
  else
12
12
  xml.title t('checkout.library_group_checkout', library_group_name: @library_group.display_name.localize)
13
13
  xml.link checkouts_url
14
- xml.tag! "atom:link", rel: 'self', href: "#{request.protocol}#{request.host_with_port}#{url_for(params.merge(format: :rss, only_path: true))}"
14
+ xml.tag! "atom:link", rel: 'self', href: "#{request.protocol}#{request.host_with_port}#{url_for(params.permit.merge(format: :rss, only_path: true))}"
15
15
  xml.tag! "atom:link", rel: 'alternate', href: checkouts_url
16
16
  end
17
17
  xml.description "Next-L Enju, an open source integrated library system developed by Project Next-L"
@@ -1,4 +1,4 @@
1
- <%- if params[:view] == 'overdue' -%><%= 'Overdue items' -%><%- else -%><%= 'Checkout items' -%><%- end -%> (created_at: <%= Time.now -%>)<%= "\n" -%>
1
+ <%- if params[:days_overdue].present? -%><%= 'Overdue items' -%><%- else -%><%= 'Checkout items' -%><%- end -%> (created_at: <%= Time.now -%>)<%= "\n" -%>
2
2
  <%- @checkouts.each do |checkout| -%>
3
3
  "<%=h checkout.user.try(:username) -%>" "<%=h checkout.item.item_identifier -%>" "<%=h checkout.item.manifestation.original_title -%>" "<%=h checkout.created_at -%>" "<%= checkout.due_date -%>"<%= "\n" -%>
4
4
  <%- end -%>
@@ -12,10 +12,16 @@
12
12
  <strong><%= t('activerecord.attributes.checkout.due_date') -%></strong><br />
13
13
  <%= l(@checkout.due_date, format: :only_date) if @checkout.due_date -%>
14
14
  </p>
15
- <%- if can? :update, @checkout -%>
15
+ <%- if policy(@checkout).update? -%>
16
16
  <p>
17
17
  <strong><%= t('checkout.current_user') -%></strong><br />
18
- <%= link_to @checkout.user_username, @checkout.user.profile if @checkout.user.try(:profile) -%>
18
+ <% if @checkout.user.try(:profile) -%>
19
+ <%= link_to @checkout.user_username, @checkout.user.profile if @checkout.user.try(:profile) -%>
20
+ (
21
+ <%= t('activerecord.attributes.profile.user_number') %>:
22
+ <%= @checkout.user.profile.user_number %>
23
+ )
24
+ <% end %>
19
25
  </p>
20
26
  <%- end -%>
21
27
  </div>
@@ -25,11 +31,9 @@
25
31
  <%= render 'manifestations/book_jacket', manifestation: @checkout.item.manifestation -%>
26
32
  <ul>
27
33
  <li><%= link_to t('page.edit'), edit_checkout_path(@checkout) -%></li>
28
- <% if @checkout.user %>
29
- <li><%= link_to t('page.back'), checkouts_path(user_id: @checkout.user.username) -%></li>
30
- <% end %>
34
+ <li><%= link_to t('page.back'), :back -%></li>
31
35
  <%- if current_user.has_role?('Librarian') -%>
32
- <li><%= link_to t('page.back_to', model: t('activerecord.models.checkout')), checkouts_path -%></li>
36
+ <li><%= link_to t('page.listing', model: t('activerecord.models.checkout')), checkouts_path -%></li>
33
37
  <%- end -%>
34
38
  </ul>
35
39
  </div>
@@ -17,7 +17,7 @@
17
17
  <%- @circulation_statuses.each do |circulation_status| -%>
18
18
  <tr class="line<%= cycle("0", "1") -%>">
19
19
  <td>
20
- <%- if can? :update, circulation_status -%>
20
+ <%- if policy(circulation_status).update? -%>
21
21
  <%= move_position(circulation_status) -%>
22
22
  <%- end -%>
23
23
  </td>
@@ -28,10 +28,10 @@
28
28
  <%= circulation_status.note %>
29
29
  </td>
30
30
  <td>
31
- <%- if can? :update, circulation_status -%>
31
+ <%- if policy(circulation_status).update? -%>
32
32
  <%= link_to t('page.edit'), edit_circulation_status_path(circulation_status) -%>
33
33
  <% end %>
34
- <%- if can? :delete, circulation_status -%>
34
+ <%- if policy(circulation_status).destroy? -%>
35
35
  <%= link_to t('page.destroy'), circulation_status_path(circulation_status), data: {confirm: t('page.are_you_sure')}, method: :delete -%>
36
36
  <%- end -%>
37
37
  </td>
@@ -44,7 +44,7 @@
44
44
 
45
45
  <div id="submenu" class="ui-corner-all ui-widget-content">
46
46
  <ul>
47
- <%- if can? :create, CirculationStatus -%>
47
+ <%- if policy(CirculationStatus).create? -%>
48
48
  <li><%= link_to t('page.new', model: t('activerecord.models.circulation_status')), new_circulation_status_path -%></li>
49
49
  <%- end -%>
50
50
  </ul>
@@ -23,7 +23,7 @@
23
23
 
24
24
  <div id="submenu" class="ui-corner-all ui-widget-content">
25
25
  <ul>
26
- <%- if can? :update, @circulation_status -%>
26
+ <%- if policy(@circulation_status).update? -%>
27
27
  <li><%= link_to t('page.edit'), edit_circulation_status_path(@circulation_status) -%></li>
28
28
  <%- end -%>
29
29
  <li><%= back_to_index(flash[:page_info]) -%></li>
@@ -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.merge(state: state.value, page: nil, view: nil, only_path: true)) %>
7
+ <%= link_to "#{i18n_state(state.value)} (#{state.count})", url_for(params.permit.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.merge(state: nil, page: nil, view: nil, only_path: true)) -%></li>
12
+ <li><%= link_to t('page.remove_this_facet'), url_for(params.permit.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.merge(sort_by: nil, only_path: true)) -%>
24
+ <%= link_to t('activerecord.attributes.reserve.created_at'), url_for(params.permit.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.merge(sort_by: 'title', only_path: true)) -%>
29
+ <%= link_to t('page.title'), url_for(params.permit.merge(sort_by: 'title', only_path: true)) -%>
30
30
  <%- end -%>
31
31
  </p>
32
32
 
@@ -35,7 +35,7 @@
35
35
  <th style="width: 30px">Id</th>
36
36
  <th><%= t('activerecord.models.manifestation') -%></th>
37
37
  <th style="width: 80px"><%= t('activerecord.attributes.reserve.state') -%></th>
38
- <%- if can? :update, @reserves.first -%>
38
+ <%- if policy(Reserve).create? -%>
39
39
  <th style="width: 70px"></th>
40
40
  <% end %>
41
41
  </tr>
@@ -61,13 +61,15 @@
61
61
  <% end %>
62
62
  </td>
63
63
  <td>
64
- <%- if can? :delete, reserve -%>
64
+ <%- if policy(reserve).update? -%>
65
65
  <%= link_to t('page.edit'), edit_reserve_path(reserve) -%>
66
66
  <%- if reserve.user.reserves.waiting.include?(reserve) -%>
67
67
  <br />
68
68
  <%= link_to t('page.cancel'), reserve_path(reserve, mode: 'cancel'), data: {confirm: t('page.are_you_sure')}, method: :put -%>
69
69
  <%- else -%>
70
70
  <br />
71
+ <% end %>
72
+ <%- if policy(reserve).destroy? -%>
71
73
  <%= link_to t('page.destroy'), reserve, data: {confirm: t('page.are_you_sure')}, method: :delete -%>
72
74
  <%- end -%>
73
75
  <%- end -%>
@@ -73,7 +73,7 @@
73
73
  <%- else -%>
74
74
  <li><%= link_to t('page.destroy'), @reserve, data: {confirm: t('page.are_you_sure')}, method: :delete -%></li>
75
75
  <%- end -%>
76
- <li><%= link_to t('page.back'), reserves_path(page: flash[:page] ||= nil) -%></li>
76
+ <li><%= link_to t('page.listing', model: t('activerecord.models.reserve')), reserves_path %></li>
77
77
  </ul>
78
78
  <!--
79
79
  <p>TODO: 予約取り消し時に、次の予約者に連絡する</p>