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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6281daed741bd1cc79341eccf54fa5f12335277b8ca176ba932f4d80ece97552
4
- data.tar.gz: acc7e4eb25d44495444425463c0b5f8e327c8d793d6f9788cfa5d4f058158c8a
3
+ metadata.gz: 83ce39d2995d4ffcafaf40c6ccdf98ff6490a6456a04b3a4613e3d564ec04296
4
+ data.tar.gz: 3b3077bca17ab0321ba8f3792127dd558fa7c74e147b6173cc174790d4365ebd
5
5
  SHA512:
6
- metadata.gz: 1d5e70ea6107e81b239df5beea6a1e24dd5957ccadbe54cd2a5a81595577f904eb4737c5e97cfb095f19ea0b225359d1c361a7981b930b63a5cdc84ffd3bcfbb
7
- data.tar.gz: 6c8fd058c37819d5a7a7f8aecd1064bb20bade05b17b39f41f63ccef4c9975aa83d4898a07b30ff2cd4d5827b640f9d3b766effd6f14fb8cc16b36db2f3d7ab4
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 text: '{"error": "forbidden"}' }
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 text: '{"error": "forbidden"}' }
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 text: '{"error": "not_found"}' }
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 text: '{"error": "server_error"}' }
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 text: '{"error": "server_error"}' }
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
@@ -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.where(username: username).first
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.where(name: row['role']).first
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.where(username: username).first
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.where(name: row['user_group']).first
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.where(name: row['required_role']).first
297
+ required_role = Role.find_by(name: row['required_role'])
298
298
  unless required_role
299
- required_role = Role.where(name: 'Librarian').first
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.where(name: row['library'].to_s.strip).first
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>
@@ -20,7 +20,7 @@
20
20
  <% unless @library.web? %>
21
21
  <div class="field">
22
22
  <%= f.label :isil -%><br />
23
- <%= f.text_field :isil, class: 'resource_identifierr' -%>
23
+ <%= f.text_field :isil, class: 'resource_identifier' -%>
24
24
  </div>
25
25
 
26
26
  <div class="field">
@@ -1,25 +1,12 @@
1
- <script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
2
- <script type="text/javascript">
3
- google.maps.event.addDomListener(window, 'load', function() {
4
- var latlng = new google.maps.LatLng(<%= library.latitude %>, <%= library.longitude %>);
5
- var options = {
6
- zoom: 16,
7
- center: latlng,
8
- mapTypeId: google.maps.MapTypeId.ROADMAP,
9
- scaleControl: true
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 &copy; <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
@@ -59,6 +59,8 @@ ja:
59
59
  max_number_of_results: 検索結果の最大件数
60
60
  book_jacket_source: 書影の取得元
61
61
  header_logo: ヘッダーのロゴ
62
+ default_custom_manifestation_label: 既定のカスタム項目(書誌)
63
+ default_custom_item_label: 既定のカスタム項目(所蔵)
62
64
  bookstore:
63
65
  name: 名前
64
66
  zip_code: 郵便番号
@@ -1,3 +1,3 @@
1
1
  module EnjuLibrary
2
- VERSION = "0.3.7"
2
+ VERSION = "0.3.8.rc.1".freeze
3
3
  end
@@ -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
@@ -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: 2019_12_19_122214) do
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"
@@ -47,4 +47,7 @@ one:
47
47
  # header_logo_file_size :integer
48
48
  # header_logo_updated_at :datetime
49
49
  # header_logo_meta :text
50
+ # library_group_id :integer not null
51
+ # login_banner :text
52
+ # footer_banner :text
50
53
  #
@@ -46,4 +46,7 @@ end
46
46
  # header_logo_file_size :integer
47
47
  # header_logo_updated_at :datetime
48
48
  # header_logo_meta :text
49
+ # library_group_id :integer not null
50
+ # login_banner :text
51
+ # footer_banner :text
49
52
  #
@@ -9,7 +9,7 @@ RSpec.describe 'Libraries', type: :system do
9
9
  sign_in users(:admin)
10
10
  end
11
11
 
12
- it 'should show library config' do
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
- it 'should not show library config' do
23
+ xit 'should not show library config' do
24
24
  visit library_path(libraries(:library_00002).id, locale: :ja)
25
- expect(page).not_to have_content '設定'
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 have_content '設定'
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 have_content '設定'
43
+ expect(page).not_to have_link '設定'
44
44
  end
45
45
  end
46
46
  end