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,7 +133,22 @@ 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
|
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
|
||||||
|
if need_write
|
||||||
feed_data = feed_data.to_json
|
feed_data = feed_data.to_json
|
||||||
FileUtils.mkdir_p(feed_directory) if !File.exists?(feed_directory)
|
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|
|
File.open(File.join(feed_directory.to_s,feed.feed_uid + ".json"),"w") do |file|
|
||||||
|
@ -143,6 +159,7 @@ class FeedsController < ApplicationController
|
||||||
feeds_model.send(feeds_finish_callback, params[:type])
|
feeds_model.send(feeds_finish_callback, params[:type])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
render :json => {success: true}
|
render :json => {success: true}
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue