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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4742f9db0ad3917fe0e1ae6848ca2bcd5f5ba7a
4
- data.tar.gz: 1f666d31c8df75f3c94c6c78ec83eede5778147c
3
+ metadata.gz: d3e6909228abfb05e27d765b4ae1ca826886d9e6
4
+ data.tar.gz: 4dd3c86961e520555ce9a7f52c005a9f53cd4c29
5
5
  SHA512:
6
- metadata.gz: 7dbc1ee13c7926817103c19cc93c83b32fe45f9aaeb910079f8104a8b38ca61d99bde96c7393c2f5717d17976ae695968997f12e820a068e8e24338d33b84bac
7
- data.tar.gz: b601e27991964ff3bb4ca04e142b1df358fe2b9a0dcb0034ef93fd48d2f45d2edef91746a0445d26061ae2587762cf0991cf1721b196b6dc15ef81d0e151fe85
6
+ metadata.gz: cad580ab88688b578872724c8374d6e80e9d3baa3d027171d8fffd2b3a4bb1ae56e75aec783c0175444137e1ac3b6d1916c6593e803749adce4bb02fd8bf88f9
7
+ data.tar.gz: 623fff1279501648d69c5cc64aea61e1058a62bc3669b0e61641ffa7906da1a1cfd2e863279ea7c34438014477f4978eaef73d088062c7afbff99a94afaf1a84
data/README.rdoc CHANGED
@@ -1,7 +1,7 @@
1
1
  = EnjuLibrary
2
- {<img src="https://travis-ci.org/next-l/enju_library.svg?branch=1.1" alt="Build Status" />}[https://travis-ci.org/next-l/enju_library]
3
- {<img src="https://coveralls.io/repos/next-l/enju_library/badge.svg?branch=1.1&service=github" alt="Coverage Status" />}[https://coveralls.io/github/next-l/enju_library?branch=1.1]
4
- {<img src="https://hakiri.io/github/next-l/enju_library/1.1.svg" alt="security" />}[https://hakiri.io/github/next-l/enju_library/1.1]
2
+ {<img src="https://travis-ci.org/next-l/enju_library.svg?branch=1.2" alt="Build Status" />}[https://travis-ci.org/next-l/enju_library]
3
+ {<img src="https://coveralls.io/repos/next-l/enju_library/badge.svg?branch=1.2&service=github" alt="Coverage Status" />}[https://coveralls.io/github/next-l/enju_library?branch=1.2]
4
+ {<img src="https://hakiri.io/github/next-l/enju_library/1.2.svg" alt="security" />}[https://hakiri.io/github/next-l/enju_library/1.2]
5
5
 
6
6
  This project rocks and uses MIT-LICENSE.
7
7
 
data/Rakefile CHANGED
@@ -1,10 +1,16 @@
1
+ #!/usr/bin/env rake
1
2
  begin
2
3
  require 'bundler/setup'
3
4
  rescue LoadError
4
5
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
6
  end
6
-
7
- require 'rdoc/task'
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
8
14
 
9
15
  RDoc::Task.new(:rdoc) do |rdoc|
10
16
  rdoc.rdoc_dir = 'rdoc'
@@ -18,9 +24,6 @@ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
24
  load 'rails/tasks/engine.rake'
19
25
 
20
26
 
21
- load 'rails/tasks/statistics.rake'
22
-
23
-
24
27
 
25
28
  Bundler::GemHelper.install_tasks
26
29
 
@@ -33,8 +36,12 @@ Rake::TestTask.new(:test) do |t|
33
36
  t.verbose = false
34
37
  end
35
38
 
39
+ require 'rspec/core'
40
+ require 'rspec/core/rake_task'
41
+
42
+ RSpec::Core::RakeTask.new(:spec) do |spec|
43
+ spec.pattern = FileList['spec/**/*_spec.rb']
44
+ end
36
45
 
37
- require "rspec/core/rake_task"
38
46
 
39
- RSpec::Core::RakeTask.new("spec")
40
- task default: :spec
47
+ task :default => :spec
@@ -1,7 +1,7 @@
1
1
  class AcceptsController < ApplicationController
2
- load_and_authorize_resource except: :index
3
- authorize_resource only: :index
4
- before_filter :get_basket, only: [:index, :create]
2
+ before_action :set_accept, only: [:show, :edit, :update, :destroy]
3
+ before_action :check_policy, only: [:index, :new, :create]
4
+ before_action :get_basket, only: [:index, :create]
5
5
 
6
6
  # GET /accepts
7
7
  # GET /accepts.json
@@ -68,6 +68,7 @@ class AcceptsController < ApplicationController
68
68
  unless @basket
69
69
  access_denied; return
70
70
  end
71
+ @accept = Accept.new(accept_params)
71
72
  @accept.basket = @basket
72
73
  @accept.librarian = current_user
73
74
 
@@ -120,6 +121,15 @@ class AcceptsController < ApplicationController
120
121
  end
121
122
 
122
123
  private
124
+ def set_accept
125
+ @accept = Accept.find(params[:id])
126
+ authorize @accept
127
+ end
128
+
129
+ def check_policy
130
+ authorize Accept
131
+ end
132
+
123
133
  def accept_params
124
134
  params.require(:accept).permit(:item_identifier, :librarian_id, :item_id)
125
135
  end
@@ -1,5 +1,6 @@
1
1
  class BasketsController < ApplicationController
2
- load_and_authorize_resource
2
+ before_action :set_basket, only: [:show, :edit, :update, :destroy]
3
+ before_action :check_policy, only: [:index, :new, :create]
3
4
 
4
5
  # GET /baskets
5
6
  # GET /baskets.json
@@ -104,6 +105,15 @@ class BasketsController < ApplicationController
104
105
  end
105
106
 
106
107
  private
108
+ def set_basket
109
+ @basket = Basket.find(params[:id])
110
+ authorize @basket
111
+ end
112
+
113
+ def check_policy
114
+ authorize Basket
115
+ end
116
+
107
117
  def basket_params
108
118
  params.require(:basket).permit(:note, :user_number)
109
119
  end
@@ -1,5 +1,7 @@
1
1
  class BookstoresController < ApplicationController
2
- load_and_authorize_resource
2
+ before_action :set_bookstore, only: [:show, :edit, :update, :destroy]
3
+ before_action :check_policy, only: [:index, :new, :create]
4
+
3
5
  # GET /bookstores
4
6
  # GET /bookstores.json
5
7
  def index
@@ -82,6 +84,15 @@ class BookstoresController < ApplicationController
82
84
  end
83
85
 
84
86
  private
87
+ def set_bookstore
88
+ @bookstore = Bookstore.find(params[:id])
89
+ authorize @bookstore
90
+ end
91
+
92
+ def check_policy
93
+ authorize Bookstore
94
+ end
95
+
85
96
  def bookstore_params
86
97
  params.require(:bookstore).permit(
87
98
  :name, :zip_code, :address, :note, :telephone_number,
@@ -1,9 +1,11 @@
1
1
  class BudgetTypesController < ApplicationController
2
- load_and_authorize_resource
2
+ before_action :set_budget_type, only: [:show, :edit, :update, :destroy]
3
+ before_action :check_policy, only: [:index, :new, :create]
4
+
3
5
  # GET /budget_types
4
6
  # GET /budget_types.json
5
7
  def index
6
- @budget_types = BudgetType.all
8
+ @budget_types = BudgetType.order(:position)
7
9
 
8
10
  respond_to do |format|
9
11
  format.html # index.html.erb
@@ -82,6 +84,15 @@ class BudgetTypesController < ApplicationController
82
84
  end
83
85
 
84
86
  private
87
+ def set_budget_type
88
+ @budget_type = BudgetType.find(params[:id])
89
+ authorize @budget_type
90
+ end
91
+
92
+ def check_policy
93
+ authorize BudgetType
94
+ end
95
+
85
96
  def budget_type_params
86
97
  params.require(:budget_type).permit(
87
98
  :name, :display_name, :note, :position
@@ -0,0 +1,43 @@
1
+ module EnjuLibrary
2
+ module Controller
3
+ extend ActiveSupport::Concern
4
+
5
+ private
6
+
7
+ def get_library_group
8
+ @library_group = LibraryGroup.site_config
9
+ end
10
+
11
+ def get_shelf
12
+ if params[:shelf_id]
13
+ @shelf = Shelf.includes(:library).find(params[:shelf_id])
14
+ authorize @shelf, :show?
15
+ end
16
+ end
17
+
18
+ def get_library
19
+ if params[:library_id]
20
+ @library = Library.find(params[:library_id])
21
+ authorize @library, :show?
22
+ end
23
+ end
24
+
25
+ def get_libraries
26
+ @libraries = Library.all_cache
27
+ end
28
+
29
+ def get_bookstore
30
+ if params[:bookstore_id]
31
+ @bookstore = Bookstore.find(params[:bookstore_id])
32
+ authorize @bookstore, :show?
33
+ end
34
+ end
35
+
36
+ def get_subscription
37
+ if params[:subscription_id]
38
+ @subscription = Subscription.find(params[:subscription_id])
39
+ authorize @subscription, :show?
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,7 +1,6 @@
1
- # -*- encoding: utf-8 -*-
2
1
  class LibrariesController < ApplicationController
3
- load_and_authorize_resource
4
- after_filter :solr_commit, only: [:create, :update, :destroy]
2
+ before_action :set_library, only: [:show, :edit, :update, :destroy]
3
+ before_action :check_policy, only: [:index, :new, :create]
5
4
 
6
5
  # GET /libraries
7
6
  # GET /libraries.json
@@ -45,6 +44,7 @@ class LibrariesController < ApplicationController
45
44
 
46
45
  respond_to do |format|
47
46
  format.html # show.html.erb
47
+ format.html.phone
48
48
  format.json { render json: @library }
49
49
  format.js
50
50
  end
@@ -117,6 +117,15 @@ class LibrariesController < ApplicationController
117
117
  end
118
118
 
119
119
  private
120
+ def set_library
121
+ @library = Library.find(params[:id])
122
+ authorize @library
123
+ end
124
+
125
+ def check_policy
126
+ authorize Library
127
+ end
128
+
120
129
  def library_params
121
130
  params.require(:library).permit(
122
131
  :name, :display_name, :short_display_name, :zip_code, :street,
@@ -128,6 +137,6 @@ class LibrariesController < ApplicationController
128
137
 
129
138
  def prepare_options
130
139
  @library_groups = LibraryGroup.all
131
- @countries = Country.all_cache
140
+ @countries = Country.order(:position)
132
141
  end
133
142
  end
@@ -1,6 +1,6 @@
1
- # -*- encoding: utf-8 -*-
2
1
  class LibraryGroupsController < ApplicationController
3
- load_and_authorize_resource
2
+ before_action :set_library_group, only: [:show, :edit, :update, :destroy]
3
+ before_action :check_policy, only: [:index, :new, :create]
4
4
 
5
5
  # GET /library_groups
6
6
  # GET /library_groups.json
@@ -24,7 +24,7 @@ class LibraryGroupsController < ApplicationController
24
24
 
25
25
  # GET /library_groups/1/edit
26
26
  def edit
27
- @countries = Country.all
27
+ @countries = Country.order(:position)
28
28
  end
29
29
 
30
30
  # PUT /library_groups/1
@@ -35,7 +35,7 @@ class LibraryGroupsController < ApplicationController
35
35
  format.html { redirect_to @library_group, notice: t('controller.successfully_updated', model: t('activerecord.models.library_group')) }
36
36
  format.json { head :no_content }
37
37
  else
38
- @countries = Country.all
38
+ @countries = Country.order(:position)
39
39
  format.html { render action: "edit" }
40
40
  format.json { render json: @library_group.errors, status: :unprocessable_entity }
41
41
  end
@@ -43,16 +43,26 @@ class LibraryGroupsController < ApplicationController
43
43
  end
44
44
 
45
45
  private
46
+ def set_library_group
47
+ @library_group = LibraryGroup.find(params[:id])
48
+ authorize @library_group
49
+ end
50
+
51
+ def check_policy
52
+ authorize LibraryGroup
53
+ end
54
+
46
55
  def library_group_params
47
56
  params.require(:library_group).permit(
48
57
  :name, :display_name, :short_name, :my_networks,
49
58
  :login_banner, :note, :country_id, :admin_networks, :url,
50
- :max_number_of_results,
59
+ :max_number_of_results, :footer_banner,
51
60
  :book_jacket_source, :screenshot_generator, :erms_url,
52
61
  :allow_bookmark_external_url, # EnjuBookmark
53
62
  {
54
63
  :colors_attributes => [:id, :property, :code]
55
- }
64
+ },
65
+ *LibraryGroup.globalize_attribute_names,
56
66
  )
57
67
  end
58
68
  end
@@ -1,9 +1,11 @@
1
1
  class RequestStatusTypesController < ApplicationController
2
- load_and_authorize_resource
2
+ before_action :set_request_status_type, only: [:show, :edit, :update, :destroy]
3
+ before_action :check_policy, only: [:index, :new, :create]
4
+
3
5
  # GET /request_status_types
4
6
  # GET /request_status_types.json
5
7
  def index
6
- @request_status_types = RequestStatusType.all
8
+ @request_status_types = RequestStatusType.order(:position)
7
9
 
8
10
  respond_to do |format|
9
11
  format.html # index.html.erb
@@ -82,6 +84,15 @@ class RequestStatusTypesController < ApplicationController
82
84
  end
83
85
 
84
86
  private
87
+ def set_request_status_type
88
+ @request_status_type = RequestStatusType.find(params[:id])
89
+ authorize @request_status_type
90
+ end
91
+
92
+ def check_policy
93
+ authorize RequestStatusType
94
+ end
95
+
85
96
  def request_status_type_params
86
97
  params.require(:request_status_type).permit(:name, :display_name, :note)
87
98
  end
@@ -1,9 +1,11 @@
1
1
  class RequestTypesController < ApplicationController
2
- load_and_authorize_resource
2
+ before_action :set_request_type, only: [:show, :edit, :update, :destroy]
3
+ before_action :check_policy, only: [:index, :new, :create]
4
+
3
5
  # GET /request_types
4
6
  # GET /request_types.json
5
7
  def index
6
- @request_types = RequestType.all
8
+ @request_types = RequestType.order(:position)
7
9
 
8
10
  respond_to do |format|
9
11
  format.html # index.html.erb
@@ -82,6 +84,15 @@ class RequestTypesController < ApplicationController
82
84
  end
83
85
 
84
86
  private
87
+ def set_request_type
88
+ @request_type = RequestType.find(params[:id])
89
+ authorize @request_type
90
+ end
91
+
92
+ def check_policy
93
+ authorize RequestType
94
+ end
95
+
85
96
  def request_type_params
86
97
  params.require(:request_type).permit(:name, :display_name, :note)
87
98
  end
@@ -1,9 +1,11 @@
1
1
  class SearchEnginesController < ApplicationController
2
- load_and_authorize_resource
2
+ before_action :set_search_engine, only: [:show, :edit, :update, :destroy]
3
+ before_action :check_policy, only: [:index, :new, :create]
4
+
3
5
  # GET /search_engines
4
6
  # GET /search_engines.json
5
7
  def index
6
- @search_engines = SearchEngine.all
8
+ @search_engines = SearchEngine.order(:position)
7
9
 
8
10
  respond_to do |format|
9
11
  format.html # index.html.erb
@@ -82,6 +84,15 @@ class SearchEnginesController < ApplicationController
82
84
  end
83
85
 
84
86
  private
87
+ def set_search_engine
88
+ @search_engine = SearchEngine.find(params[:id])
89
+ authorize @search_engine
90
+ end
91
+
92
+ def check_policy
93
+ authorize SearchEngine
94
+ end
95
+
85
96
  def search_engine_params
86
97
  params.require(:search_engine).permit(
87
98
  :name, :display_name, :url, :base_url, :http_method,
@@ -1,7 +1,8 @@
1
1
  class ShelvesController < ApplicationController
2
- load_and_authorize_resource
3
- before_filter :get_library
4
- before_filter :get_libraries, only: [:new, :edit, :create, :update]
2
+ before_action :set_shelf, only: [:show, :edit, :update, :destroy]
3
+ before_action :check_policy, only: [:index, :new, :create]
4
+ before_action :get_library
5
+ before_action :get_libraries, only: [:new, :edit, :create, :update]
5
6
 
6
7
  # GET /shelves
7
8
  # GET /shelves.json
@@ -55,7 +56,7 @@ class ShelvesController < ApplicationController
55
56
  respond_to do |format|
56
57
  format.html # show.html.erb
57
58
  format.json { render json: @shelf }
58
- format.mobile
59
+ format.html.phone
59
60
  end
60
61
  end
61
62
 
@@ -135,6 +136,15 @@ class ShelvesController < ApplicationController
135
136
  end
136
137
 
137
138
  private
139
+ def set_shelf
140
+ @shelf = Shelf.find(params[:id])
141
+ authorize @shelf
142
+ end
143
+
144
+ def check_policy
145
+ authorize Shelf
146
+ end
147
+
138
148
  def shelf_params
139
149
  params.require(:shelf).permit(
140
150
  :name, :display_name, :note, :library_id, :closed
@@ -1,6 +1,7 @@
1
1
  class SubscribesController < ApplicationController
2
- load_and_authorize_resource
3
- before_filter :get_subscription, :get_work
2
+ before_action :set_subscribe, only: [:show, :edit, :update, :destroy]
3
+ before_action :check_policy, only: [:index, :new, :create]
4
+ before_action :get_subscription, :get_work
4
5
 
5
6
  # GET /subscribes
6
7
  # GET /subscribes.json
@@ -81,6 +82,15 @@ class SubscribesController < ApplicationController
81
82
  end
82
83
 
83
84
  private
85
+ def set_subscribe
86
+ @subscribe = Subscribe.find(params[:id])
87
+ authorize @subscribe
88
+ end
89
+
90
+ def check_policy
91
+ authorize Subscribe
92
+ end
93
+
84
94
  def subscribe_params
85
95
  params.require(:subscribe).permit(
86
96
  :subscription_id, :work_id, :start_at, :end_at
@@ -1,7 +1,7 @@
1
1
  class SubscriptionsController < ApplicationController
2
- load_and_authorize_resource
3
- before_filter :get_work
4
- after_filter :solr_commit, only: [:create, :update, :destroy]
2
+ before_action :set_subscription, only: [:show, :edit, :update, :destroy]
3
+ before_action :check_policy, only: [:index, :new, :create]
4
+ before_action :get_work
5
5
 
6
6
  # GET /subscriptions
7
7
  # GET /subscriptions.json
@@ -86,6 +86,15 @@ class SubscriptionsController < ApplicationController
86
86
  end
87
87
 
88
88
  private
89
+ def set_subscription
90
+ @subscription = Subscription.find(params[:id])
91
+ authorize @subscription
92
+ end
93
+
94
+ def check_policy
95
+ authorize Subscription
96
+ end
97
+
89
98
  def subscription_params
90
99
  params.require(:subscription).permit(
91
100
  :title, :note, :order_list_id, :user_id
@@ -1,7 +1,7 @@
1
1
  class WithdrawsController < ApplicationController
2
- load_and_authorize_resource except: :index
3
- authorize_resource only: :index
4
- before_filter :get_basket, only: [:index, :create]
2
+ before_action :set_withdraw, only: [:show, :edit, :update, :destroy]
3
+ before_action :check_policy, only: [:index, :new, :create]
4
+ before_action :get_basket, only: [:index, :create]
5
5
 
6
6
  # GET /withdraws
7
7
  # GET /withdraws.json
@@ -49,6 +49,7 @@ class WithdrawsController < ApplicationController
49
49
  @basket.user = current_user
50
50
  @basket.save!
51
51
  @withdraw = Withdraw.new
52
+ authorize @withdraw, :new?
52
53
  @withdraws = []
53
54
 
54
55
  respond_to do |format|
@@ -68,6 +69,7 @@ class WithdrawsController < ApplicationController
68
69
  unless @basket
69
70
  access_denied; return
70
71
  end
72
+ @withdraw = Withdraw.new(withdraw_params)
71
73
  @withdraw.basket = @basket
72
74
  @withdraw.librarian = current_user
73
75
 
@@ -120,6 +122,15 @@ class WithdrawsController < ApplicationController
120
122
  end
121
123
 
122
124
  private
125
+ def set_withdraw
126
+ @withdraw = Withdraw.find(params[:id])
127
+ authorize @withdraw
128
+ end
129
+
130
+ def check_policy
131
+ authorize Withdraw
132
+ end
133
+
123
134
  def withdraw_params
124
135
  params.require(:withdraw).permit(:item_identifier, :librarian_id, :item_id)
125
136
  end
@@ -6,10 +6,10 @@ module ShelvesHelper
6
6
  content_tag :li do
7
7
  if current
8
8
  content_tag :strong do
9
- link_to("#{library.display_name.localize} (" + facet.count.to_s + ")", url_for(params.merge(page: nil, library_id: library.name, only_path: true)))
9
+ link_to("#{library.display_name.localize} (" + facet.count.to_s + ")", url_for(params.permit.merge(page: nil, library_id: library.name, only_path: true)))
10
10
  end
11
11
  else
12
- link_to("#{library.display_name.localize} (" + facet.count.to_s + ")", url_for(params.merge(page: nil, library_id: library.name, only_path: true)))
12
+ link_to("#{library.display_name.localize} (" + facet.count.to_s + ")", url_for(params.permit.merge(page: nil, library_id: library.name, only_path: true)))
13
13
  end
14
14
  end
15
15
  end
data/app/models/accept.rb CHANGED
@@ -4,10 +4,8 @@ class Accept < ActiveRecord::Base
4
4
  belongs_to :item, touch: true
5
5
  belongs_to :librarian, class_name: 'User'
6
6
 
7
- enju_circulation_accept_model if defined?(EnjuCirculation)
8
-
9
- validates_uniqueness_of :item_id, message: I18n.t('accept.already_accepted')
10
- validates_presence_of :item_id, message: I18n.t('accept.item_not_found')
7
+ validates_uniqueness_of :item_id #, message: I18n.t('accept.already_accepted')
8
+ validates_presence_of :item_id #, message: I18n.t('accept.item_not_found')
11
9
  validates_presence_of :basket_id
12
10
 
13
11
  attr_accessor :item_identifier
data/app/models/basket.rb CHANGED
@@ -5,8 +5,6 @@ class Basket < ActiveRecord::Base
5
5
  has_many :accepts
6
6
  has_many :withdraws
7
7
 
8
- enju_circulation_basket_model if defined?(EnjuCirculation)
9
-
10
8
  validates_associated :user, on: :create
11
9
  # 貸出完了後にかごのユーザidは破棄する
12
10
  validates_presence_of :user, on: :create
@@ -1,7 +1,6 @@
1
1
  class BudgetType < 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('budget_types.position') }
5
4
  has_many :items
6
5
 
7
6
  private
@@ -0,0 +1,32 @@
1
+ module EnjuLibrary
2
+ module EnjuItem
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ has_one :accept
7
+ scope :accepted_between, lambda{|from, to| includes(:accept).where('items.created_at BETWEEN ? AND ?', Time.zone.parse(from).beginning_of_day, Time.zone.parse(to).end_of_day)}
8
+
9
+ belongs_to :shelf, counter_cache: true, validate: true
10
+ validates_associated :shelf
11
+
12
+ searchable do
13
+ string :library do
14
+ shelf.library.name if shelf
15
+ end
16
+ end
17
+ end
18
+
19
+ def shelf_name
20
+ shelf.name
21
+ end
22
+
23
+ def hold?(library)
24
+ return true if shelf.library == library
25
+ false
26
+ end
27
+
28
+ def library_url
29
+ "#{LibraryGroup.site_config.url}libraries/#{shelf.library.name}"
30
+ end
31
+ end
32
+ end
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  class LibraryGroup < ActiveRecord::Base
3
2
  #include Singleton
4
3
  include MasterModel
@@ -12,21 +11,15 @@ class LibraryGroup < ActiveRecord::Base
12
11
  greater_than_or_equal_to: 0
13
12
  }
14
13
  accepts_nested_attributes_for :colors, update_only: true
15
- if Rails::VERSION::MAJOR >= 4
16
- store :settings, accessors: [
17
- :max_number_of_results, :family_name_first,
18
- :pub_year_facet_range_interval,
19
- :book_jacket_source, :book_jacket_unknown_resource,
20
- :screenshot_generator, :erms_url
21
- ], coder: JSON
22
- else
23
- store :settings, accessors: [
24
- :max_number_of_results, :family_name_first,
25
- :pub_year_facet_range_interval,
26
- :book_jacket_source, :book_jacket_unknown_resource,
27
- :screenshot_generator, :erms_url
28
- ]
29
- end
14
+ store :settings, accessors: [
15
+ :max_number_of_results, :family_name_first,
16
+ :pub_year_facet_range_interval,
17
+ :book_jacket_source, :book_jacket_unknown_resource,
18
+ :screenshot_generator, :erms_url
19
+ ], coder: JSON
20
+
21
+ translates :login_banner, :footer_banner
22
+ globalize_accessors
30
23
 
31
24
  def self.site_config
32
25
  LibraryGroup.find(1)
@@ -1,7 +1,6 @@
1
1
  class RequestStatusType < 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_status_types.position') }
5
4
  has_many :reserves
6
5
 
7
6
  private