fix the problem that when upload failed if will lead to not upload
success furthor more and let show description tag can also work for image
This commit is contained in:
parent
b84c4af63a
commit
d82207aa68
|
@ -473,33 +473,34 @@ class Admin::GalleriesController < OrbitAdminController
|
||||||
|
|
||||||
def upload_process
|
def upload_process
|
||||||
if AlbumUnprocess.first.upload_success
|
if AlbumUnprocess.first.upload_success
|
||||||
album_unprocess = AlbumUnprocess.all
|
album_unprocess = Array(AlbumUnprocess.all)
|
||||||
count = album_unprocess.count
|
count = album_unprocess.count
|
||||||
Thread.new do
|
Thread.new do
|
||||||
begin
|
album_unprocess.each_with_index do |un_image,i|
|
||||||
album_unprocess.each_with_index do |un_image,i|
|
begin
|
||||||
album = AlbumImage.all.select{|value| value.id.to_s == un_image.image_id.to_s}[0]
|
album = AlbumImage.all.select{|value| value.id.to_s == un_image.image_id.to_s}[0]
|
||||||
album.file = un_image.save_var
|
album.file = un_image.save_var
|
||||||
album.save!
|
album.save!
|
||||||
file = un_image.save_var.tempfile
|
file = un_image.save_var.tempfile
|
||||||
file.close
|
file.close
|
||||||
File.delete file.path
|
File.delete file.path
|
||||||
un_image.delete
|
un_image.delete
|
||||||
variable = AlbumVariable.first
|
variable = AlbumVariable.first
|
||||||
variable.progress_filename = album[:file]
|
variable.progress_filename = album[:file]
|
||||||
variable.progress_percent = ((i+1)*100.0/count).floor.to_s + '%'
|
variable.progress_percent = ((i+1)*100.0/count).floor.to_s + '%'
|
||||||
variable.save!
|
variable.save!
|
||||||
end
|
rescue => e
|
||||||
rescue => e
|
puts ['err',un_image.inspect,e.inspect]
|
||||||
puts ['err',e.inspect]
|
un_image.destroy
|
||||||
end
|
end
|
||||||
variable = AlbumVariable.first
|
|
||||||
variable.finish = true
|
|
||||||
variable.save!
|
|
||||||
end
|
end
|
||||||
album_temp = AlbumUnprocess.first
|
variable = AlbumVariable.first
|
||||||
album_temp.upload_success = false
|
variable.finish = true
|
||||||
album_temp.save!
|
variable.save!
|
||||||
|
end
|
||||||
|
album_temp = AlbumUnprocess.first
|
||||||
|
album_temp.upload_success = false
|
||||||
|
album_temp.save!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def start_upload_process
|
def start_upload_process
|
||||||
|
|
|
@ -63,7 +63,7 @@ class GalleriesController < ApplicationController
|
||||||
images = album.album_images.asc(:order).collect do |a|
|
images = album.album_images.asc(:order).collect do |a|
|
||||||
alt_text = (a.description.nil? || a.description == "" ? "gallery image" : a.description)
|
alt_text = (a.description.nil? || a.description == "" ? "gallery image" : a.description)
|
||||||
{
|
{
|
||||||
"image-description" => a.description,
|
"image-description" => (flag ? a.description : ''),
|
||||||
"alt_title" => alt_text,
|
"alt_title" => alt_text,
|
||||||
"link_to_show" => "/xhr/galleries/theater/" + a.id.to_s,
|
"link_to_show" => "/xhr/galleries/theater/" + a.id.to_s,
|
||||||
"thumb-src" => a.file.thumb.url
|
"thumb-src" => a.file.thumb.url
|
||||||
|
|
Loading…
Reference in New Issue