forked from saurabh/orbit4-5
Handle some exceptions
This commit is contained in:
parent
9a142e3bb6
commit
5af7e681c1
|
@ -20,3 +20,4 @@
|
|||
app/views/frontend
|
||||
/public/uploads/*
|
||||
public/assets/*
|
||||
public/import_status.yml
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
}
|
||||
.alert{
|
||||
width: 500px;
|
||||
margin: 0 auto;
|
||||
margin: 20px auto 0;
|
||||
}
|
||||
.module-icon{
|
||||
font-size: 64px;
|
||||
|
@ -104,7 +104,7 @@
|
|||
</div>
|
||||
|
||||
<div id="site-url-wrapper" class="import-wrapper">
|
||||
<input type="text" class="import-url" name="url" placeholder="http://www.rulingcom.com">
|
||||
<input type="text" class="import-url" name="url" value="" placeholder="http://www.rulingcom.com">
|
||||
<button id="check-site-url" class="btn btn-primary pull-right">Next <i class="icons-arrow-right"></i></button>
|
||||
<span><a href='http://installer.tp.rulingcom.com/rss2-export-api.zip'>Download Rss2 Export API</a></span>
|
||||
</div>
|
||||
|
@ -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...<br/><br/>");
|
||||
|
||||
if(dataList!=null && categories!=null){
|
||||
|
@ -422,6 +425,11 @@
|
|||
if(progress>=dataList.length) return;
|
||||
|
||||
var data = dataList[progress];
|
||||
if(data['category']==0){
|
||||
progress++;
|
||||
importModuleData();
|
||||
return;
|
||||
}
|
||||
var category_id = categories[data['category']]['id'];
|
||||
var Sn = data['Sn'];
|
||||
|
||||
|
@ -439,6 +447,10 @@
|
|||
category: category_id
|
||||
}
|
||||
}).done(function(data){
|
||||
}).fail(function(data){
|
||||
$("#alert-msg").html('Faild to import Sn:'+progress+'<br/>Message:'+data['status']+'-'+data['statusText']);
|
||||
$(".alert").fadeIn(300).delay(5000).fadeOut(300);
|
||||
}).always(function(){
|
||||
progress++;
|
||||
percentage = parseInt((progress/dataList.length)*100)+'%';
|
||||
$("#import-progress .bar").css('width',percentage);
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
---
|
||||
total_images: 6
|
||||
current_status: 0
|
||||
success: true
|
||||
current_album_id: '1'
|
||||
current_album_name: "系統測試"
|
Loading…
Reference in New Issue