Skip to content

Commit

Permalink
Merge pull request #121 from lishengbao/graduation
Browse files Browse the repository at this point in the history
Fix the problem of uploading multiple pictures
  • Loading branch information
lishengbao authored Aug 16, 2024
2 parents c217539 + 4f33418 commit de7fb8d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ def resolve(label: nil, level: 'repo', software_report: nil)
software_report_data["subject_id"] = subject.id
software_report_data["short_code"] = TpcSoftwareGraduationReport.generate_short_code
report = TpcSoftwareGraduationReport.create(software_report_data)
architecture_diagrams.each do |architecture_diagram|
report.architecture_diagrams.attach(data: architecture_diagram.base64, filename: architecture_diagram.filename)
if architecture_diagrams.length > 0
diagrams_to_attach = architecture_diagrams.map do |architecture_diagram|
{
data: architecture_diagram.base64,
filename: architecture_diagram.filename
}
end
report.architecture_diagrams.attach(diagrams_to_attach)
end
report.save!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,14 @@ def resolve(label: nil,
software_report_data["website_url"] = ""
software_report_data["short_code"] = TpcSoftwareSelectionReport.generate_short_code
report = TpcSoftwareSelectionReport.create(software_report_data)
architecture_diagrams.each do |architecture_diagram|
report.architecture_diagrams.attach(data: architecture_diagram.base64, filename: architecture_diagram.filename)
if architecture_diagrams.length > 0
diagrams_to_attach = architecture_diagrams.map do |architecture_diagram|
{
data: architecture_diagram.base64,
filename: architecture_diagram.filename
}
end
report.architecture_diagrams.attach(diagrams_to_attach)
end
report.save!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ def resolve(report_id: nil, software_report: nil)
end

if new_images.present?
new_images.each do |image|
graduation_report.architecture_diagrams.attach(data: image.base64, filename: image.filename)
diagrams_to_attach = new_images.map do |architecture_diagram|
{
data: architecture_diagram.base64,
filename: architecture_diagram.filename
}
end
graduation_report.architecture_diagrams.attach(diagrams_to_attach)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ def resolve(report_id: nil, software_report: nil)
end

if new_images.present?
new_images.each do |image|
selection_report.architecture_diagrams.attach(data: image.base64, filename: image.filename)
diagrams_to_attach = new_images.map do |architecture_diagram|
{
data: architecture_diagram.base64,
filename: architecture_diagram.filename
}
end
selection_report.architecture_diagrams.attach(diagrams_to_attach)
end
end

Expand Down

0 comments on commit de7fb8d

Please sign in to comment.