Add update_all notify callback.
This commit is contained in:
parent
c4c876c074
commit
1ce77b43e1
|
@ -22,6 +22,7 @@ class FeedsController < ApplicationController
|
||||||
feed_directory = File.join(main_directory.to_s, feed.id.to_s)
|
feed_directory = File.join(main_directory.to_s, feed.id.to_s)
|
||||||
feed_data = JSON.parse(File.read(File.join(feed_directory.to_s, feed.feed_uid + ".json")))
|
feed_data = JSON.parse(File.read(File.join(feed_directory.to_s, feed.feed_uid + ".json")))
|
||||||
channel_key_pluralize = feed_annc.channel_key.pluralize
|
channel_key_pluralize = feed_annc.channel_key.pluralize
|
||||||
|
need_write = true
|
||||||
if params[:type] == 'create'
|
if params[:type] == 'create'
|
||||||
trans = {}
|
trans = {}
|
||||||
locales.each do |locale|
|
locales.each do |locale|
|
||||||
|
@ -132,15 +133,31 @@ class FeedsController < ApplicationController
|
||||||
if can_create_record
|
if can_create_record
|
||||||
feeds_model.where(feeds_uid_field.to_sym.in =>params[:data].map{|a| a["id"]}, :site_feed_id=>feed_id).destroy
|
feeds_model.where(feeds_uid_field.to_sym.in =>params[:data].map{|a| a["id"]}, :site_feed_id=>feed_id).destroy
|
||||||
end
|
end
|
||||||
|
elsif params[:type] == 'update_all'
|
||||||
|
feed_data = params[:data]
|
||||||
|
FileUtils.mkdir_p(feed_directory) if !File.exists?(feed_directory)
|
||||||
|
File.open(File.join(feed_directory.to_s,feed.feed_uid + ".json"),"w") do |file|
|
||||||
|
feed_data.force_encoding("utf-8")
|
||||||
|
file.write(feed_data)
|
||||||
|
end
|
||||||
|
need_write = false
|
||||||
|
feed_annc.all_contents_for_feed_will_change!
|
||||||
|
feed_annc[:all_contents_for_feed] = feed_annc.cache_annc
|
||||||
|
feed_annc.save!
|
||||||
|
if feeds_finish_callback
|
||||||
|
feeds_model.send(feeds_finish_callback, 'update_all', {"data"=>feed.get_annc(false),"feed_id"=>feed.id,"category_id"=>feed.merge_with_category})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
feed_data = feed_data.to_json
|
if need_write
|
||||||
FileUtils.mkdir_p(feed_directory) if !File.exists?(feed_directory)
|
feed_data = feed_data.to_json
|
||||||
File.open(File.join(feed_directory.to_s,feed.feed_uid + ".json"),"w") do |file|
|
FileUtils.mkdir_p(feed_directory) if !File.exists?(feed_directory)
|
||||||
feed_data.force_encoding("utf-8")
|
File.open(File.join(feed_directory.to_s,feed.feed_uid + ".json"),"w") do |file|
|
||||||
file.write(feed_data)
|
feed_data.force_encoding("utf-8")
|
||||||
end
|
file.write(feed_data)
|
||||||
if feeds_finish_callback
|
end
|
||||||
feeds_model.send(feeds_finish_callback, params[:type])
|
if feeds_finish_callback
|
||||||
|
feeds_model.send(feeds_finish_callback, params[:type])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
render :json => {success: true}
|
render :json => {success: true}
|
||||||
|
|
Loading…
Reference in New Issue