enju_biblio 0.3.13 → 0.3.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/agent_import_results_controller.rb +1 -1
  3. data/app/controllers/items_controller.rb +2 -2
  4. data/app/controllers/manifestations_controller.rb +4 -4
  5. data/app/controllers/resource_import_results_controller.rb +2 -2
  6. data/app/models/item.rb +1 -1
  7. data/app/models/manifestation.rb +3 -2
  8. data/app/models/resource_import_file.rb +8 -4
  9. data/app/views/agent_import_results/{index.txt.ruby → index.text.ruby} +0 -0
  10. data/app/views/agent_relationship_types/index.html.erb +3 -3
  11. data/app/views/items/index.text.ruby +13 -0
  12. data/app/views/manifestations/_title.html.erb +1 -1
  13. data/app/views/manifestations/index.text.ruby +13 -0
  14. data/app/views/manifestations/{show.txt.ruby → show.text.ruby} +0 -0
  15. data/app/views/resource_import_results/{index.txt.ruby → index.text.ruby} +0 -0
  16. data/lib/enju_biblio/version.rb +1 -1
  17. data/spec/controllers/items_controller_spec.rb +5 -0
  18. data/spec/controllers/manifestations_controller_spec.rb +2 -2
  19. data/spec/fixtures/items.yml +1 -0
  20. data/spec/fixtures/manifestations.yml +1 -0
  21. data/spec/models/manifestation_spec.rb +11 -1
  22. data/spec/models/resource_import_file_spec.rb +18 -0
  23. data/spec/views/agent_import_results/{index.txt.ruby_spec.rb → index.text.ruby_spec.rb} +1 -1
  24. data/spec/views/manifestations/{index.txt.ruby_spec.rb → index.text.ruby_spec.rb} +1 -1
  25. data/spec/views/manifestations/{show.txt.ruby_spec.rb → show.text.ruby_spec.rb} +1 -1
  26. data/spec/views/resource_import_results/{index.txt.ruby_spec.rb → index.text.ruby_spec.rb} +1 -1
  27. metadata +515 -515
  28. data/app/views/items/index.txt.erb +0 -4
  29. data/app/views/manifestations/index.txt.ruby +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: afa249847e374fa2a87ea6801bfb851af30e99edc72fd982a32ce52d1674fa0c
4
- data.tar.gz: 5ab7f1b8abd52e9c841c0445dd1a04db2d752fd077aada5672d70ea2ed2d8262
3
+ metadata.gz: '088d27a989a71a9301fd1946a90d8c790720b2ecffa02bc2eef9d3a9c05a31bb'
4
+ data.tar.gz: b946f1cd533e99b47cb6a799a3d0f167b597d6291ee864372354037dfc3ad050
5
5
  SHA512:
6
- metadata.gz: e937c7448b783f607e851da92fa21b38c7bb44677b572e47b7f11a3ef5cc9133e76e74a1b2a13657041acfbeef89ed9240fbbe8cc606179167606cfd8fd5075a
7
- data.tar.gz: 42b259f6e9d84b40a93b66d649c171b1d8a6ec84cdffc773d8871223a5de707383e3e82dfaddb4ceb76d980001cb8e1ec6096b35d29647dd298d0426460a936a
6
+ metadata.gz: 5815c72d545147d3048239c9c52749a1239ff73e06aa2fbc8e37014d8272b8d87b9dcd7c260b321512fd7bbc47d1383548abddff5bbfb5431c7f78aa7335cad4
7
+ data.tar.gz: b4da9e3a16f2a498cd8b70478422fb37dd511a69cb3bb94252d53c3c7df9e2876006c45a843915d594424350eac2f0f41ae567107d04aa60f812f59656d658d2
@@ -15,7 +15,7 @@ class AgentImportResultsController < ApplicationController
15
15
  respond_to do |format|
16
16
  format.html # index.html.erb
17
17
  format.json { render json: @agent_import_results }
18
- format.txt
18
+ format.text
19
19
  end
20
20
  end
21
21
 
@@ -18,7 +18,7 @@ class ItemsController < ApplicationController
18
18
  @count = {}
19
19
  if user_signed_in?
20
20
  if current_user.has_role?('Librarian')
21
- if params[:format] == 'txt'
21
+ if params[:format] == 'text'
22
22
  per_page = 65534
23
23
  elsif params[:mode] == 'barcode'
24
24
  per_page = 40
@@ -134,7 +134,7 @@ class ItemsController < ApplicationController
134
134
  respond_to do |format|
135
135
  format.html # index.html.erb
136
136
  format.json
137
- format.txt { render layout: false }
137
+ format.text
138
138
  format.atom
139
139
  end
140
140
  end
@@ -29,7 +29,7 @@ class ManifestationsController < ApplicationController
29
29
  sort, @count = {}, {}
30
30
  query = ""
31
31
 
32
- if params[:format] == 'txt'
32
+ if request.format.text?
33
33
  per_page = 65534
34
34
  end
35
35
 
@@ -251,7 +251,7 @@ class ManifestationsController < ApplicationController
251
251
  format.html.phone
252
252
  format.xml { render xml: @manifestations }
253
253
  format.rss { render layout: false }
254
- format.txt { render layout: false }
254
+ format.text { render layout: false }
255
255
  format.rdf { render layout: false }
256
256
  format.atom
257
257
  format.mods
@@ -321,8 +321,8 @@ class ManifestationsController < ApplicationController
321
321
  format.rdf
322
322
  format.mods
323
323
  format.json
324
- format.txt
325
- format.js
324
+ format.text
325
+ format.js { render template: 'manifestations/show.js' }
326
326
  format.download {
327
327
  if @manifestation.attachment.path
328
328
  if ENV['ENJU_STORAGE'] == 's3'
@@ -7,7 +7,7 @@ class ResourceImportResultsController < ApplicationController
7
7
  def index
8
8
  @resource_import_file = ResourceImportFile.find_by(id: params[:resource_import_file_id])
9
9
  if @resource_import_file
10
- if params[:format].to_s.downcase == 'txt'
10
+ if params[:format].to_s.downcase == 'text'
11
11
  @resource_import_results = @resource_import_file.resource_import_results
12
12
  else
13
13
  @resource_import_results = @resource_import_file.resource_import_results.page(params[:page])
@@ -19,7 +19,7 @@ class ResourceImportResultsController < ApplicationController
19
19
  respond_to do |format|
20
20
  format.html # index.html.erb
21
21
  format.json { render json: @resource_import_results }
22
- format.txt
22
+ format.text
23
23
  end
24
24
  end
25
25
 
data/app/models/item.rb CHANGED
@@ -123,7 +123,7 @@ class Item < ApplicationRecord
123
123
  budget_type: budget_type&.name,
124
124
  item_required_role: required_role.name,
125
125
  item_price: price,
126
- memo: memo
126
+ item_memo: memo
127
127
  })
128
128
 
129
129
  ItemCustomProperty.order(:position).each do |custom_property|
@@ -37,7 +37,7 @@ class Manifestation < ApplicationRecord
37
37
  text :title, default_boost: 2 do
38
38
  titles
39
39
  end
40
- [ :fulltext, :note, :creator, :contributor, :publisher, :description, :statement_of_responsibility ].each do |field|
40
+ [ :fulltext, :note, :creator, :contributor, :publisher, :abstract, :description, :statement_of_responsibility ].each do |field|
41
41
  text field do
42
42
  if series_master?
43
43
  derived_manifestations.map{|c| c.send(field) }.flatten.compact
@@ -587,6 +587,7 @@ class Manifestation < ApplicationRecord
587
587
  price: price,
588
588
  access_address: access_address,
589
589
  manifestation_required_role: required_role.name,
590
+ abstract: abstract,
590
591
  description: description,
591
592
  note: note
592
593
  }
@@ -615,7 +616,7 @@ class Manifestation < ApplicationRecord
615
616
 
616
617
  if ['Administrator', 'Librarian'].include?(role)
617
618
  record.merge!({
618
- memo: memo
619
+ manifestation_memo: memo
619
620
  })
620
621
  ManifestationCustomProperty.order(:position).each do |custom_property|
621
622
  custom_value = manifestation_custom_values.find_by(manifestation_custom_property: custom_property)
@@ -458,12 +458,12 @@ class ResourceImportFile < ApplicationRecord
458
458
  edition edition_string serial_number isbn issn manifestation_price
459
459
  width height depth number_of_pages jpno lccn budget_type bookstore
460
460
  language fulltext_content required_role doi content_type frequency
461
- extent start_page end_page dimensions
461
+ extent start_page end_page dimensions abstract manifestation_memo
462
462
  ncid
463
463
  ndl_bib_id
464
464
  statement_of_responsibility acquired_at call_number circulation_status
465
465
  binding_item_identifier binding_call_number binded_at item_price
466
- use_restriction include_supplements item_note item_url
466
+ use_restriction include_supplements item_note item_url item_memo
467
467
  dummy
468
468
  )
469
469
  header_columns += ManifestationCustomProperty.order(:position).pluck(:name).map{|c| "manifestation:#{c}"}
@@ -541,7 +541,8 @@ class ResourceImportFile < ApplicationRecord
541
541
  binding_call_number: row['binding_call_number'],
542
542
  binded_at: binded_at,
543
543
  url: row['item_url'],
544
- note: row['item_note'].try(:gsub, /\\n/, "\n")
544
+ note: row['item_note'].try(:gsub, /\\n/, "\n"),
545
+ memo: row['item_memo'].try(:gsub, /\\n/, "\n")
545
546
  )
546
547
  manifestation.items << item
547
548
  if defined?(EnjuCirculation)
@@ -600,6 +601,7 @@ class ResourceImportFile < ApplicationRecord
600
601
 
601
602
  item.price = row['item_price'] if row['item_price'].present?
602
603
  item.note = row['item_note'].try(:gsub, /\\n/, "\n") if row['item_note'].present?
604
+ item.memo = row['item_memo'].try(:gsub, /\\n/, "\n") if row['item_memo'].present?
603
605
  item.url = row['item_url'] if row['item_url'].present?
604
606
 
605
607
  if row['include_supplements']
@@ -716,9 +718,11 @@ class ResourceImportFile < ApplicationRecord
716
718
  depth: row['depth'],
717
719
  height: row['height'],
718
720
  price: row['manifestation_price'],
721
+ abstract: row['abstract'].try(:gsub, /\\n/, "\n"),
719
722
  description: row['description'].try(:gsub, /\\n/, "\n"),
720
723
  #:description_transcription => row['description_transcription'],
721
724
  note: row['note'].try(:gsub, /\\n/, "\n"),
725
+ memo: row['manifestation_memo'].try(:gsub, /\\n/, "\n"),
722
726
  statement_of_responsibility: row['statement_of_responsibility'],
723
727
  access_address: row['access_address'],
724
728
  manifestation_identifier: row['manifestation_identifier'],
@@ -783,7 +787,7 @@ class ResourceImportFile < ApplicationRecord
783
787
  unless identifiers.empty?
784
788
  identifiers.each do |v|
785
789
  v.manifestation = manifestation
786
- v.save!
790
+ v.save
787
791
  end
788
792
  end
789
793
  else
@@ -18,7 +18,7 @@
18
18
  <%- @agent_relationship_types.each do |agent_relationship_type| -%>
19
19
  <tr class="line<%= cycle("0", "1") -%>">
20
20
  <td>
21
- <%- if policy(agent).update?_relationship_type -%>
21
+ <%- if policy(agent_relationship_type).update? -%>
22
22
  <%= move_position(agent_relationship_type) -%>
23
23
  <%- end -%>
24
24
  </td>
@@ -29,10 +29,10 @@
29
29
  <%= agent_relationship_type.note %>
30
30
  </td>
31
31
  <td>
32
- <%- if policy(agent).update?_relationship_type -%>
32
+ <%- if policy(agent_relationship_type).update? -%>
33
33
  <%= link_to t('page.edit'), edit_agent_relationship_type_path(agent_relationship_type) -%>
34
34
  <% end %>
35
- <%- if policy(agent).destroy?_relationship_type -%>
35
+ <%- if policy(agent_relationship_type).destroy? -%>
36
36
  <%= link_to t('page.destroy'), agent_relationship_type_path(agent_relationship_type), data: {confirm: t('page.are_you_sure')}, method: :delete -%>
37
37
  <%- end -%>
38
38
  </td>
@@ -0,0 +1,13 @@
1
+ csv = %w[title isbn item_identifier call_number created_at].to_csv(col_sep: "\t")
2
+
3
+ @items.map{|item|
4
+ [
5
+ item.manifestation.original_title,
6
+ item.manifestation.identifier_contents(:isbn).join("; "),
7
+ item.item_identifier,
8
+ item.call_number,
9
+ item.created_at
10
+ ]
11
+ }
12
+
13
+ csv
@@ -19,7 +19,7 @@
19
19
  <%= t('agent.publisher') -%>: <%= agents_list(manifestation.publishers.readable_by(current_user), itemprop: 'publisher') -%>
20
20
  <% end %>
21
21
  <%- if manifestation.date_of_publication? -%>
22
- <meta itemprop="publishDate" content="<%= manifestation.date_of_publication.iso8601 %>" />
22
+ <meta itemprop="datePublished" content="<%= manifestation.date_of_publication.iso8601 %>" />
23
23
  (<%= t('activerecord.attributes.manifestation.pub_date') %>: <%= manifestation.pub_date -%>)
24
24
  <%- end -%>
25
25
  <%- if manifestation.access_address? -%>
@@ -0,0 +1,13 @@
1
+ csv = (Manifestation.csv_header(role: current_user_role_name) + Item.csv_header(role: current_user_role_name)).to_csv(col_sep: "\t")
2
+
3
+ @manifestations.map{|manifestation|
4
+ if manifestation.items.empty?
5
+ csv += manifestation.to_hash(role: current_user_role_name).values.to_csv(col_sep: "\t")
6
+ else
7
+ manifestation.items.each do |item|
8
+ csv += (manifestation.to_hash(role: current_user_role_name).values + item.to_hash(role: current_user_role_name).values).to_csv(col_sep: "\t")
9
+ end
10
+ end
11
+ }
12
+
13
+ csv
@@ -1,3 +1,3 @@
1
1
  module EnjuBiblio
2
- VERSION = "0.3.13".freeze
2
+ VERSION = "0.3.14".freeze
3
3
  end
@@ -47,6 +47,11 @@ describe ItemsController do
47
47
  expect(assigns(:items).count).to eq 1
48
48
  end
49
49
 
50
+ it 'accepts text format' do
51
+ get :index, format: :text
52
+ expect(assigns(:items)).to_not be_nil
53
+ end
54
+
50
55
  describe 'in JSON response' do
51
56
  render_views
52
57
  it 'should not assign unnecessary attributes' do
@@ -51,8 +51,8 @@ describe ManifestationsController do
51
51
  expect(assigns(:manifestations)).to_not be_nil
52
52
  end
53
53
 
54
- it 'assigns all manifestations as @manifestations in txt format without operation' do
55
- get :index, format: 'txt'
54
+ it 'assigns all manifestations as @manifestations in text format without operation' do
55
+ get :index, format: :text
56
56
  expect(response).to be_successful
57
57
  expect(assigns(:manifestations)).to_not be_nil
58
58
  expect(response).to render_template('manifestations/index')
@@ -10,6 +10,7 @@ item_00001:
10
10
  id: 1
11
11
  include_supplements: false
12
12
  created_at: 2007-08-24 23:46:00.484813 +09:00
13
+ memo: 所蔵確認用のメモ
13
14
  item_00002:
14
15
  updated_at: 2007-08-24 23:46:01.641413 +09:00
15
16
  item_identifier: '00002'
@@ -18,6 +18,7 @@ manifestation_00001:
18
18
  repository_content: true
19
19
  extent: "123p"
20
20
  dimensions: "25cm"
21
+ memo: 確認用の書誌情報
21
22
  manifestation_00002:
22
23
  carrier_type_id: 1
23
24
  language_id: 1
@@ -158,6 +158,8 @@ describe Manifestation, solr: true do
158
158
  csv["classification:ndc9"].compact.inject(0){|count, a| count += 1 if a == '400'; count}.should eq manifestations(:manifestation_00001).items.count
159
159
  csv["extent"].compact.should_not be_empty
160
160
  csv["dimensions"].compact.should_not be_empty
161
+ csv["manifestation_memo"].compact.should be_empty
162
+ csv["item_memo"].compact.should be_empty
161
163
  end
162
164
 
163
165
  it "should export edition fields" do
@@ -212,17 +214,25 @@ describe Manifestation, solr: true do
212
214
  expect(csv["bookstore"].compact).not_to be_empty
213
215
  expect(csv["item_price"].compact).not_to be_empty
214
216
  expect(csv["budget_type"].compact).not_to be_empty
217
+ expect(csv["manifestation_memo"].compact).not_to be_empty
218
+ expect(csv["item_memo"].compact).not_to be_empty
215
219
  end
216
220
 
217
221
  it 'should escape LF/CR to "\n"' do
218
- manifestation = FactoryBot.create(:manifestation, description: "test\ntest", note: "test\ntest")
222
+ manifestation = FactoryBot.create(:manifestation,
223
+ abstract: "test\ntest",
224
+ description: "test\ntest",
225
+ note: "test\ntest"
226
+ )
219
227
  item = FactoryBot.create(:item, manifestation: manifestation, note: "test\ntest")
220
228
  lines = Manifestation.export
221
229
  csv = CSV.parse(lines, headers: true, col_sep: "\t")
230
+ expect(csv["abstract"].compact).not_to be_empty
222
231
  expect(csv["description"].compact).not_to be_empty
223
232
  expect(csv["note"].compact).not_to be_empty
224
233
  expect(csv["item_note"].compact).not_to be_empty
225
234
  m = csv.find{|row| row["manifestation_id"].to_i == manifestation.id }
235
+ expect(m["abstract"]).to eq "test\ntest"
226
236
  expect(m["description"]).to eq "test\ntest"
227
237
  expect(m["note"]).to eq "test\ntest"
228
238
  expect(m["item_note"]).to eq "test\ntest"
@@ -67,6 +67,8 @@ describe ResourceImportFile do
67
67
  item_10101.manifestation.frequency.name.should eq 'monthly'
68
68
  item_10101.manifestation.extent.should eq 'xv, 213 pages'
69
69
  item_10101.manifestation.dimensions.should eq '20cm'
70
+ expect(item_10101.memo).to eq '個別資料メモ1'
71
+ expect(item_10101.manifestation.memo).to eq '書誌メモ1'
70
72
 
71
73
  item_10102 = Item.find_by(item_identifier: '10102')
72
74
  item_10102.manifestation.date_of_publication.should eq Time.zone.parse('2001-01-01')
@@ -167,6 +169,22 @@ describe ResourceImportFile do
167
169
  expect(item_10103.manifestation.manifestation_custom_values.pluck(:value)).to eq ["カスタム項目テスト1", "カスタム項目テスト2"]
168
170
  expect(item_10103.item_custom_values.pluck(:value)).to eq ['カスタム項目テスト3', 'カスタム項目テスト4']
169
171
  end
172
+
173
+ it "should import multiple rows in a cell" do
174
+ file = ResourceImportFile.create(
175
+ resource_import: File.new("#{Rails.root}/../../examples/resource_import_file_sample5.tsv"),
176
+ default_shelf_id: 3,
177
+ user: users(:admin),
178
+ edit_mode: 'create'
179
+ )
180
+ file.import_start
181
+
182
+ manifestation = Manifestation.find_by(manifestation_identifier: 10201)
183
+ expect(manifestation.original_title).to eq "改行を含む\nタイトル"
184
+ expect(manifestation.abstract).to eq "改行を含む\n目次の\n情報"
185
+ expect(manifestation.note).to eq "改行を\n含む\n注記の\n情報"
186
+ expect(manifestation.description).to eq "改行を\n含む\n説明の情報"
187
+ end
170
188
  end
171
189
 
172
190
  describe "ISBN import" do
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- describe "agent_import_results/index.txt.ruby" do
3
+ describe "agent_import_results/index.text.ruby" do
4
4
  fixtures :all
5
5
 
6
6
  before(:each) do
@@ -1,6 +1,6 @@
1
1
  require "rails_helper.rb"
2
2
 
3
- describe "manifestations/index.txt.ruby" do
3
+ describe "manifestations/index.text.ruby" do
4
4
  before(:each) do
5
5
  manifestation = FactoryBot.create(:manifestation)
6
6
  manifestation.items << FactoryBot.create(:item, bookstore_id: 1, budget_type_id: 1, price: 100)
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- describe "manifestations/show.txt.ruby" do
3
+ describe "manifestations/show.text.ruby" do
4
4
  fixtures :all
5
5
 
6
6
  before(:each) do
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- describe "resource_import_results/index.txt.ruby" do
3
+ describe "resource_import_results/index.text.ruby" do
4
4
  fixtures :all
5
5
 
6
6
  before(:each) do