enju_library 0.4.0.beta.4 → 0.4.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/controllers/library_groups_controller.rb +1 -4
  4. data/app/helpers/enju_library/application_helper.rb +2 -2
  5. data/app/mailers/notifier.rb +2 -2
  6. data/app/mailers/user_export_mailer.rb +2 -2
  7. data/app/mailers/user_import_mailer.rb +2 -2
  8. data/app/models/accept.rb +6 -6
  9. data/app/models/basket.rb +4 -4
  10. data/app/models/bookstore.rb +3 -4
  11. data/app/models/budget_type.rb +3 -3
  12. data/app/models/color.rb +4 -4
  13. data/app/models/concerns/enju_library/enju_user.rb +62 -0
  14. data/app/models/library.rb +5 -6
  15. data/app/models/library_group.rb +5 -4
  16. data/app/models/request_status_type.rb +3 -3
  17. data/app/models/request_type.rb +3 -3
  18. data/app/models/search_engine.rb +3 -3
  19. data/app/models/shelf.rb +5 -6
  20. data/app/models/subscribe.rb +4 -4
  21. data/app/models/subscription.rb +5 -6
  22. data/app/models/user_export_file.rb +14 -20
  23. data/app/models/user_export_file_state_machine.rb +1 -1
  24. data/app/models/user_export_file_transition.rb +4 -4
  25. data/app/models/user_group.rb +3 -4
  26. data/app/models/user_import_file.rb +13 -21
  27. data/app/models/user_import_file_state_machine.rb +1 -1
  28. data/app/models/user_import_file_transition.rb +4 -4
  29. data/app/models/user_import_result.rb +5 -5
  30. data/app/models/withdraw.rb +4 -10
  31. data/app/policies/shelf_policy.rb +1 -1
  32. data/app/views/layouts/libraries.html.erb +31 -0
  33. data/app/views/libraries/_map.html.erb +8 -24
  34. data/app/views/libraries/_map_header.html.erb +6 -0
  35. data/app/views/library_groups/_form.html.erb +1 -3
  36. data/app/views/library_groups/show.html.erb +1 -1
  37. data/app/views/user_groups/show.html.erb +5 -3
  38. data/app/views/user_import_files/_results.html.erb +5 -0
  39. data/app/views/user_import_results/index.html.erb +0 -11
  40. data/db/migrate/059_create_libraries.rb +1 -2
  41. data/db/migrate/069_create_shelves.rb +1 -2
  42. data/db/migrate/077_create_user_groups.rb +1 -2
  43. data/db/migrate/080_create_library_groups.rb +1 -1
  44. data/db/migrate/120_create_baskets.rb +1 -1
  45. data/db/migrate/124_create_bookstores.rb +1 -2
  46. data/db/migrate/130_create_request_status_types.rb +1 -1
  47. data/db/migrate/131_create_request_types.rb +1 -1
  48. data/db/migrate/20081006090811_create_subscriptions.rb +1 -2
  49. data/db/migrate/20081006093246_create_subscribes.rb +1 -1
  50. data/db/migrate/20081023092436_create_search_engines.rb +1 -1
  51. data/db/migrate/20100211105551_add_admin_networks_to_library_group.rb +1 -1
  52. data/db/migrate/20100314190054_add_opening_hour_to_library.rb +1 -1
  53. data/db/migrate/20110222073537_add_url_to_library_group.rb +1 -1
  54. data/db/migrate/20110318183304_add_valid_period_for_new_user_to_user_group.rb +1 -1
  55. data/db/migrate/20120105074911_add_isil_to_library.rb +1 -1
  56. data/db/migrate/20120129014038_create_budget_types.rb +1 -1
  57. data/db/migrate/20120319173203_create_accepts.rb +1 -1
  58. data/db/migrate/20120510140958_add_closed_to_shelf.rb +1 -1
  59. data/db/migrate/20130412083556_add_latitude_and_longitude_to_library.rb +1 -1
  60. data/db/migrate/20140110122216_create_user_import_files.rb +1 -1
  61. data/db/migrate/20140110131010_create_user_import_results.rb +1 -1
  62. data/db/migrate/20140524074813_create_user_import_file_transitions.rb +1 -1
  63. data/db/migrate/20140628072217_add_user_encoding_to_user_import_file.rb +1 -1
  64. data/db/migrate/20140709113413_create_user_export_files.rb +1 -1
  65. data/db/migrate/20140709113905_create_user_export_file_transitions.rb +1 -1
  66. data/db/migrate/20140720170714_add_default_library_id_to_user_import_file.rb +1 -1
  67. data/db/migrate/20140720170735_add_default_user_group_id_to_user_import_file.rb +1 -1
  68. data/db/migrate/20140821151023_create_colors.rb +1 -1
  69. data/db/migrate/20150221063719_add_settings_to_library_group.rb +1 -1
  70. data/db/migrate/20150506105356_add_error_message_to_user_import_result.rb +1 -1
  71. data/db/migrate/20150924115059_create_withdraws.rb +1 -1
  72. data/db/migrate/20160610093229_add_html_snippet_to_library_group.rb +1 -1
  73. data/db/migrate/20160627232219_add_most_recent_to_user_import_file_transitions.rb +1 -1
  74. data/db/migrate/20160627232316_add_most_recent_to_user_export_file_transitions.rb +1 -1
  75. data/db/migrate/20160813191647_add_max_number_of_results_to_library_group.rb +1 -1
  76. data/db/migrate/20160813191733_add_family_name_first_to_library_group.rb +1 -1
  77. data/db/migrate/20160813192542_add_pub_year_facet_range_interval_to_library_group.rb +1 -1
  78. data/db/migrate/20160813203039_add_user_id_to_library_group.rb +1 -1
  79. data/db/migrate/20170305064014_add_csv_charset_conversion_to_library_group.rb +1 -1
  80. data/db/migrate/20171014084528_add_header_logo_to_library_group.rb +1 -1
  81. data/db/migrate/20171126133835_rename_login_banner_to_old_login_banner.rb +1 -1
  82. data/db/migrate/20171126135238_add_foreign_key_to_library_group_id_on_library.rb +1 -1
  83. data/db/migrate/20180102162311_add_header_logo_meta_to_library_group.rb +1 -1
  84. data/db/migrate/20180107160726_add_constraints_to_most_recent_for_user_import_file_transitions.rb +1 -1
  85. data/db/migrate/20180107160740_add_constraints_to_most_recent_for_user_export_file_transitions.rb +1 -1
  86. data/db/migrate/20191216131755_add_email_to_library_group.rb +6 -0
  87. data/lib/enju_library/version.rb +1 -1
  88. data/lib/generators/enju_library/setup/setup_generator.rb +4 -3
  89. data/lib/generators/enju_library/setup/templates/db/fixtures/library_groups.yml +2 -2
  90. data/lib/generators/enju_library/setup/templates/db/fixtures/search_engines.yml +9 -0
  91. data/spec/dummy/app/assets/config/manifest.js +2 -0
  92. data/spec/dummy/app/controllers/application_controller.rb +0 -1
  93. data/spec/dummy/app/models/user.rb +0 -2
  94. data/spec/dummy/config/initializers/assets.rb +1 -1
  95. data/spec/dummy/db/migrate/001_create_agents.rb +0 -1
  96. data/spec/dummy/db/migrate/005_create_manifestations.rb +0 -1
  97. data/spec/dummy/db/migrate/006_create_items.rb +0 -1
  98. data/spec/dummy/db/migrate/20190818075603_add_memo_to_manifestation.rb +5 -0
  99. data/spec/dummy/db/migrate/20190818075628_add_memo_to_item.rb +5 -0
  100. data/spec/dummy/db/migrate/20191219122214_create_custom_properties.rb +12 -0
  101. data/spec/dummy/db/schema.rb +98 -90
  102. data/spec/dummy/db/test.sqlite3 +0 -0
  103. data/spec/dummy/postcss.config.js +12 -0
  104. data/spec/factories/accepts.rb +6 -6
  105. data/spec/factories/budget_types.rb +3 -3
  106. data/spec/fixtures/baskets.yml +4 -4
  107. data/spec/fixtures/bookstores.yml +3 -11
  108. data/spec/fixtures/budget_types.yml +3 -3
  109. data/spec/fixtures/colors.yml +4 -4
  110. data/spec/fixtures/events.yml +0 -9
  111. data/spec/fixtures/libraries.yml +5 -6
  112. data/spec/fixtures/library_groups.yml +6 -5
  113. data/spec/fixtures/request_status_types.yml +3 -3
  114. data/spec/fixtures/request_types.yml +3 -3
  115. data/spec/fixtures/search_engines.yml +3 -3
  116. data/spec/fixtures/shelves.yml +4 -5
  117. data/spec/fixtures/subscribes.yml +4 -4
  118. data/spec/fixtures/subscriptions.yml +5 -6
  119. data/spec/fixtures/user_export_files.yml +4 -4
  120. data/spec/fixtures/user_groups.yml +3 -4
  121. data/spec/fixtures/user_import_files.yml +6 -6
  122. data/spec/fixtures/user_import_results.yml +5 -5
  123. data/spec/fixtures/withdraws.yml +4 -4
  124. data/spec/models/accept_spec.rb +6 -6
  125. data/spec/models/basket_spec.rb +4 -4
  126. data/spec/models/bookstore_spec.rb +3 -4
  127. data/spec/models/budget_type_spec.rb +3 -3
  128. data/spec/models/library_group_spec.rb +5 -4
  129. data/spec/models/library_spec.rb +5 -6
  130. data/spec/models/request_status_type_spec.rb +3 -3
  131. data/spec/models/request_type_spec.rb +3 -3
  132. data/spec/models/search_engine_spec.rb +3 -3
  133. data/spec/models/shelf_spec.rb +4 -5
  134. data/spec/models/subscribe_spec.rb +4 -4
  135. data/spec/models/subscription_spec.rb +5 -6
  136. data/spec/models/user_export_file_spec.rb +4 -4
  137. data/spec/models/user_group_spec.rb +3 -4
  138. data/spec/models/user_import_file_spec.rb +8 -8
  139. data/spec/models/user_import_result_spec.rb +5 -5
  140. data/spec/models/withdraw_spec.rb +4 -4
  141. data/spec/system/libraries_spec.rb +5 -5
  142. data/spec/system/user_groups_spec.rb +46 -0
  143. metadata +32 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3fe45c54c07a749094837b2e5d64b05c02d155aa024feeb44528fc474adf67c2
4
- data.tar.gz: 3e6293caed7ef2a3133ea3cd84266e4de9dd2c030d888f93d982b1a83e41a41d
3
+ metadata.gz: 6e02d4568d0ebba73a6e192a03f02967e316948576fe92c354b252a1207a6fab
4
+ data.tar.gz: 5f636e16cae0839f342760ff305111ea2c64c66542bf9c1f3df71f8831f5b244
5
5
  SHA512:
6
- metadata.gz: 012a3b4be7f5cb082bbbf62702cb7cdeb4e15887f26c79db53b27c7a1b2dc348ebb9bcbb994b146051fe7bf3bd8825eece6f609aaa5157393edcb3731a49f1c9
7
- data.tar.gz: fedf2c70dbf9e8311af543bb74ff664b8c15fccf2a3b32e4969f125509cffa985a9bdb1b9b0dd4dd68c77c6d2da37b35f76e982591d77cadf799ee2eb2449ffd
6
+ metadata.gz: 5b27017e8be6fd505cca262eb24db031f56927d0bea438a9f63f047b805c3a0f802e90f71922fc6cfc6783cd6775dde04a4df39e3f2ba56e5a9b91c94a2cf82a
7
+ data.tar.gz: 97bca63336e0ff89d6db94bb87c68e0d2a67b9381a90424ad20a91e808ce5cc3414c2e354d80c99ddbf761366ed25e4c5db4a6f0daa7838066866b867db0f9aa
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # EnjuLibrary
2
- ![](https://github.com/next-l/enju_library/workflows/Ruby/badge.svg?branch=2.x)
2
+ [![CircleCI](https://circleci.com/gh/next-l/enju_library/tree/2.x.svg?style=svg)](https://circleci.com/gh/next-l/enju_library/tree/2.x)
3
3
  [![Coverage Status](https://coveralls.io/repos/github/next-l/enju_library/badge.svg?branch=2.x)](https://coveralls.io/github/next-l/enju_library?branch=2.x)
4
4
 
5
5
  This project rocks and uses MIT-LICENSE.
@@ -91,10 +91,7 @@ class LibraryGroupsController < ApplicationController
91
91
  },
92
92
  {
93
93
  colors_attributes: [:id, :property, :code]
94
- },
95
- {
96
- user_attributes: [:email]
97
- },
94
+ }
98
95
  )
99
96
  end
100
97
  end
@@ -7,10 +7,10 @@ module EnjuLibrary
7
7
  content_tag :li do
8
8
  if current
9
9
  content_tag :strong do
10
- link_to("#{library.display_name.localize} (" + facet.count.to_s + ")", url_for(filtered_params.merge(page: nil, library_id: library.name, only_path: true)))
10
+ link_to("#{library.display_name} (" + facet.count.to_s + ")", url_for(filtered_params.merge(page: nil, library_id: library.name, only_path: true)))
11
11
  end
12
12
  else
13
- link_to("#{library.display_name.localize} (" + facet.count.to_s + ")", url_for(filtered_params.merge(page: nil, library_id: library.name, only_path: true)))
13
+ link_to("#{library.display_name} (" + facet.count.to_s + ")", url_for(filtered_params.merge(page: nil, library_id: library.name, only_path: true)))
14
14
  end
15
15
  end
16
16
  end
@@ -2,7 +2,7 @@ class Notifier < ActionMailer::Base
2
2
  def message_notification(message_id)
3
3
  message = Message.find(message_id)
4
4
  I18n.locale = message.receiver.profile.locale.try(:to_sym) || I18n.default_locale
5
- from = "#{LibraryGroup.system_name(message.receiver.profile.locale)} <#{LibraryGroup.site_config.user.email}>"
5
+ from = "#{LibraryGroup.system_name(message.receiver.profile.locale)} <#{LibraryGroup.site_config.email}>"
6
6
  if message.subject
7
7
  subject = message.subject
8
8
  else
@@ -21,7 +21,7 @@ class Notifier < ActionMailer::Base
21
21
  def manifestation_info(user_id, manifestation_id)
22
22
  user = User.find(user_id)
23
23
  manifestation = Manifestation.find(manifestation_id)
24
- from = "#{LibraryGroup.system_name(user.profile.locale)} <#{LibraryGroup.site_config.user.email}>"
24
+ from = "#{LibraryGroup.system_name(user.profile.locale)} <#{LibraryGroup.site_config.email}>"
25
25
  subject = "#{manifestation.original_title} : #{LibraryGroup.system_name(user.profile.locale)}"
26
26
  @user = user
27
27
  @manifestation = manifestation
@@ -2,7 +2,7 @@ class UserExportMailer < ApplicationMailer
2
2
  def completed(user_export_file)
3
3
  @user_export_file = user_export_file
4
4
  @library_group = LibraryGroup.site_config
5
- from = "#{LibraryGroup.system_name(user_export_file.user.profile.locale)} <#{@library_group.user.email}>"
5
+ from = "#{LibraryGroup.system_name(user_export_file.user.profile.locale)} <#{@library_group.email}>"
6
6
  subject = "#{I18n.t('user_export_mailer.completed.subject')}: #{@user_export_file.id}"
7
7
  mail(from: from, to: user_export_file.user.email, subject: subject)
8
8
  end
@@ -10,7 +10,7 @@ class UserExportMailer < ApplicationMailer
10
10
  def failed(user_export_file)
11
11
  @user_export_file = user_export_file
12
12
  @library_group = LibraryGroup.site_config
13
- from = "#{LibraryGroup.system_name(user_export_file.user.profile.locale)} <#{@library_group.user.email}>"
13
+ from = "#{LibraryGroup.system_name(user_export_file.user.profile.locale)} <#{@library_group.email}>"
14
14
  subject = "#{I18n.t('user_export_mailer.failed.subject')}: #{@user_export_file.id}"
15
15
  mail(from: from, to: user_export_file.user.email, subject: subject)
16
16
  end
@@ -2,7 +2,7 @@ class UserImportMailer < ApplicationMailer
2
2
  def completed(user_import_file)
3
3
  @user_import_file = user_import_file
4
4
  @library_group = LibraryGroup.site_config
5
- from = "#{LibraryGroup.system_name(user_import_file.user.profile.locale)} <#{@library_group.user.email}>"
5
+ from = "#{LibraryGroup.system_name(user_import_file.user.profile.locale)} <#{@library_group.email}>"
6
6
  subject = "#{I18n.t('user_import_mailer.completed.subject')}: #{@user_import_file.id}"
7
7
  mail(from: from, to: user_import_file.user.email, subject: subject)
8
8
  end
@@ -10,7 +10,7 @@ class UserImportMailer < ApplicationMailer
10
10
  def failed(user_import_file)
11
11
  @user_import_file = user_import_file
12
12
  @library_group = LibraryGroup.site_config
13
- from = "#{LibraryGroup.system_name(user_import_file.user.profile.locale)} <#{@library_group.user.email}>"
13
+ from = "#{LibraryGroup.system_name(user_import_file.user.profile.locale)} <#{@library_group.email}>"
14
14
  subject = "#{I18n.t('user_import_mailer.failed.subject')}: #{@user_import_file.id}"
15
15
  mail(from: from, to: user_import_file.user.email, subject: subject)
16
16
  end
@@ -17,10 +17,10 @@ end
17
17
  #
18
18
  # Table name: accepts
19
19
  #
20
- # id :integer not null, primary key
21
- # basket_id :integer
22
- # item_id :integer
23
- # librarian_id :integer
24
- # created_at :datetime
25
- # updated_at :datetime
20
+ # id :bigint not null, primary key
21
+ # basket_id :bigint
22
+ # item_id :bigint
23
+ # librarian_id :bigint
24
+ # created_at :datetime not null
25
+ # updated_at :datetime not null
26
26
  #
@@ -30,10 +30,10 @@ end
30
30
  #
31
31
  # Table name: baskets
32
32
  #
33
- # id :integer not null, primary key
34
- # user_id :integer
33
+ # id :bigint not null, primary key
34
+ # user_id :bigint
35
35
  # note :text
36
36
  # lock_version :integer default(0), not null
37
- # created_at :datetime
38
- # updated_at :datetime
37
+ # created_at :datetime not null
38
+ # updated_at :datetime not null
39
39
  #
@@ -17,7 +17,7 @@ end
17
17
  #
18
18
  # Table name: bookstores
19
19
  #
20
- # id :integer not null, primary key
20
+ # id :bigint not null, primary key
21
21
  # name :text not null
22
22
  # zip_code :string
23
23
  # address :text
@@ -26,7 +26,6 @@ end
26
26
  # fax_number :string
27
27
  # url :string
28
28
  # position :integer
29
- # deleted_at :datetime
30
- # created_at :datetime
31
- # updated_at :datetime
29
+ # created_at :datetime not null
30
+ # updated_at :datetime not null
32
31
  #
@@ -15,12 +15,12 @@ end
15
15
  #
16
16
  # Table name: budget_types
17
17
  #
18
- # id :integer not null, primary key
18
+ # id :bigint not null, primary key
19
19
  # name :string
20
20
  # display_name :text
21
21
  # note :text
22
22
  # position :integer
23
- # created_at :datetime
24
- # updated_at :datetime
23
+ # created_at :datetime not null
24
+ # updated_at :datetime not null
25
25
  # display_name_translations :jsonb not null
26
26
  #
@@ -12,11 +12,11 @@ end
12
12
  #
13
13
  # Table name: colors
14
14
  #
15
- # id :integer not null, primary key
16
- # library_group_id :integer
15
+ # id :bigint not null, primary key
16
+ # library_group_id :bigint
17
17
  # property :string
18
18
  # code :string
19
19
  # position :integer
20
- # created_at :datetime
21
- # updated_at :datetime
20
+ # created_at :datetime not null
21
+ # updated_at :datetime not null
22
22
  #
@@ -5,6 +5,68 @@ module EnjuLibrary
5
5
  included do
6
6
  include EnjuSeed::EnjuUser
7
7
  has_many :basket, dependent: :destroy
8
+
9
+ def self.csv_header(role: 'Librarian')
10
+ User.new.to_hash(role: 'Librarian').keys
11
+ end
12
+
13
+ # ユーザの情報をエクスポートします。
14
+ # @param [Hash] options
15
+ def to_hash(role: 'Librarian')
16
+ record = {
17
+ username: username,
18
+ full_name: profile.try(:full_name),
19
+ full_name_transcription: profile.try(:full_name_transcription),
20
+ email: email,
21
+ user_number: profile.try(:user_number),
22
+ role: send(:role).try(:name),
23
+ user_group: profile.try(:user_group).try(:name),
24
+ library: profile.try(:library).try(:name),
25
+ locale: profile.try(:locale),
26
+ locked: access_locked?,
27
+ required_role: profile.try(:required_role).try(:name),
28
+ created_at: created_at,
29
+ updated_at: updated_at,
30
+ expired_at: profile.try(:expired_at),
31
+ keyword_list: profile.try(:keyword_list),
32
+ note: profile.try(:note)
33
+ }
34
+
35
+ if defined?(EnjuCirculation)
36
+ record.merge!(
37
+ checkout_icalendar_token: checkout_icalendar_token,
38
+ save_checkout_history: save_checkout_history
39
+ )
40
+ end
41
+
42
+ if defined?(EnjuSearchLog)
43
+ record.merge!(
44
+ save_search_history: save_checkout_history
45
+ )
46
+ end
47
+
48
+ if defined?(EnjuBookmark)
49
+ record.merge!(
50
+ share_bookmarks: share_bookmarks
51
+ )
52
+ end
53
+
54
+ record
55
+ end
56
+
57
+ def self.export(role: 'Librarian', col_sep: "\t")
58
+ file = Tempfile.create do |f|
59
+ f.write User.csv_header(role: role).to_csv(col_sep: col_sep)
60
+ User.find_each do |user|
61
+ # f.write user.to_hash(role: role).values.to_csv(col_sep: col_sep)
62
+ end
63
+
64
+ f.rewind
65
+ f.read
66
+ end
67
+
68
+ file
69
+ end
8
70
  end
9
71
  end
10
72
  end
@@ -79,7 +79,7 @@ end
79
79
  #
80
80
  # Table name: libraries
81
81
  #
82
- # id :integer not null, primary key
82
+ # id :bigint not null, primary key
83
83
  # name :string not null
84
84
  # display_name :text
85
85
  # short_display_name :string not null
@@ -93,13 +93,12 @@ end
93
93
  # note :text
94
94
  # call_number_rows :integer default(1), not null
95
95
  # call_number_delimiter :string default("|"), not null
96
- # library_group_id :integer not null
96
+ # library_group_id :bigint not null
97
97
  # users_count :integer default(0), not null
98
98
  # position :integer
99
- # country_id :integer
100
- # created_at :datetime
101
- # updated_at :datetime
102
- # deleted_at :datetime
99
+ # country_id :bigint
100
+ # created_at :datetime not null
101
+ # updated_at :datetime not null
103
102
  # opening_hour :text
104
103
  # isil :string
105
104
  # latitude :float
@@ -79,7 +79,7 @@ end
79
79
  #
80
80
  # Table name: library_groups
81
81
  #
82
- # id :integer not null, primary key
82
+ # id :bigint not null, primary key
83
83
  # name :string not null
84
84
  # display_name :text
85
85
  # short_name :string not null
@@ -88,8 +88,8 @@ end
88
88
  # note :text
89
89
  # country_id :integer
90
90
  # position :integer
91
- # created_at :datetime
92
- # updated_at :datetime
91
+ # created_at :datetime not null
92
+ # updated_at :datetime not null
93
93
  # admin_networks :text
94
94
  # allow_bookmark_external_url :boolean default(FALSE), not null
95
95
  # url :string default("http://localhost:3000/")
@@ -100,7 +100,7 @@ end
100
100
  # family_name_first :boolean default(TRUE)
101
101
  # screenshot_generator :string
102
102
  # pub_year_facet_range_interval :integer default(10)
103
- # user_id :integer
103
+ # user_id :bigint
104
104
  # csv_charset_conversion :boolean default(FALSE), not null
105
105
  # header_logo_file_name :string
106
106
  # header_logo_content_type :string
@@ -110,4 +110,5 @@ end
110
110
  # display_name_translations :jsonb not null
111
111
  # login_banner_translations :jsonb not null
112
112
  # footer_banner_translations :jsonb not null
113
+ # email :string
113
114
  #
@@ -15,12 +15,12 @@ end
15
15
  #
16
16
  # Table name: request_status_types
17
17
  #
18
- # id :integer not null, primary key
18
+ # id :bigint not null, primary key
19
19
  # name :string not null
20
20
  # display_name :text
21
21
  # note :text
22
22
  # position :integer
23
- # created_at :datetime
24
- # updated_at :datetime
23
+ # created_at :datetime not null
24
+ # updated_at :datetime not null
25
25
  # display_name_translations :jsonb not null
26
26
  #
@@ -14,12 +14,12 @@ end
14
14
  #
15
15
  # Table name: request_types
16
16
  #
17
- # id :integer not null, primary key
17
+ # id :bigint not null, primary key
18
18
  # name :string not null
19
19
  # display_name :text
20
20
  # note :text
21
21
  # position :integer
22
- # created_at :datetime
23
- # updated_at :datetime
22
+ # created_at :datetime not null
23
+ # updated_at :datetime not null
24
24
  # display_name_translations :jsonb not null
25
25
  #
@@ -26,7 +26,7 @@ end
26
26
  #
27
27
  # Table name: search_engines
28
28
  #
29
- # id :integer not null, primary key
29
+ # id :bigint not null, primary key
30
30
  # name :string not null
31
31
  # display_name :text
32
32
  # url :string not null
@@ -36,7 +36,7 @@ end
36
36
  # additional_param :text
37
37
  # note :text
38
38
  # position :integer
39
- # created_at :datetime
40
- # updated_at :datetime
39
+ # created_at :datetime not null
40
+ # updated_at :datetime not null
41
41
  # display_name_translations :jsonb not null
42
42
  #
@@ -39,7 +39,7 @@ class Shelf < ApplicationRecord
39
39
  end
40
40
 
41
41
  def localized_display_name
42
- display_name.localize
42
+ display_name
43
43
  end
44
44
 
45
45
  # http://stackoverflow.com/a/12437606
@@ -54,16 +54,15 @@ end
54
54
  #
55
55
  # Table name: shelves
56
56
  #
57
- # id :integer not null, primary key
57
+ # id :bigint not null, primary key
58
58
  # name :string not null
59
59
  # display_name :text
60
60
  # note :text
61
- # library_id :integer not null
61
+ # library_id :bigint not null
62
62
  # items_count :integer default(0), not null
63
63
  # position :integer
64
- # created_at :datetime
65
- # updated_at :datetime
66
- # deleted_at :datetime
64
+ # created_at :datetime not null
65
+ # updated_at :datetime not null
67
66
  # closed :boolean default(FALSE), not null
68
67
  # display_name_translations :jsonb not null
69
68
  #
@@ -11,11 +11,11 @@ end
11
11
  #
12
12
  # Table name: subscribes
13
13
  #
14
- # id :integer not null, primary key
15
- # subscription_id :integer not null
14
+ # id :bigint not null, primary key
15
+ # subscription_id :bigint not null
16
16
  # work_id :integer not null
17
17
  # start_at :datetime not null
18
18
  # end_at :datetime not null
19
- # created_at :datetime
20
- # updated_at :datetime
19
+ # created_at :datetime not null
20
+ # updated_at :datetime not null
21
21
  #
@@ -28,13 +28,12 @@ end
28
28
  #
29
29
  # Table name: subscriptions
30
30
  #
31
- # id :integer not null, primary key
31
+ # id :bigint not null, primary key
32
32
  # title :text not null
33
33
  # note :text
34
- # user_id :integer
35
- # order_list_id :integer
36
- # deleted_at :datetime
34
+ # user_id :bigint
35
+ # order_list_id :bigint
37
36
  # subscribes_count :integer default(0), not null
38
- # created_at :datetime
39
- # updated_at :datetime
37
+ # created_at :datetime not null
38
+ # updated_at :datetime not null
40
39
  #
@@ -31,14 +31,16 @@ class UserExportFile < ApplicationRecord
31
31
 
32
32
  # エクスポートの処理を実行します。
33
33
  def export!
34
- transition_to!(:started)
35
- tempfile = Tempfile.new(['user_export_file_', '.txt'])
36
- file = User.export(format: :txt)
37
- tempfile.puts(file)
38
- tempfile.close
39
- self.user_export = File.new(tempfile.path, 'r')
40
- save!
41
- transition_to!(:completed)
34
+ UserExportFile.transaction do
35
+ transition_to!(:started)
36
+ role_name = user.try(:role).try(:name)
37
+ tsv = User.export(role: role_name)
38
+ self.user_export = StringIO.new(tsv)
39
+ self.user_export.instance_write(:filename, "user_export.txt")
40
+ save!
41
+ transition_to!(:completed)
42
+ end
43
+
42
44
  mailer = UserExportMailer.completed(self)
43
45
  send_message(mailer)
44
46
  rescue => e
@@ -46,27 +48,19 @@ class UserExportFile < ApplicationRecord
46
48
  mailer = UserExportMailer.failed(self)
47
49
  raise e
48
50
  end
49
-
50
- def self.transition_class
51
- UserExportFileTransition
52
- end
53
-
54
- def self.initial_state
55
- :pending
56
- end
57
51
  end
58
52
 
59
53
  # == Schema Information
60
54
  #
61
55
  # Table name: user_export_files
62
56
  #
63
- # id :integer not null, primary key
64
- # user_id :integer
57
+ # id :bigint not null, primary key
58
+ # user_id :bigint
65
59
  # user_export_file_name :string
66
60
  # user_export_content_type :string
67
61
  # user_export_file_size :bigint
68
62
  # user_export_updated_at :datetime
69
63
  # executed_at :datetime
70
- # created_at :datetime
71
- # updated_at :datetime
64
+ # created_at :datetime not null
65
+ # updated_at :datetime not null
72
66
  #