enju_library 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 (116) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +3 -3
  3. data/Rakefile +15 -8
  4. data/app/controllers/accepts_controller.rb +13 -3
  5. data/app/controllers/baskets_controller.rb +11 -1
  6. data/app/controllers/bookstores_controller.rb +12 -1
  7. data/app/controllers/budget_types_controller.rb +13 -2
  8. data/app/controllers/concerns/enju_library/controller.rb +43 -0
  9. data/app/controllers/libraries_controller.rb +13 -4
  10. data/app/controllers/library_groups_controller.rb +16 -6
  11. data/app/controllers/request_status_types_controller.rb +13 -2
  12. data/app/controllers/request_types_controller.rb +13 -2
  13. data/app/controllers/search_engines_controller.rb +13 -2
  14. data/app/controllers/shelves_controller.rb +14 -4
  15. data/app/controllers/subscribes_controller.rb +12 -2
  16. data/app/controllers/subscriptions_controller.rb +12 -3
  17. data/app/controllers/withdraws_controller.rb +14 -3
  18. data/app/helpers/shelves_helper.rb +2 -2
  19. data/app/models/accept.rb +2 -4
  20. data/app/models/basket.rb +0 -2
  21. data/app/models/budget_type.rb +0 -1
  22. data/app/models/concerns/enju_library/enju_item.rb +32 -0
  23. data/app/models/library_group.rb +9 -16
  24. data/app/models/request_status_type.rb +0 -1
  25. data/app/models/request_type.rb +0 -1
  26. data/app/models/search_engine.rb +0 -1
  27. data/app/models/withdraw.rb +8 -4
  28. data/app/policies/accept_policy.rb +21 -0
  29. data/app/policies/basket_policy.rb +21 -0
  30. data/app/policies/bookstore_policy.rb +23 -0
  31. data/app/policies/budget_type_policy.rb +21 -0
  32. data/app/policies/library_group_policy.rb +23 -0
  33. data/app/policies/library_policy.rb +25 -0
  34. data/app/policies/request_status_type_policy.rb +21 -0
  35. data/app/policies/request_type_policy.rb +21 -0
  36. data/app/policies/search_engine_policy.rb +21 -0
  37. data/app/policies/shelf_policy.rb +23 -0
  38. data/app/policies/subscribe_policy.rb +21 -0
  39. data/app/policies/subscription_policy.rb +21 -0
  40. data/app/policies/withdraw_policy.rb +21 -0
  41. data/app/views/accepts/index.html.erb +1 -1
  42. data/app/views/accepts/show.html.erb +1 -1
  43. data/app/views/baskets/edit.html.erb +1 -1
  44. data/app/views/baskets/new.html.erb +3 -1
  45. data/app/views/bookstores/index.html.erb +4 -4
  46. data/app/views/bookstores/show.html.erb +2 -2
  47. data/app/views/budget_types/index.html.erb +4 -4
  48. data/app/views/budget_types/show.html.erb +2 -2
  49. data/app/views/libraries/{_map.mobile.erb → _map.html+phone.erb} +0 -0
  50. data/app/views/libraries/index.html.erb +4 -4
  51. data/app/views/libraries/{show.mobile.erb → show.html+phone.erb} +0 -0
  52. data/app/views/libraries/show.html.erb +5 -5
  53. data/app/views/library_groups/_color_fields.html.erb +5 -0
  54. data/app/views/library_groups/_form.html.erb +17 -7
  55. data/app/views/library_groups/edit.html.erb +1 -1
  56. data/app/views/library_groups/index.html.erb +1 -1
  57. data/app/views/library_groups/show.html.erb +6 -2
  58. data/app/views/picture_files/_index_shelf.html.erb +4 -4
  59. data/app/views/request_status_types/index.html.erb +6 -4
  60. data/app/views/request_status_types/show.html.erb +1 -1
  61. data/app/views/request_types/index.html.erb +6 -4
  62. data/app/views/request_types/show.html.erb +1 -1
  63. data/app/views/search_engines/index.html.erb +4 -4
  64. data/app/views/search_engines/show.html.erb +2 -2
  65. data/app/views/shelves/_library_facet.html.erb +1 -1
  66. data/app/views/shelves/index.html.erb +4 -4
  67. data/app/views/shelves/{show.mobile.erb → show.html+phone.erb} +0 -0
  68. data/app/views/shelves/show.html.erb +3 -3
  69. data/app/views/subscriptions/index.html.erb +3 -1
  70. data/app/views/subscriptions/show.html.erb +1 -1
  71. data/app/views/withdraws/index.html.erb +1 -1
  72. data/app/views/withdraws/show.html.erb +1 -1
  73. data/config/locales/translation_en.yml +2 -1
  74. data/config/locales/translation_ja.yml +2 -1
  75. data/db/migrate/20151213070943_add_translation_table_to_library_group.rb +13 -0
  76. data/db/migrate/20151213072705_add_footer_banner_to_library_group.rb +9 -0
  77. data/lib/enju_library/engine.rb +3 -0
  78. data/lib/enju_library/version.rb +1 -1
  79. data/lib/enju_library.rb +0 -41
  80. data/lib/generators/enju_library/setup/setup_generator.rb +2 -0
  81. data/lib/generators/enju_library/setup/templates/db/fixtures/library_group/translations.yml +10 -0
  82. data/lib/tasks/enju_library_tasks.rake +6 -2
  83. data/spec/controllers/accepts_controller_spec.rb +6 -6
  84. data/spec/controllers/baskets_controller_spec.rb +7 -7
  85. data/spec/controllers/bookstores_controller_spec.rb +11 -11
  86. data/spec/controllers/budget_types_controller_spec.rb +1 -1
  87. data/spec/controllers/libraries_controller_spec.rb +9 -9
  88. data/spec/controllers/library_groups_controller_spec.rb +3 -3
  89. data/spec/controllers/request_status_types_controller_spec.rb +16 -16
  90. data/spec/controllers/request_types_controller_spec.rb +16 -16
  91. data/spec/controllers/search_engines_controller_spec.rb +13 -13
  92. data/spec/controllers/shelves_controller_spec.rb +10 -9
  93. data/spec/controllers/subscribes_controller_spec.rb +8 -8
  94. data/spec/controllers/subscriptions_controller_spec.rb +8 -8
  95. data/spec/controllers/withdraws_controller_spec.rb +11 -3
  96. data/spec/dummy/app/controllers/application_controller.rb +6 -3
  97. data/spec/dummy/app/models/user.rb +2 -2
  98. data/spec/dummy/config/application.rb +8 -38
  99. data/spec/dummy/config/environments/development.rb +22 -18
  100. data/spec/dummy/config/environments/production.rb +46 -34
  101. data/spec/dummy/config/environments/test.rb +21 -14
  102. data/spec/dummy/config/initializers/enju_leaf.rb +6 -0
  103. data/spec/dummy/db/schema.rb +13 -1
  104. data/spec/models/withdraw_spec.rb +2 -0
  105. data/spec/spec_helper.rb +1 -1
  106. data/spec/views/accepts/index.html.erb_spec.rb +1 -0
  107. data/spec/views/budget_types/index.html.erb_spec.rb +1 -0
  108. data/spec/views/budget_types/show.html.erb_spec.rb +1 -0
  109. data/spec/views/libraries/show.html.erb_spec.rb +2 -1
  110. data/spec/views/library_groups/edit.html.erb_spec.rb +1 -0
  111. data/spec/views/library_groups/show.html.erb_spec.rb +2 -0
  112. data/spec/views/withdraws/index.html.erb_spec.rb +2 -0
  113. metadata +52 -105
  114. data/app/models/enju_library/ability.rb +0 -72
  115. data/lib/enju_library/item.rb +0 -39
  116. data/spec/dummy/app/models/ability.rb +0 -68
@@ -1,7 +1,6 @@
1
1
  class RequestType < ActiveRecord::Base
2
2
  include MasterModel
3
3
  validates :name, presence: true, format: { with: /\A[0-9A-Za-z][0-9A-Za-z_\-\s,]*[0-9a-z]\Z/ }
4
- default_scope { order('request_types.position') }
5
4
 
6
5
  private
7
6
  def valid_name?
@@ -1,5 +1,4 @@
1
1
  class SearchEngine < ActiveRecord::Base
2
- default_scope { order('search_engines.position') }
3
2
  acts_as_list
4
3
 
5
4
  validates :name, presence: true
@@ -3,15 +3,19 @@ class Withdraw < ActiveRecord::Base
3
3
  belongs_to :item, touch: true
4
4
  belongs_to :librarian, class_name: 'User'
5
5
 
6
- enju_circulation_withdraw_model if defined?(EnjuCirculation)
7
-
8
- validates_uniqueness_of :item_id, message: I18n.t('withdraw.already_withdrawn')
9
- validates_presence_of :item_id, message: I18n.t('withdraw.item_not_found')
6
+ validates :item_id,
7
+ uniqueness: true, #{ message: I18n.t('withdraw.already_withdrawn', locale: I18n.default_locale) },
8
+ presence: true #, { message: I18n.translate('withdraw.item_not_found', locale: I18n.default_locale) }
10
9
  validates_presence_of :basket_id
10
+ validate :check_item
11
11
 
12
12
  attr_accessor :item_identifier
13
13
 
14
14
  paginates_per 10
15
+
16
+ def check_item
17
+ errors.add(:item) if item.try(:rent?)
18
+ end
15
19
  end
16
20
 
17
21
  # == Schema Information
@@ -0,0 +1,21 @@
1
+ class AcceptPolicy < 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
+ true if user.try(:has_role?, 'Librarian')
12
+ end
13
+
14
+ def update?
15
+ true if user.try(:has_role?, 'Librarian')
16
+ end
17
+
18
+ def destroy?
19
+ true if user.try(:has_role?, 'Librarian')
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ class BasketPolicy < 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
+ true if user.try(:has_role?, 'Librarian')
12
+ end
13
+
14
+ def update?
15
+ true if user.try(:has_role?, 'Librarian')
16
+ end
17
+
18
+ def destroy?
19
+ true if user.try(:has_role?, 'Librarian')
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ class BookstorePolicy < 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
+ true if user.try(:has_role?, 'Administrator')
12
+ end
13
+
14
+ def update?
15
+ true if user.try(:has_role?, 'Administrator')
16
+ end
17
+
18
+ def destroy?
19
+ if user.try(:has_role?, 'Administrator')
20
+ true if record.items.empty?
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ class BudgetTypePolicy < 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
+ true if user.try(:has_role?, 'Administrator')
12
+ end
13
+
14
+ def update?
15
+ true if user.try(:has_role?, 'Administrator')
16
+ end
17
+
18
+ def destroy?
19
+ true if user.try(:has_role?, 'Administrator')
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ class LibraryGroupPolicy < 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
+ true if user.try(:has_role?, 'Administrator')
12
+ end
13
+
14
+ def update?
15
+ true if user.try(:has_role?, 'Administrator')
16
+ end
17
+
18
+ def destroy?
19
+ if user.try(:has_role?, 'Administrator')
20
+ true if record.shelves.empty? && !record.web?
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ class LibraryPolicy < 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?, 'Administrator')
12
+ end
13
+
14
+ def update?
15
+ true if user.try(:has_role?, 'Administrator')
16
+ end
17
+
18
+ def destroy?
19
+ if user.try(:has_role?, 'Administrator')
20
+ if record.profiles.empty?
21
+ true if record.shelves.empty? && !record.web?
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ class RequestStatusTypePolicy < 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
+ true if user.try(:has_role?, 'Administrator')
16
+ end
17
+
18
+ def destroy?
19
+ false
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ class RequestTypePolicy < 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
+ true if user.try(:has_role?, 'Administrator')
16
+ end
17
+
18
+ def destroy?
19
+ false
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ class SearchEnginePolicy < 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
+ true if user.try(:has_role?, 'Administrator')
12
+ end
13
+
14
+ def update?
15
+ true if user.try(:has_role?, 'Administrator')
16
+ end
17
+
18
+ def destroy?
19
+ true if user.try(:has_role?, 'Administrator')
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ class ShelfPolicy < 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?, 'Administrator')
12
+ end
13
+
14
+ def update?
15
+ true if user.try(:has_role?, 'Administrator')
16
+ end
17
+
18
+ def destroy?
19
+ if user.try(:has_role?, 'Administrator')
20
+ true if record.items.empty? && !record.web_shelf?
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ class SubscribePolicy < 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
+ true if user.try(:has_role?, 'Librarian')
12
+ end
13
+
14
+ def update?
15
+ true if user.try(:has_role?, 'Librarian')
16
+ end
17
+
18
+ def destroy?
19
+ true if user.try(:has_role?, 'Librarian')
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ class SubscriptionPolicy < 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
+ true if user.try(:has_role?, 'Librarian')
12
+ end
13
+
14
+ def update?
15
+ true if user.try(:has_role?, 'Librarian')
16
+ end
17
+
18
+ def destroy?
19
+ true if user.try(:has_role?, 'Librarian')
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ class WithdrawPolicy < 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
+ true if user.try(:has_role?, 'Librarian')
12
+ end
13
+
14
+ def update?
15
+ true if user.try(:has_role?, 'Librarian')
16
+ end
17
+
18
+ def destroy?
19
+ true if user.try(:has_role?, 'Librarian')
20
+ end
21
+ end
@@ -29,7 +29,7 @@
29
29
  <% end %>
30
30
  </td>
31
31
  <td>
32
- <%- if can? :delete, accept -%>
32
+ <%- if policy(accept).destroy? -%>
33
33
  <%= link_to t('page.destroy'), accept, data: {confirm: t('page.are_you_sure')}, method: :delete -%>
34
34
  <%- end -%>
35
35
  </td>
@@ -26,6 +26,6 @@
26
26
 
27
27
  <div id="submenu" class="ui-corner-all ui-widget-content">
28
28
  <ul>
29
- <li><%= back_to_index(flash[:page_info]) -%></li>
29
+ <li><%= link_to t('page.back'), :back -%></li>
30
30
  </ul>
31
31
  </div>
@@ -25,6 +25,6 @@
25
25
  <div id="submenu" class="ui-corner-all ui-widget-content">
26
26
  <ul>
27
27
  <li><%= link_to t('page.show'), basket_path(@basket) -%></li>
28
- <li><%= link_to t('page.back'), user_baskets_path(@basket.user) -%></li>
28
+ <li><%= link_to t('page.back'), baskets_path(user_id: @basket.user.username) -%></li>
29
29
  </ul>
30
30
  </div>
@@ -23,7 +23,9 @@
23
23
 
24
24
  <div id="submenu" class="ui-corner-all ui-widget-content">
25
25
  <ul>
26
- <li><%= link_to t('activerecord.models.checkin'), new_checkin_path -%></li>
26
+ <% if defined?(EnjuCirculation) %>
27
+ <li><%= link_to t('page.new', model: t('activerecord.models.checkin')), new_checkin_path -%></li>
28
+ <% end %>
27
29
  <li><%= link_to t('page.search_resource', model: t('activerecord.models.profile')), profiles_path -%></li>
28
30
  </ul>
29
31
  </div>
@@ -14,7 +14,7 @@
14
14
  <%- @bookstores.each_with_index do |bookstore, i| -%>
15
15
  <tr class="line<%= cycle("0", "1") -%>">
16
16
  <td>
17
- <%- if can? :update, bookstore -%>
17
+ <%- if policy(bookstore).update? -%>
18
18
  <%= move_position(bookstore) -%>
19
19
  <%- end -%>
20
20
  </td>
@@ -25,10 +25,10 @@
25
25
  <td><%= bookstore.telephone_number -%></td>
26
26
  <td><%= bookstore.fax_number -%></td>
27
27
  <td>
28
- <%- if can? :update, bookstore -%>
28
+ <%- if policy(bookstore).update? -%>
29
29
  <%= link_to t('page.edit'), edit_bookstore_path(bookstore) -%>
30
30
  <% end %>
31
- <%- if can? :delete, bookstore -%>
31
+ <%- if policy(bookstore).destroy? -%>
32
32
  <%= link_to t('page.destroy'), bookstore, data: {confirm: t('page.are_you_sure')}, method: :delete -%>
33
33
  <%- end -%>
34
34
  </td>
@@ -41,7 +41,7 @@
41
41
  </div>
42
42
 
43
43
  <div id="submenu" class="ui-corner-all ui-widget-content">
44
- <%- if can? :create, Bookstore -%>
44
+ <%- if policy(Bookstore).create? -%>
45
45
  <ul>
46
46
  <li><%= link_to t('page.new', model: t('activerecord.models.bookstore')), new_bookstore_path -%></li>
47
47
  </ul>
@@ -43,10 +43,10 @@
43
43
 
44
44
  <div id="submenu" class="ui-corner-all ui-widget-content">
45
45
  <ul>
46
- <%- if can? :update, @bookstore -%>
46
+ <%- if policy(@bookstore).update? -%>
47
47
  <li><%= link_to t('page.edit'), edit_bookstore_path(@bookstore) -%></li>
48
48
  <%- end -%>
49
- <li><%= back_to_index(flash[:page_info]) -%></li>
49
+ <li><%= link_to t('page.back'), :back -%></li>
50
50
  <% if defined?(EnjuPurchaseRequest) %>
51
51
  <li><%= link_to t('activerecord.models.order_list'), bookstore_order_lists_path(@bookstore) -%></li>
52
52
  <% end %>
@@ -14,7 +14,7 @@
14
14
  <%- @budget_types.each do |budget_type| -%>
15
15
  <tr class="line<%= cycle("0", "1") -%>">
16
16
  <td>
17
- <%- if can? :update, budget_type -%>
17
+ <%- if policy(budget_type).update? -%>
18
18
  <%= move_position(budget_type) -%>
19
19
  <%- end -%>
20
20
  </td>
@@ -22,10 +22,10 @@
22
22
  <td><%= link_to budget_type.display_name.localize, budget_type -%></td>
23
23
  <td><%= budget_type.note -%></td>
24
24
  <td>
25
- <%- if can? :update, budget_type -%>
25
+ <%- if policy(budget_type).update? -%>
26
26
  <%= link_to t('page.edit'), edit_budget_type_path(budget_type) -%>
27
27
  <% end %>
28
- <%- if can? :delete, budget_type -%>
28
+ <%- if policy(budget_type).destroy? -%>
29
29
  <%= link_to t('page.destroy'), budget_type, data: {confirm: t('page.are_you_sure')}, method: :delete -%>
30
30
  <%- end -%>
31
31
  </td>
@@ -38,7 +38,7 @@
38
38
 
39
39
  <div id="submenu" class="ui-corner-all ui-widget-content">
40
40
  <ul>
41
- <%- if can? :create, BudgetType -%>
41
+ <%- if policy(BudgetType).create? -%>
42
42
  <li><%= link_to t('page.new', model: t('activerecord.models.budget_type')), new_budget_type_path -%></li>
43
43
  <%- end -%>
44
44
  </ul>
@@ -23,9 +23,9 @@
23
23
 
24
24
  <div id="submenu" class="ui-corner-all ui-widget-content">
25
25
  <ul>
26
- <%- if can? :update, @budget_type -%>
26
+ <%- if policy(@budget_type).update? -%>
27
27
  <li><%= link_to t('page.edit'), edit_budget_type_path(@budget_type) -%></li>
28
28
  <%- end -%>
29
- <li><%= back_to_index(flash[:page_info]) -%></li>
29
+ <li><%= link_to t('page.back'), :back -%></li>
30
30
  </ul>
31
31
  </div>
@@ -40,7 +40,7 @@
40
40
  <%- @libraries.each_with_index do |library, i| -%>
41
41
  <tr class="line<%= cycle("0", "1") -%>">
42
42
  <td>
43
- <%- if can?(:update, library) and params[:query].blank? -%>
43
+ <%- if policy(library).update? and params[:query].blank? -%>
44
44
  <%= library.first? ? image_tag('icons/stop.png', size: '16x16') : link_to(image_tag('icons/arrow_up.png', size: '16x16', alt: t('page.asc')), {action: 'update', move: 'higher', id: library.name}, method: :put) -%>
45
45
  <%= library.last? ? image_tag('icons/stop.png', size: '16x16') : link_to(image_tag('icons/arrow_down.png', size: '16x16', alt: t('page.desc')), {action: 'update', move: 'lower', id: library.name}, method: :put) -%>
46
46
  <%- end -%>
@@ -66,10 +66,10 @@
66
66
  <% end %>
67
67
  </td>
68
68
  <td>
69
- <%- if can? :update, library -%>
69
+ <%- if policy(library).update? -%>
70
70
  <%= link_to t('page.edit'), edit_library_path(library) -%>
71
71
  <% end %>
72
- <%- if can? :delete, library -%>
72
+ <%- if policy(library).destroy? -%>
73
73
  <%= link_to t('page.destroy'), library, data: {confirm: t('page.are_you_sure')}, method: :delete -%>
74
74
  <%- end -%>
75
75
  </td>
@@ -83,7 +83,7 @@
83
83
 
84
84
  <div id="submenu" class="ui-corner-all ui-widget-content">
85
85
  <ul>
86
- <%- if can? :create, Library -%>
86
+ <%- if policy(Library).create? -%>
87
87
  <li><%= link_to t('page.new', model: t('activerecord.models.library')), new_library_path -%></li>
88
88
  <%- end -%>
89
89
  </ul>
@@ -36,7 +36,7 @@
36
36
  <% if defined?(EnjuEvent) %>
37
37
  <li><a href="#tab4"><em><%= t('activerecord.models.event') -%></em></a></li>
38
38
  <% end %>
39
- <%- if can? :update, @library -%>
39
+ <%- if policy(@library).update? -%>
40
40
  <li><a href="#tab5"><em><%= t('page.configuration') -%></em></a></li>
41
41
  <%- end -%>
42
42
  </ul>
@@ -97,7 +97,7 @@
97
97
  </div>
98
98
  <% end %>
99
99
 
100
- <%- if can? :update, @library -%>
100
+ <%- if policy(@library).update? -%>
101
101
  <div id="tab5">
102
102
  <h3><%= t('page.configuration') -%></h3>
103
103
  <p>
@@ -119,15 +119,15 @@
119
119
 
120
120
  <div id="submenu" class="ui-corner-all ui-widget-content">
121
121
  <ul>
122
- <%- if can? :update, @library -%>
122
+ <%- if policy(@library).update? -%>
123
123
  <li><%= link_to t('page.edit'), edit_library_path(@library) -%></li>
124
124
  <%- end -%>
125
125
 
126
- <%- if can? :create, Shelf and !@library.web? -%>
126
+ <%- if policy(Shelf).create? and !@library.web? -%>
127
127
  <li><%= link_to t('page.new', model: t('activerecord.models.shelf')), new_shelf_path(library_id: @library.id) -%></li>
128
128
  <%- end -%>
129
129
  <% if defined?(EnjuEvent) %>
130
- <%- if can? :create, Event and !@library.web? -%>
130
+ <%- if policy(Event).create? and !@library.web? -%>
131
131
  <li><%= link_to t('page.new', model: t('activerecord.models.event')), new_event_path(library_id: @library.id) -%></li>
132
132
  <%- end -%>
133
133
  <%- end -%>
@@ -0,0 +1,5 @@
1
+ <div class="nested-fields">
2
+ <%= f.text_field :property, disabled: true %>
3
+ <%= f.text_field :code %>
4
+ <%= link_to_remove_association t('page.remove'), f, data: {confirm: t('page.are_you_sure')} %><br />
5
+ </div>
@@ -21,10 +21,19 @@
21
21
  <%= f.url_field :url, class: 'resource_url' -%>
22
22
  </div>
23
23
 
24
- <div class="field">
25
- <%= f.label :login_banner -%><br />
26
- <%= f.text_area :login_banner -%>
27
- </div>
24
+ <% @available_languages.each do |language| -%>
25
+ <div class="field">
26
+ <%= f.label :login_banner -%> (<%= language.display_name.localize -%>)<br />
27
+ <%= f.text_area LibraryGroup.localized_attr_name_for(:login_banner, language.iso_639_1) -%>
28
+ </div>
29
+ <% end -%>
30
+
31
+ <% @available_languages.each do |language| -%>
32
+ <div>
33
+ <%= f.label :footer_banner -%> (<%= language.display_name.localize -%>)<br />
34
+ <%= f.text_area LibraryGroup.localized_attr_name_for(:footer_banner, language.iso_639_1) -%>
35
+ </div>
36
+ <% end -%>
28
37
 
29
38
  <div class="field">
30
39
  <%= f.label :max_number_of_results -%><br />
@@ -39,10 +48,11 @@
39
48
  <div class="field">
40
49
  <%= f.label :color -%><br />
41
50
  <%= f.fields_for :colors do |color_form| %>
42
- <%= color_form.text_field :property, disabled: true %>
43
- <%= color_form.text_field :code %>
44
- <br />
51
+ <%= render 'color_fields', f: color_form %>
45
52
  <% end %>
53
+ <div class="links">
54
+ <p><%= link_to_add_association t('page.add'), f, :colors %></p>
55
+ </div>
46
56
  </div>
47
57
 
48
58
  <div class="field">
@@ -7,6 +7,6 @@
7
7
 
8
8
  <div id="submenu" class="ui-corner-all ui-widget-content">
9
9
  <ul>
10
- <li><%= link_to t('page.back'), library_groups_path -%></li>
10
+ <li><%= link_to t('page.show'), @library_group -%></li>
11
11
  </ul>
12
12
  </div>
@@ -16,7 +16,7 @@
16
16
  <td><%= library_group.name -%></td>
17
17
  <td><%= library_group.user.email -%></td>
18
18
  <td>
19
- <%= link_to t('page.edit'), edit_library_group_path(library_group) if can?(:update, library_group) -%>
19
+ <%= link_to t('page.edit'), edit_library_group_path(library_group) if policy(library_group).update? -%>
20
20
  </td>
21
21
  </tr>
22
22
  <%- end -%>
@@ -28,6 +28,11 @@
28
28
  <%= markdown_helper(@library_group.login_banner) -%>
29
29
  </p>
30
30
 
31
+ <p>
32
+ <strong><%= t('activerecord.attributes.library_group.footer_banner') -%>:</strong>
33
+ <%= markdown_helper(@library_group.footer_banner) -%>
34
+ </p>
35
+
31
36
  <p>
32
37
  <strong><%= t('activerecord.attributes.library_group.max_number_of_results') -%>:</strong>
33
38
  <%= @library_group.max_number_of_results -%>
@@ -88,9 +93,8 @@
88
93
 
89
94
  <div id="submenu" class="ui-corner-all ui-widget-content">
90
95
  <ul>
91
- <%- if can? :update, @library_group -%>
96
+ <%- if policy(@library_group).update? -%>
92
97
  <li><%= link_to t('page.edit'), edit_library_group_path(@library_group) -%></li>
93
98
  <%- end -%>
94
- <li><%= back_to_index(flash[:page_info]) -%></li>
95
99
  </ul>
96
100
  </div>