mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-10 05:46:47 +08:00
Format according to Houndbot #4
This commit is contained in:
parent
970341e7d7
commit
90b220ddda
3 changed files with 17 additions and 15 deletions
|
@ -289,5 +289,4 @@ class TeamsController < ApplicationController
|
||||||
:samples
|
:samples
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,8 @@ require 'csv'
|
||||||
|
|
||||||
class TeamZipExport < ZipExport
|
class TeamZipExport < ZipExport
|
||||||
has_attached_file :zip_file,
|
has_attached_file :zip_file,
|
||||||
path: '/zip_exports/:attachment/:id_partition/:hash/:style/:filename'
|
path: '/zip_exports/:attachment/:id_partition/' \
|
||||||
|
':hash/:style/:filename'
|
||||||
validates_attachment :zip_file,
|
validates_attachment :zip_file,
|
||||||
content_type: { content_type: 'application/zip' }
|
content_type: { content_type: 'application/zip' }
|
||||||
|
|
||||||
|
@ -19,10 +20,8 @@ class TeamZipExport < ZipExport
|
||||||
).first
|
).first
|
||||||
output_file = File.new(
|
output_file = File.new(
|
||||||
File.join(Rails.root,
|
File.join(Rails.root,
|
||||||
"tmp/zip-ready/projects_export-timestamp-#{Time.now.to_i}.zip"
|
"tmp/zip-ready/projects_export-timestamp-#{Time.now.to_i}.zip"),
|
||||||
),
|
'w+')
|
||||||
'w+'
|
|
||||||
)
|
|
||||||
fill_content(dir_to_zip, data, type, options)
|
fill_content(dir_to_zip, data, type, options)
|
||||||
zip!(dir_to_zip, output_file.path)
|
zip!(dir_to_zip, output_file.path)
|
||||||
self.zip_file = File.open(output_file)
|
self.zip_file = File.open(output_file)
|
||||||
|
@ -34,9 +33,9 @@ class TeamZipExport < ZipExport
|
||||||
private
|
private
|
||||||
|
|
||||||
# Export all functionality
|
# Export all functionality
|
||||||
def generate_teams_zip(tmp_dir, data, _options = {})
|
def generate_teams_zip(tmp_dir, data, options = {})
|
||||||
# Create team folder
|
# Create team folder
|
||||||
@team = _options[:team]
|
@team = options[:team]
|
||||||
team_path = "#{tmp_dir}/#{handle_name(@team.name)}"
|
team_path = "#{tmp_dir}/#{handle_name(@team.name)}"
|
||||||
FileUtils.mkdir_p(team_path)
|
FileUtils.mkdir_p(team_path)
|
||||||
|
|
||||||
|
@ -47,8 +46,12 @@ class TeamZipExport < ZipExport
|
||||||
# Iterate through every project
|
# Iterate through every project
|
||||||
data.each_with_index do |(_, p), ind|
|
data.each_with_index do |(_, p), ind|
|
||||||
project_name = handle_name(p.name) + "_#{ind}"
|
project_name = handle_name(p.name) + "_#{ind}"
|
||||||
root = p.archived ? "#{team_path}/Archived projects" :
|
root =
|
||||||
|
if p.archived
|
||||||
|
"#{team_path}/Archived projects"
|
||||||
|
else
|
||||||
"#{team_path}/Projects"
|
"#{team_path}/Projects"
|
||||||
|
end
|
||||||
root += "/#{project_name}"
|
root += "/#{project_name}"
|
||||||
FileUtils.mkdir_p(root)
|
FileUtils.mkdir_p(root)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue