fixed announcement rendering..

This commit is contained in:
Harry Bomrah 2013-11-08 12:55:15 +08:00 committed by saurabhbhatia
parent 2f61f55be2
commit 9e432a5a93
5 changed files with 27 additions and 27 deletions

View File

@ -9,19 +9,30 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
end
def search_result
if params[:search_query] == ""
@bulletins = get_bulletins_for_index
else
@search = Bulletin.solr_search do
fulltext params[:search_query]
with(:frontend_search,true)
with(:available_lang).any_of([I18n.locale.to_s])
end
# @bulletins = Bulletin.where(:category_id.in => params[:category_id]).and(:is_rejected=>false).and(:is_pending=>false)
search_result = @search.results.collect{|result| result.id}
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.any_in(_id:search_result).page( params[:page_main]).per(@page_num)
end
end
def index
end
def get_bulletins_for_index
@item = Page.find(params[:page_id]) rescue nil
if @item
if @item.frontend_data_count
@page_num = @item.frontend_data_count
@ -30,32 +41,23 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
end
@frontend_style = @item.frontend_style
end
@item = Page.find(params[:page_id]) rescue nil
if !params[:search_query].blank?
@search = Bulletin.solr_search do
fulltext params[:search_query]
with(:frontend_search,true)
with(:available_lang).any_of([I18n.locale.to_s])
end
search_result = @search.results.collect{|result| result.id}
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.any_in(_id:search_result).page( params[:page_main]).per(@page_num)
else
date_now = Time.now
if !params[:category_id].blank? && !params[:tag_id].blank?
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:category_id => params[:category_id], :tagged_ids => params[:tag_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:category_id.in => params[:category_id], :tagged_ids.in => params[:tag_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
# @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:category_id.in=>params[:category_id],:tagged_ids.in=>params[:tag_id])
@current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
debugger
elsif !params[:category_id].blank?
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.where(:category_id => params[:category_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.where(:category_id.in => params[:category_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
@current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank?
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => params[:tag_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids.in => params[:tag_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
else
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
end
# delayed_impressionist(@tag) if @tag
end
@bulletins
end
def show

View File

@ -39,7 +39,7 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num)
end
@categories = get_categories_for_index
@categories = @module_app.categories.enabled
end
@ -62,7 +62,7 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(@page_num )
end
@categories = get_categories_for_index
@categories = @module_app.categories.enabled
end
@ -139,7 +139,7 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
def bulletins_side_bar
@tags_and_class = @module_app.sorted_tags_for_cloud
@categories = get_categories_for_index
@categories = @module_app.categories.enabled
end
def bulletins_search_block

View File

@ -1,7 +1,6 @@
<% # encoding: utf-8 %>
<%= flash_messages %>
<h1 class="h1"><%= @page.title rescue nil %></h1>
<table class="table table-bordered">

View File

@ -1,7 +1,6 @@
<% # encoding: utf-8 %>
<%= flash_messages %>
<h1 class="h1"><%= @page.title rescue nil %></h1>
<table class="table table-bordered">
@ -23,7 +22,7 @@
<% @bulletins.each do |post| %>
<tr>
<td><%= post.bulletin_category.title rescue nil %></td>
<td><%= link_to post.title, panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %>
<td><%= link_to post.title, panel_announcement_front_end_bulletin_path(post, :category_id => post.category_id) %>
<%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %>
</td>
<td><%= display_date_time(post.postdate) %></td>

View File

@ -1,6 +1,6 @@
<%= stylesheet_link_tag "default_widget" %>
<script type='text/javascript' src='/assets/jquery.mu.image.resize.js'></script>
<script type='text/javascript' src='/assets/jquery.mu.image.resize.degsin.js'></script>
<script type='text/javascript' src='/assets/lib/jquery.mu.image.resize.js'></script>
<!-- <script type='text/javascript' src='/assets/lib/jquery.mu.image.resize.degsin.js'></script> -->
<div id="bulletin_widget">
<%= render 'index' %>