enju_biblio 0.3.10.rc.1 → 0.3.10.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/item_custom_properties_controller.rb +8 -3
- data/app/controllers/manifestation_custom_properties_controller.rb +8 -3
- data/app/controllers/manifestations_controller.rb +1 -1
- data/app/models/item.rb +8 -4
- data/app/models/item_custom_property.rb +7 -7
- data/app/models/item_custom_value.rb +3 -3
- data/app/models/manifestation.rb +38 -12
- data/app/models/manifestation_custom_property.rb +7 -7
- data/app/models/manifestation_custom_value.rb +3 -3
- data/app/models/picture_file.rb +0 -2
- data/app/models/resource_export_file.rb +4 -2
- data/app/models/resource_import_file.rb +74 -56
- data/app/policies/item_custom_property_policy.rb +3 -3
- data/app/policies/manifestation_custom_property_policy.rb +3 -3
- data/app/views/item_custom_properties/edit.html.erb +12 -5
- data/app/views/item_custom_properties/index.html.erb +14 -7
- data/app/views/item_custom_properties/new.html.erb +11 -4
- data/app/views/item_custom_properties/show.html.erb +24 -17
- data/app/views/manifestation_custom_properties/edit.html.erb +12 -5
- data/app/views/manifestation_custom_properties/index.html.erb +14 -7
- data/app/views/manifestation_custom_properties/new.html.erb +11 -4
- data/app/views/manifestation_custom_properties/show.html.erb +24 -17
- data/app/views/manifestations/_export_detail.html.erb +1 -0
- data/app/views/manifestations/_export_list.html.erb +1 -0
- data/app/views/manifestations/_form.html.erb +5 -0
- data/app/views/manifestations/_show_detail_librarian.html.erb +6 -0
- data/app/views/manifestations/_show_detail_user.html.erb +8 -0
- data/app/views/manifestations/show.json.jbuilder +2 -0
- data/config/locales/translation_en.yml +2 -0
- data/config/locales/translation_ja.yml +2 -0
- data/db/migrate/20081027150907_create_picture_files.rb +0 -2
- data/lib/enju_biblio/version.rb +1 -1
- data/spec/controllers/item_custom_properties_controller_spec.rb +449 -0
- data/spec/controllers/manifestation_custom_properties_controller_spec.rb +449 -0
- data/spec/dummy/db/schema.rb +0 -2
- data/spec/fixtures/item_custom_properties.yml +7 -7
- data/spec/fixtures/manifestation_custom_properties.yml +7 -7
- data/spec/fixtures/picture_files.yml +0 -2
- data/spec/models/item_custom_property_spec.rb +7 -7
- data/spec/models/item_custom_value_spec.rb +3 -3
- data/spec/models/manifestation_custom_property_spec.rb +7 -7
- data/spec/models/manifestation_custom_value_spec.rb +3 -3
- data/spec/models/manifestation_spec.rb +1 -1
- data/spec/models/picture_file_spec.rb +0 -2
- data/spec/models/resource_export_file_spec.rb +49 -8
- data/spec/models/resource_import_file_spec.rb +5 -1
- data/spec/views/item_custom_properties/index.html.erb_spec.rb +1 -0
- data/spec/views/manifestation_custom_properties/index.html.erb_spec.rb +1 -0
- data/spec/views/manifestations/show.json.jbuilder_spec.rb +16 -0
- metadata +543 -536
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 594364b4007cd3a2d5af9b206dc7d579c1ed730c373b9fe729fd3de1861f823f
|
4
|
+
data.tar.gz: 53f930524db4aeeaf96d8afb953930e42c131d5220b3dadb7d36c0d92b28468c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69f690f9759526909b6526c7af9c27ee59fdbb2f55749ef04d37e7843979768baf792d4db9ed7998f2a98393f46a985241b0014737a5caebb27319db9f219e93
|
7
|
+
data.tar.gz: 108835494715119038df44b303a935abd29f370fd587e344b419554cca9492a352b03aa13e78617937bd9a03d72401caf56544c21a40c0f7e9135831fbade087
|
@@ -25,7 +25,7 @@ class ItemCustomPropertiesController < ApplicationController
|
|
25
25
|
@item_custom_property = ItemCustomProperty.new(item_custom_property_params)
|
26
26
|
|
27
27
|
if @item_custom_property.save
|
28
|
-
redirect_to @item_custom_property, notice: '
|
28
|
+
redirect_to @item_custom_property, notice: t('controller.successfully_created', model: t('activerecord.models.item_custom_property'))
|
29
29
|
else
|
30
30
|
render :new
|
31
31
|
end
|
@@ -33,8 +33,13 @@ class ItemCustomPropertiesController < ApplicationController
|
|
33
33
|
|
34
34
|
# PATCH/PUT /item_custom_properties/1
|
35
35
|
def update
|
36
|
+
if params[:move]
|
37
|
+
move_position(@item_custom_property, params[:move])
|
38
|
+
return
|
39
|
+
end
|
40
|
+
|
36
41
|
if @item_custom_property.update(item_custom_property_params)
|
37
|
-
redirect_to @item_custom_property, notice: '
|
42
|
+
redirect_to @item_custom_property, notice: t('controller.successfully_updated', model: t('activerecord.models.item_custom_property'))
|
38
43
|
else
|
39
44
|
render :edit
|
40
45
|
end
|
@@ -43,7 +48,7 @@ class ItemCustomPropertiesController < ApplicationController
|
|
43
48
|
# DELETE /item_custom_properties/1
|
44
49
|
def destroy
|
45
50
|
@item_custom_property.destroy
|
46
|
-
redirect_to item_custom_properties_url, notice: '
|
51
|
+
redirect_to item_custom_properties_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.item_custom_property'))
|
47
52
|
end
|
48
53
|
|
49
54
|
private
|
@@ -25,7 +25,7 @@ class ManifestationCustomPropertiesController < ApplicationController
|
|
25
25
|
@manifestation_custom_property = ManifestationCustomProperty.new(manifestation_custom_property_params)
|
26
26
|
|
27
27
|
if @manifestation_custom_property.save
|
28
|
-
redirect_to @manifestation_custom_property, notice: '
|
28
|
+
redirect_to @manifestation_custom_property, notice: t('controller.successfully_created', model: t('activerecord.models.manifestation_custom_property'))
|
29
29
|
else
|
30
30
|
render :new
|
31
31
|
end
|
@@ -33,8 +33,13 @@ class ManifestationCustomPropertiesController < ApplicationController
|
|
33
33
|
|
34
34
|
# PATCH/PUT /manifestation_custom_properties/1
|
35
35
|
def update
|
36
|
+
if params[:move]
|
37
|
+
move_position(@manifestation_custom_property, params[:move])
|
38
|
+
return
|
39
|
+
end
|
40
|
+
|
36
41
|
if @manifestation_custom_property.update(manifestation_custom_property_params)
|
37
|
-
redirect_to @manifestation_custom_property, notice: '
|
42
|
+
redirect_to @manifestation_custom_property, notice: t('controller.successfully_updated', model: t('activerecord.models.manifestation_custom_property'))
|
38
43
|
else
|
39
44
|
render :edit
|
40
45
|
end
|
@@ -43,7 +48,7 @@ class ManifestationCustomPropertiesController < ApplicationController
|
|
43
48
|
# DELETE /manifestation_custom_properties/1
|
44
49
|
def destroy
|
45
50
|
@manifestation_custom_property.destroy
|
46
|
-
redirect_to manifestation_custom_properties_url, notice: '
|
51
|
+
redirect_to manifestation_custom_properties_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.manifestation_custom_property'))
|
47
52
|
end
|
48
53
|
|
49
54
|
private
|
data/app/models/item.rb
CHANGED
@@ -107,10 +107,11 @@ class Item < ApplicationRecord
|
|
107
107
|
record = {
|
108
108
|
item_id: id,
|
109
109
|
item_identifier: item_identifier,
|
110
|
+
binding_item_identifier: binding_item_identifier,
|
110
111
|
call_number: call_number,
|
111
112
|
shelf: shelf.name,
|
112
113
|
item_note: note,
|
113
|
-
accepted_at: accept
|
114
|
+
accepted_at: accept&.created_at,
|
114
115
|
acquired_at: acquired_at,
|
115
116
|
item_created_at: created_at,
|
116
117
|
item_updated_at: updated_at
|
@@ -118,8 +119,9 @@ class Item < ApplicationRecord
|
|
118
119
|
|
119
120
|
if ['Administrator', 'Librarian'].include?(role)
|
120
121
|
record.merge!({
|
121
|
-
bookstore: bookstore
|
122
|
-
budget_type: budget_type
|
122
|
+
bookstore: bookstore&.name,
|
123
|
+
budget_type: budget_type&.name,
|
124
|
+
item_required_role: required_role.name,
|
123
125
|
item_price: price,
|
124
126
|
memo: memo
|
125
127
|
})
|
@@ -131,7 +133,9 @@ class Item < ApplicationRecord
|
|
131
133
|
|
132
134
|
if defined?(EnjuCirculation)
|
133
135
|
record.merge!({
|
134
|
-
use_restriction: use_restriction
|
136
|
+
use_restriction: use_restriction&.name,
|
137
|
+
circulation_status: circulation_status&.name,
|
138
|
+
checkout_type: checkout_type&.name,
|
135
139
|
total_checkouts: checkouts.count
|
136
140
|
})
|
137
141
|
end
|
@@ -8,11 +8,11 @@ end
|
|
8
8
|
#
|
9
9
|
# Table name: item_custom_properties
|
10
10
|
#
|
11
|
-
# id
|
12
|
-
# name
|
13
|
-
#
|
14
|
-
# note
|
15
|
-
# position
|
16
|
-
# created_at
|
17
|
-
# updated_at
|
11
|
+
# id :integer not null, primary key
|
12
|
+
# name :string not null
|
13
|
+
# display_name :text not null
|
14
|
+
# note :text
|
15
|
+
# position :integer default(1), not null
|
16
|
+
# created_at :datetime not null
|
17
|
+
# updated_at :datetime not null
|
18
18
|
#
|
@@ -8,9 +8,9 @@ end
|
|
8
8
|
#
|
9
9
|
# Table name: item_custom_values
|
10
10
|
#
|
11
|
-
# id :
|
12
|
-
# item_custom_property_id :
|
13
|
-
# item_id :
|
11
|
+
# id :integer not null, primary key
|
12
|
+
# item_custom_property_id :integer not null
|
13
|
+
# item_id :integer not null
|
14
14
|
# value :text
|
15
15
|
# created_at :datetime not null
|
16
16
|
# updated_at :datetime not null
|
data/app/models/manifestation.rb
CHANGED
@@ -96,7 +96,7 @@ class Manifestation < ApplicationRecord
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
string :language do
|
99
|
-
language
|
99
|
+
language&.name
|
100
100
|
end
|
101
101
|
string :item_identifier, multiple: true do
|
102
102
|
if series_master?
|
@@ -120,7 +120,7 @@ class Manifestation < ApplicationRecord
|
|
120
120
|
end
|
121
121
|
time :date_of_publication
|
122
122
|
integer :pub_year do
|
123
|
-
date_of_publication
|
123
|
+
date_of_publication&.year
|
124
124
|
end
|
125
125
|
integer :creator_ids, multiple: true
|
126
126
|
integer :contributor_ids, multiple: true
|
@@ -357,7 +357,7 @@ class Manifestation < ApplicationRecord
|
|
357
357
|
# TODO: よりよい推薦方法
|
358
358
|
def self.pickup(keyword = nil, current_user = nil)
|
359
359
|
return nil if self.cached_numdocs < 5
|
360
|
-
if current_user
|
360
|
+
if current_user&.role
|
361
361
|
current_role_id = current_user.role.id
|
362
362
|
else
|
363
363
|
current_role_id = 1
|
@@ -433,7 +433,7 @@ class Manifestation < ApplicationRecord
|
|
433
433
|
end
|
434
434
|
|
435
435
|
def index_series_statement
|
436
|
-
series_statements.map{|s| s.index; s.root_manifestation
|
436
|
+
series_statements.map{|s| s.index; s.root_manifestation&.index}
|
437
437
|
end
|
438
438
|
|
439
439
|
def acquired_at
|
@@ -541,16 +541,34 @@ class Manifestation < ApplicationRecord
|
|
541
541
|
def to_hash(role: 'Guest')
|
542
542
|
record = {
|
543
543
|
manifestation_id: id,
|
544
|
-
|
544
|
+
original_title: original_title,
|
545
545
|
title_alternative: title_alternative,
|
546
546
|
title_transcription: title_transcription,
|
547
547
|
statement_of_responsibility: statement_of_responsibility,
|
548
548
|
serial: serial,
|
549
549
|
manifestation_identifier: manifestation_identifier,
|
550
|
-
creator:
|
551
|
-
|
552
|
-
|
553
|
-
|
550
|
+
creator: creates.map{|create|
|
551
|
+
if create.create_type
|
552
|
+
"#{create.agent.full_name}||#{create.creator_type.name}"
|
553
|
+
else
|
554
|
+
"#{create.agent.full_name}"
|
555
|
+
end
|
556
|
+
}.join('//'),
|
557
|
+
contributor: realizes.map{|realize|
|
558
|
+
if realize.realize_type
|
559
|
+
"#{realize.agent.full_name}||#{realize.realize_type.name}"
|
560
|
+
else
|
561
|
+
"#{realize.agent.full_name}"
|
562
|
+
end
|
563
|
+
}.join('//'),
|
564
|
+
publisher: produces.map{|produce|
|
565
|
+
if produce.produce_type
|
566
|
+
"#{produce.agent.full_name}||#{produce.realize_type.name}"
|
567
|
+
else
|
568
|
+
"#{produce.agent.full_name}"
|
569
|
+
end
|
570
|
+
}.join('//'),
|
571
|
+
pub_date: date_of_publication,
|
554
572
|
year_of_publication: year_of_publication,
|
555
573
|
publication_place: publication_place,
|
556
574
|
manifestation_created_at: created_at,
|
@@ -577,13 +595,13 @@ class Manifestation < ApplicationRecord
|
|
577
595
|
depth: depth,
|
578
596
|
price: price,
|
579
597
|
access_address: access_address,
|
580
|
-
|
598
|
+
manifestation_required_role: required_role.name,
|
581
599
|
description: description,
|
582
600
|
note: note
|
583
601
|
}
|
584
602
|
|
585
603
|
IdentifierType.find_each do |type|
|
586
|
-
record[type.name.to_sym] = identifiers.where(identifier_type: type).pluck(:body).join('//')
|
604
|
+
record[:"identifier:#{type.name.to_sym}"] = identifiers.where(identifier_type: type).pluck(:body).join('//')
|
587
605
|
end
|
588
606
|
|
589
607
|
series = series_statements.order(:position)
|
@@ -610,7 +628,7 @@ class Manifestation < ApplicationRecord
|
|
610
628
|
})
|
611
629
|
ManifestationCustomProperty.order(:position).each do |custom_property|
|
612
630
|
custom_value = manifestation_custom_values.find_by(manifestation_custom_property: custom_property)
|
613
|
-
record[:"manifestation:#{custom_property.name}"] = custom_value
|
631
|
+
record[:"manifestation:#{custom_property.name}"] = custom_value&.value
|
614
632
|
end
|
615
633
|
end
|
616
634
|
|
@@ -623,6 +641,14 @@ class Manifestation < ApplicationRecord
|
|
623
641
|
end
|
624
642
|
end
|
625
643
|
|
644
|
+
if defined?(EnjuNdl)
|
645
|
+
record["jpno"] = identifier_contents(:jpno).first
|
646
|
+
end
|
647
|
+
|
648
|
+
if defined?(EnjuNii)
|
649
|
+
record["ncid"] = ncid_record&.body
|
650
|
+
end
|
651
|
+
|
626
652
|
record
|
627
653
|
end
|
628
654
|
|
@@ -8,11 +8,11 @@ end
|
|
8
8
|
#
|
9
9
|
# Table name: manifestation_custom_properties
|
10
10
|
#
|
11
|
-
# id
|
12
|
-
# name
|
13
|
-
#
|
14
|
-
# note
|
15
|
-
# position
|
16
|
-
# created_at
|
17
|
-
# updated_at
|
11
|
+
# id :integer not null, primary key
|
12
|
+
# name :string not null
|
13
|
+
# display_name :text not null
|
14
|
+
# note :text
|
15
|
+
# position :integer default(1), not null
|
16
|
+
# created_at :datetime not null
|
17
|
+
# updated_at :datetime not null
|
18
18
|
#
|
@@ -8,9 +8,9 @@ end
|
|
8
8
|
#
|
9
9
|
# Table name: manifestation_custom_values
|
10
10
|
#
|
11
|
-
# id :
|
12
|
-
# manifestation_custom_property_id :
|
13
|
-
# manifestation_id :
|
11
|
+
# id :integer not null, primary key
|
12
|
+
# manifestation_custom_property_id :integer not null
|
13
|
+
# manifestation_id :integer not null
|
14
14
|
# value :text
|
15
15
|
# created_at :datetime not null
|
16
16
|
# updated_at :datetime not null
|
data/app/models/picture_file.rb
CHANGED
@@ -31,8 +31,10 @@ class ResourceExportFile < ApplicationRecord
|
|
31
31
|
transition_to!(:started)
|
32
32
|
role_name = user.try(:role).try(:name)
|
33
33
|
tsv = Manifestation.export(role: role_name)
|
34
|
-
|
35
|
-
|
34
|
+
file = StringIO.new(tsv)
|
35
|
+
file.class.class_eval { attr_accessor :original_filename, :content_type }
|
36
|
+
file.original_filename = 'resource_export.txt'
|
37
|
+
self.resource_export = file
|
36
38
|
save!
|
37
39
|
transition_to!(:completed)
|
38
40
|
mailer = ResourceExportMailer.completed(self)
|
@@ -322,55 +322,15 @@ class ResourceImportFile < ApplicationRecord
|
|
322
322
|
rows.each do |row|
|
323
323
|
row_num += 1
|
324
324
|
import_result = ResourceImportResult.create!(resource_import_file_id: id, body: row.fields.join("\t"))
|
325
|
-
|
326
|
-
item
|
325
|
+
item = Item.find_by(item_identifier: row['item_identifier'].to_s.strip) if row['item_identifier'].to_s.strip.present?
|
326
|
+
unless item
|
327
|
+
item = Item.find_by(id: row['item_id'].to_s.strip) if row['item_id'].to_s.strip.present?
|
328
|
+
end
|
329
|
+
|
327
330
|
if item
|
328
331
|
if item.manifestation
|
329
332
|
fetch(row, edit_mode: 'update')
|
330
|
-
|
331
|
-
|
332
|
-
shelf = Shelf.find_by(name: row['shelf'].to_s.strip)
|
333
|
-
bookstore = Bookstore.find_by(name: row['bookstore'])
|
334
|
-
required_role = Role.find_by(name: row['required_role'])
|
335
|
-
|
336
|
-
item.shelf = shelf if shelf
|
337
|
-
item.bookstore = bookstore if bookstore
|
338
|
-
item.required_role = required_role if required_role
|
339
|
-
|
340
|
-
acquired_at = Time.zone.parse(row['acquired_at']) rescue nil
|
341
|
-
binded_at = Time.zone.parse(row['binded_at']) rescue nil
|
342
|
-
item.acquired_at = acquired_at if acquired_at
|
343
|
-
item.binded_at = binded_at if binded_at
|
344
|
-
|
345
|
-
if defined?(EnjuCirculation)
|
346
|
-
circulation_status = CirculationStatus.find_by(name: row['circulation_status'])
|
347
|
-
checkout_type = CheckoutType.find_by(name: row['checkout_type'])
|
348
|
-
use_restriction = UseRestriction.find_by(name: row['use_restriction'].to_s.strip)
|
349
|
-
item.circulation_status = circulation_status if circulation_status
|
350
|
-
item.checkout_type = checkout_type if checkout_type
|
351
|
-
item.use_restriction = use_restriction if use_restriction
|
352
|
-
end
|
353
|
-
|
354
|
-
item_columns = %w(
|
355
|
-
call_number
|
356
|
-
binding_item_identifier binding_call_number binded_at
|
357
|
-
)
|
358
|
-
item_columns.each do |column|
|
359
|
-
if row[column].present?
|
360
|
-
item.assign_attributes(:"#{column}" => row[column])
|
361
|
-
end
|
362
|
-
end
|
363
|
-
|
364
|
-
item.price = row['item_price'] if row['item_price'].present?
|
365
|
-
item.note = row['item_note'].try(:gsub, /\\n/, "\n") if row['item_note'].present?
|
366
|
-
item.url = row['item_url'] if row['item_url'].present?
|
367
|
-
|
368
|
-
if row['include_supplements']
|
369
|
-
if %w(t true).include?(row['include_supplements'].downcase.strip)
|
370
|
-
item.include_supplements = true
|
371
|
-
else
|
372
|
-
item.include_supplements = false if item.include_supplements
|
373
|
-
end
|
333
|
+
item = update_item(item, row)
|
374
334
|
end
|
375
335
|
|
376
336
|
ResourceImportFile.import_item_custom_value(row, item).each do |value|
|
@@ -419,8 +379,11 @@ class ResourceImportFile < ApplicationRecord
|
|
419
379
|
|
420
380
|
rows.each do |row|
|
421
381
|
row_num += 1
|
422
|
-
|
423
|
-
item
|
382
|
+
item = Item.find_by(item_identifier: row['item_identifier'].to_s.strip) if row['item_identifier'].to_s.strip.present?
|
383
|
+
unless item
|
384
|
+
item = Item.find_by(id: row['item_id'].to_s.strip) if row['item_id'].to_s.strip.present?
|
385
|
+
end
|
386
|
+
|
424
387
|
if item
|
425
388
|
item.destroy if item.removable?
|
426
389
|
end
|
@@ -444,10 +407,9 @@ class ResourceImportFile < ApplicationRecord
|
|
444
407
|
row_num = 1
|
445
408
|
|
446
409
|
rows.each do |row|
|
447
|
-
|
448
|
-
item = Item.find_by(item_identifier: item_identifier)
|
410
|
+
item = Item.find_by(item_identifier: row['item_identifier'].to_s.strip) if row['item_identifier'].to_s.strip.present?
|
449
411
|
unless item
|
450
|
-
item = Item.find_by(id: row['item_id'].to_s.strip)
|
412
|
+
item = Item.find_by(id: row['item_id'].to_s.strip) if row['item_id'].to_s.strip.present?
|
451
413
|
end
|
452
414
|
|
453
415
|
manifestation_identifier = row['manifestation_identifier'].to_s.strip
|
@@ -603,12 +565,68 @@ class ResourceImportFile < ApplicationRecord
|
|
603
565
|
item
|
604
566
|
end
|
605
567
|
|
568
|
+
def update_item(item, row)
|
569
|
+
shelf = Shelf.find_by(name: row['shelf'].to_s.strip)
|
570
|
+
bookstore = Bookstore.find_by(name: row['bookstore'])
|
571
|
+
required_role = Role.find_by(name: row['required_role'])
|
572
|
+
|
573
|
+
item.shelf = shelf if shelf
|
574
|
+
item.bookstore = bookstore if bookstore
|
575
|
+
item.required_role = required_role if required_role
|
576
|
+
|
577
|
+
acquired_at = Time.zone.parse(row['acquired_at']) rescue nil
|
578
|
+
binded_at = Time.zone.parse(row['binded_at']) rescue nil
|
579
|
+
item.acquired_at = acquired_at if acquired_at
|
580
|
+
item.binded_at = binded_at if binded_at
|
581
|
+
|
582
|
+
if defined?(EnjuCirculation)
|
583
|
+
circulation_status = CirculationStatus.find_by(name: row['circulation_status'])
|
584
|
+
checkout_type = CheckoutType.find_by(name: row['checkout_type'])
|
585
|
+
use_restriction = UseRestriction.find_by(name: row['use_restriction'].to_s.strip)
|
586
|
+
item.circulation_status = circulation_status if circulation_status
|
587
|
+
item.checkout_type = checkout_type if checkout_type
|
588
|
+
item.use_restriction = use_restriction if use_restriction
|
589
|
+
end
|
590
|
+
|
591
|
+
item_columns = %w(
|
592
|
+
call_number
|
593
|
+
binding_item_identifier binding_call_number binded_at
|
594
|
+
)
|
595
|
+
item_columns.each do |column|
|
596
|
+
if row[column].present?
|
597
|
+
item.assign_attributes(:"#{column}" => row[column])
|
598
|
+
end
|
599
|
+
end
|
600
|
+
|
601
|
+
item.price = row['item_price'] if row['item_price'].present?
|
602
|
+
item.note = row['item_note'].try(:gsub, /\\n/, "\n") if row['item_note'].present?
|
603
|
+
item.url = row['item_url'] if row['item_url'].present?
|
604
|
+
|
605
|
+
if row['include_supplements']
|
606
|
+
if %w(t true).include?(row['include_supplements'].downcase.strip)
|
607
|
+
item.include_supplements = true
|
608
|
+
else
|
609
|
+
item.include_supplements = false if item.include_supplements
|
610
|
+
end
|
611
|
+
end
|
612
|
+
|
613
|
+
item
|
614
|
+
end
|
615
|
+
|
606
616
|
def fetch(row, options = {edit_mode: 'create'})
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
617
|
+
manifestation = nil
|
618
|
+
item = nil
|
619
|
+
|
620
|
+
if options[:edit_mode] == 'update'
|
621
|
+
if row['item_identifier'].to_s.strip.present?
|
622
|
+
item = Item.find_by(item_identifier: row['item_identifier'].to_s.strip)
|
623
|
+
end
|
624
|
+
if row['item_id'].to_s.strip.present?
|
625
|
+
item = Item.find_by(id: row['item_id'].to_s.strip)
|
626
|
+
end
|
627
|
+
|
628
|
+
manifestation = item.manifestation if item
|
629
|
+
|
612
630
|
unless manifestation
|
613
631
|
manifestation_identifier = row['manifestation_identifier'].to_s.strip
|
614
632
|
manifestation = Manifestation.find_by(manifestation_identifier: manifestation_identifier) if manifestation_identifier
|