enju_event 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -0
  3. data/app/controllers/concerns/enju_event/enju_libraries_controller.rb +17 -0
  4. data/app/controllers/event_categories_controller.rb +1 -1
  5. data/app/controllers/event_export_files_controller.rb +1 -1
  6. data/app/controllers/event_import_files_controller.rb +3 -2
  7. data/app/controllers/event_import_results_controller.rb +2 -2
  8. data/app/controllers/events_controller.rb +7 -1
  9. data/app/controllers/participates_controller.rb +1 -1
  10. data/app/jobs/event_export_file_job.rb +1 -1
  11. data/app/jobs/event_import_file_job.rb +1 -1
  12. data/app/mailers/event_export_mailer.rb +17 -0
  13. data/app/mailers/event_import_mailer.rb +17 -0
  14. data/app/models/concerns/enju_event/enju_library.rb +15 -0
  15. data/app/models/event.rb +37 -24
  16. data/app/models/event_category.rb +1 -1
  17. data/app/models/event_export_file.rb +15 -10
  18. data/app/models/event_export_file_transition.rb +1 -1
  19. data/app/models/event_import_file.rb +13 -3
  20. data/app/models/event_import_file_transition.rb +1 -1
  21. data/app/models/event_import_result.rb +1 -2
  22. data/app/models/participate.rb +1 -1
  23. data/app/models/place.rb +1 -1
  24. data/app/views/event_export_mailer/completed.en.text.erb +9 -0
  25. data/app/views/event_export_mailer/completed.ja.text.erb +9 -0
  26. data/app/views/event_export_mailer/failed.en.text.erb +9 -0
  27. data/app/views/event_export_mailer/failed.ja.text.erb +9 -0
  28. data/app/views/event_import_files/_results.html.erb +26 -0
  29. data/app/views/event_import_files/show.html.erb +70 -74
  30. data/app/views/event_import_mailer/completed.en.text.erb +9 -0
  31. data/app/views/event_import_mailer/completed.ja.text.erb +9 -0
  32. data/app/views/event_import_mailer/failed.en.text.erb +9 -0
  33. data/app/views/event_import_mailer/failed.ja.text.erb +9 -0
  34. data/app/views/event_import_results/index.html.erb +0 -11
  35. data/app/views/events/index.html.erb +22 -22
  36. data/app/views/events/index.txt.ruby +7 -0
  37. data/app/views/layouts/mailer.html.erb +13 -0
  38. data/app/views/layouts/mailer.text.erb +1 -0
  39. data/config/locales/translation_en.yml +12 -0
  40. data/config/locales/translation_ja.yml +12 -0
  41. data/lib/enju_event/version.rb +1 -1
  42. data/spec/controllers/event_import_files_controller_spec.rb +2 -2
  43. data/spec/controllers/event_import_results_controller_spec.rb +2 -2
  44. data/spec/controllers/libraries_controller_spec.rb +41 -0
  45. data/spec/dummy/app/assets/config/manifest.js +5 -0
  46. data/spec/dummy/app/jobs/application_job.rb +7 -0
  47. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  48. data/spec/dummy/app/models/application_record.rb +3 -0
  49. data/spec/dummy/app/models/user.rb +1 -1
  50. data/spec/dummy/config/application.rb +1 -1
  51. data/spec/dummy/config/initializers/assets.rb +1 -0
  52. data/spec/dummy/config/storage.yml +34 -0
  53. data/spec/dummy/db/migrate/20100606065209_create_user_has_roles.rb +2 -4
  54. data/spec/dummy/db/migrate/20140122054321_create_profiles.rb +4 -5
  55. data/spec/dummy/db/migrate/20150421023923_create_identities.rb +14 -0
  56. data/spec/dummy/db/migrate/20151126005552_add_provider_to_identity.rb +5 -0
  57. data/spec/dummy/db/migrate/20151213070943_add_translation_table_to_library_group.rb +0 -8
  58. data/spec/dummy/db/migrate/20160319144230_create_issn_records.rb +11 -0
  59. data/spec/dummy/db/migrate/20160506144040_create_isbn_records.rb +11 -0
  60. data/spec/dummy/db/migrate/20170116134107_create_issn_record_and_manifestations.rb +11 -0
  61. data/spec/dummy/db/migrate/20170116134120_create_isbn_record_and_manifestations.rb +11 -0
  62. data/spec/dummy/db/migrate/20180107162659_add_constraints_to_most_recent_for_message_transitions.rb +13 -0
  63. data/spec/dummy/db/migrate/20180107162711_add_constraints_to_most_recent_for_message_request_transitions.rb +13 -0
  64. data/spec/dummy/db/migrate/20181026064038_add_login_banner_to_library_group.rb +6 -0
  65. data/spec/dummy/db/migrate/20181030072731_add_not_null_to_position_on_carrier_type.rb +14 -0
  66. data/spec/dummy/db/migrate/20181030074920_add_not_null_to_position_on_library.rb +14 -0
  67. data/spec/dummy/db/migrate/20190208135957_create_active_storage_tables.active_storage.rb +27 -0
  68. data/spec/dummy/db/migrate/20190311154610_create_periodicals.rb +10 -0
  69. data/spec/dummy/db/migrate/20190314151124_add_full_name_translations_to_create.rb +7 -0
  70. data/spec/dummy/db/schema.rb +114 -25
  71. data/spec/factories/event_export_file.rb +5 -0
  72. data/spec/factories/event_import_file.rb +7 -0
  73. data/spec/factories/event_import_result.rb +6 -0
  74. data/spec/mailers/event_export_spec.rb +5 -0
  75. data/spec/mailers/event_import_spec.rb +5 -0
  76. data/spec/mailers/previews/event_export_preview.rb +4 -0
  77. data/spec/mailers/previews/event_import_preview.rb +4 -0
  78. data/spec/models/event_export_file_spec.rb +1 -1
  79. data/spec/models/event_import_file_spec.rb +1 -1
  80. data/spec/rails_helper.rb +6 -0
  81. data/spec/system/event_import_results_spec.rb +17 -0
  82. data/spec/system/events_spec.rb +22 -0
  83. data/spec/views/events/index.json.jbuilder_spec.rb +22 -0
  84. metadata +153 -9
  85. data/README.rdoc +0 -10
  86. data/spec/support/resque.rb +0 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe8972f33249e3c93091453371867af2aaad982ff8e5556f98965b3986bdba47
4
- data.tar.gz: 384fd3ed3fbcfc45c2e42547688376feb12b45971175261f8efd7cb68339ea88
3
+ metadata.gz: 4c09dc227acb998f612104371e9211b43d9206edfccb3f229311a8d10c710f7f
4
+ data.tar.gz: b00ab7c4d137983044ca7dd1620e7916596b40dadd78e8e398e3e1c77e8604d1
5
5
  SHA512:
6
- metadata.gz: 4989defc134bdfb65c0a72f29b7a46811beda71d73eb630515eaa5932dcbcd9dbb7e72324dc814f221bddde485dbc5e688af278b37dc89eb4510e0f03bb552ed
7
- data.tar.gz: 2604ba288359404444ac06c3be9c18c6b3067d666f14ec42ecb67f78d9406ff1d3d0c4ff10ecfa54152e3b3e176e898b2add1a8be2a0c8b3ff1a840756f2bcdd
6
+ metadata.gz: 71911c2e7ab9c57f2c10e53bd183ec40e9cc436f2d410fbc50abff90fa49f29208da966ef250d124c8af3081f562baf5532231063f4952c9cfac27149c8df37c
7
+ data.tar.gz: bd6193c2f51731140c1cb97ed5be3752ca0abf2d9ef3866313597f3cf44c8248d4b22abefc0f0c3a1c59943a6b0700631279c491e61e25757d9ad52ced7919a2
data/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # EnjuEvent
2
+ [![Travis CI](https://travis-ci.com/next-l/enju_event.svg?branch=1.3)](https://travis-ci.com/next-l/enju_event)
3
+ [![Coverage Status](https://coveralls.io/repos/github/next-l/enju_event/badge.svg?branch=1.3)](https://coveralls.io/github/next-l/enju_event?branch=1.3)
4
+ [![security](https://hakiri.io/github/next-l/enju_event/1.3.svg)](https://hakiri.io/github/next-l/enju_event/1.3)
5
+
6
+ This project rocks and uses MIT-LICENSE.
7
+
8
+ ## 製作者・貢献者 (Authors and contributors)
9
+ * [TANABE, Kosuke](https://github.com/nabeta) ([@nabeta](https://twitter.com/nabeta))
10
+ * [Project Next-L](https://www.next-l.jp) ([@ProjectNextL](https://twitter.com/ProjectNextL))
11
+
@@ -0,0 +1,17 @@
1
+ module EnjuEvent
2
+ module EnjuLibrariesController
3
+ extend ActiveSupport::Concern
4
+
5
+ def show
6
+ search = Sunspot.new_search(Event)
7
+ library_id = @library.id
8
+ search.build do
9
+ with(:library_id).equal_to library_id
10
+ order_by(:start_at, :desc)
11
+ end
12
+ page = params[:event_page] || 1
13
+ search.query.paginate(page.to_i, Event.default_per_page)
14
+ @events = search.execute!.results
15
+ end
16
+ end
17
+ end
@@ -62,7 +62,7 @@ class EventCategoriesController < ApplicationController
62
62
  end
63
63
 
64
64
  respond_to do |format|
65
- if @event_category.update_attributes(event_category_params)
65
+ if @event_category.update(event_category_params)
66
66
  format.html { redirect_to @event_category, notice: t('controller.successfully_updated', model: t('activerecord.models.event_category')) }
67
67
  format.json { head :no_content }
68
68
  else
@@ -76,7 +76,7 @@ class EventExportFilesController < ApplicationController
76
76
  # PUT /event_export_files/1.json
77
77
  def update
78
78
  respond_to do |format|
79
- if @event_export_file.update_attributes(event_export_file_params)
79
+ if @event_export_file.update(event_export_file_params)
80
80
  if @event_export_file.mode == 'export'
81
81
  EventExportFileJob.perform_later(@event_export_file)
82
82
  end
@@ -6,7 +6,7 @@ class EventImportFilesController < ApplicationController
6
6
  # GET /event_import_files
7
7
  # GET /event_import_files.json
8
8
  def index
9
- @event_import_files = EventImportFile.page(params[:page])
9
+ @event_import_files = EventImportFile.order(created_at: :desc).page(params[:page])
10
10
 
11
11
  respond_to do |format|
12
12
  format.html # index.html.erb
@@ -22,6 +22,7 @@ class EventImportFilesController < ApplicationController
22
22
  file = @event_import_file.event_import.path
23
23
  end
24
24
  end
25
+ @event_import_results = @event_import_file.event_import_results.page(params[:page])
25
26
 
26
27
  respond_to do |format|
27
28
  format.html # show.html.erb
@@ -78,7 +79,7 @@ class EventImportFilesController < ApplicationController
78
79
  # PUT /event_import_files/1.json
79
80
  def update
80
81
  respond_to do |format|
81
- if @event_import_file.update_attributes(event_import_file_params)
82
+ if @event_import_file.update(event_import_file_params)
82
83
  if @event_import_file.mode == 'import'
83
84
  EventImportFileJob.perform_later(@event_import_file)
84
85
  end
@@ -7,9 +7,9 @@ class EventImportResultsController < ApplicationController
7
7
  def index
8
8
  @event_import_file = EventImportFile.where(id: params[:event_import_file_id]).first
9
9
  if @event_import_file
10
- @event_import_results = @event_import_file.event_import_results.page(params[:page])
10
+ @event_import_results = @event_import_file.event_import_results.order(created_at: :desc).page(params[:page])
11
11
  else
12
- @event_import_results = EventImportResult.page(params[:page])
12
+ @event_import_results = EventImportResult.order(created_at: :desc).page(params[:page])
13
13
  end
14
14
 
15
15
  respond_to do |format|
@@ -125,7 +125,7 @@ class EventsController < ApplicationController
125
125
  @event.set_date
126
126
 
127
127
  respond_to do |format|
128
- if @event.update_attributes(event_params)
128
+ if @event.update(event_params)
129
129
 
130
130
  flash[:notice] = t('controller.successfully_updated', model: t('activerecord.models.event'))
131
131
  format.html { redirect_to(@event) }
@@ -169,4 +169,10 @@ class EventsController < ApplicationController
169
169
  def prepare_options
170
170
  @event_categories = EventCategory.all
171
171
  end
172
+
173
+ def filtered_params
174
+ params.permit([:format, :library_id, :mode, :query, :page, :per_page])
175
+ end
176
+
177
+ helper_method :filtered_params
172
178
  end
@@ -58,7 +58,7 @@ class ParticipatesController < ApplicationController
58
58
  # PUT /participates/1.json
59
59
  def update
60
60
  respond_to do |format|
61
- if @participate.update_attributes(participate_params)
61
+ if @participate.update(participate_params)
62
62
  flash[:notice] = 'Participate was successfully updated.'
63
63
  format.html { redirect_to(@participate) }
64
64
  format.json { head :no_content }
@@ -1,4 +1,4 @@
1
- class EventExportFileJob < ActiveJob::Base
1
+ class EventExportFileJob < ApplicationJob
2
2
  queue_as :enju_leaf
3
3
 
4
4
  def perform(event_export_file)
@@ -1,4 +1,4 @@
1
- class EventImportFileJob < ActiveJob::Base
1
+ class EventImportFileJob < ApplicationJob
2
2
  queue_as :enju_leaf
3
3
 
4
4
  def perform(event_import_file)
@@ -0,0 +1,17 @@
1
+ class EventExportMailer < ApplicationMailer
2
+ def completed(event_export_file)
3
+ @event_export_file = event_export_file
4
+ @library_group = LibraryGroup.site_config
5
+ from = "#{LibraryGroup.system_name(event_export_file.user.profile.locale)} <#{@library_group.user.email}>"
6
+ subject = "#{I18n.t('event_export_mailer.completed.subject')}: #{@event_export_file.id}"
7
+ mail(from: from, to: event_export_file.user.email, subject: subject)
8
+ end
9
+
10
+ def failed(event_export_file)
11
+ @event_export_file = event_export_file
12
+ @library_group = LibraryGroup.site_config
13
+ from = "#{LibraryGroup.system_name(event_export_file.user.profile.locale)} <#{@library_group.user.email}>"
14
+ subject = "#{I18n.t('event_export_mailer.failed.subject')}: #{@event_export_file.id}"
15
+ mail(from: from, to: event_export_file.user.email, subject: subject)
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ class EventImportMailer < ApplicationMailer
2
+ def completed(event_import_file)
3
+ @event_import_file = event_import_file
4
+ @library_group = LibraryGroup.site_config
5
+ from = "#{LibraryGroup.system_name(event_import_file.user.profile.locale)} <#{@library_group.user.email}>"
6
+ subject = "#{I18n.t('event_import_mailer.completed.subject')}: #{@event_import_file.id}"
7
+ mail(from: from, to: event_import_file.user.email, subject: subject)
8
+ end
9
+
10
+ def failed(event_import_file)
11
+ @event_import_file = event_import_file
12
+ @library_group = LibraryGroup.site_config
13
+ from = "#{LibraryGroup.system_name(event_import_file.user.profile.locale)} <#{@library_group.user.email}>"
14
+ subject = "#{I18n.t('event_import_mailer.failed.subject')}: #{@event_import_file.id}"
15
+ mail(from: from, to: event_import_file.user.email, subject: subject)
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ module EnjuEvent
2
+ module EnjuLibrary
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ has_many :events
7
+ end
8
+
9
+ def closed?(date)
10
+ events.closing_days.map{ |c|
11
+ c.start_at.beginning_of_day
12
+ }.include?(date.beginning_of_day)
13
+ end
14
+ end
15
+ end
data/app/models/event.rb CHANGED
@@ -1,4 +1,4 @@
1
- class Event < ActiveRecord::Base
1
+ class Event < ApplicationRecord
2
2
  scope :closing_days, -> { includes(:event_category).where('event_categories.name' => 'closed') }
3
3
  scope :on, lambda {|datetime| where('start_at >= ? AND start_at < ?', datetime.beginning_of_day, datetime.tomorrow.beginning_of_day + 1)}
4
4
  scope :past, lambda {|datetime| where('end_at <= ?', Time.zone.parse(datetime).beginning_of_day)}
@@ -56,30 +56,43 @@ class Event < ActiveRecord::Base
56
56
  self.display_name = name if display_name.blank?
57
57
  end
58
58
 
59
- def self.export(options = {format: :txt})
60
- header = %w(
61
- name
62
- event_category
63
- library
64
- start_at
65
- end_at
66
- all_day
67
- )
68
- lines = []
69
- Event.find_each.map{|e|
70
- line = []
71
- line << e.name
72
- line << e.event_category.name
73
- line << e.library.name
74
- line << e.start_at
75
- line << e.end_at
76
- line << e.all_day
77
- lines << line
59
+ # CSVのヘッダ
60
+ # @param [String] role 権限
61
+ def self.csv_header(role: 'Guest')
62
+ Event.new.to_hash(role: role).keys
63
+ end
64
+
65
+ # CSV出力用のハッシュ
66
+ # @param [String] role 権限
67
+ def to_hash(role: 'Guest')
68
+ record = {
69
+ name: name,
70
+ display_name: display_name,
71
+ event_category: event_category.try(:name),
72
+ library: library.try(:name),
73
+ start_at: start_at,
74
+ end_at: end_at,
75
+ all_day: all_day,
76
+ note: note,
77
+ created_at: created_at,
78
+ updated_at: updated_at
78
79
  }
79
- if options[:format] == :txt
80
- lines.map{|line| line.to_csv(col_sep: "\t")}.unshift(header.to_csv(col_sep: "\t")).join
81
- else
82
- event
80
+
81
+ record
82
+ end
83
+
84
+ # TSVでのエクスポート
85
+ # @param [String] role 権限
86
+ # @param [String] col_sep 区切り文字
87
+ def self.export(role: 'Guest', col_sep: "\t")
88
+ file = Tempfile.create('event_export') do |f|
89
+ f.write Event.csv_header(role: role).to_csv(col_sep: col_sep)
90
+ Event.find_each do |event|
91
+ f.write event.to_hash(role: role).values.to_csv(col_sep: col_sep)
92
+ end
93
+
94
+ f.rewind
95
+ f.read
83
96
  end
84
97
  end
85
98
  end
@@ -1,4 +1,4 @@
1
- class EventCategory < ActiveRecord::Base
1
+ class EventCategory < ApplicationRecord
2
2
  include MasterModel
3
3
  default_scope { order('position') }
4
4
  has_many :events
@@ -1,4 +1,4 @@
1
- class EventExportFile < ActiveRecord::Base
1
+ class EventExportFile < ApplicationRecord
2
2
  include Statesman::Adapters::ActiveRecordQueries
3
3
  include ExportFile
4
4
 
@@ -26,18 +26,23 @@ class EventExportFile < ActiveRecord::Base
26
26
  to: :state_machine
27
27
 
28
28
  def export!
29
- transition_to!(:started)
30
- tempfile = Tempfile.new(['event_export_file_', '.txt'])
31
- file = Event.export(format: :txt)
32
- tempfile.puts(file)
33
- tempfile.close
34
- self.event_export = File.new(tempfile.path, "r")
35
- if save
36
- send_message
29
+ role_name = user.try(:role).try(:name)
30
+ tsv = Event.export(role: role_name)
31
+
32
+ EventExportFile.transaction do
33
+ transition_to!(:started)
34
+ role_name = user.try(:role).try(:name)
35
+ self.event_export = StringIO.new(tsv)
36
+ self.event_export.instance_write(:filename, "event_export.txt")
37
+ save!
38
+ transition_to!(:completed)
37
39
  end
38
- transition_to!(:completed)
40
+ mailer = EventExportMailer.completed(self)
41
+ send_message(mailer)
39
42
  rescue => e
40
43
  transition_to!(:failed)
44
+ mailer = EventExportMailer.failed(self)
45
+ send_message(mailer)
41
46
  raise e
42
47
  end
43
48
 
@@ -1,4 +1,4 @@
1
- class EventExportFileTransition < ActiveRecord::Base
1
+ class EventExportFileTransition < ApplicationRecord
2
2
  include Statesman::Adapters::ActiveRecordTransition
3
3
 
4
4
 
@@ -1,7 +1,6 @@
1
- class EventImportFile < ActiveRecord::Base
1
+ class EventImportFile < ApplicationRecord
2
2
  include Statesman::Adapters::ActiveRecordQueries
3
3
  include ImportFile
4
- default_scope {order('event_import_files.id DESC')}
5
4
  scope :not_imported, -> {in_state(:pending)}
6
5
  scope :stucked, -> {in_state(:pending).where('event_import_files.created_at < ?', 1.hour.ago)}
7
6
 
@@ -90,12 +89,15 @@ class EventImportFile < ActiveRecord::Base
90
89
  Sunspot.commit
91
90
  rows.close
92
91
  transition_to!(:completed)
93
- send_message
92
+ mailer = EventImportMailer.completed(self)
93
+ send_message(mailer)
94
94
  num
95
95
  rescue => e
96
96
  self.error_message = "line #{row_num}: #{e.message}"
97
97
  save
98
98
  transition_to!(:failed)
99
+ mailer = EventImportMailer.failed(self)
100
+ send_message(mailer)
99
101
  raise e
100
102
  end
101
103
 
@@ -125,10 +127,14 @@ class EventImportFile < ActiveRecord::Base
125
127
  event.save!
126
128
  end
127
129
  transition_to!(:completed)
130
+ mailer = EventImportMailer.completed(self)
131
+ send_message(mailer)
128
132
  rescue => e
129
133
  self.error_message = "line #{row_num}: #{e.message}"
130
134
  save
131
135
  transition_to!(:failed)
136
+ mailer = EventImportMailer.failed(self)
137
+ send_message(mailer)
132
138
  raise e
133
139
  end
134
140
 
@@ -147,10 +153,14 @@ class EventImportFile < ActiveRecord::Base
147
153
  event.destroy
148
154
  end
149
155
  transition_to!(:completed)
156
+ mailer = EventImportMailer.completed(self)
157
+ send_message(mailer)
150
158
  rescue => e
151
159
  self.error_message = "line #{row_num}: #{e.message}"
152
160
  save
153
161
  transition_to!(:failed)
162
+ mailer = EventImportMailer.failed(self)
163
+ send_message(mailer)
154
164
  raise e
155
165
  end
156
166
 
@@ -1,4 +1,4 @@
1
- class EventImportFileTransition < ActiveRecord::Base
1
+ class EventImportFileTransition < ApplicationRecord
2
2
  include Statesman::Adapters::ActiveRecordTransition
3
3
 
4
4
 
@@ -1,5 +1,4 @@
1
- class EventImportResult < ActiveRecord::Base
2
- default_scope { order('event_import_results.id') }
1
+ class EventImportResult < ApplicationRecord
3
2
  scope :file_id, proc{|file_id| where(event_import_file_id: file_id)}
4
3
  scope :failed, -> { where(event_id: nil) }
5
4
 
@@ -1,4 +1,4 @@
1
- class Participate < ActiveRecord::Base
1
+ class Participate < ApplicationRecord
2
2
  belongs_to :agent
3
3
  belongs_to :event
4
4
 
data/app/models/place.rb CHANGED
@@ -1,4 +1,4 @@
1
- class Place < ActiveRecord::Base
1
+ class Place < ApplicationRecord
2
2
  has_many :events
3
3
  validates :term, presence: true
4
4
  end
@@ -0,0 +1,9 @@
1
+ The following export task is completed.
2
+
3
+ ID: <%= @event_export_file.id %>
4
+ Created at: <%= @event_export_file.created_at %>
5
+ Detail: <%= event_export_file_url(@event_export_file) %>
6
+
7
+ --
8
+ <%= @library_group.display_name %>
9
+ <%= root_url %>
@@ -0,0 +1,9 @@
1
+ 以下の資料のインポートが完了しました。
2
+
3
+ ID: <%= @event_export_file.id %>
4
+ 作成時刻: <%= @event_export_file.created_at %>
5
+ 詳細: <%= event_export_file_url(@event_export_file) %>
6
+
7
+ --
8
+ <%= @library_group.display_name %>
9
+ <%= root_url %>
@@ -0,0 +1,9 @@
1
+ The following export task failed.
2
+
3
+ ID: <%= @event_export_file.id %>
4
+ Created at: <%= @event_export_file.created_at %>
5
+ Detail: <%= event_export_file_url(@event_export_file) %>
6
+
7
+ --
8
+ <%= @library_group.display_name %>
9
+ <%= root_url %>
@@ -0,0 +1,9 @@
1
+ 以下の資料のインポートに失敗しました。
2
+
3
+ ID: <%= @event_export_file.id %>
4
+ 作成時刻: <%= @event_export_file.created_at %>
5
+ 詳細: <%= event_export_file_url(@event_export_file) %>
6
+
7
+ --
8
+ <%= @library_group.display_name %>
9
+ <%= root_url %>
@@ -0,0 +1,26 @@
1
+ <h2><%= t('activerecord.models.event_import_result') %></h2>
2
+ <p>
3
+ <%= link_to((image_tag 'icons/page_white_excel.png', size: '16x16', class: 'enju_icon', alt: 'TSV'), event_import_results_path(event_import_file_id: @event_import_file.id, format: :txt, locale: @locale.to_s)) -%>
4
+ (<%= link_to 'TSV', event_import_results_path(event_import_file_id: @event_import_file.id, format: :txt, locale: @locale.to_s) -%>)
5
+ </p>
6
+
7
+ <table class="table table-striped index">
8
+ <tr>
9
+ <th><%= t('activerecord.attributes.event_import_result.lineno') %></th>
10
+ <th><%= t('activerecord.attributes.event_import_result.body') %></th>
11
+ <th><%= t('activerecord.models.event') %></th>
12
+ <th></th>
13
+ </tr>
14
+ <% @event_import_results.each_with_index do |event_import_result, idx| %>
15
+ <tr class="line<%= cycle("0", "1") -%>">
16
+ <td><%= @event_import_results.offset_value + idx + 1 %></td>
17
+ <td><%= event_import_result.body.inspect %></td>
18
+ <td><%= link_to event_import_result.event.display_name, event_import_result.event if event_import_result.event %></td>
19
+ <td>
20
+ <%= link_to t('page.show'), event_import_result %>
21
+ <%= link_to t('page.destroy'), event_import_result, data: {confirm: t('page.are_you_sure')}, method: :delete %>
22
+ </td>
23
+ </tr>
24
+ <% end %>
25
+ </table>
26
+ <%= paginate(@event_import_results) %>
@@ -1,85 +1,81 @@
1
1
  <div id="content_detail" class="ui-corner-all ui-widget-content">
2
- <h1 class="title"><%= t('page.showing', model: t('activerecord.models.event_import_file')) -%></h1>
3
- <div id="content_list">
4
- <p id="notice"><%= notice %></p>
5
-
6
- <p>
7
- <strong>Id:</strong>
8
- <%= @event_import_file.id -%>
9
- </p>
10
-
11
- <p>
12
- <strong><%= t('activerecord.attributes.event_import_file.event_import_file_name') -%>:</strong>
13
- <%= link_to @event_import_file.event_import_file_name, event_import_file_path(@event_import_file, format: :download) if @event_import_file.event_import_file_name %>
14
- </p>
15
-
16
- <p>
17
- <strong><%= t('activerecord.attributes.event_import_file.event_import_content_type') -%>:</strong>
18
- <%= @event_import_file.event_import_content_type -%>
19
- </p>
20
-
21
- <p>
22
- <strong><%= t('activerecord.attributes.event_import_file.event_import_file_size') -%>:</strong>
23
- <%= @event_import_file.event_import_file_size -%>
24
- </p>
25
-
26
- <p>
27
- <strong><%= t('activerecord.attributes.event_import_file.event_import_fingerprint') -%>:</strong>
28
- <%= @event_import_file.event_import_fingerprint -%>
29
- </p>
30
-
31
- <p>
32
- <strong><%= t('page.created_at') -%>:</strong>
33
- <%= l(@event_import_file.created_at) if @event_import_file.created_at -%>
34
- </p>
35
-
36
- <p>
37
- <strong><%= t('activerecord.attributes.event_import_file.executed_at') -%>:</strong>
38
- <%= l(@event_import_file.executed_at) if @event_import_file.executed_at -%>
39
- </p>
40
-
41
- <p>
42
- <strong><%= t('activerecord.attributes.event_import_file.edit_mode') -%>:</strong>
43
- <%= @event_import_file.edit_mode -%>
44
- </p>
45
-
46
- <p>
47
- <strong><%= t('activerecord.attributes.event_import_file.user_encoding') -%>:</strong>
48
- <%= @event_import_file.user_encoding -%>
49
- </p>
50
-
51
- <p>
52
- <strong><%= t('activerecord.attributes.event_import_file.default_event_category_id') -%>:</strong>
53
- <%= link_to @event_import_file.default_event_category.display_name.localize, @event_import_file.default_event_category if @event_import_file.default_event_category.try(:display_name) -%>
54
- </p>
55
-
56
- <p>
57
- <strong><%= t('activerecord.attributes.event_import_file.default_library_id') -%>:</strong>
58
- <%= link_to @event_import_file.default_library.display_name.localize, @event_import_file.default_library if @event_import_file.default_library.try(:display_name) -%>
59
- </p>
60
-
61
- <p>
62
- <strong><%= t('activerecord.attributes.event_import_file.state') -%>:</strong>
63
- <%= localized_state(@event_import_file.current_state) -%>
64
- </p>
65
-
66
- <p>
67
- <strong><%= t('activerecord.attributes.event_import_file.error_message') -%>:</strong>
68
- <%= @event_import_file.error_message -%>
69
- </p>
2
+ <h1 class="title"><%= t('page.showing', model: t('activerecord.models.event_import_file')) -%></h1>
3
+ <div id="content_list">
4
+ <p id="notice"><%= notice %></p>
5
+
6
+ <p>
7
+ <strong>Id:</strong>
8
+ <%= @event_import_file.id -%>
9
+ </p>
10
+
11
+ <% if @event_import_file.event_import_file_name %>
12
+ <p>
13
+ <strong><%= t('activerecord.attributes.event_import_file.event_import_file_name') -%>:</strong>
14
+ <%= link_to @event_import_file.event_import_file_name, event_import_file_path(@event_import_file, format: :download) %>
15
+ (<%= @event_import_file.event_import_content_type -%>)
16
+ </p>
17
+
18
+ <p>
19
+ <strong><%= t('activerecord.attributes.event_import_file.event_import_file_size') -%>:</strong>
20
+ <%= @event_import_file.event_import_file_size -%>
21
+ </p>
22
+ <% end %>
70
23
 
71
- <p>
72
- <strong><%= t('activerecord.models.user') -%>:</strong>
73
- <%= link_to @event_import_file.user.username, @event_import_file.user.profile if @event_import_file.user.try(:profile) -%>
74
- </p>
24
+ <p>
25
+ <strong><%= t('page.created_at') -%>:</strong>
26
+ <%= l(@event_import_file.created_at) if @event_import_file.created_at -%>
27
+ </p>
28
+
29
+ <p>
30
+ <strong><%= t('activerecord.attributes.event_import_file.executed_at') -%>:</strong>
31
+ <%= l(@event_import_file.executed_at) if @event_import_file.executed_at -%>
32
+ </p>
33
+
34
+ <p>
35
+ <strong><%= t('activerecord.attributes.event_import_file.edit_mode') -%>:</strong>
36
+ <%= @event_import_file.edit_mode -%>
37
+ </p>
38
+
39
+ <p>
40
+ <strong><%= t('activerecord.attributes.event_import_file.user_encoding') -%>:</strong>
41
+ <%= @event_import_file.user_encoding -%>
42
+ </p>
43
+
44
+ <p>
45
+ <strong><%= t('activerecord.attributes.event_import_file.default_event_category_id') -%>:</strong>
46
+ <%= link_to @event_import_file.default_event_category.display_name.localize, @event_import_file.default_event_category if @event_import_file.default_event_category.try(:display_name) -%>
47
+ </p>
48
+
49
+ <p>
50
+ <strong><%= t('activerecord.attributes.event_import_file.default_library_id') -%>:</strong>
51
+ <%= link_to @event_import_file.default_library.display_name.localize, @event_import_file.default_library if @event_import_file.default_library.try(:display_name) -%>
52
+ </p>
53
+
54
+ <p>
55
+ <strong><%= t('activerecord.attributes.event_import_file.state') -%>:</strong>
56
+ <%= localized_state(@event_import_file.current_state) -%>
57
+ </p>
58
+
59
+ <p>
60
+ <strong><%= t('activerecord.attributes.event_import_file.error_message') -%>:</strong>
61
+ <%= simple_format(@event_import_file.error_message) -%>
62
+ </p>
63
+
64
+ <p>
65
+ <strong><%= t('activerecord.models.user') -%>:</strong>
66
+ <%= link_to @event_import_file.user.username, @event_import_file.user.profile if @event_import_file.user.try(:profile) -%>
67
+ </p>
68
+
69
+ <% if @event_import_results %>
70
+ <%= render 'results' %>
71
+ <% end %>
75
72
 
76
- </div>
73
+ </div>
77
74
  </div>
78
75
 
79
76
  <div id="submenu" class="ui-corner-all ui-widget-content">
80
77
  <%= form_for(@event_import_file) do |f| %>
81
78
  <ul>
82
- <li><%= link_to t('activerecord.models.event_import_result'), event_import_results_path(event_import_file_id: @event_import_file.id) -%></li>
83
79
  <li><%= back_to_index(flash[:page_info]) -%></li>
84
80
  <% if current_user.has_role?('Administrator') %>
85
81
  <li><%= link_to 'Resque', resque_path %></li>
@@ -0,0 +1,9 @@
1
+ The following import task is completed.
2
+
3
+ ID: <%= @event_import_file.id %>
4
+ Created at: <%= @event_import_file.created_at %>
5
+ Detail: <%= event_import_file_url(@event_import_file) %>
6
+
7
+ --
8
+ <%= @library_group.display_name %>
9
+ <%= root_url %>