enju_library 0.1.2 → 0.2.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +3 -3
- data/Rakefile +15 -8
- data/app/controllers/accepts_controller.rb +13 -3
- data/app/controllers/baskets_controller.rb +11 -1
- data/app/controllers/bookstores_controller.rb +12 -1
- data/app/controllers/budget_types_controller.rb +13 -2
- data/app/controllers/concerns/enju_library/controller.rb +43 -0
- data/app/controllers/libraries_controller.rb +13 -4
- data/app/controllers/library_groups_controller.rb +16 -6
- data/app/controllers/request_status_types_controller.rb +13 -2
- data/app/controllers/request_types_controller.rb +13 -2
- data/app/controllers/search_engines_controller.rb +13 -2
- data/app/controllers/shelves_controller.rb +14 -4
- data/app/controllers/subscribes_controller.rb +12 -2
- data/app/controllers/subscriptions_controller.rb +12 -3
- data/app/controllers/withdraws_controller.rb +14 -3
- data/app/helpers/shelves_helper.rb +2 -2
- data/app/models/accept.rb +2 -4
- data/app/models/basket.rb +0 -2
- data/app/models/budget_type.rb +0 -1
- data/app/models/concerns/enju_library/enju_item.rb +32 -0
- data/app/models/library_group.rb +9 -16
- data/app/models/request_status_type.rb +0 -1
- data/app/models/request_type.rb +0 -1
- data/app/models/search_engine.rb +0 -1
- data/app/models/withdraw.rb +8 -4
- data/app/policies/accept_policy.rb +21 -0
- data/app/policies/basket_policy.rb +21 -0
- data/app/policies/bookstore_policy.rb +23 -0
- data/app/policies/budget_type_policy.rb +21 -0
- data/app/policies/library_group_policy.rb +23 -0
- data/app/policies/library_policy.rb +25 -0
- data/app/policies/request_status_type_policy.rb +21 -0
- data/app/policies/request_type_policy.rb +21 -0
- data/app/policies/search_engine_policy.rb +21 -0
- data/app/policies/shelf_policy.rb +23 -0
- data/app/policies/subscribe_policy.rb +21 -0
- data/app/policies/subscription_policy.rb +21 -0
- data/app/policies/withdraw_policy.rb +21 -0
- data/app/views/accepts/index.html.erb +1 -1
- data/app/views/accepts/show.html.erb +1 -1
- data/app/views/baskets/edit.html.erb +1 -1
- data/app/views/baskets/new.html.erb +3 -1
- data/app/views/bookstores/index.html.erb +4 -4
- data/app/views/bookstores/show.html.erb +2 -2
- data/app/views/budget_types/index.html.erb +4 -4
- data/app/views/budget_types/show.html.erb +2 -2
- data/app/views/libraries/{_map.mobile.erb → _map.html+phone.erb} +0 -0
- data/app/views/libraries/index.html.erb +4 -4
- data/app/views/libraries/{show.mobile.erb → show.html+phone.erb} +0 -0
- data/app/views/libraries/show.html.erb +5 -5
- data/app/views/library_groups/_color_fields.html.erb +5 -0
- data/app/views/library_groups/_form.html.erb +17 -7
- data/app/views/library_groups/edit.html.erb +1 -1
- data/app/views/library_groups/index.html.erb +1 -1
- data/app/views/library_groups/show.html.erb +6 -2
- data/app/views/picture_files/_index_shelf.html.erb +4 -4
- data/app/views/request_status_types/index.html.erb +6 -4
- data/app/views/request_status_types/show.html.erb +1 -1
- data/app/views/request_types/index.html.erb +6 -4
- data/app/views/request_types/show.html.erb +1 -1
- data/app/views/search_engines/index.html.erb +4 -4
- data/app/views/search_engines/show.html.erb +2 -2
- data/app/views/shelves/_library_facet.html.erb +1 -1
- data/app/views/shelves/index.html.erb +4 -4
- data/app/views/shelves/{show.mobile.erb → show.html+phone.erb} +0 -0
- data/app/views/shelves/show.html.erb +3 -3
- data/app/views/subscriptions/index.html.erb +3 -1
- data/app/views/subscriptions/show.html.erb +1 -1
- data/app/views/withdraws/index.html.erb +1 -1
- data/app/views/withdraws/show.html.erb +1 -1
- data/config/locales/translation_en.yml +2 -1
- data/config/locales/translation_ja.yml +2 -1
- data/db/migrate/20151213070943_add_translation_table_to_library_group.rb +13 -0
- data/db/migrate/20151213072705_add_footer_banner_to_library_group.rb +9 -0
- data/lib/enju_library/engine.rb +3 -0
- data/lib/enju_library/version.rb +1 -1
- data/lib/enju_library.rb +0 -41
- data/lib/generators/enju_library/setup/setup_generator.rb +2 -0
- data/lib/generators/enju_library/setup/templates/db/fixtures/library_group/translations.yml +10 -0
- data/lib/tasks/enju_library_tasks.rake +6 -2
- data/spec/controllers/accepts_controller_spec.rb +6 -6
- data/spec/controllers/baskets_controller_spec.rb +7 -7
- data/spec/controllers/bookstores_controller_spec.rb +11 -11
- data/spec/controllers/budget_types_controller_spec.rb +1 -1
- data/spec/controllers/libraries_controller_spec.rb +9 -9
- data/spec/controllers/library_groups_controller_spec.rb +3 -3
- data/spec/controllers/request_status_types_controller_spec.rb +16 -16
- data/spec/controllers/request_types_controller_spec.rb +16 -16
- data/spec/controllers/search_engines_controller_spec.rb +13 -13
- data/spec/controllers/shelves_controller_spec.rb +10 -9
- data/spec/controllers/subscribes_controller_spec.rb +8 -8
- data/spec/controllers/subscriptions_controller_spec.rb +8 -8
- data/spec/controllers/withdraws_controller_spec.rb +11 -3
- data/spec/dummy/app/controllers/application_controller.rb +6 -3
- data/spec/dummy/app/models/user.rb +2 -2
- data/spec/dummy/config/application.rb +8 -38
- data/spec/dummy/config/environments/development.rb +22 -18
- data/spec/dummy/config/environments/production.rb +46 -34
- data/spec/dummy/config/environments/test.rb +21 -14
- data/spec/dummy/config/initializers/enju_leaf.rb +6 -0
- data/spec/dummy/db/schema.rb +13 -1
- data/spec/models/withdraw_spec.rb +2 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/views/accepts/index.html.erb_spec.rb +1 -0
- data/spec/views/budget_types/index.html.erb_spec.rb +1 -0
- data/spec/views/budget_types/show.html.erb_spec.rb +1 -0
- data/spec/views/libraries/show.html.erb_spec.rb +2 -1
- data/spec/views/library_groups/edit.html.erb_spec.rb +1 -0
- data/spec/views/library_groups/show.html.erb_spec.rb +2 -0
- data/spec/views/withdraws/index.html.erb_spec.rb +2 -0
- metadata +52 -105
- data/app/models/enju_library/ability.rb +0 -72
- data/lib/enju_library/item.rb +0 -39
- data/spec/dummy/app/models/ability.rb +0 -68
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3e6909228abfb05e27d765b4ae1ca826886d9e6
|
4
|
+
data.tar.gz: 4dd3c86961e520555ce9a7f52c005a9f53cd4c29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
3
|
-
{<img src="https://coveralls.io/repos/next-l/enju_library/badge.svg?branch=1.
|
4
|
-
{<img src="https://hakiri.io/github/next-l/enju_library/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
|
-
|
40
|
-
task default: :spec
|
47
|
+
task :default => :spec
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class AcceptsController < ApplicationController
|
2
|
-
|
3
|
-
|
4
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
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
|
-
|
4
|
-
|
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.
|
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
|
-
|
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.
|
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.
|
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
|
-
|
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.
|
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
|
-
|
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.
|
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
|
-
|
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.
|
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
|
-
|
3
|
-
|
4
|
-
|
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.
|
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
|
-
|
3
|
-
|
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
|
-
|
3
|
-
|
4
|
-
|
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
|
-
|
3
|
-
|
4
|
-
|
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
|
-
|
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
data/app/models/budget_type.rb
CHANGED
@@ -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
|
data/app/models/library_group.rb
CHANGED
@@ -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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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)
|