Skip to content

Commit 21f9bcf

Browse files
leefaisonrbess
andauthored
Start display for SubGuide cards (#123)
* Start display for SubGuide cards Co-authored-by: Bess Sadler <[email protected]> * remove unused methods * remove redundant test --------- Co-authored-by: Bess Sadler <[email protected]>
1 parent 4b36e92 commit 21f9bcf

File tree

15 files changed

+50
-74
lines changed

15 files changed

+50
-74
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# frozen_string_literal: true
2+
3+
# Controller for SubGuideCards
4+
class SubGuideCardsController < ApplicationController
5+
def index; end
6+
7+
def show
8+
@sub_guide_card = SubGuideCard.find(params[:id])
9+
end
10+
end

app/services/guide_card_loading_service.rb

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,4 @@ def import
2424
end
2525
puts 'task completed!'
2626
end
27-
28-
def scan
29-
guide_card_data = CSV.parse(File.read(csv_location), headers: true)
30-
heading_pairs = [[0, 4], [1, 5], [2, 6], [3, 7]]
31-
guide_card_data.each do |card|
32-
heading_pairs.each do |pair|
33-
if card[pair[0]] != card[pair[1]]
34-
Rails.logger.info("#{card[pair[0]]} does not match #{card[pair[1]]} in record #{card[0]}")
35-
end
36-
end
37-
end
38-
end
39-
40-
# this method deduplicates CSV data for GuideCards
41-
def deduplicate_csv_headings(new_csv)
42-
guide_card_data = CSV.parse(File.read(csv_location), headers: true)
43-
CSV.open(new_csv, 'wb') do |csv|
44-
csv << %w[ID heading sortid path]
45-
guide_card_data.each do |card|
46-
csv << [card[0], card[1], card[2], card[3]]
47-
end
48-
end
49-
end
5027
end
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<h1><%= @guide_card.heading %></h1>
2-
<h2><%= @guide_card.sortid %></h2>
32
<h2><%= @guide_card.path %></h2>
43

54

65
<h2>List of SubGuide cards</h2>
76
<ul>
87
<% @sub_guide_cards.each do |sub_guide| %>
9-
<li><%= sub_guide.heading %></li>
8+
<li> <%= link_to sub_guide.heading, sub_guide_card_path(sub_guide.id) %> </li>
109
<% end %>
1110
</ul>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>SubGuideCards#index</h1>
2+
<p>Find me in app/views/sub_guide_cards/index.html.erb</p>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<h1>SubGuideCards#show</h1>
2+
<p>Find me in app/views/sub_guide_cards/show.html.erb</p>
3+
<%= @sub_guide_card.heading %>

config/routes.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
get 'guide_cards/', to: 'guide_cards#index'
77
get 'guide_cards/:id', to: 'guide_cards#show'
88
resources :guide_cards
9+
get 'sub_guide_cards/', to: 'sub_guide_cards#index'
10+
get 'sub_guide_cards/:id', to: 'sub_guide_cards#show'
11+
resources :sub_guide_cards
912
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
1013

1114
# Defines the root path route ("/")

spec/fixtures/guide_card_fixture.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ ID,heading,sortid,path,ID,heading,sortid,path
99
8,AID,8.5,14/0001/A1007,8,AID,8.5,14/0001/A1007
1010
9,AILA,9.5,14/0002/A1008,9,AILA,9.5,14/0002/A1008
1111
10,A.L.,10.5,14/0002/A1009,10,A.L.,10.5,14/0002/A1009
12-
11,A.M.,11.5,14/0002/A1010,11,A.M.,11.5,14/0002/A1010
12+
11,A.M.,11.5,14/0002/A1010,11,A.M.,11.5,14/0002/A1010
13+
2869,Bible,2870.5,sub,2869,Bible,2870.5,sub

spec/fixtures/subguide_card_fixture.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ ID,heading,sortid,parentid,path,heading,sortid,parentid,path
44
3,Afdeling voor ...,50351.5,50345.5,9/0091/A3038,Afdeling voor ...,50351.5,50345.5,9/0091/A3038
55
4,(Without subdivision),50352.5,540.5,sub,(Without subdivision),50352.5,540.5,sub
66
5,(As author),50353.5,50352.5,sub,(As author),50353.5,50352.5,sub
7-
57,Nauchnyi sovet "Istoriia istoricheskoi nauki " ... 8/0097/A3100,50405.5,50358.5,8/0097/A3100,Nauchnyi sovet "Istoriia istoricheskoi nauki " ... 8/0097/A3100,50405.5,50358.5,8/0097/A3100
7+
57,Nauchnyi sovet "Istoriia istoricheskoi nauki " ... 8/0097/A3100,50405.5,50358.5,8/0097/A3100,Nauchnyi sovet "Istoriia istoricheskoi nauki " ... 8/0097/A3100,50405.5,50358.5,8/0097/A3100
8+
1625,Manuscripts,51625.5,2870.5,sub,Manuscripts,51625.5,2870.5,sub

spec/requests/guide_cards_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
it 'shows the metadata for a specific item' do
2222
get '/guide_cards/3'
2323
expect(response.body).to include('AALAS')
24-
expect(response.body).to include('3.5')
2524
expect(response.body).to include('14/0001/A1002')
2625
end
2726
end

spec/services/card_image_loading_service_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
sgls.import
2424
expect(CardImage.count).to eq 0
2525
cils.import
26-
expect(CardImage.count).to eq 12
26+
expect(CardImage.count).to eq 14
2727
images = CardImage.where(path: '9/0091/A3037')
2828
expect(images.map(&:image_name)).to contain_exactly('imagecat-disk9-0091-A3037-1358.0110.tif', 'imagecat-disk9-0091-A3037-1358.0111.tif')
2929
end

0 commit comments

Comments
 (0)