fix approval at news and announcement for abnormal flags that causing search result fault.

This commit is contained in:
Matthew K. Fu JuYuan 2012-08-03 12:45:47 +08:00
parent 69901403cd
commit d7ad029d4b
14 changed files with 85 additions and 149 deletions

View File

@ -306,3 +306,4 @@ en:
sitesearch: Google Site Search
site_setting_help: Please Enter the search argument for Google search.
result_get: "Searched about ' %{search_word} ' Found %{item_num} items"
too_many: "Search about ' %{search_word} 'resulted more than %{exceed_num} items maybe try to search with more specific terms?"

View File

@ -442,7 +442,9 @@ zh_tw:
site_search: "全站搜尋"
sitesearch: Google Site Search
site_setting_help: 請輸入送交Google搜尋的參數
result_get: "搜尋標題有關 ' %{search_word} ' 共搜尋到%{item_num}筆資料"
result_get: "搜尋有關 ' %{search_word} ' 共搜尋到%{item_num}筆資料"
too_many: "搜尋有關 ' %{search_word} ' 尋找到超過 %{exceed_num} 筆資料,請嘗試加入更多關鍵字縮小搜尋範圍,以作更精確的搜尋"
activerecord:
errors:
template: # ~ 2.3.5 backward compatible

View File

@ -10,7 +10,7 @@ namespace :matt_dev do
task :searching_02 => :environment do
a= Bulletin.solr_search do #("Bulletin",'我',:conditions =>{:is_checked=>true,:is_hidden=>false})
fulltext ''
fulltext '關島'
with(:frontend_search,true)
#with(:is_hidden,true)
end

View File

@ -9,7 +9,7 @@ namespace :mid_site do
admin_role = nil
sub_role = nil
test_account_ldap_id ='139716'
MiddleSiteConnection.establish
#MiddleSiteConnection.establish
task :sync => :environment do
info_profile = Info.first(conditions: {:key => 'profile'})

View File

@ -10,11 +10,8 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle
def approve
notice = ""
@bulletin = Bulletin.find params[:bulletin_id]
@bulletin.is_checked = params[:bulletin][:is_checked]
@bulletin.not_checked_reason = params[:bulletin][:not_checked_reason]
@bulletin.proc_check(params[:bulletin][:is_checked],params[:bulletin][:not_checked_reason])
@bulletin.de_pending
if @bulletin.save
notice = t('bulletin.approve_bulletin_success')
else

View File

@ -34,12 +34,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@filter = {new_filter[:type] => [new_filter[:id].to_s]}
end
# @bulletins = Bulletin.where("bulletin_category_id" => params[:bulletin_category_id]).desc("postdate") if params[:bulletin_category_id]
# @bulletins = Bulletin.search(params[:search], params[:category_id])
# @bulletins = Bulletin.all.order_by([params[:sort], params[:direction]])
# @bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered_bulletins : Bulletin.all.page(params[:page]).per(10)
@bulletin_categories = get_categories_for_index("BulletinCategory")
@bulletin_category_ids = @bulletin_categories.collect{|t| t.id.to_s} + [nil]
@ -63,15 +57,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
def show
@bulletin = Bulletin.find(params[:id])
get_tags
# get_categorys
# @bulletin_categorys = BulletinCategory.where("_id" => params[:id])
# if params[:id]
# @bulletins = Bulletin.where("bulletin_category_id" => params[:id])
# else
# @bulletins = Bulletin.desc("postdate desc")
# end
respond_to do |format|
format.html # show.html.erb
@ -85,10 +70,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@bulletin = Bulletin.new(:postdate => DateTime.now)
@link_url = panel_announcement_back_end_bulletins_path
# @bulletin.bulletin_files.build
# @bulletin.bulletin_files.new
get_tags
respond_to do |format|
format.html # new.html.erb
@ -141,6 +122,9 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@bulletin.create_user_id = current_user.id
@bulletin.update_user_id = current_user.id
if(is_manager? || is_admin?)
@bulletin.de_pending
end
respond_to do |format|
if @bulletin.save
@ -159,11 +143,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
end
def link_quick_add
# debugger
@bulletin_link = BulletinLink.new
@link_url = panel_announcement_back_end_bulletins_path
@bulletin_link.bulletin_id = params[:bulletin_id]
respond_to do |format|
@ -173,29 +154,17 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
end
def link_quick_edit
# debugger
@bulletin_link = BulletinLink.find(params[:bulletin_id])
@link_url = panel_announcement_back_end_bulletin_path(@bulletin_link)
# @bulletin = Bulletin.find(params[:bulletin_id])
# @link_url = panel_announcement_back_end_bulletin_path(@bulletin)
respond_to do |format|
format.js
end
end
def file_quick_add
# debugger
@bulletin_file = BulletinFile.new
@file_url = panel_announcement_back_end_bulletins_path
@bulletin_file.bulletin_id = params[:bulletin_id]
respond_to do |format|
format.js
end
@ -203,11 +172,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
end
def file_quick_edit
# debugger
@bulletin_file = BulletinFile.find(params[:bulletin_id])
@file_url = panel_announcement_back_end_bulletin_path(@bulletin_file)
respond_to do |format|
format.js
end
@ -215,6 +181,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# PUT /bulletins/1
# PUT /bulletins/1.xml
def update
if params[:bulletin_link]
@ -249,7 +216,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@bulletin = Bulletin.find(params[:id])
# @bulletin.image.clear if params[:bulletin][:image_del] == '1'
# if params[:bulletin][:image_del] == '1'
# @bulletin.remove_image!
@ -262,6 +228,11 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
respond_to do |format|
if @bulletin.update_attributes(params[:bulletin])
if(is_manager? || is_admin?)
@bulletin.is_checked = true
@bulletin.is_rejected = false
@bulletin.de_pending!
end
# if (params[:bulletin][:is_checked] == "false")
# @bulletin.is_rejected = true
# @bulletin.save!
@ -277,7 +248,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
format.xml { head :ok }
else
get_tags
format.html { render :action => "edit" }
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
end

View File

@ -10,12 +10,12 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
def index
if !params[:search_query].blank?
search_cond = {:is_checked=>true,:is_hidden=>false,:is_pending => false}
search_cond.merge!({:bulletin_category_id => "#{params[:category_id]}" }) if !params[:category_id].blank?
# search_cond = {:is_checked=>true,:is_hidden=>false,:is_pending => false}
# search_cond.merge!({:bulletin_category_id => "#{params[:category_id]}" }) if !params[:category_id].blank?
@search = Bulletin.solr_search do
fulltext params[:search_query]
#with(:frontend_search,true)
with(:frontend_search,true)
#order_by(:average_rating)
end
search_result = @search.results.collect{|result| result.id}

View File

@ -60,7 +60,7 @@ class Bulletin
validates :title, :at_least_one => true
before_save :check_deadline,:update_status,:update_avliable_language
before_save :check_deadline,:update_avliable_language
after_save :save_bulletin_links
after_save :save_bulletin_files
@ -70,68 +70,39 @@ class Bulletin
title_translations.to_a.collect{|t| t[1]}
end
text :texts do
text_translations.to_a.collect{|t| t[1]}
text_translations.to_a.collect{|t| Nokogiri::HTML(t[1]).text}
end
# text :text do
# a = (title_translations["zh_tw"] + title_translations["en"])
# a
# end
boolean :frontend_search do
!is_hidden && !is_pending && is_checked
( !is_hidden && !is_pending && is_checked && !is_rejected )
end
integer :view_count
string :bulletin_category_id
end
# redis_search_index(:title_field => :s_title,
# :alias_field =>:s_title_en ,
# :score_field => :view_count,
# :condition_fields => [:is_checked,:is_hidden,:bulletin_category_id,:is_pending],
# :ext_fields => [])
def proc_check(check,not_pass_info = "")
self.is_checked = true
if check =="true"
self.is_rejected = false
elsif check == "false"
self.is_rejected = true
self.not_checked_reason = not_pass_info
end
end
# def gen_title_for_search
# # [s_title,s_title_en,s_text_en,s_text_zh_tw].join(' ')
# end
#alias_method
# def s_title
# self.title_translations["zh_tw"]
# end
# def s_title_was
# self.title_was["zh_tw"]
# end
# def s_title_en
# self.title_translations["en"]
# end
# def s_title_en_was
# self.title_was["en"]
# end
# def s_text_en
# Nokogiri::HTML(self.text.en).text
# end
# def s_text_zh_tw
# Nokogiri::HTML(self.text.zh_tw).text
# end
# scope :currently_available, lambda { |category, limit|
# # limit ||= 5
# # {
# # debugger
# # a=1
# :where => {:bulletin_category_id => bulletin_category_id, :disable => false}#,
# # :limit => limit
# # }
# }
def de_pending
self.is_pending = false
end
def de_pending!
de_pending
self.save!
end
def publish_month
published_at.strftime("%B %Y")
end
@ -233,21 +204,6 @@ class Bulletin
end
def update_status
if !self.is_pending
if !self.is_checked
# self.is_pending = false
self.is_rejected = true
#self.is_checked = false
elsif self.is_checked
# self.is_pending = false
self.is_rejected = false
#self.is_checked = true
end
end
return true
end
def update_avliable_language
VALID_LOCALES.each do |locale|
if (title_translations[locale].blank? rescue true)

View File

@ -18,8 +18,10 @@
<% if @bulletins.blank? and !params[:search_query].blank? %>
<%=render :partial => 'shared/search_not_found' %>
<% elsif !params[:search_query].blank? %>
<%= t("search.result_get",:search_word => params[:search_query],:item_num=>@bulletins.count) %>
<%= t("search.result_get",:search_word => params[:search_query],:item_num=>@bulletins.count) unless (@bulletins.count == 30) %>
<%= t("search.too_many",:search_word => params[:search_query],:exceed_num=>@bulletins.count) if (@bulletins.count ==30) %>
<% end %>
<% @bulletins.each do |post| %>
<tr>
<td><%= (post.bulletin_category.title rescue nil ) if !params[:search_query].blank? %></td>

View File

@ -10,11 +10,8 @@ class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController
def approve
notice = ""
@news_bulletin = NewsBulletin.find params[:news_bulletin_id]
@news_bulletin.is_checked = params[:news_bulletin][:is_checked]
@news_bulletin.not_checked_reason = params[:news_bulletin][:not_checked_reason]
@news_bulletin.proc_check(params[:news_bulletin][:is_checked],params[:news_bulletin][:not_checked_reason])
@news_bulletin.de_pending
if @news_bulletin.save
notice = t('news_bulletin.approve_bulletin_success')
else

View File

@ -148,6 +148,10 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
@news_bulletin.create_user_id = current_user.id
@news_bulletin.update_user_id = current_user.id
if(is_manager? || is_admin?)
@news_bulletin.de_pending
end
respond_to do |format|
if @news_bulletin.save
expire_page(:controller=>'panel/news/widget/news_bulletins' , :action=>'home_banner')
@ -267,6 +271,11 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
respond_to do |format|
if @news_bulletin.update_attributes(params[:news_bulletin])
if(is_manager? || is_admin?)
@news_bulletin.is_checked = true
@news_bulletin.is_rejected = false
@news_bulletin.de_pending!
end
expire_page(:controller=>'panel/news/widget/news_bulletins' , :action=>'home_banner')
# format.html { redirect_to(panel_news_back_end_news_bulletin_url(@news_bulletin), :notice => t('news_bulletin.update_news_bulletin_success')) }
format.html { redirect_to(panel_news_back_end_news_bulletins_url, :notice => t('news_bulletin.update_success')) }

View File

@ -10,12 +10,13 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController
def index
if !params[:search_query].blank?
search_cond = {:is_checked=>true,:is_hidden=>false,:is_pending=>false,:is_pending=>false}
search_cond.merge!({:news_bulletin_category_id => "#{params[:category_id]}" }) if !params[:category_id].blank?
# search_cond = {:is_checked=>true,:is_hidden=>false,:is_pending=>false,:is_pending=>false}
# search_cond.merge!({:news_bulletin_category_id => "#{params[:category_id]}" }) if !params[:category_id].blank?
@search = NewsBulletin.solr_search do
fulltext params[:search_query]
with(:frontend_search,true)
#order_by(:average_rating)
end
search_result = @search.results.collect{|result| result.id}
@news_bulletins = NewsBulletin.all.available_for_lang(I18n.locale).can_display.any_in(_id:search_result).page( params[:page_main]).per(10)

View File

@ -61,7 +61,7 @@ class NewsBulletin
validates :title, :at_least_one => true
before_save :update_status,:update_avliable_language
before_save :update_avliable_language
after_save :save_news_bulletin_links
after_save :save_news_bulletin_files
@ -96,12 +96,12 @@ class NewsBulletin
title_translations.to_a.collect{|t| t[1]}
end
text :texts do
text_translations.to_a.collect{|t| t[1]}
text_translations.to_a.collect{|t| Nokogiri::HTML(t[1]).text}
end
integer :view_count
boolean :frontend_search do
!is_hidden && !is_pending && is_checked
( !is_hidden && !is_pending && is_checked && !is_rejected )
end
@ -156,10 +156,25 @@ class NewsBulletin
end
def proc_check(check,not_pass_info = "")
self.is_checked = true
if check =="true"
self.is_rejected = false
elsif check == "false"
self.is_rejected = true
self.not_checked_reason = not_pass_info
end
end
def de_pending
self.is_pending = false
end
def de_pending!
de_pending
self.save!
end
def is_expired?
Date.today > self.deadline ? true : false rescue false
#some dates might sat as nil so rescue false
@ -229,19 +244,4 @@ class NewsBulletin
end
end
def update_status
if !self.is_pending
if !self.is_checked
# self.is_pending = false
self.is_rejected = true
#self.is_checked = false
elsif self.is_checked
# self.is_pending = false
self.is_rejected = false
#self.is_checked = true
end
end
return true
end
end

View File

@ -10,7 +10,8 @@
<% if @news_bulletins.blank? and !params[:search_query].blank? %>
<%=render :partial => 'shared/search_not_found' %>
<% elsif !params[:search_query].blank? %>
<%= t("search.result_get",:search_word => params[:search_query],:item_num=>@news_bulletins.count) %>
<%= t("search.result_get",:search_word => params[:search_query],:item_num=>@news_bulletins.count) unless (@bulletins.count == 30)%>
<%= t("search.too_many",:search_word => params[:search_query],:exceed_num=>@bulletins.count) if (@bulletins.count ==30) %>
<% end %>
<table class="table table-bordered">
<tbody>