enju_biblio 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/items_controller.rb +0 -4
- data/app/controllers/manifestations_controller.rb +4 -10
- data/app/models/agent.rb +6 -6
- data/app/models/agent_import_file.rb +7 -7
- data/app/models/item.rb +0 -12
- data/app/models/manifestation.rb +0 -12
- data/app/models/resource_import_file.rb +15 -15
- data/app/views/agent_import_results/index.txt.ruby +5 -0
- data/app/views/agent_relationship_types/_form.html.erb +1 -1
- data/app/views/agent_types/_form.html.erb +1 -1
- data/app/views/carrier_types/_form.html.erb +1 -1
- data/app/views/create_types/_form.html.erb +1 -1
- data/app/views/form_of_works/_form.html.erb +1 -1
- data/app/views/frequencies/_form.html.erb +1 -1
- data/app/views/items/_form.html.erb +0 -10
- data/app/views/items/show.html.erb +0 -7
- data/app/views/licenses/_form.html.erb +1 -1
- data/app/views/manifestation_relationship_types/_form.html.erb +1 -1
- data/app/views/manifestations/_form.html.erb +0 -10
- data/app/views/manifestations/_show_detail_librarian.html.erb +0 -8
- data/app/views/medium_of_performances/_form.html.erb +1 -1
- data/app/views/produce_types/_form.html.erb +1 -1
- data/app/views/realize_types/_form.html.erb +1 -1
- data/app/views/resource_import_results/index.txt.ruby +5 -0
- data/app/views/series_statement_merges/_form.html.erb +1 -1
- data/db/migrate/20200322053443_add_default_custom_label_to_library_group.rb +6 -0
- data/db/migrate/20200322083313_create_custom_labels.rb +10 -0
- data/db/migrate/{20191219122214_create_custom_properties.rb → 20200322083458_create_custom_properties.rb} +1 -1
- data/lib/enju_biblio/version.rb +1 -1
- data/spec/controllers/items_controller_spec.rb +0 -25
- data/spec/controllers/manifestations_controller_spec.rb +0 -25
- data/spec/dummy/db/schema.rb +13 -2
- data/spec/fixtures/library_groups.yml +31 -15
- data/spec/fixtures/resource_import_results.yml +2 -2
- data/spec/models/manifestation_spec.rb +0 -25
- data/spec/views/agent_import_results/index.html.erb_spec.rb +29 -0
- data/spec/views/agent_import_results/index.txt.ruby_spec.rb +20 -0
- data/spec/views/agent_import_results/show.html.erb_spec.rb +24 -0
- data/spec/views/manifestations/show.txt.ruby_spec.rb +1 -1
- data/spec/views/resource_import_results/index.txt.ruby_spec.rb +22 -0
- data/spec/views/resource_import_results/show.html.erb_spec.rb +1 -1
- metadata +33 -32
- data/app/models/custom_property.rb +0 -17
- data/app/views/agent_import_results/index.txt.erb +0 -3
- data/app/views/items/_custom_property_fields.html.erb +0 -7
- data/app/views/manifestations/_custom_property_fields.html.erb +0 -7
- data/app/views/resource_import_results/index.txt.erb +0 -3
- data/spec/factories/custom_property.rb +0 -18
- data/spec/models/custom_property_spec.rb +0 -18
- data/spec/system/custom_properties_spec.rb +0 -84
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26edca170abbc3255a6a2f00579b4da714df3bbe174873e4b110c79da9c59a87
|
4
|
+
data.tar.gz: 2e7d74038d3e5bfb1f2fb44f54a6e86aad624b84e8f20c55cb818a4bf74e8bf0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6e053f60b7a611c81ddc0b052def4209d96d1fd23044dc81296dc755e19409d64b625109f34da67588c7984fce670cc4b74973b99af927a459ea910b6d9f4c5
|
7
|
+
data.tar.gz: 1d920ee17e99acf17fd92e18ff3186139daf93940e1be813b5b1f99ffdc0d008029bde5735c05a4978363b185d32090b4f683f3abc63786d7641285f903924f2
|
@@ -274,10 +274,6 @@ class ItemsController < ApplicationController
|
|
274
274
|
:binding_item_identifier, :binding_call_number, :binded_at,
|
275
275
|
:use_restriction_id, :memo,
|
276
276
|
{item_has_use_restriction_attributes: :use_restriction_id}, # EnjuCirculation
|
277
|
-
{custom_properties_attributes: [
|
278
|
-
:id, :label, :value,
|
279
|
-
:_destroy
|
280
|
-
]}
|
281
277
|
)
|
282
278
|
end
|
283
279
|
|
@@ -355,8 +355,8 @@ class ManifestationsController < ApplicationController
|
|
355
355
|
# GET /manifestations/new.json
|
356
356
|
def new
|
357
357
|
@manifestation = Manifestation.new
|
358
|
-
@manifestation.language = Language.
|
359
|
-
@parent = Manifestation.
|
358
|
+
@manifestation.language = Language.find_by(iso_639_1: @locale)
|
359
|
+
@parent = Manifestation.find_by(id: params[:parent_id]) if params[:parent_id].present?
|
360
360
|
if @parent
|
361
361
|
@manifestation.parent_id = @parent.id
|
362
362
|
[ :original_title, :title_transcription,
|
@@ -549,10 +549,6 @@ class ManifestationsController < ApplicationController
|
|
549
549
|
{identifiers_attributes: [
|
550
550
|
:id, :body, :identifier_type_id,
|
551
551
|
:_destroy
|
552
|
-
]},
|
553
|
-
{custom_properties_attributes: [
|
554
|
-
:id, :label, :value,
|
555
|
-
:_destroy
|
556
552
|
]}
|
557
553
|
)
|
558
554
|
end
|
@@ -783,7 +779,7 @@ class ManifestationsController < ApplicationController
|
|
783
779
|
if options[:pub_date_from].blank?
|
784
780
|
pub_date[:from] = "*"
|
785
781
|
else
|
786
|
-
year = options[:pub_date_from].rjust(4, "0")
|
782
|
+
year = options[:pub_date_from].to_s.gsub(/\D/, '').rjust(4, "0")
|
787
783
|
if year.length == 4
|
788
784
|
pub_date[:from] = Time.zone.parse(Time.utc(year).to_s).beginning_of_year.utc.iso8601
|
789
785
|
else
|
@@ -797,7 +793,7 @@ class ManifestationsController < ApplicationController
|
|
797
793
|
if options[:pub_date_until].blank?
|
798
794
|
pub_date[:until] = "*"
|
799
795
|
else
|
800
|
-
year = options[:pub_date_until].rjust(4, "0")
|
796
|
+
year = options[:pub_date_until].to_s.gsub(/\D/, '').rjust(4, "0")
|
801
797
|
if year.length == 4
|
802
798
|
pub_date[:until] = Time.zone.parse(Time.utc(year).to_s).end_of_year.utc.iso8601
|
803
799
|
else
|
@@ -812,8 +808,6 @@ class ManifestationsController < ApplicationController
|
|
812
808
|
|
813
809
|
def set_pub_date(query, options)
|
814
810
|
unless options[:pub_date_from].blank? && options[:pub_date_until].blank?
|
815
|
-
options[:pub_date_from].to_s.gsub!(/\D/, '')
|
816
|
-
options[:pub_date_until].to_s.gsub!(/\D/, '')
|
817
811
|
pub_date = parse_pub_date(options)
|
818
812
|
query = "#{query} date_of_publication_d:[#{pub_date[:from]} TO #{pub_date[:until]}]"
|
819
813
|
end
|
data/app/models/agent.rb
CHANGED
@@ -76,7 +76,7 @@ class Agent < ApplicationRecord
|
|
76
76
|
paginates_per 10
|
77
77
|
|
78
78
|
def set_role_and_name
|
79
|
-
self.required_role = Role.
|
79
|
+
self.required_role = Role.find_by(name: 'Librarian') if required_role_id.nil?
|
80
80
|
set_full_name
|
81
81
|
end
|
82
82
|
|
@@ -202,15 +202,15 @@ class Agent < ApplicationRecord
|
|
202
202
|
end
|
203
203
|
|
204
204
|
def created(work)
|
205
|
-
creates.
|
205
|
+
creates.find_by(work_id: work.id)
|
206
206
|
end
|
207
207
|
|
208
208
|
def realized(expression)
|
209
|
-
realizes.
|
209
|
+
realizes.find_by(expression_id: expression.id)
|
210
210
|
end
|
211
211
|
|
212
212
|
def produced(manifestation)
|
213
|
-
produces.
|
213
|
+
produces.find_by(manifestation_id: manifestation.id)
|
214
214
|
end
|
215
215
|
|
216
216
|
def owned(item)
|
@@ -222,7 +222,7 @@ class Agent < ApplicationRecord
|
|
222
222
|
agent_lists.each do |agent_list|
|
223
223
|
name_and_role = agent_list[:full_name].split('||')
|
224
224
|
if agent_list[:agent_identifier].present?
|
225
|
-
agent = Agent.
|
225
|
+
agent = Agent.find_by(agent_identifier: agent_list[:agent_identifier])
|
226
226
|
else
|
227
227
|
agents_matched = Agent.where(full_name: name_and_role[0])
|
228
228
|
agents_matched = agents_matched.where(place: agent_list[:place]) if agent_list[:place]
|
@@ -237,7 +237,7 @@ class Agent < ApplicationRecord
|
|
237
237
|
place: agent_list[:place],
|
238
238
|
language_id: 1,
|
239
239
|
)
|
240
|
-
agent.required_role = Role.
|
240
|
+
agent.required_role = Role.find_by(name: 'Guest')
|
241
241
|
agent.save
|
242
242
|
end
|
243
243
|
agents << agent
|
@@ -116,7 +116,7 @@ class AgentImportFile < ApplicationRecord
|
|
116
116
|
rows.each do |row|
|
117
117
|
row_num += 1
|
118
118
|
next if row['dummy'].to_s.strip.present?
|
119
|
-
agent = Agent.
|
119
|
+
agent = Agent.find_by(id: row['id'])
|
120
120
|
if agent
|
121
121
|
agent.full_name = row['full_name'] if row['full_name'].to_s.strip.present?
|
122
122
|
agent.full_name_transcription = row['full_name_transcription'] if row['full_name_transcription'].to_s.strip.present?
|
@@ -151,7 +151,7 @@ class AgentImportFile < ApplicationRecord
|
|
151
151
|
rows.each do |row|
|
152
152
|
row_num += 1
|
153
153
|
next if row['dummy'].to_s.strip.present?
|
154
|
-
agent = Agent.
|
154
|
+
agent = Agent.find_by(id: row['id'].to_s.strip)
|
155
155
|
if agent
|
156
156
|
agent.picture_files.destroy_all
|
157
157
|
agent.reload
|
@@ -225,15 +225,15 @@ class AgentImportFile < ApplicationRecord
|
|
225
225
|
|
226
226
|
#if row['username'].to_s.strip.blank?
|
227
227
|
agent.email = row['email'].to_s.strip
|
228
|
-
agent.required_role = Role.
|
228
|
+
agent.required_role = Role.find_by(name: row['required_role'].to_s.strip.camelize) || Role.find_by(name: 'Guest')
|
229
229
|
#else
|
230
230
|
# agent.required_role = Role.where(name: row['required_role'].to_s.strip.camelize).first || Role.where('Librarian').first
|
231
231
|
#end
|
232
|
-
language = Language.
|
233
|
-
language = Language.
|
234
|
-
language = Language.
|
232
|
+
language = Language.find_by(name: row['language'].to_s.strip.camelize)
|
233
|
+
language = Language.find_by(iso_639_2: row['language'].to_s.strip.downcase) unless language
|
234
|
+
language = Language.find_by(iso_639_1: row['language'].to_s.strip.downcase) unless language
|
235
235
|
agent.language = language if language
|
236
|
-
country = Country.
|
236
|
+
country = Country.find_by(name: row['country'].to_s.strip)
|
237
237
|
agent.country = country if country
|
238
238
|
agent
|
239
239
|
end
|
data/app/models/item.rb
CHANGED
@@ -19,8 +19,6 @@ class Item < ApplicationRecord
|
|
19
19
|
belongs_to :budget_type, optional: true
|
20
20
|
has_one :accept, dependent: :destroy
|
21
21
|
has_one :withdraw, dependent: :destroy
|
22
|
-
has_many :custom_properties, as: :resource, dependent: :destroy
|
23
|
-
accepts_nested_attributes_for :custom_properties, allow_destroy: true, reject_if: :all_blank
|
24
22
|
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)}
|
25
23
|
|
26
24
|
belongs_to :shelf, counter_cache: true
|
@@ -124,16 +122,6 @@ class Item < ApplicationRecord
|
|
124
122
|
memo: memo
|
125
123
|
})
|
126
124
|
|
127
|
-
# 最もカスタム項目の多い資料について、カスタム項目の個数を取得する
|
128
|
-
ActiveRecord::Base.connection.execute('SELECT max(record_count) FROM (SELECT count(*) AS record_count, resource_id, resource_type FROM custom_properties GROUP BY resource_id, resource_type) AS type_count ;').first.values[0].to_i.times do |i|
|
129
|
-
property = custom_properties[i]
|
130
|
-
if property
|
131
|
-
record[:"item_custom_property_#{i + 1}"] = "#{property.label}: #{property.value}"
|
132
|
-
else
|
133
|
-
record[:"item_custom_property_#{i + 1}"] = nil
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
125
|
if defined?(EnjuCirculation)
|
138
126
|
record.merge!({
|
139
127
|
use_restriction: use_restriction.try(:name),
|
data/app/models/manifestation.rb
CHANGED
@@ -25,13 +25,11 @@ class Manifestation < ApplicationRecord
|
|
25
25
|
belongs_to :required_role, class_name: 'Role', foreign_key: 'required_role_id'
|
26
26
|
has_one :resource_import_result
|
27
27
|
has_many :identifiers, dependent: :destroy
|
28
|
-
has_many :custom_properties, as: :resource, dependent: :destroy
|
29
28
|
accepts_nested_attributes_for :creators, allow_destroy: true, reject_if: :all_blank
|
30
29
|
accepts_nested_attributes_for :contributors, allow_destroy: true, reject_if: :all_blank
|
31
30
|
accepts_nested_attributes_for :publishers, allow_destroy: true, reject_if: :all_blank
|
32
31
|
accepts_nested_attributes_for :series_statements, allow_destroy: true, reject_if: :all_blank
|
33
32
|
accepts_nested_attributes_for :identifiers, allow_destroy: true, reject_if: :all_blank
|
34
|
-
accepts_nested_attributes_for :custom_properties, allow_destroy: true, reject_if: :all_blank
|
35
33
|
|
36
34
|
searchable do
|
37
35
|
text :title, default_boost: 2 do
|
@@ -608,16 +606,6 @@ class Manifestation < ApplicationRecord
|
|
608
606
|
record.merge!({
|
609
607
|
memo: memo
|
610
608
|
})
|
611
|
-
|
612
|
-
# 最もカスタム項目の多い資料について、カスタム項目の個数を取得する
|
613
|
-
ActiveRecord::Base.connection.execute('SELECT max(record_count) FROM (SELECT count(*) AS record_count, resource_id, resource_type FROM custom_properties GROUP BY resource_id, resource_type) AS type_count ;').first.values[0].to_i.times do |i|
|
614
|
-
property = custom_properties[i]
|
615
|
-
if property
|
616
|
-
record[:"manifestation_custom_property_#{i + 1}"] = "#{property.label}: #{property.value}"
|
617
|
-
else
|
618
|
-
record[:"manifestation_custom_property_#{i + 1}"] = nil
|
619
|
-
end
|
620
|
-
end
|
621
609
|
end
|
622
610
|
|
623
611
|
if defined?(EnjuSubject)
|
@@ -318,28 +318,28 @@ class ResourceImportFile < ApplicationRecord
|
|
318
318
|
fetch(row, edit_mode: 'update')
|
319
319
|
end
|
320
320
|
|
321
|
-
if defined?(EnjuCirculation)
|
322
|
-
circulation_status = CirculationStatus.find_by(name: row['circulation_status'])
|
323
|
-
checkout_type = CheckoutType.find_by(name: row['checkout_type'])
|
324
|
-
use_restriction = UseRestriction.find_by(name: row['use_restriction'].to_s.strip)
|
325
|
-
end
|
326
|
-
|
327
321
|
shelf = Shelf.find_by(name: row['shelf'].to_s.strip)
|
328
322
|
bookstore = Bookstore.find_by(name: row['bookstore'])
|
329
323
|
required_role = Role.find_by(name: row['required_role'])
|
330
324
|
|
331
325
|
item.shelf = shelf if shelf
|
332
|
-
item.circulation_status = circulation_status if circulation_status
|
333
|
-
item.checkout_type = checkout_type if checkout_type
|
334
326
|
item.bookstore = bookstore if bookstore
|
335
327
|
item.required_role = required_role if required_role
|
336
|
-
item.use_restriction = use_restriction if use_restriction
|
337
328
|
|
338
329
|
acquired_at = Time.zone.parse(row['acquired_at']) rescue nil
|
339
330
|
binded_at = Time.zone.parse(row['binded_at']) rescue nil
|
340
331
|
item.acquired_at = acquired_at if acquired_at
|
341
332
|
item.binded_at = binded_at if binded_at
|
342
333
|
|
334
|
+
if defined?(EnjuCirculation)
|
335
|
+
circulation_status = CirculationStatus.find_by(name: row['circulation_status'])
|
336
|
+
checkout_type = CheckoutType.find_by(name: row['checkout_type'])
|
337
|
+
use_restriction = UseRestriction.find_by(name: row['use_restriction'].to_s.strip)
|
338
|
+
item.circulation_status = circulation_status if circulation_status
|
339
|
+
item.checkout_type = checkout_type if checkout_type
|
340
|
+
item.use_restriction = use_restriction if use_restriction
|
341
|
+
end
|
342
|
+
|
343
343
|
item_columns = %w(
|
344
344
|
call_number
|
345
345
|
binding_item_identifier binding_call_number binded_at
|
@@ -608,13 +608,13 @@ class ResourceImportFile < ApplicationRecord
|
|
608
608
|
end
|
609
609
|
|
610
610
|
# TODO: 小数点以下の表現
|
611
|
-
language = Language.
|
612
|
-
language = Language.
|
613
|
-
language = Language.
|
611
|
+
language = Language.find_by(name: row['language'].to_s.strip.camelize)
|
612
|
+
language = Language.find_by(iso_639_2: row['language'].to_s.strip.downcase) unless language
|
613
|
+
language = Language.find_by(iso_639_1: row['language'].to_s.strip.downcase) unless language
|
614
614
|
|
615
|
-
carrier_type = CarrierType.
|
616
|
-
content_type = ContentType.
|
617
|
-
frequency = Frequency.
|
615
|
+
carrier_type = CarrierType.find_by(name: row['carrier_type'].to_s.strip)
|
616
|
+
content_type = ContentType.find_by(name: row['content_type'].to_s.strip)
|
617
|
+
frequency = Frequency.find_by(name: row['frequency'].to_s.strip)
|
618
618
|
|
619
619
|
fulltext_content = serial = nil
|
620
620
|
if %w(t true).include?(row['fulltext_content'].to_s.downcase.strip)
|
@@ -89,16 +89,6 @@
|
|
89
89
|
<%= f.text_field :binding_item_identifier, class: 'resource_identifier' -%>
|
90
90
|
</div>
|
91
91
|
|
92
|
-
<div class="field">
|
93
|
-
<%= f.label :custom_property -%><br />
|
94
|
-
<%= f.fields_for :custom_properties do |custom_property_form| %>
|
95
|
-
<%= render 'custom_property_fields', f: custom_property_form %>
|
96
|
-
<% end %>
|
97
|
-
<div class="links">
|
98
|
-
<p><%= link_to_add_association t('page.add'), f, :custom_properties %></p>
|
99
|
-
</div>
|
100
|
-
</div>
|
101
|
-
|
102
92
|
<div class="field">
|
103
93
|
<%= f.label :note -%><br />
|
104
94
|
<%= f.text_area :note, class: 'resource_textarea' -%>
|
@@ -112,13 +112,6 @@
|
|
112
112
|
</p>
|
113
113
|
|
114
114
|
<% if current_user.try(:has_role?, 'Librarian') %>
|
115
|
-
<% @item.custom_properties.each do |custom_property| %>
|
116
|
-
<p>
|
117
|
-
<strong><%= custom_property.label -%>:</strong>
|
118
|
-
<%= custom_property.value -%>
|
119
|
-
</p>
|
120
|
-
<% end %>
|
121
|
-
|
122
115
|
<p>
|
123
116
|
<strong><%= t('activerecord.attributes.item.memo') -%>:</strong>
|
124
117
|
<%= simple_format(@item.memo) %>
|
@@ -192,16 +192,6 @@
|
|
192
192
|
<%= f.text_area :description, class: 'resource_textarea' -%>
|
193
193
|
</div>
|
194
194
|
|
195
|
-
<div class="field">
|
196
|
-
<%= f.label :custom_property -%><br />
|
197
|
-
<%= f.fields_for :custom_properties do |custom_property_form| %>
|
198
|
-
<%= render 'custom_property_fields', f: custom_property_form %>
|
199
|
-
<% end %>
|
200
|
-
<div class="links">
|
201
|
-
<p><%= link_to_add_association t('page.add'), f, :custom_properties %></p>
|
202
|
-
</div>
|
203
|
-
</div>
|
204
|
-
|
205
195
|
<div class="field">
|
206
196
|
<%= f.label :note -%><br />
|
207
197
|
<%= f.text_area :note, class: 'resource_textarea' -%>
|
@@ -101,14 +101,6 @@
|
|
101
101
|
<%= raw simple_format(h(manifestation.description)) -%>
|
102
102
|
</td>
|
103
103
|
</tr>
|
104
|
-
<% @manifestation.custom_properties.each do |custom_property| %>
|
105
|
-
<tr>
|
106
|
-
<td><%= custom_property.label -%>:</td>
|
107
|
-
<td>
|
108
|
-
<%= custom_property.value -%>
|
109
|
-
</td>
|
110
|
-
</tr>
|
111
|
-
<% end %>
|
112
104
|
<tr>
|
113
105
|
<td><%= t('activerecord.attributes.manifestation.note') -%>:</td>
|
114
106
|
<td>
|