Temporary fix: show for default widget

- the task migrate:recreate_page_parts must be run
	- "create_parts" in page.rb must be unprotected
This commit is contained in:
chris 2013-02-05 16:34:22 +08:00
parent 7105f103e1
commit 29b8fec89a
3 changed files with 32 additions and 27 deletions

View File

@ -11,31 +11,34 @@ class DefaultWidgetController< OrbitWidgetController
end
def default_widget
@tag_class = nil
if !params[:id].blank?
redirect_to eval("#{@page_part.module_app.widget_fields_link_method['title']['method']}('#{params[:id]}', {inner: true})")
else
@tag_class = nil
@default_widget = @page_part.module_app.get_default_widget
@widget_image_field = @default_widget["image"] || @default_widget[:image]
data_limit = case @page_part
when Page
@fields = @page_part.frontend_field
@page_part.frontend_data_count.is_a?(Fixnum) ? @page_part.frontend_data_count : (@page_part.frontend_data_count.to_i rescue 3)
when PagePart
@fields = @page_part.widget_field
@page_part.widget_data_count.is_a?(Fixnum) ? @page_part.widget_data_count : (@page_part.widget_data_count.to_i rescue 3)
@default_widget = @page_part.module_app.get_default_widget
@widget_image_field = @default_widget["image"] || @default_widget[:image]
data_limit = case @page_part
when Page
@fields = @page_part.frontend_field
@page_part.frontend_data_count.is_a?(Fixnum) ? @page_part.frontend_data_count : (@page_part.frontend_data_count.to_i rescue 3)
when PagePart
@fields = @page_part.widget_field
@page_part.widget_data_count.is_a?(Fixnum) ? @page_part.widget_data_count : (@page_part.widget_data_count.to_i rescue 3)
end
@data = eval(@default_widget["query"]).limit(data_limit).includes(@widget_image_field).desc(:created_at)
case params[:type]
when "typeA"
@tag_class = 'default_widget_typeA'
render "typeA"
when /typeB_/
@tag_class = "default_widget_#{params[:type]}"
render "typeB"
when "typeC"
@tag_class = 'default_widget_typeC'
render "typeC"
end
end
@data = eval(@default_widget["query"]).limit(data_limit).includes(@widget_image_field).desc(:created_at)
case params[:type]
when "typeA"
@tag_class = 'default_widget_typeA'
render "typeA"
when /typeB_/
@tag_class = "default_widget_#{params[:type]}"
render "typeB"
when "typeC"
@tag_class = 'default_widget_typeC'
render "typeC"
end
end
end

View File

@ -69,12 +69,13 @@ class PagesController < ApplicationController
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => params[:tag_id]})
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => ''}) unless @item
elsif !params[:category_id].blank?
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action],category: params[:category_id]).any_in(tag: [nil,'']).first
@item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action], category: params[:category_id]).any_in(tag: [nil,'']).first
elsif !params[:tag_id].blank?
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action],tag: params[:tag_id]).any_in(category: [nil,'']).first
@item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action], tag: params[:tag_id]).any_in(category: [nil,'']).first
end
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action]).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first unless @item
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action]).first unless @item
@item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action]).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first unless @item
@item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action]).first unless @item
@item = Item.where(module_app_id: module_app.id, app_frontend_url: 'default_widget').first unless @item
raise PageError,'Missing Frontend Page' if @item.nil?
end

View File

@ -116,6 +116,7 @@ module ParserFrontEnd
if (content["main"] == "true" && !page.module_app.nil?)
if page.app_frontend_url == 'default_widget'
url = "/panel/orbit_app/widget/#{page.frontend_style}?inner=true"
url << "&id=\#{params[:id] if params[:id] && !params[:id].eql?(page.id.to_s)}"
else
url = "/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}\#{(\"/\" + params[:id]) if params[:id] && !params[:id].eql?(page.id.to_s)}\#{(\"/\" + params[:controller_action]) if params[:controller_action] && params[:id]}?inner=true"
end