mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-24 08:41:56 +08:00
Fix file name of inventory export, add archived columns to exports [SCI-8760]
This commit is contained in:
parent
88392ecd9d
commit
e5fe82a297
3 changed files with 6 additions and 5 deletions
|
@ -47,7 +47,7 @@ class RepositoriesExportJob < ApplicationJob
|
||||||
csv_file = FileUtils.touch("#{path}/#{repository_name}.csv").first
|
csv_file = FileUtils.touch("#{path}/#{repository_name}.csv").first
|
||||||
|
|
||||||
# Define headers and columns IDs
|
# Define headers and columns IDs
|
||||||
col_ids = [-3, -4, -5, -6] + repository.repository_columns.map(&:id)
|
col_ids = [-3, -4, -5, -6, -7, -8] + repository.repository_columns.map(&:id)
|
||||||
|
|
||||||
# Define callback function for file name
|
# Define callback function for file name
|
||||||
assets = {}
|
assets = {}
|
||||||
|
|
|
@ -49,11 +49,12 @@ class ZipExport < ApplicationRecord
|
||||||
I18n.backend.date_format = user.settings[:date_format] || Constants::DEFAULT_DATE_FORMAT
|
I18n.backend.date_format = user.settings[:date_format] || Constants::DEFAULT_DATE_FORMAT
|
||||||
zip_input_dir = FileUtils.mkdir_p(File.join(Rails.root, "tmp/temp_zip_#{Time.now.to_i}")).first
|
zip_input_dir = FileUtils.mkdir_p(File.join(Rails.root, "tmp/temp_zip_#{Time.now.to_i}")).first
|
||||||
tmp_zip_dir = FileUtils.mkdir_p(File.join(Rails.root, 'tmp/zip-ready')).first
|
tmp_zip_dir = FileUtils.mkdir_p(File.join(Rails.root, 'tmp/zip-ready')).first
|
||||||
tmp_full_zip_name = File.join(tmp_zip_dir, "export_#{Time.now.strftime('%F %H-%M-%S_UTC')}.zip")
|
tmp_zip_name = "export_#{Time.now.strftime('%F %H-%M-%S_UTC')}.zip"
|
||||||
|
tmp_full_zip_name = File.join(tmp_zip_dir, tmp_zip_name)
|
||||||
|
|
||||||
fill_content(zip_input_dir, data, type, options)
|
fill_content(zip_input_dir, data, type, options)
|
||||||
zip!(zip_input_dir, tmp_full_zip_name)
|
zip!(zip_input_dir, tmp_full_zip_name)
|
||||||
zip_file.attach(io: File.open(tmp_full_zip_name), filename: tmp_full_zip_name)
|
zip_file.attach(io: File.open(tmp_full_zip_name), filename: tmp_zip_name)
|
||||||
generate_notification(user) if save
|
generate_notification(user) if save
|
||||||
ensure
|
ensure
|
||||||
FileUtils.rm_rf([zip_input_dir, tmp_full_zip_name], secure: true)
|
FileUtils.rm_rf([zip_input_dir, tmp_full_zip_name], secure: true)
|
||||||
|
|
|
@ -80,9 +80,9 @@ module RepositoryZipExport
|
||||||
when -6
|
when -6
|
||||||
I18n.l(row.created_at, format: :full)
|
I18n.l(row.created_at, format: :full)
|
||||||
when -7
|
when -7
|
||||||
row.archived_by.full_name
|
row.archived_by.present? ? row.archived_by.full_name : ''
|
||||||
when -8
|
when -8
|
||||||
I18n.l(row.archived_on, format: :full)
|
row.archived_on.present? ? I18n.l(row.archived_on, format: :full) : ''
|
||||||
else
|
else
|
||||||
cell = row.repository_cells
|
cell = row.repository_cells
|
||||||
.find_by(repository_column_id: c_id)
|
.find_by(repository_column_id: c_id)
|
||||||
|
|
Loading…
Reference in a new issue