fix approval at news and announcement for abnormal flags that causing search result fault.
This commit is contained in:
parent
1cdc0e24bd
commit
06919e76ed
|
@ -306,3 +306,4 @@ en:
|
||||||
sitesearch: Google Site Search
|
sitesearch: Google Site Search
|
||||||
site_setting_help: Please Enter the search argument for Google search.
|
site_setting_help: Please Enter the search argument for Google search.
|
||||||
result_get: "Searched about ' %{search_word} ' Found %{item_num} items"
|
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?"
|
||||||
|
|
|
@ -442,7 +442,9 @@ zh_tw:
|
||||||
site_search: "全站搜尋"
|
site_search: "全站搜尋"
|
||||||
sitesearch: Google Site Search
|
sitesearch: Google Site Search
|
||||||
site_setting_help: 請輸入送交Google搜尋的參數
|
site_setting_help: 請輸入送交Google搜尋的參數
|
||||||
result_get: "搜尋標題有關 ' %{search_word} ' 共搜尋到%{item_num}筆資料"
|
result_get: "搜尋有關 ' %{search_word} ' 共搜尋到%{item_num}筆資料"
|
||||||
|
too_many: "搜尋有關 ' %{search_word} ' 尋找到超過 %{exceed_num} 筆資料,請嘗試加入更多關鍵字縮小搜尋範圍,以作更精確的搜尋"
|
||||||
|
|
||||||
activerecord:
|
activerecord:
|
||||||
errors:
|
errors:
|
||||||
template: # ~ 2.3.5 backward compatible
|
template: # ~ 2.3.5 backward compatible
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace :matt_dev do
|
||||||
|
|
||||||
task :searching_02 => :environment do
|
task :searching_02 => :environment do
|
||||||
a= Bulletin.solr_search do #("Bulletin",'我',:conditions =>{:is_checked=>true,:is_hidden=>false})
|
a= Bulletin.solr_search do #("Bulletin",'我',:conditions =>{:is_checked=>true,:is_hidden=>false})
|
||||||
fulltext '我'
|
fulltext '關島'
|
||||||
with(:frontend_search,true)
|
with(:frontend_search,true)
|
||||||
#with(:is_hidden,true)
|
#with(:is_hidden,true)
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace :mid_site do
|
||||||
admin_role = nil
|
admin_role = nil
|
||||||
sub_role = nil
|
sub_role = nil
|
||||||
test_account_ldap_id ='139716'
|
test_account_ldap_id ='139716'
|
||||||
MiddleSiteConnection.establish
|
#MiddleSiteConnection.establish
|
||||||
|
|
||||||
task :sync => :environment do
|
task :sync => :environment do
|
||||||
info_profile = Info.first(conditions: {:key => 'profile'})
|
info_profile = Info.first(conditions: {:key => 'profile'})
|
||||||
|
|
|
@ -10,11 +10,8 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle
|
||||||
def approve
|
def approve
|
||||||
notice = ""
|
notice = ""
|
||||||
@bulletin = Bulletin.find params[:bulletin_id]
|
@bulletin = Bulletin.find params[:bulletin_id]
|
||||||
|
@bulletin.proc_check(params[:bulletin][:is_checked],params[:bulletin][:not_checked_reason])
|
||||||
@bulletin.is_checked = params[:bulletin][:is_checked]
|
|
||||||
@bulletin.not_checked_reason = params[:bulletin][:not_checked_reason]
|
|
||||||
@bulletin.de_pending
|
@bulletin.de_pending
|
||||||
|
|
||||||
if @bulletin.save
|
if @bulletin.save
|
||||||
notice = t('bulletin.approve_bulletin_success')
|
notice = t('bulletin.approve_bulletin_success')
|
||||||
else
|
else
|
||||||
|
|
|
@ -14,8 +14,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
def index
|
def index
|
||||||
# @bulletins = Bulletin.all
|
# @bulletins = Bulletin.all
|
||||||
# @bulletins = Bulletin.desc("postdate desc")
|
# @bulletins = Bulletin.desc("postdate desc")
|
||||||
get_categorys('BulletinCategory',params[:bulletin_category_id])
|
get_categorys('BulletinCategory',params[:bulletin_category_id])
|
||||||
get_tags
|
get_tags
|
||||||
|
|
||||||
@filter = params[:filter]
|
@filter = params[:filter]
|
||||||
new_filter = params[:new_filter]
|
new_filter = params[:new_filter]
|
||||||
|
@ -34,12 +34,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
@filter = {new_filter[:type] => [new_filter[:id].to_s]}
|
@filter = {new_filter[:type] => [new_filter[:id].to_s]}
|
||||||
end
|
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_categories = get_categories_for_index("BulletinCategory")
|
||||||
@bulletin_category_ids = @bulletin_categories.collect{|t| t.id.to_s} + [nil]
|
@bulletin_category_ids = @bulletin_categories.collect{|t| t.id.to_s} + [nil]
|
||||||
|
|
||||||
|
@ -62,16 +56,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
# GET /bulletins/1.xml
|
# GET /bulletins/1.xml
|
||||||
def show
|
def show
|
||||||
@bulletin = Bulletin.find(params[:id])
|
@bulletin = Bulletin.find(params[:id])
|
||||||
get_tags
|
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|
|
respond_to do |format|
|
||||||
format.html # show.html.erb
|
format.html # show.html.erb
|
||||||
|
@ -84,13 +69,9 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
def new
|
def new
|
||||||
@bulletin = Bulletin.new(:postdate => DateTime.now)
|
@bulletin = Bulletin.new(:postdate => DateTime.now)
|
||||||
|
|
||||||
@link_url = panel_announcement_back_end_bulletins_path
|
@link_url = panel_announcement_back_end_bulletins_path
|
||||||
|
get_tags
|
||||||
# @bulletin.bulletin_files.build
|
respond_to do |format|
|
||||||
# @bulletin.bulletin_files.new
|
|
||||||
|
|
||||||
get_tags
|
|
||||||
respond_to do |format|
|
|
||||||
format.html # new.html.erb
|
format.html # new.html.erb
|
||||||
format.xml { render :xml => @bulletin }
|
format.xml { render :xml => @bulletin }
|
||||||
end
|
end
|
||||||
|
@ -141,6 +122,9 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
|
|
||||||
@bulletin.create_user_id = current_user.id
|
@bulletin.create_user_id = current_user.id
|
||||||
@bulletin.update_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|
|
respond_to do |format|
|
||||||
if @bulletin.save
|
if @bulletin.save
|
||||||
|
@ -159,12 +143,9 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_quick_add
|
def link_quick_add
|
||||||
# debugger
|
|
||||||
|
|
||||||
@bulletin_link = BulletinLink.new
|
@bulletin_link = BulletinLink.new
|
||||||
@link_url = panel_announcement_back_end_bulletins_path
|
@link_url = panel_announcement_back_end_bulletins_path
|
||||||
|
@bulletin_link.bulletin_id = params[:bulletin_id]
|
||||||
@bulletin_link.bulletin_id = params[:bulletin_id]
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
|
@ -173,29 +154,17 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_quick_edit
|
def link_quick_edit
|
||||||
# debugger
|
|
||||||
@bulletin_link = BulletinLink.find(params[:bulletin_id])
|
@bulletin_link = BulletinLink.find(params[:bulletin_id])
|
||||||
|
@link_url = panel_announcement_back_end_bulletin_path(@bulletin_link)
|
||||||
@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|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def file_quick_add
|
def file_quick_add
|
||||||
# debugger
|
|
||||||
|
|
||||||
@bulletin_file = BulletinFile.new
|
@bulletin_file = BulletinFile.new
|
||||||
@file_url = panel_announcement_back_end_bulletins_path
|
@file_url = panel_announcement_back_end_bulletins_path
|
||||||
|
|
||||||
@bulletin_file.bulletin_id = params[:bulletin_id]
|
@bulletin_file.bulletin_id = params[:bulletin_id]
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
|
@ -203,11 +172,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
end
|
end
|
||||||
|
|
||||||
def file_quick_edit
|
def file_quick_edit
|
||||||
# debugger
|
|
||||||
@bulletin_file = BulletinFile.find(params[:bulletin_id])
|
@bulletin_file = BulletinFile.find(params[:bulletin_id])
|
||||||
|
|
||||||
@file_url = panel_announcement_back_end_bulletin_path(@bulletin_file)
|
@file_url = panel_announcement_back_end_bulletin_path(@bulletin_file)
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
|
@ -215,6 +181,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
|
|
||||||
# PUT /bulletins/1
|
# PUT /bulletins/1
|
||||||
# PUT /bulletins/1.xml
|
# PUT /bulletins/1.xml
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|
||||||
if params[:bulletin_link]
|
if params[:bulletin_link]
|
||||||
|
@ -249,7 +216,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
|
|
||||||
@bulletin = Bulletin.find(params[:id])
|
@bulletin = Bulletin.find(params[:id])
|
||||||
|
|
||||||
|
|
||||||
# @bulletin.image.clear if params[:bulletin][:image_del] == '1'
|
# @bulletin.image.clear if params[:bulletin][:image_del] == '1'
|
||||||
# if params[:bulletin][:image_del] == '1'
|
# if params[:bulletin][:image_del] == '1'
|
||||||
# @bulletin.remove_image!
|
# @bulletin.remove_image!
|
||||||
|
@ -262,6 +228,11 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
||||||
if @bulletin.update_attributes(params[:bulletin])
|
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")
|
# if (params[:bulletin][:is_checked] == "false")
|
||||||
# @bulletin.is_rejected = true
|
# @bulletin.is_rejected = true
|
||||||
# @bulletin.save!
|
# @bulletin.save!
|
||||||
|
@ -276,8 +247,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
format.js { render 'toggle_enable' }
|
format.js { render 'toggle_enable' }
|
||||||
format.xml { head :ok }
|
format.xml { head :ok }
|
||||||
else
|
else
|
||||||
get_tags
|
get_tags
|
||||||
|
|
||||||
format.html { render :action => "edit" }
|
format.html { render :action => "edit" }
|
||||||
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
|
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,12 +11,12 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
||||||
def index
|
def index
|
||||||
@page = Page.find(params[:page_id])
|
@page = Page.find(params[:page_id])
|
||||||
if !params[:search_query].blank?
|
if !params[:search_query].blank?
|
||||||
search_cond = {:is_checked=>true,:is_hidden=>false,:is_pending => false}
|
# 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.merge!({:bulletin_category_id => "#{params[:category_id]}" }) if !params[:category_id].blank?
|
||||||
|
|
||||||
@search = Bulletin.solr_search do
|
@search = Bulletin.solr_search do
|
||||||
fulltext params[:search_query]
|
fulltext params[:search_query]
|
||||||
#with(:frontend_search,true)
|
with(:frontend_search,true)
|
||||||
|
#order_by(:average_rating)
|
||||||
end
|
end
|
||||||
search_result = @search.results.collect{|result| result.id}
|
search_result = @search.results.collect{|result| result.id}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ class Bulletin
|
||||||
|
|
||||||
validates :title, :at_least_one => true
|
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_links
|
||||||
after_save :save_bulletin_files
|
after_save :save_bulletin_files
|
||||||
|
@ -70,68 +70,39 @@ class Bulletin
|
||||||
title_translations.to_a.collect{|t| t[1]}
|
title_translations.to_a.collect{|t| t[1]}
|
||||||
end
|
end
|
||||||
text :texts do
|
text :texts do
|
||||||
text_translations.to_a.collect{|t| t[1]}
|
text_translations.to_a.collect{|t| Nokogiri::HTML(t[1]).text}
|
||||||
end
|
end
|
||||||
# text :text do
|
# text :text do
|
||||||
# a = (title_translations["zh_tw"] + title_translations["en"])
|
# a = (title_translations["zh_tw"] + title_translations["en"])
|
||||||
# a
|
# a
|
||||||
# end
|
# end
|
||||||
boolean :frontend_search do
|
boolean :frontend_search do
|
||||||
!is_hidden && !is_pending && is_checked
|
( !is_hidden && !is_pending && is_checked && !is_rejected )
|
||||||
end
|
end
|
||||||
|
|
||||||
integer :view_count
|
integer :view_count
|
||||||
string :bulletin_category_id
|
string :bulletin_category_id
|
||||||
end
|
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
|
def de_pending
|
||||||
self.is_pending = false
|
self.is_pending = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def de_pending!
|
||||||
|
de_pending
|
||||||
|
self.save!
|
||||||
|
end
|
||||||
|
|
||||||
def publish_month
|
def publish_month
|
||||||
published_at.strftime("%B %Y")
|
published_at.strftime("%B %Y")
|
||||||
end
|
end
|
||||||
|
@ -233,21 +204,6 @@ class Bulletin
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
def update_avliable_language
|
def update_avliable_language
|
||||||
VALID_LOCALES.each do |locale|
|
VALID_LOCALES.each do |locale|
|
||||||
if (title_translations[locale].blank? rescue true)
|
if (title_translations[locale].blank? rescue true)
|
||||||
|
|
|
@ -14,8 +14,10 @@
|
||||||
<% if @bulletins.blank? and !params[:search_query].blank? %>
|
<% if @bulletins.blank? and !params[:search_query].blank? %>
|
||||||
<%=render :partial => 'shared/search_not_found' %>
|
<%=render :partial => 'shared/search_not_found' %>
|
||||||
<% elsif !params[:search_query].blank? %>
|
<% 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 %>
|
<% end %>
|
||||||
|
|
||||||
<% @bulletins.each do |post| %>
|
<% @bulletins.each do |post| %>
|
||||||
<tr class=<%= cycle('odd', '') %>>
|
<tr class=<%= cycle('odd', '') %>>
|
||||||
<td><%= (post.bulletin_category.title rescue nil ) if !params[:search_query].blank? %></td>
|
<td><%= (post.bulletin_category.title rescue nil ) if !params[:search_query].blank? %></td>
|
||||||
|
|
|
@ -10,11 +10,8 @@ class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController
|
||||||
def approve
|
def approve
|
||||||
notice = ""
|
notice = ""
|
||||||
@news_bulletin = NewsBulletin.find params[:news_bulletin_id]
|
@news_bulletin = NewsBulletin.find params[:news_bulletin_id]
|
||||||
|
@news_bulletin.proc_check(params[:news_bulletin][:is_checked],params[:news_bulletin][:not_checked_reason])
|
||||||
@news_bulletin.is_checked = params[:news_bulletin][:is_checked]
|
|
||||||
@news_bulletin.not_checked_reason = params[:news_bulletin][:not_checked_reason]
|
|
||||||
@news_bulletin.de_pending
|
@news_bulletin.de_pending
|
||||||
|
|
||||||
if @news_bulletin.save
|
if @news_bulletin.save
|
||||||
notice = t('news_bulletin.approve_bulletin_success')
|
notice = t('news_bulletin.approve_bulletin_success')
|
||||||
else
|
else
|
||||||
|
|
|
@ -148,6 +148,10 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
|
||||||
@news_bulletin.create_user_id = current_user.id
|
@news_bulletin.create_user_id = current_user.id
|
||||||
@news_bulletin.update_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|
|
respond_to do |format|
|
||||||
if @news_bulletin.save
|
if @news_bulletin.save
|
||||||
expire_page(:controller=>'panel/news/widget/news_bulletins' , :action=>'home_banner')
|
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|
|
respond_to do |format|
|
||||||
if @news_bulletin.update_attributes(params[:news_bulletin])
|
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')
|
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_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')) }
|
format.html { redirect_to(panel_news_back_end_news_bulletins_url, :notice => t('news_bulletin.update_success')) }
|
||||||
|
|
|
@ -11,12 +11,13 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController
|
||||||
def index
|
def index
|
||||||
@page = Page.find(params[:page_id])
|
@page = Page.find(params[:page_id])
|
||||||
if !params[:search_query].blank?
|
if !params[:search_query].blank?
|
||||||
search_cond = {:is_checked=>true,:is_hidden=>false,:is_pending=>false,:is_pending=>false}
|
# 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.merge!({:news_bulletin_category_id => "#{params[:category_id]}" }) if !params[:category_id].blank?
|
||||||
|
|
||||||
@search = NewsBulletin.solr_search do
|
@search = NewsBulletin.solr_search do
|
||||||
fulltext params[:search_query]
|
fulltext params[:search_query]
|
||||||
with(:frontend_search,true)
|
with(:frontend_search,true)
|
||||||
|
#order_by(:average_rating)
|
||||||
end
|
end
|
||||||
search_result = @search.results.collect{|result| result.id}
|
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)
|
@news_bulletins = NewsBulletin.all.available_for_lang(I18n.locale).can_display.any_in(_id:search_result).page( params[:page_main]).per(10)
|
||||||
|
|
|
@ -61,7 +61,7 @@ class NewsBulletin
|
||||||
|
|
||||||
validates :title, :at_least_one => true
|
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_links
|
||||||
after_save :save_news_bulletin_files
|
after_save :save_news_bulletin_files
|
||||||
|
@ -96,12 +96,12 @@ class NewsBulletin
|
||||||
title_translations.to_a.collect{|t| t[1]}
|
title_translations.to_a.collect{|t| t[1]}
|
||||||
end
|
end
|
||||||
text :texts do
|
text :texts do
|
||||||
text_translations.to_a.collect{|t| t[1]}
|
text_translations.to_a.collect{|t| Nokogiri::HTML(t[1]).text}
|
||||||
end
|
end
|
||||||
integer :view_count
|
integer :view_count
|
||||||
|
|
||||||
boolean :frontend_search do
|
boolean :frontend_search do
|
||||||
!is_hidden && !is_pending && is_checked
|
( !is_hidden && !is_pending && is_checked && !is_rejected )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,10 +156,25 @@ class NewsBulletin
|
||||||
|
|
||||||
end
|
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
|
def de_pending
|
||||||
self.is_pending = false
|
self.is_pending = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def de_pending!
|
||||||
|
de_pending
|
||||||
|
self.save!
|
||||||
|
end
|
||||||
|
|
||||||
def is_expired?
|
def is_expired?
|
||||||
Date.today > self.deadline ? true : false rescue false
|
Date.today > self.deadline ? true : false rescue false
|
||||||
#some dates might sat as nil so rescue false
|
#some dates might sat as nil so rescue false
|
||||||
|
@ -229,19 +244,4 @@ class NewsBulletin
|
||||||
end
|
end
|
||||||
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
|
end
|
|
@ -9,7 +9,6 @@
|
||||||
<% elsif !params[:search_query].blank? %>
|
<% 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) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<table class="table table-bordered">
|
<table class="table table-bordered">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Reference in New Issue