mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-09 05:18:01 +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
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -4,7 +4,8 @@ require 'csv'
|
|||
|
||||
class TeamZipExport < ZipExport
|
||||
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,
|
||||
content_type: { content_type: 'application/zip' }
|
||||
|
||||
|
@ -19,10 +20,8 @@ class TeamZipExport < ZipExport
|
|||
).first
|
||||
output_file = File.new(
|
||||
File.join(Rails.root,
|
||||
"tmp/zip-ready/projects_export-timestamp-#{Time.now.to_i}.zip"
|
||||
),
|
||||
'w+'
|
||||
)
|
||||
"tmp/zip-ready/projects_export-timestamp-#{Time.now.to_i}.zip"),
|
||||
'w+')
|
||||
fill_content(dir_to_zip, data, type, options)
|
||||
zip!(dir_to_zip, output_file.path)
|
||||
self.zip_file = File.open(output_file)
|
||||
|
@ -34,9 +33,9 @@ class TeamZipExport < ZipExport
|
|||
private
|
||||
|
||||
# Export all functionality
|
||||
def generate_teams_zip(tmp_dir, data, _options = {})
|
||||
def generate_teams_zip(tmp_dir, data, options = {})
|
||||
# Create team folder
|
||||
@team = _options[:team]
|
||||
@team = options[:team]
|
||||
team_path = "#{tmp_dir}/#{handle_name(@team.name)}"
|
||||
FileUtils.mkdir_p(team_path)
|
||||
|
||||
|
@ -47,8 +46,12 @@ class TeamZipExport < ZipExport
|
|||
# Iterate through every project
|
||||
data.each_with_index do |(_, p), 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"
|
||||
end
|
||||
root += "/#{project_name}"
|
||||
FileUtils.mkdir_p(root)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue