enju_library 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/mailers/application_mailer.rb +4 -0
- data/app/mailers/user_export_mailer.rb +17 -0
- data/app/mailers/user_import_mailer.rb +17 -0
- data/app/models/concerns/export_file.rb +8 -9
- data/app/models/concerns/import_file.rb +7 -7
- data/app/models/user_export_file.rb +4 -3
- data/app/models/user_import_file.rb +13 -4
- data/app/views/user_export_mailer/completed.en.text.erb +9 -0
- data/app/views/user_export_mailer/completed.ja.text.erb +9 -0
- data/app/views/user_export_mailer/failed.en.text.erb +9 -0
- data/app/views/user_export_mailer/failed.ja.text.erb +9 -0
- data/app/views/user_import_mailer/completed.en.text.erb +9 -0
- data/app/views/user_import_mailer/completed.ja.text.erb +9 -0
- data/app/views/user_import_mailer/failed.en.text.erb +9 -0
- data/app/views/user_import_mailer/failed.ja.text.erb +9 -0
- data/config/locales/translation_en.yml +11 -0
- data/config/locales/translation_ja.yml +11 -0
- data/lib/enju_library/version.rb +1 -1
- data/spec/mailers/previews/user_export_preview.rb +4 -0
- data/spec/mailers/previews/user_import_preview.rb +4 -0
- data/spec/mailers/user_export_spec.rb +5 -0
- data/spec/mailers/user_import_spec.rb +5 -0
- data/spec/models/basket_spec.rb +0 -1
- data/spec/models/library_group_spec.rb +0 -1
- data/spec/models/library_spec.rb +0 -1
- data/spec/models/request_status_type_spec.rb +0 -1
- data/spec/models/request_type_spec.rb +0 -1
- data/spec/models/search_engine_spec.rb +0 -1
- data/spec/models/shelf_spec.rb +0 -1
- data/spec/models/subscribe_spec.rb +0 -1
- data/spec/models/user_export_file_spec.rb +1 -1
- data/spec/models/user_group_spec.rb +0 -1
- data/spec/models/user_import_file_spec.rb +1 -1
- data/spec/models/user_import_result_spec.rb +0 -1
- metadata +35 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 518d6386e03d122a166917fc15a446fd49a9fbf2651c462b145750ddc67f848b
|
4
|
+
data.tar.gz: 79d27b3572eb819d9ded99e22b7ead5c44c02c7b9e6d4ba2caaec5b151da6170
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1f11e2a73dae41c407941907c3c367150125f067ec7f7dea9a06055ad6c3aa769091535af07ef73dfa6677a3f1a87a22b6abec8aafa091d4a1e63afa3d9aa92
|
7
|
+
data.tar.gz: 70fc2466822926ce04dfb8cca850ddc877c4b72e2def06f372db94de6cdb0fa97e71c1df410846a943a6b55063b09c3b59664a4482e755cbd12a323a79c5dcf9
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class UserExportMailer < ApplicationMailer
|
2
|
+
def completed(user_export_file)
|
3
|
+
@user_export_file = user_export_file
|
4
|
+
@library_group = LibraryGroup.site_config
|
5
|
+
from = "#{LibraryGroup.system_name(user_export_file.user.profile.locale)} <#{@library_group.user.email}>"
|
6
|
+
subject = "#{I18n.t('user_export_mailer.completed.subject')}: #{@user_export_file.id}"
|
7
|
+
mail(from: from, to: user_export_file.user.email, subject: subject)
|
8
|
+
end
|
9
|
+
|
10
|
+
def failed(user_export_file)
|
11
|
+
@user_export_file = user_export_file
|
12
|
+
@library_group = LibraryGroup.site_config
|
13
|
+
from = "#{LibraryGroup.system_name(user_export_file.user.profile.locale)} <#{@library_group.user.email}>"
|
14
|
+
subject = "#{I18n.t('user_export_mailer.failed.subject')}: #{@user_export_file.id}"
|
15
|
+
mail(from: from, to: user_export_file.user.email, subject: subject)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class UserImportMailer < ApplicationMailer
|
2
|
+
def completed(user_import_file)
|
3
|
+
@user_import_file = user_import_file
|
4
|
+
@library_group = LibraryGroup.site_config
|
5
|
+
from = "#{LibraryGroup.system_name(user_import_file.user.profile.locale)} <#{@library_group.user.email}>"
|
6
|
+
subject = "#{I18n.t('user_import_mailer.completed.subject')}: #{@user_import_file.id}"
|
7
|
+
mail(from: from, to: user_import_file.user.email, subject: subject)
|
8
|
+
end
|
9
|
+
|
10
|
+
def failed(user_import_file)
|
11
|
+
@user_import_file = user_import_file
|
12
|
+
@library_group = LibraryGroup.site_config
|
13
|
+
from = "#{LibraryGroup.system_name(user_import_file.user.profile.locale)} <#{@library_group.user.email}>"
|
14
|
+
subject = "#{I18n.t('user_import_mailer.failed.subject')}: #{@user_import_file.id}"
|
15
|
+
mail(from: from, to: user_import_file.user.email, subject: subject)
|
16
|
+
end
|
17
|
+
end
|
@@ -7,14 +7,13 @@ module ExportFile
|
|
7
7
|
attr_accessor :mode
|
8
8
|
end
|
9
9
|
|
10
|
-
def send_message
|
11
|
-
sender = User.find(1)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
request.transition_to!(:sent)
|
10
|
+
def send_message(mailer)
|
11
|
+
sender = User.find(1)
|
12
|
+
message = Message.create!(
|
13
|
+
recipient: user.username,
|
14
|
+
sender: sender,
|
15
|
+
body: mailer.body.raw_source,
|
16
|
+
subject: mailer.subject
|
17
|
+
)
|
19
18
|
end
|
20
19
|
end
|
@@ -44,14 +44,14 @@ module ImportFile
|
|
44
44
|
end
|
45
45
|
|
46
46
|
# インポート完了時のメッセージを送信します。
|
47
|
-
def send_message
|
47
|
+
def send_message(mailer)
|
48
48
|
sender = User.find(1)
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
49
|
+
message = Message.create!(
|
50
|
+
recipient: user.username,
|
51
|
+
sender: sender,
|
52
|
+
body: mailer.body.raw_source,
|
53
|
+
subject: mailer.subject
|
54
|
+
)
|
55
55
|
end
|
56
56
|
|
57
57
|
private
|
@@ -34,12 +34,13 @@ class UserExportFile < ActiveRecord::Base
|
|
34
34
|
tempfile.puts(file)
|
35
35
|
tempfile.close
|
36
36
|
self.user_export = File.new(tempfile.path, 'r')
|
37
|
-
|
38
|
-
send_message
|
39
|
-
end
|
37
|
+
save!
|
40
38
|
transition_to!(:completed)
|
39
|
+
mailer = UserExportMailer.completed(self)
|
40
|
+
send_message(mailer)
|
41
41
|
rescue => e
|
42
42
|
transition_to!(:failed)
|
43
|
+
mailer = UserExportMailer.failed(self)
|
43
44
|
raise e
|
44
45
|
end
|
45
46
|
|
@@ -115,10 +115,13 @@ class UserImportFile < ActiveRecord::Base
|
|
115
115
|
else
|
116
116
|
transition_to!(:completed)
|
117
117
|
end
|
118
|
-
|
118
|
+
mailer = UserImportMailer.completed(self)
|
119
|
+
send_message(mailer)
|
119
120
|
num
|
120
121
|
rescue => e
|
121
122
|
transition_to!(:failed)
|
123
|
+
mailer = UserImportMailer.failed(self)
|
124
|
+
send_message(mailer)
|
122
125
|
raise e
|
123
126
|
end
|
124
127
|
|
@@ -161,14 +164,17 @@ class UserImportFile < ActiveRecord::Base
|
|
161
164
|
end
|
162
165
|
|
163
166
|
rows.close
|
164
|
-
transition_to!(:completed)
|
165
167
|
Sunspot.commit
|
166
|
-
|
168
|
+
transition_to!(:completed)
|
169
|
+
mailer = UserImportMailer.completed(self)
|
170
|
+
send_message(mailer)
|
167
171
|
num
|
168
172
|
rescue => e
|
169
173
|
self.error_message = "line #{row_num}: #{e.message}"
|
170
174
|
save
|
171
175
|
transition_to!(:failed)
|
176
|
+
mailer = UserImportMailer.failed(self)
|
177
|
+
send_message(mailer)
|
172
178
|
raise e
|
173
179
|
end
|
174
180
|
|
@@ -195,11 +201,14 @@ class UserImportFile < ActiveRecord::Base
|
|
195
201
|
end
|
196
202
|
end
|
197
203
|
transition_to!(:completed)
|
198
|
-
|
204
|
+
mailer = UserImportMailer.completed(self)
|
205
|
+
send_message(mailer)
|
199
206
|
rescue => e
|
200
207
|
self.error_message = "line #{row_num}: #{e.message}"
|
201
208
|
save
|
202
209
|
transition_to!(:failed)
|
210
|
+
mailer = UserImportMailer.failed(self)
|
211
|
+
send_message(mailer)
|
203
212
|
raise e
|
204
213
|
end
|
205
214
|
|
@@ -131,3 +131,14 @@ en:
|
|
131
131
|
google: Google Books
|
132
132
|
openbd: openBD
|
133
133
|
hanmotocom: Hanmoto.com
|
134
|
+
|
135
|
+
user_import_mailer:
|
136
|
+
completed:
|
137
|
+
subject: 'Import completed'
|
138
|
+
failed:
|
139
|
+
subject: 'Import failed'
|
140
|
+
user_export_mailer:
|
141
|
+
completed:
|
142
|
+
subject: 'Export completed'
|
143
|
+
failed:
|
144
|
+
subject: 'Export failed'
|
@@ -131,3 +131,14 @@ ja:
|
|
131
131
|
google: Googleブックス
|
132
132
|
openbd: openBD
|
133
133
|
hanmotocom: 版元ドットコム
|
134
|
+
|
135
|
+
user_import_mailer:
|
136
|
+
completed:
|
137
|
+
subject: 'インポートが完了しました'
|
138
|
+
failed:
|
139
|
+
subject: 'インポートに失敗しました'
|
140
|
+
user_export_mailer:
|
141
|
+
completed:
|
142
|
+
subject: 'エクスポートが完了しました'
|
143
|
+
failed:
|
144
|
+
subject: 'エクスポートに失敗しました'
|
data/lib/enju_library/version.rb
CHANGED
data/spec/models/basket_spec.rb
CHANGED
data/spec/models/library_spec.rb
CHANGED
data/spec/models/shelf_spec.rb
CHANGED
@@ -9,7 +9,7 @@ describe UserExportFile do
|
|
9
9
|
file.export!
|
10
10
|
#UserExportFileJob.perform_later(file).should be_truthy
|
11
11
|
Message.count.should eq message_count + 1
|
12
|
-
Message.order(:
|
12
|
+
Message.order(:created_at).last.subject.should eq "エクスポートが完了しました: #{file.id}"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -86,7 +86,7 @@ describe UserImportFile do
|
|
86
86
|
@file.user = User.where(username: 'librarian1').first
|
87
87
|
@file.import_start
|
88
88
|
Message.count.should eq old_message_count + 1
|
89
|
-
Message.order(:
|
89
|
+
Message.order(:created_at).last.subject.should eq "インポートが完了しました: #{@file.id}"
|
90
90
|
end
|
91
91
|
|
92
92
|
it "should not import users that have higher roles than current user's role" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enju_library
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kosuke Tanabe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: enju_seed
|
@@ -360,6 +360,20 @@ dependencies:
|
|
360
360
|
- - ">="
|
361
361
|
- !ruby/object:Gem::Version
|
362
362
|
version: '0'
|
363
|
+
- !ruby/object:Gem::Dependency
|
364
|
+
name: annotate
|
365
|
+
requirement: !ruby/object:Gem::Requirement
|
366
|
+
requirements:
|
367
|
+
- - ">="
|
368
|
+
- !ruby/object:Gem::Version
|
369
|
+
version: '0'
|
370
|
+
type: :development
|
371
|
+
prerelease: false
|
372
|
+
version_requirements: !ruby/object:Gem::Requirement
|
373
|
+
requirements:
|
374
|
+
- - ">="
|
375
|
+
- !ruby/object:Gem::Version
|
376
|
+
version: '0'
|
363
377
|
description: Library module for Next-L Enju
|
364
378
|
email:
|
365
379
|
- nabeta@fastmail.fm
|
@@ -392,7 +406,10 @@ files:
|
|
392
406
|
- app/helpers/shelves_helper.rb
|
393
407
|
- app/jobs/user_export_file_job.rb
|
394
408
|
- app/jobs/user_import_file_job.rb
|
409
|
+
- app/mailers/application_mailer.rb
|
395
410
|
- app/mailers/notifier.rb
|
411
|
+
- app/mailers/user_export_mailer.rb
|
412
|
+
- app/mailers/user_import_mailer.rb
|
396
413
|
- app/models/accept.rb
|
397
414
|
- app/models/basket.rb
|
398
415
|
- app/models/bookstore.rb
|
@@ -517,6 +534,10 @@ files:
|
|
517
534
|
- app/views/user_export_files/index.html.erb
|
518
535
|
- app/views/user_export_files/new.html.erb
|
519
536
|
- app/views/user_export_files/show.html.erb
|
537
|
+
- app/views/user_export_mailer/completed.en.text.erb
|
538
|
+
- app/views/user_export_mailer/completed.ja.text.erb
|
539
|
+
- app/views/user_export_mailer/failed.en.text.erb
|
540
|
+
- app/views/user_export_mailer/failed.ja.text.erb
|
520
541
|
- app/views/user_groups/_form.html.erb
|
521
542
|
- app/views/user_groups/edit.html.erb
|
522
543
|
- app/views/user_groups/index.html.erb
|
@@ -528,6 +549,10 @@ files:
|
|
528
549
|
- app/views/user_import_files/index.html.erb
|
529
550
|
- app/views/user_import_files/new.html.erb
|
530
551
|
- app/views/user_import_files/show.html.erb
|
552
|
+
- app/views/user_import_mailer/completed.en.text.erb
|
553
|
+
- app/views/user_import_mailer/completed.ja.text.erb
|
554
|
+
- app/views/user_import_mailer/failed.en.text.erb
|
555
|
+
- app/views/user_import_mailer/failed.ja.text.erb
|
531
556
|
- app/views/user_import_results/_form.html.erb
|
532
557
|
- app/views/user_import_results/_list.html.erb
|
533
558
|
- app/views/user_import_results/_list_lines.html.erb
|
@@ -955,6 +980,10 @@ files:
|
|
955
980
|
- spec/fixtures/users.yml
|
956
981
|
- spec/fixtures/withdraws.yml
|
957
982
|
- spec/libraries_spec.rb
|
983
|
+
- spec/mailers/previews/user_export_preview.rb
|
984
|
+
- spec/mailers/previews/user_import_preview.rb
|
985
|
+
- spec/mailers/user_export_spec.rb
|
986
|
+
- spec/mailers/user_import_spec.rb
|
958
987
|
- spec/models/accept_spec.rb
|
959
988
|
- spec/models/basket_spec.rb
|
960
989
|
- spec/models/bookstore_spec.rb
|
@@ -1282,6 +1311,10 @@ test_files:
|
|
1282
1311
|
- spec/dummy/db/migrate/20111129044509_add_pickup_location_to_reserve.rb
|
1283
1312
|
- spec/dummy/README.rdoc
|
1284
1313
|
- spec/libraries_spec.rb
|
1314
|
+
- spec/mailers/user_export_spec.rb
|
1315
|
+
- spec/mailers/user_import_spec.rb
|
1316
|
+
- spec/mailers/previews/user_import_preview.rb
|
1317
|
+
- spec/mailers/previews/user_export_preview.rb
|
1285
1318
|
- spec/models/library_group_spec.rb
|
1286
1319
|
- spec/models/request_type_spec.rb
|
1287
1320
|
- spec/models/withdraw_spec.rb
|