* 'ntu' of https://github.com/Rulingcom/orbit:
  Fix for page_part and widget back-end
  regenerate pageparts
This commit is contained in:
Rueshyna 2012-12-27 16:49:50 +08:00
commit 3346f83923
3 changed files with 20 additions and 7 deletions

View File

@ -28,7 +28,7 @@ class Page < Item
before_save :create_parts, if: Proc.new { |page| page.new_record? || page.design_id_changed? } before_save :create_parts, if: Proc.new { |page| page.new_record? || page.design_id_changed? }
after_save :generate_html after_save :generate_html
protected # protected
def create_parts def create_parts
@ -38,7 +38,8 @@ class Page < Item
page_design.layout.layout_parts.each do |layout_part| page_design.layout.layout_parts.each do |layout_part|
current_part = self.page_parts.detect{|page_part| page_part.name.eql?(layout_part.name)} current_part = self.page_parts.detect{|page_part| page_part.name.eql?(layout_part.name)}
current_part = self.page_parts.build(:name => layout_part.name) unless current_part current_part = self.page_parts.build(:name => layout_part.name) unless current_part
if current_part.name.eql?(menu_part.name) && menu_part
if menu_part && current_part.name.eql?(menu_part.name)
if current_part.new_record? if current_part.new_record?
current_part.kind = menu_part.kind current_part.kind = menu_part.kind
current_part.public_r_tag = menu_part.public_r_tag current_part.public_r_tag = menu_part.public_r_tag
@ -51,8 +52,8 @@ class Page < Item
current_part.update_attributes(:kind => menu_part.kind, :public_r_tag => menu_part.public_r_tag, :public_r_tag_object_id => menu_part.public_r_tag_object_id) current_part.update_attributes(:kind => menu_part.kind, :public_r_tag => menu_part.public_r_tag, :public_r_tag_object_id => menu_part.public_r_tag_object_id)
end end
end end
else elsif current_part.new_record?
if current_part.new_record? PagePart.without_callback(:save, :after, :update_parent) do
current_part.save current_part.save
end end
end end

View File

@ -206,7 +206,12 @@ module ParserCommon
when 'text' when 'text'
ret << part.content rescue '' ret << part.content rescue ''
when 'module_widget' when 'module_widget'
url = "/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true" url = case part.widget_path
when 'default_widget'
"/panel/orbit_app/widget/#{part.widget_style}?inner=true"
else
"/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true"
end
options = "&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&search_query=#{params[:search_query]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}" options = "&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&search_query=#{params[:search_query]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}"
ret << "<div class='dymanic_load widget' path='#{url + options}'></div>" ret << "<div class='dymanic_load widget' path='#{url + options}'></div>"
when 'public_r_tag' when 'public_r_tag'

View File

@ -312,4 +312,11 @@ namespace :migrate do
end end
end end
task :recreate_page_parts => :environment do
Page.all.each do |page|
page.create_parts
page.save
end
end
end end