diff --git a/.gitignore b/.gitignore index 97ef970..9bc0d3e 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ app/views/frontend /public/uploads/* public/assets/* +public/import_status.yml diff --git a/app/controllers/admin/import_controller.rb b/app/controllers/admin/import_controller.rb index 047aa43..6618157 100644 --- a/app/controllers/admin/import_controller.rb +++ b/app/controllers/admin/import_controller.rb @@ -154,9 +154,12 @@ class Admin::ImportController < OrbitAdminController a = Asset.new a.remote_data_url = url a.title_translations = {"en" => a.data.filename, "zh_tw" => a.data.filename} - a.save! - @user.assets << a - temp.gsub!(CGI::escapeHTML(url), a.data.to_s) + if(a.save! rescue false) + temp.gsub!(CGI::escapeHTML(url), "#") + else + @user.assets << a + temp.gsub!(CGI::escapeHTML(url), a.data.to_s) + end end news['Content'][locale] = temp end @@ -172,8 +175,9 @@ class Admin::ImportController < OrbitAdminController bl = BulletinLink.new bl.url = news["URL"] bl.title_translations = {"en" => "Link", "zh_tw" => "Link"} - bl.save! - bulletin.bulletin_links << bl + if (bl.save! rescue false) + bulletin.bulletin_links << bl + end end news['files'].each do |f| bf = BulletinFile.new @@ -192,9 +196,10 @@ class Admin::ImportController < OrbitAdminController file = File.new("tmp/uploads/#{bf.title}#{file_ext}","w+b") file.write(bf.file.read) bf.file.cache!(file) - bf.save! - bulletin.bulletin_files << bf + if (bf.save! rescue false) + bulletin.bulletin_files << bf + end File.delete(file) end diff --git a/app/views/admin/import/index.html.erb b/app/views/admin/import/index.html.erb index 2d7809c..f280664 100644 --- a/app/views/admin/import/index.html.erb +++ b/app/views/admin/import/index.html.erb @@ -66,7 +66,7 @@ } .alert{ width: 500px; - margin: 0 auto; + margin: 20px auto 0; } .module-icon{ font-size: 64px; @@ -104,7 +104,7 @@
@@ -204,6 +204,7 @@ $("#import-back-btn").click(function(){ $("#import-progress").fadeOut(300,function(){ $("#import-head").fadeIn(0); + $('#import-start-btn').show(); $("#import-modules").fadeIn(300); }); }); @@ -364,6 +365,7 @@ var importModule = function(m){ module = m; + progress = 0; dataList=Array(); categories=null; @@ -409,6 +411,7 @@ var importModuleDatas = function(){ progress = 0; + $('#import-start-btn').hide(); $("#import-progress-text").html("Start import...