enju_biblio 0.0.9 → 0.1.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/accepts_controller.rb +83 -0
- data/app/controllers/items_controller.rb +2 -2
- data/app/controllers/manifestations_controller.rb +8 -8
- data/app/controllers/patrons_controller.rb +18 -4
- data/app/controllers/series_has_manifestations_controller.rb +1 -1
- data/app/controllers/series_statements_controller.rb +2 -5
- data/app/models/accept.rb +36 -0
- data/app/models/create.rb +0 -4
- data/app/models/donate.rb +0 -4
- data/app/models/exemplify.rb +0 -4
- data/app/models/import_request.rb +0 -4
- data/app/models/item.rb +2 -4
- data/app/models/manifestation.rb +5 -8
- data/app/models/own.rb +0 -3
- data/app/models/patron.rb +2 -4
- data/app/models/picture_file.rb +0 -4
- data/app/models/produce.rb +0 -4
- data/app/models/realize.rb +0 -4
- data/app/models/series_has_manifestation.rb +1 -3
- data/app/models/series_statement.rb +2 -4
- data/app/views/accepts/_form.html.erb +11 -0
- data/app/views/accepts/_list.html.erb +31 -0
- data/app/views/accepts/edit.html.erb +13 -0
- data/app/views/accepts/index.csv.erb +4 -0
- data/app/views/accepts/index.html.erb +49 -0
- data/app/views/accepts/index.js.erb +1 -0
- data/app/views/accepts/new.html.erb +14 -0
- data/app/views/accepts/show.html.erb +31 -0
- data/app/views/countries/index.html.erb +1 -1
- data/app/views/creates/_index.html.erb +1 -1
- data/app/views/creates/_index_patron.html.erb +1 -1
- data/app/views/creates/_index_work.html.erb +1 -1
- data/app/views/donates/index.html.erb +1 -1
- data/app/views/exemplifies/index.html.erb +1 -1
- data/app/views/extents/index.html.erb +1 -1
- data/app/views/import_requests/index.html.erb +1 -1
- data/app/views/items/index.html.erb +1 -1
- data/app/views/items/index.mobile.erb +1 -1
- data/app/views/languages/index.html.erb +1 -1
- data/app/views/licenses/index.html.erb +1 -1
- data/app/views/manifestations/_list.html.erb +2 -2
- data/app/views/manifestations/_manifestation.html.erb +1 -1
- data/app/views/manifestations/_question_list.html.erb +2 -2
- data/app/views/manifestations/_tab_list.html.erb +1 -1
- data/app/views/manifestations/index.html.erb +2 -2
- data/app/views/manifestations/index.mobile.erb +1 -1
- data/app/views/medium_of_performances/index.html.erb +1 -1
- data/app/views/owns/index.html.erb +1 -1
- data/app/views/patron_import_files/index.html.erb +1 -1
- data/app/views/patron_import_results/index.html.erb +1 -1
- data/app/views/patrons/_expression_list.html.erb +2 -2
- data/app/views/patrons/_index.html.erb +1 -1
- data/app/views/patrons/_index_expression.html.erb +1 -1
- data/app/views/patrons/_index_manifestation.html.erb +1 -1
- data/app/views/patrons/_index_patron.html.erb +1 -1
- data/app/views/patrons/_index_patron_merge_list.html.erb +1 -1
- data/app/views/patrons/_index_work.html.erb +1 -1
- data/app/views/patrons/_manifestation_list.html.erb +2 -2
- data/app/views/patrons/_work_list.html.erb +2 -2
- data/app/views/patrons/index.mobile.erb +1 -1
- data/app/views/picture_files/_index.html.erb +1 -1
- data/app/views/picture_files/_index_event.html.erb +1 -1
- data/app/views/picture_files/_index_manifestation.html.erb +1 -1
- data/app/views/picture_files/_index_patron.html.erb +1 -1
- data/app/views/picture_files/_index_shelf.html.erb +1 -1
- data/app/views/produces/_index.html.erb +1 -1
- data/app/views/produces/_index_manifestation.html.erb +1 -1
- data/app/views/produces/_index_patron.html.erb +1 -1
- data/app/views/realizes/_index.html.erb +1 -1
- data/app/views/realizes/_index_expression.html.erb +1 -1
- data/app/views/realizes/_index_patron.html.erb +1 -1
- data/app/views/resource_import_files/index.html.erb +1 -1
- data/app/views/resource_import_results/index.html.erb +1 -1
- data/app/views/series_has_manifestations/index.html.erb +1 -1
- data/app/views/series_statements/_index.html.erb +1 -1
- data/app/views/series_statements/_index_manifestation.html.erb +1 -1
- data/app/views/series_statements/_index_series_statement_merge_list.html.erb +1 -1
- data/app/views/series_statements/_manifestation_list.html.erb +2 -2
- data/{spec/dummy/db → db}/migrate/120_create_baskets.rb +0 -0
- data/{spec/dummy/db → db}/migrate/20120319173203_create_accepts.rb +0 -0
- data/lib/enju_biblio.rb +4 -0
- data/lib/enju_biblio/engine.rb +0 -3
- data/lib/enju_biblio/version.rb +1 -1
- data/lib/generators/enju_biblio/views_generator.rb +51 -0
- data/spec/controllers/accepts_controller_spec.rb +304 -0
- data/spec/dummy/app/models/ability.rb +2 -0
- data/spec/dummy/config/application.rb +9 -1
- data/spec/dummy/config/initializers/kaminari_config.rb +9 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/plugins/ext.rb +0 -2
- data/spec/dummy/tmp/cache/4F7/F90/default_role +0 -0
- data/spec/dummy/tmp/cache/6E4/420/search_engine_all +0 -0
- data/spec/factories/accepts.rb +9 -0
- data/spec/factories/basket.rb +5 -0
- data/spec/models/accept_spec.rb +22 -0
- data/spec/requests/accepts_spec.rb +11 -0
- data/spec/routing/accepts_routing_spec.rb +27 -0
- data/spec/views/accepts/edit.html.erb_spec.rb +18 -0
- data/spec/views/accepts/index.html.erb_spec.rb +25 -0
- data/spec/views/accepts/new.html.erb_spec.rb +29 -0
- data/spec/views/accepts/show.html.erb_spec.rb +17 -0
- data/spec/views/creates/index.html.erb_spec.rb +2 -2
- data/spec/views/exemplifies/index.html.erb_spec.rb +2 -2
- data/spec/views/owns/index.html.erb_spec.rb +2 -2
- data/spec/views/produces/index.html.erb_spec.rb +2 -2
- data/spec/views/realizes/index.html.erb_spec.rb +2 -2
- data/spec/views/series_has_manifestations/index.html.erb_spec.rb +2 -2
- metadata +50 -42
- data/app/views/resource_import_files/_show_object_list.html.erb +0 -26
- data/spec/dummy/lib/enju_leaf.rb +0 -9
- data/spec/dummy/lib/enju_leaf/calculate_stat.rb +0 -30
- data/spec/dummy/lib/plugins/ext/will_paginate.rb +0 -64
@@ -0,0 +1,83 @@
|
|
1
|
+
class AcceptsController < InheritedResources::Base
|
2
|
+
load_and_authorize_resource :except => :index
|
3
|
+
authorize_resource :only => :index
|
4
|
+
respond_to :html, :json
|
5
|
+
before_filter :get_basket, :only => [:index, :create]
|
6
|
+
|
7
|
+
# GET /accepts
|
8
|
+
# GET /accepts.json
|
9
|
+
def index
|
10
|
+
if params[:format] == 'csv'
|
11
|
+
@accepts = Accept.order('accepts.created_at DESC').page(params[:page]).per(65534)
|
12
|
+
else
|
13
|
+
if params[:accept]
|
14
|
+
@query = params[:accept][:item_identifier].to_s.strip
|
15
|
+
item = Item.where(:item_identifier => @query).first if @query.present?
|
16
|
+
end
|
17
|
+
|
18
|
+
if item
|
19
|
+
@accepts = Accept.order('accepts.created_at DESC').where(:item_id => item.id).page(params[:page])
|
20
|
+
else
|
21
|
+
if @basket
|
22
|
+
@accepts = @basket.accepts.page(params[:page])
|
23
|
+
else
|
24
|
+
@accepts = Accept.page(params[:page])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
respond_to do |format|
|
30
|
+
format.html # index.html.erb
|
31
|
+
format.json { render :json => @accepts }
|
32
|
+
format.js { @accept = Accept.new }
|
33
|
+
format.csv
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# GET /new
|
38
|
+
# GET /new.json
|
39
|
+
def new
|
40
|
+
@basket = Basket.new
|
41
|
+
@basket.user = current_user
|
42
|
+
@basket.save!
|
43
|
+
@accept = Accept.new
|
44
|
+
@accepts = []
|
45
|
+
|
46
|
+
respond_to do |format|
|
47
|
+
format.html # new.html.erb
|
48
|
+
format.json { render :json => @patron }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# POST /accepts
|
53
|
+
# POST /accepts.json
|
54
|
+
def create
|
55
|
+
unless @basket
|
56
|
+
access_denied; return
|
57
|
+
end
|
58
|
+
@accept.basket = @basket
|
59
|
+
@accept.librarian = current_user
|
60
|
+
|
61
|
+
flash[:message] = ''
|
62
|
+
if @accept.item_identifier.blank?
|
63
|
+
flash[:message] << t('accept.enter_item_identifier') if @accept.item_identifier.blank?
|
64
|
+
else
|
65
|
+
item = Item.where(:item_identifier => @accept.item_identifier.to_s.strip).first
|
66
|
+
end
|
67
|
+
@accept.item = item
|
68
|
+
|
69
|
+
respond_to do |format|
|
70
|
+
if @accept.save
|
71
|
+
flash[:message] << t('accept.successfully_accepted', :model => t('activerecord.models.accept'))
|
72
|
+
format.html { redirect_to basket_accepts_url(@basket) }
|
73
|
+
format.json { render :json => @accept, :status => :created, :location => @accept }
|
74
|
+
format.js { redirect_to basket_accepts_url(@basket, :format => :js) }
|
75
|
+
else
|
76
|
+
@accepts = @basket.accepts.page(params[:page])
|
77
|
+
format.html { render :action => "index" }
|
78
|
+
format.json { render :json => @accept.errors, :status => :unprocessable_entity }
|
79
|
+
format.js { render :action => "index" }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -17,7 +17,7 @@ class ItemsController < ApplicationController
|
|
17
17
|
# GET /items.json
|
18
18
|
def index
|
19
19
|
query = params[:query].to_s.strip
|
20
|
-
per_page = Item.
|
20
|
+
per_page = Item.default_per_page
|
21
21
|
@count = {}
|
22
22
|
if user_signed_in?
|
23
23
|
if current_user.has_role?('Librarian')
|
@@ -40,7 +40,7 @@ class ItemsController < ApplicationController
|
|
40
40
|
mode = 'not_on_shelf'
|
41
41
|
end
|
42
42
|
order = 'items.id'
|
43
|
-
@items = Item.inventory_items(@inventory_file, mode).order(order).page(params[:page]).
|
43
|
+
@items = Item.inventory_items(@inventory_file, mode).order(order).page(params[:page]).per(per_page)
|
44
44
|
else
|
45
45
|
access_denied
|
46
46
|
return
|
@@ -223,7 +223,7 @@ class ManifestationsController < ApplicationController
|
|
223
223
|
end
|
224
224
|
|
225
225
|
page ||= params[:page] || 1
|
226
|
-
per_page ||= Manifestation.
|
226
|
+
per_page ||= Manifestation.default_per_page
|
227
227
|
if params[:format] == 'sru'
|
228
228
|
search.query.start_record(params[:startRecord] || 1, params[:maximumRecords] || 200)
|
229
229
|
else
|
@@ -242,9 +242,9 @@ class ManifestationsController < ApplicationController
|
|
242
242
|
else
|
243
243
|
max_count = @count[:query_result]
|
244
244
|
end
|
245
|
-
@manifestations =
|
246
|
-
|
247
|
-
|
245
|
+
@manifestations = Kaminari.paginate_array(
|
246
|
+
search_result.results, :total_count => max_count
|
247
|
+
).page(page)
|
248
248
|
|
249
249
|
if params[:format].blank? or params[:format] == 'html'
|
250
250
|
@carrier_type_facet = search_result.facet(:carrier_type).rows
|
@@ -264,7 +264,7 @@ class ManifestationsController < ApplicationController
|
|
264
264
|
end
|
265
265
|
|
266
266
|
if defined?(EnjuSearchLog)
|
267
|
-
save_search_history(query, @manifestations.
|
267
|
+
save_search_history(query, @manifestations.limit_value, @count[:query_result], current_user)
|
268
268
|
end
|
269
269
|
|
270
270
|
if defined?(EnjuOai)
|
@@ -274,7 +274,7 @@ class ManifestationsController < ApplicationController
|
|
274
274
|
params[:resumptionToken],
|
275
275
|
@from_time || Manifestation.last.updated_at,
|
276
276
|
@until_time || Manifestation.first.updated_at,
|
277
|
-
@manifestations.
|
277
|
+
@manifestations.limit_value
|
278
278
|
)
|
279
279
|
else
|
280
280
|
@oai[:errors] << 'noRecordsMatch'
|
@@ -361,8 +361,8 @@ class ManifestationsController < ApplicationController
|
|
361
361
|
@reserve = current_user.reserves.where(:manifestation_id => @manifestation.id).first if user_signed_in?
|
362
362
|
end
|
363
363
|
|
364
|
-
if
|
365
|
-
@
|
364
|
+
if defined?(EnjuQuestion)
|
365
|
+
@questions = @manifestation.questions(:user => current_user, :page => params[:question_page])
|
366
366
|
end
|
367
367
|
|
368
368
|
if @manifestation.attachment.path
|
@@ -78,7 +78,7 @@ class PatronsController < ApplicationController
|
|
78
78
|
end
|
79
79
|
|
80
80
|
page = params[:page] || 1
|
81
|
-
search.query.paginate(page.to_i, Patron.
|
81
|
+
search.query.paginate(page.to_i, Patron.default_per_page)
|
82
82
|
@patrons = search.execute!.results
|
83
83
|
|
84
84
|
flash[:page_info] = {:page => page, :query => query}
|
@@ -109,9 +109,23 @@ class PatronsController < ApplicationController
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
|
-
|
113
|
-
|
114
|
-
@
|
112
|
+
patron = @patron
|
113
|
+
role = current_user.try(:role) || Role.default_role
|
114
|
+
@works = Manifestation.search do
|
115
|
+
with(:creator_ids).equal_to patron.id
|
116
|
+
with(:required_role_id).less_than_or_equal_to role.id
|
117
|
+
paginate :page => params[:work_list_page], :per_page => Manifestation.default_per_page
|
118
|
+
end.results
|
119
|
+
@expressions = Manifestation.search do
|
120
|
+
with(:contributor_ids).equal_to patron.id
|
121
|
+
with(:required_role_id).less_than_or_equal_to role.id
|
122
|
+
paginate :page => params[:expression_list_page], :per_page => Manifestation.default_per_page
|
123
|
+
end.results
|
124
|
+
@manifestations = Manifestation.search do
|
125
|
+
with(:publisher_ids).equal_to patron.id
|
126
|
+
with(:required_role_id).less_than_or_equal_to role.id
|
127
|
+
paginate :page => params[:manifestation_list_page], :per_page => Manifestation.default_per_page
|
128
|
+
end.results
|
115
129
|
|
116
130
|
respond_to do |format|
|
117
131
|
format.html # show.html.erb
|
@@ -9,7 +9,7 @@ class SeriesHasManifestationsController < ApplicationController
|
|
9
9
|
# GET /series_has_manifestations
|
10
10
|
# GET /series_has_manifestations.json
|
11
11
|
def index
|
12
|
-
@series_has_manifestations = SeriesHasManifestation.
|
12
|
+
@series_has_manifestations = SeriesHasManifestation.page(params[:page])
|
13
13
|
|
14
14
|
respond_to do |format|
|
15
15
|
format.html # index.html.erb
|
@@ -20,7 +20,7 @@ class SeriesStatementsController < ApplicationController
|
|
20
20
|
end
|
21
21
|
search.build do
|
22
22
|
fulltext query if query.present?
|
23
|
-
paginate :page => page.to_i, :per_page => SeriesStatement.
|
23
|
+
paginate :page => page.to_i, :per_page => SeriesStatement.default_per_page
|
24
24
|
order_by :position, :asc
|
25
25
|
end
|
26
26
|
#work = @work
|
@@ -34,7 +34,7 @@ class SeriesStatementsController < ApplicationController
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
page = params[:page] || 1
|
37
|
-
search.query.paginate(page.to_i, SeriesStatement.
|
37
|
+
search.query.paginate(page.to_i, SeriesStatement.default_per_page)
|
38
38
|
@series_statements = search.execute!.results
|
39
39
|
|
40
40
|
respond_to do |format|
|
@@ -46,9 +46,6 @@ class SeriesStatementsController < ApplicationController
|
|
46
46
|
# GET /series_statements/1
|
47
47
|
# GET /series_statements/1.json
|
48
48
|
def show
|
49
|
-
#@manifestations = @series_statement.manifestations.order('date_of_publication DESC').page(params[:manifestation_page]).per_page(Manifestation.per_page)
|
50
|
-
#store_location
|
51
|
-
|
52
49
|
respond_to do |format|
|
53
50
|
format.html { # show.html.erb
|
54
51
|
redirect_to series_statement_manifestations_url(@series_statement)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class Accept < ActiveRecord::Base
|
2
|
+
attr_accessible :item_identifier, :librarian_id, :item_id
|
3
|
+
default_scope :order => 'accepts.id DESC'
|
4
|
+
belongs_to :basket
|
5
|
+
belongs_to :item
|
6
|
+
belongs_to :librarian, :class_name => 'User'
|
7
|
+
|
8
|
+
validates_uniqueness_of :item_id, :message => I18n.t('accept.already_accepted')
|
9
|
+
validates_presence_of :item_id, :message => I18n.t('accept.item_not_found')
|
10
|
+
validates_presence_of :basket_id
|
11
|
+
|
12
|
+
before_save :accept!, :on => :create
|
13
|
+
|
14
|
+
attr_accessor :item_identifier
|
15
|
+
|
16
|
+
paginates_per 10
|
17
|
+
|
18
|
+
def accept!
|
19
|
+
if defined?(EnjuCirculation)
|
20
|
+
item.circulation_status = CirculationStatus.where(:name => 'Available On Shelf').first
|
21
|
+
end
|
22
|
+
item.save(:validate => false)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
# == Schema Information
|
26
|
+
#
|
27
|
+
# Table name: accepts
|
28
|
+
#
|
29
|
+
# id :integer not null, primary key
|
30
|
+
# basket_id :integer
|
31
|
+
# item_id :integer
|
32
|
+
# librarian_id :integer
|
33
|
+
# created_at :datetime not null
|
34
|
+
# updated_at :datetime not null
|
35
|
+
#
|
36
|
+
|
data/app/models/create.rb
CHANGED
data/app/models/donate.rb
CHANGED
data/app/models/exemplify.rb
CHANGED
data/app/models/item.rb
CHANGED
@@ -32,7 +32,7 @@ class Item < ActiveRecord::Base
|
|
32
32
|
has_paper_trail
|
33
33
|
normalize_attributes :item_identifier
|
34
34
|
|
35
|
-
enju_export
|
35
|
+
#enju_export
|
36
36
|
|
37
37
|
searchable do
|
38
38
|
text :item_identifier, :note, :title, :creator, :contributor, :publisher
|
@@ -84,9 +84,7 @@ class Item < ActiveRecord::Base
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
-
|
88
|
-
10
|
89
|
-
end
|
87
|
+
paginates_per 10
|
90
88
|
|
91
89
|
def title
|
92
90
|
manifestation.try(:original_title)
|
data/app/models/manifestation.rb
CHANGED
@@ -176,9 +176,8 @@ class Manifestation < ActiveRecord::Base
|
|
176
176
|
enju_ndl_search
|
177
177
|
#enju_amazon
|
178
178
|
enju_oai
|
179
|
-
#
|
180
|
-
#
|
181
|
-
enju_export
|
179
|
+
#enju_nii
|
180
|
+
#enju_export
|
182
181
|
|
183
182
|
has_paper_trail
|
184
183
|
if configatron.uploaded_file.storage == :s3
|
@@ -210,11 +209,9 @@ class Manifestation < ActiveRecord::Base
|
|
210
209
|
after_save :index_series_statement
|
211
210
|
after_destroy :index_series_statement
|
212
211
|
normalize_attributes :manifestation_identifier, :pub_date, :isbn, :issn, :nbn, :lccn, :original_title
|
213
|
-
|
212
|
+
paginates_per 10
|
214
213
|
|
215
|
-
|
216
|
-
10
|
217
|
-
end
|
214
|
+
attr_accessor :during_import
|
218
215
|
|
219
216
|
def check_isbn
|
220
217
|
if isbn.present?
|
@@ -510,7 +507,7 @@ class Manifestation < ActiveRecord::Base
|
|
510
507
|
if defined?(EnjuQuestion)
|
511
508
|
def questions(options = {})
|
512
509
|
id = self.id
|
513
|
-
options = {:page => 1, :per_page => Question.
|
510
|
+
options = {:page => 1, :per_page => Question.default_per_page}.merge(options)
|
514
511
|
page = options[:page]
|
515
512
|
per_page = options[:per_page]
|
516
513
|
user = options[:user]
|
data/app/models/own.rb
CHANGED
data/app/models/patron.rb
CHANGED
@@ -78,11 +78,9 @@ class Patron < ActiveRecord::Base
|
|
78
78
|
integer :patron_type_id
|
79
79
|
end
|
80
80
|
|
81
|
-
enju_export
|
81
|
+
#enju_export
|
82
82
|
|
83
|
-
|
84
|
-
10
|
85
|
-
end
|
83
|
+
paginates_per 10
|
86
84
|
|
87
85
|
def set_role_and_name
|
88
86
|
self.required_role = Role.where(:name => 'Librarian').first if self.required_role_id.nil?
|
data/app/models/picture_file.rb
CHANGED
@@ -21,10 +21,6 @@ class PictureFile < ActiveRecord::Base
|
|
21
21
|
# http://railsforum.com/viewtopic.php?id=11615
|
22
22
|
acts_as_list :scope => 'picture_attachable_type=\'#{picture_attachable_type}\''
|
23
23
|
normalize_attributes :picture_attachable_type
|
24
|
-
|
25
|
-
def self.per_page
|
26
|
-
10
|
27
|
-
end
|
28
24
|
end
|
29
25
|
|
30
26
|
# == Schema Information
|
data/app/models/produce.rb
CHANGED
data/app/models/realize.rb
CHANGED
@@ -25,12 +25,10 @@ class SeriesStatement < ActiveRecord::Base
|
|
25
25
|
integer :series_statement_merge_list_ids, :multiple => true if defined?(EnjuResourceMerge)
|
26
26
|
end
|
27
27
|
|
28
|
-
attr_accessor :selected
|
29
28
|
normalize_attributes :original_title, :issn
|
29
|
+
paginates_per 10
|
30
30
|
|
31
|
-
|
32
|
-
10
|
33
|
-
end
|
31
|
+
attr_accessor :selected
|
34
32
|
|
35
33
|
def last_issue
|
36
34
|
manifestations.where('date_of_publication IS NOT NULL').order('date_of_publication DESC').first || manifestations.order(:id).last
|