enju_library 0.3.7 → 0.3.8.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/enju_library/controller.rb +5 -5
- data/app/models/library_group.rb +5 -2
- data/app/models/user_export_file_state_machine.rb +1 -1
- data/app/models/user_import_file.rb +7 -7
- data/app/models/user_import_file_state_machine.rb +1 -1
- data/app/views/layouts/libraries.html.erb +31 -0
- data/app/views/libraries/_form.html.erb +1 -1
- data/app/views/libraries/_map.html.erb +10 -23
- data/app/views/libraries/_map_header.html.erb +6 -0
- data/config/locales/translation_en.yml +2 -0
- data/config/locales/translation_ja.yml +2 -0
- data/lib/enju_library/version.rb +1 -1
- data/spec/dummy/db/migrate/20200425072340_create_manifestation_custom_properties.rb +12 -0
- data/spec/dummy/db/migrate/20200425072349_create_item_custom_properties.rb +12 -0
- data/spec/dummy/db/migrate/20200425074758_create_manifestation_custom_values.rb +12 -0
- data/spec/dummy/db/migrate/20200425074822_create_item_custom_values.rb +12 -0
- data/spec/dummy/db/schema.rb +43 -10
- data/spec/fixtures/library_groups.yml +3 -0
- data/spec/models/library_group_spec.rb +3 -0
- data/spec/system/libraries_spec.rb +5 -5
- metadata +415 -393
- data/spec/dummy/db/migrate/20191219122214_create_custom_properties.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83ce39d2995d4ffcafaf40c6ccdf98ff6490a6456a04b3a4613e3d564ec04296
|
4
|
+
data.tar.gz: 3b3077bca17ab0321ba8f3792127dd558fa7c74e147b6173cc174790d4365ebd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15dc6a0c238aa98c462b83131bafa57fc528362bcef595416c52a9a2df30179bc54629d330ad1f702a6189f10cb3e7b626027b8e19d6e78a2096a6e63dd19ed4
|
7
|
+
data.tar.gz: 56af5c02f50402a74c0acb7752ebc0e5a078e4a265a8d1acebc18479bd37be05aeed4cb0dafb13862cff7cc1738fbc988467e1d71e8887fbe5abe555ed320fca
|
@@ -21,7 +21,7 @@ module EnjuLibrary
|
|
21
21
|
format.html {render template: 'page/403', status: :forbidden}
|
22
22
|
# format.html.phone {render template: 'page/403', status: 403}
|
23
23
|
format.xml {render template: 'page/403', status: :forbidden}
|
24
|
-
format.json { render
|
24
|
+
format.json { render json: {"error": "forbidden"} }
|
25
25
|
format.rss {render template: 'page/403.xml', status: :forbidden}
|
26
26
|
end
|
27
27
|
else
|
@@ -29,7 +29,7 @@ module EnjuLibrary
|
|
29
29
|
format.html { redirect_to main_app.new_user_session_url }
|
30
30
|
# format.html.phone { redirect_to new_user_session_url }
|
31
31
|
format.xml { render template: 'page/403', status: :forbidden }
|
32
|
-
format.json { render
|
32
|
+
format.json { render json: {"error": "forbidden"} }
|
33
33
|
format.rss { render template: 'page/403.xml', status: :forbidden }
|
34
34
|
end
|
35
35
|
end
|
@@ -41,7 +41,7 @@ module EnjuLibrary
|
|
41
41
|
format.html { render template: 'page/404', status: :not_found }
|
42
42
|
# format.html.phone { render template: 'page/404', status: 404 }
|
43
43
|
format.xml { render template: 'page/404', status: :not_found }
|
44
|
-
format.json { render
|
44
|
+
format.json { render json: {"error": "not_found"} }
|
45
45
|
format.rss { render template: 'page/404.xml', status: :not_found }
|
46
46
|
end
|
47
47
|
end
|
@@ -57,7 +57,7 @@ module EnjuLibrary
|
|
57
57
|
format.html {render file: "#{Rails.root}/public/500", layout: false, status: :internal_server_error}
|
58
58
|
# format.html.phone {render file: "#{Rails.root}/public/500", layout: false, status: 500}
|
59
59
|
format.xml {render template: 'page/500', status: :internal_server_error}
|
60
|
-
format.json { render
|
60
|
+
format.json { render json: {"error": "server_error"} }
|
61
61
|
format.xml {render template: 'page/500.xml', status: :internal_server_error}
|
62
62
|
end
|
63
63
|
end
|
@@ -70,7 +70,7 @@ module EnjuLibrary
|
|
70
70
|
format.html {render template: "page/500_nosolr", layout: false, status: :internal_server_error}
|
71
71
|
# format.html.phone {render template: "page/500_nosolr", layout: false, status: 500}
|
72
72
|
format.xml {render template: 'page/500', status: :internal_server_error}
|
73
|
-
format.json { render
|
73
|
+
format.json { render json: {"error": "server_error"} }
|
74
74
|
format.xml {render template: 'page/500.xml', status: :internal_server_error}
|
75
75
|
end
|
76
76
|
end
|
data/app/models/library_group.rb
CHANGED
@@ -2,8 +2,8 @@ class LibraryGroup < ApplicationRecord
|
|
2
2
|
#include Singleton
|
3
3
|
include MasterModel
|
4
4
|
|
5
|
-
has_many :libraries
|
6
|
-
has_many :colors
|
5
|
+
has_many :libraries, dependent: :destroy
|
6
|
+
has_many :colors, dependent: :destroy
|
7
7
|
belongs_to :country, optional: true
|
8
8
|
belongs_to :user, optional: true
|
9
9
|
|
@@ -108,4 +108,7 @@ end
|
|
108
108
|
# header_logo_file_size :integer
|
109
109
|
# header_logo_updated_at :datetime
|
110
110
|
# header_logo_meta :text
|
111
|
+
# library_group_id :integer not null
|
112
|
+
# login_banner :text
|
113
|
+
# footer_banner :text
|
111
114
|
#
|
@@ -6,7 +6,7 @@ class UserExportFileStateMachine
|
|
6
6
|
state :completed
|
7
7
|
state :failed
|
8
8
|
|
9
|
-
transition from: :pending, to: :started
|
9
|
+
transition from: :pending, to: [:started, :failed]
|
10
10
|
transition from: :started, to: [:completed, :failed]
|
11
11
|
|
12
12
|
after_transition(from: :pending, to: :started) do |user_export_file|
|
@@ -62,14 +62,14 @@ class UserImportFile < ApplicationRecord
|
|
62
62
|
next if row['dummy'].to_s.strip.present?
|
63
63
|
|
64
64
|
username = row['username']
|
65
|
-
new_user = User.
|
65
|
+
new_user = User.find_by(username: username)
|
66
66
|
if new_user
|
67
67
|
import_result.user = new_user
|
68
68
|
import_result.save
|
69
69
|
num[:user_found] += 1
|
70
70
|
else
|
71
71
|
new_user = User.new
|
72
|
-
new_user.role = Role.
|
72
|
+
new_user.role = Role.find_by(name: row['role'])
|
73
73
|
if new_user.role
|
74
74
|
unless user.has_role?(new_user.role.name)
|
75
75
|
num[:failed] += 1
|
@@ -145,7 +145,7 @@ class UserImportFile < ApplicationRecord
|
|
145
145
|
)
|
146
146
|
|
147
147
|
username = row['username']
|
148
|
-
new_user = User.
|
148
|
+
new_user = User.find_by(username: username)
|
149
149
|
if new_user.try(:profile)
|
150
150
|
new_user.assign_attributes(set_user_params(row))
|
151
151
|
new_user.profile.assign_attributes(set_profile_params(row))
|
@@ -288,15 +288,15 @@ class UserImportFile < ApplicationRecord
|
|
288
288
|
# @param [Hash] row 利用者情報のハッシュ
|
289
289
|
def set_profile_params(row)
|
290
290
|
params = {}
|
291
|
-
user_group = UserGroup.
|
291
|
+
user_group = UserGroup.find_by(name: row['user_group'])
|
292
292
|
unless user_group
|
293
293
|
user_group = default_user_group
|
294
294
|
end
|
295
295
|
params[:user_group_id] = user_group.id if user_group
|
296
296
|
|
297
|
-
required_role = Role.
|
297
|
+
required_role = Role.find_by(name: row['required_role'])
|
298
298
|
unless required_role
|
299
|
-
required_role = Role.
|
299
|
+
required_role = Role.find_by(name: 'Librarian')
|
300
300
|
end
|
301
301
|
params[:required_role_id] = required_role.id if required_role
|
302
302
|
|
@@ -318,7 +318,7 @@ class UserImportFile < ApplicationRecord
|
|
318
318
|
params[:locale] = row['locale']
|
319
319
|
end
|
320
320
|
|
321
|
-
library = Library.
|
321
|
+
library = Library.find_by(name: row['library'].to_s.strip)
|
322
322
|
unless library
|
323
323
|
library = default_library || Library.web
|
324
324
|
end
|
@@ -6,7 +6,7 @@ class UserImportFileStateMachine
|
|
6
6
|
state :completed
|
7
7
|
state :failed
|
8
8
|
|
9
|
-
transition from: :pending, to: :started
|
9
|
+
transition from: :pending, to: [:started, :failed]
|
10
10
|
transition from: :started, to: [:completed, :failed]
|
11
11
|
|
12
12
|
after_transition(from: :pending, to: :started) do |user_import_file|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= @locale.to_s -%>" lang="<%= @locale.to_s -%>">
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8" />
|
5
|
+
<%= render 'page/include' %>
|
6
|
+
<title><%= title(controller.controller_name) %></title>
|
7
|
+
<%- if controller.controller_name == 'manifestations' and controller.action_name == 'index' -%>
|
8
|
+
<%= auto_discovery_link_tag(:rss, url_for(params.permit.merge(format: 'rss', page: nil, commit: nil, only_path: true)), title: (t('manifestation.library_group_manifestation', library_group_name: @library_group.display_name) + " (RSS)")) %>
|
9
|
+
<%= auto_discovery_link_tag(:atom, url_for(params.permit.merge(format: 'atom', page: nil, commit: nil, only_path: true)), title: (t('manifestation.library_group_manifestation', library_group_name: @library_group.display_name) + " (Atom)")) %>
|
10
|
+
<% if defined?(EnjuNews) %>
|
11
|
+
<%= auto_discovery_link_tag(:rss, news_posts_url(format: :rss, locale: @locale), title: (t('news_post.library_group_news_post', library_group_name: @library_group.display_name) + " (RSS)")) %>
|
12
|
+
<%= auto_discovery_link_tag(:atom, news_posts_url(format: :atom, locale: @locale), title: (t('news_post.library_group_news_post', library_group_name: @library_group.display_name) + " (Atom)")) %>
|
13
|
+
<% end %>
|
14
|
+
<% end %>
|
15
|
+
<%= render 'libraries/map_header' %>
|
16
|
+
</head>
|
17
|
+
<body itemscope itemtype="http://schema.org/WebPage">
|
18
|
+
|
19
|
+
<%= render 'page/header' %>
|
20
|
+
<%= render 'page/menu' %>
|
21
|
+
|
22
|
+
<div id="content">
|
23
|
+
|
24
|
+
<%= yield %>
|
25
|
+
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<%= render 'page/footer' %>
|
29
|
+
|
30
|
+
</body>
|
31
|
+
</html>
|
@@ -1,25 +1,12 @@
|
|
1
|
-
<
|
2
|
-
<script
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
var map = new google.maps.Map(document.getElementById("library_map"), options);
|
12
|
-
var marker = new google.maps.Marker({
|
13
|
-
position: latlng,
|
14
|
-
map: map,
|
15
|
-
title: '<%= library.display_name.localize %>'
|
16
|
-
});
|
17
|
-
var infowindow = new google.maps.InfoWindow({
|
18
|
-
content: '<%= library.display_name.localize %>'
|
19
|
-
});
|
20
|
-
google.maps.event.addListener(marker, 'click', function() {
|
21
|
-
infowindow.open(map,marker);
|
22
|
-
});
|
1
|
+
<div id="library_map" style="width: 500px; height: 500px;"></div>
|
2
|
+
<script>
|
3
|
+
var mymap = L.map('library_map').setView([<%= @library.latitude %>, <%= @library.longitude %>], 13);
|
4
|
+
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
5
|
+
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
6
|
+
maxZoom: 18
|
7
|
+
}).addTo(mymap);
|
8
|
+
L.marker([<%= @library.latitude %>, <%= @library.longitude %>]).addTo(mymap).bindPopup('<%= @library.display_name.localize %>').openPopup();
|
9
|
+
jQuery(document).ready(function ($) {
|
10
|
+
mymap.invalidateSize();
|
23
11
|
});
|
24
12
|
</script>
|
25
|
-
<div id="library_map" style="width: 500px; height: 500px;"></div>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css"
|
2
|
+
integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
|
3
|
+
crossorigin=""/>
|
4
|
+
<script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js"
|
5
|
+
integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew=="
|
6
|
+
crossorigin=""></script>
|
@@ -59,6 +59,8 @@ en:
|
|
59
59
|
max_number_of_results: Max number of results
|
60
60
|
book_jacket_source: Book jacket source
|
61
61
|
header_logo: Header logo
|
62
|
+
default_custom_manifestation_label: Default custom properties (Manifestation)
|
63
|
+
default_custom_item_label: Default custom properties (Item)
|
62
64
|
bookstore:
|
63
65
|
name: Name
|
64
66
|
zip_code: Zip code
|
data/lib/enju_library/version.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateManifestationCustomProperties < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
create_table :manifestation_custom_properties do |t|
|
4
|
+
t.string :name, null: false, comment: 'ラベル名', index: {unique: true}
|
5
|
+
t.text :display_name, null: false, comment: '表示名'
|
6
|
+
t.text :note, comment: '備考'
|
7
|
+
t.integer :position, default: 1, null: false
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateItemCustomProperties < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
create_table :item_custom_properties do |t|
|
4
|
+
t.string :name, null: false, comment: 'ラベル名', index: {unique: true}
|
5
|
+
t.text :display_name, null: false, comment: '表示名'
|
6
|
+
t.text :note, comment: '備考'
|
7
|
+
t.integer :position, default: 1, null: false
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateManifestationCustomValues < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
create_table :manifestation_custom_values do |t|
|
4
|
+
t.references :manifestation_custom_property, null: false, foreign_key: true, index: {name: 'index_manifestation_custom_values_on_custom_property_id'}
|
5
|
+
t.references :manifestation, null: false, foreign_key: true
|
6
|
+
t.text :value
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
add_index :manifestation_custom_values, [:manifestation_custom_property_id, :manifestation_id], unique: true, name: 'index_manifestation_custom_values_on_property_manifestation'
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateItemCustomValues < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
create_table :item_custom_values do |t|
|
4
|
+
t.references :item_custom_property, null: false, foreign_key: true, index: {name: 'index_item_custom_values_on_custom_property_id'}
|
5
|
+
t.references :item, null: false, foreign_key: true
|
6
|
+
t.text :value
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
add_index :item_custom_values, [:item_custom_property_id, :item_id], unique: true, name: 'index_item_custom_values_on_custom_item_property_and_item_id'
|
11
|
+
end
|
12
|
+
end
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
#
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
12
12
|
|
13
|
-
ActiveRecord::Schema.define(version:
|
13
|
+
ActiveRecord::Schema.define(version: 2020_04_25_074822) do
|
14
14
|
|
15
15
|
create_table "accepts", force: :cascade do |t|
|
16
16
|
t.integer "basket_id"
|
@@ -433,15 +433,6 @@ ActiveRecord::Schema.define(version: 2019_12_19_122214) do
|
|
433
433
|
t.index ["work_id"], name: "index_creates_on_work_id"
|
434
434
|
end
|
435
435
|
|
436
|
-
create_table "custom_properties", force: :cascade do |t|
|
437
|
-
t.integer "resource_id", null: false
|
438
|
-
t.string "resource_type", null: false
|
439
|
-
t.text "label", null: false
|
440
|
-
t.text "value"
|
441
|
-
t.datetime "created_at", null: false
|
442
|
-
t.datetime "updated_at", null: false
|
443
|
-
end
|
444
|
-
|
445
436
|
create_table "demands", force: :cascade do |t|
|
446
437
|
t.integer "user_id"
|
447
438
|
t.integer "item_id"
|
@@ -646,6 +637,27 @@ ActiveRecord::Schema.define(version: 2019_12_19_122214) do
|
|
646
637
|
t.index ["user_id"], name: "index_import_requests_on_user_id"
|
647
638
|
end
|
648
639
|
|
640
|
+
create_table "item_custom_properties", force: :cascade do |t|
|
641
|
+
t.string "name", null: false
|
642
|
+
t.text "display_name", null: false
|
643
|
+
t.text "note"
|
644
|
+
t.integer "position", default: 1, null: false
|
645
|
+
t.datetime "created_at", null: false
|
646
|
+
t.datetime "updated_at", null: false
|
647
|
+
t.index ["name"], name: "index_item_custom_properties_on_name", unique: true
|
648
|
+
end
|
649
|
+
|
650
|
+
create_table "item_custom_values", force: :cascade do |t|
|
651
|
+
t.integer "item_custom_property_id", null: false
|
652
|
+
t.integer "item_id", null: false
|
653
|
+
t.text "value"
|
654
|
+
t.datetime "created_at", null: false
|
655
|
+
t.datetime "updated_at", null: false
|
656
|
+
t.index ["item_custom_property_id", "item_id"], name: "index_item_custom_values_on_custom_item_property_and_item_id", unique: true
|
657
|
+
t.index ["item_custom_property_id"], name: "index_item_custom_values_on_custom_property_id"
|
658
|
+
t.index ["item_id"], name: "index_item_custom_values_on_item_id"
|
659
|
+
end
|
660
|
+
|
649
661
|
create_table "item_has_use_restrictions", force: :cascade do |t|
|
650
662
|
t.integer "item_id", null: false
|
651
663
|
t.integer "use_restriction_id", null: false
|
@@ -824,6 +836,27 @@ ActiveRecord::Schema.define(version: 2019_12_19_122214) do
|
|
824
836
|
t.index ["user_id"], name: "index_manifestation_checkout_stats_on_user_id"
|
825
837
|
end
|
826
838
|
|
839
|
+
create_table "manifestation_custom_properties", force: :cascade do |t|
|
840
|
+
t.string "name", null: false
|
841
|
+
t.text "display_name", null: false
|
842
|
+
t.text "note"
|
843
|
+
t.integer "position", default: 1, null: false
|
844
|
+
t.datetime "created_at", null: false
|
845
|
+
t.datetime "updated_at", null: false
|
846
|
+
t.index ["name"], name: "index_manifestation_custom_properties_on_name", unique: true
|
847
|
+
end
|
848
|
+
|
849
|
+
create_table "manifestation_custom_values", force: :cascade do |t|
|
850
|
+
t.integer "manifestation_custom_property_id", null: false
|
851
|
+
t.integer "manifestation_id", null: false
|
852
|
+
t.text "value"
|
853
|
+
t.datetime "created_at", null: false
|
854
|
+
t.datetime "updated_at", null: false
|
855
|
+
t.index ["manifestation_custom_property_id", "manifestation_id"], name: "index_manifestation_custom_values_on_property_manifestation", unique: true
|
856
|
+
t.index ["manifestation_custom_property_id"], name: "index_manifestation_custom_values_on_custom_property_id"
|
857
|
+
t.index ["manifestation_id"], name: "index_manifestation_custom_values_on_manifestation_id"
|
858
|
+
end
|
859
|
+
|
827
860
|
create_table "manifestation_relationship_types", force: :cascade do |t|
|
828
861
|
t.string "name", null: false
|
829
862
|
t.text "display_name"
|
@@ -9,7 +9,7 @@ RSpec.describe 'Libraries', type: :system do
|
|
9
9
|
sign_in users(:admin)
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
xit 'should show library config' do
|
13
13
|
visit library_path(libraries(:library_00002).id, locale: :ja)
|
14
14
|
expect(page).to have_content '設定'
|
15
15
|
end
|
@@ -20,9 +20,9 @@ RSpec.describe 'Libraries', type: :system do
|
|
20
20
|
sign_in users(:librarian1)
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
xit 'should not show library config' do
|
24
24
|
visit library_path(libraries(:library_00002).id, locale: :ja)
|
25
|
-
expect(page).not_to
|
25
|
+
expect(page).not_to have_link '設定'
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -33,14 +33,14 @@ RSpec.describe 'Libraries', type: :system do
|
|
33
33
|
|
34
34
|
it 'should not show library config' do
|
35
35
|
visit library_path(libraries(:library_00002).id, locale: :ja)
|
36
|
-
expect(page).not_to
|
36
|
+
expect(page).not_to have_link '設定'
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
describe 'When not logged in' do
|
41
41
|
it 'should not show library config' do
|
42
42
|
visit library_path(libraries(:library_00002).id, locale: :ja)
|
43
|
-
expect(page).not_to
|
43
|
+
expect(page).not_to have_link '設定'
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|