Fix links and remove unneeded codes

This commit is contained in:
Bernie Chiu 2013-12-11 17:26:47 +08:00 committed by saurabhbhatia
parent f13c21c1b4
commit 5faa7e73c0
2 changed files with 5 additions and 20 deletions

View File

@ -33,15 +33,7 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
@category_id = @part.category @category_id = @part.category
date_now = Time.now date_now = Time.now
if !@category_id.blank?
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:category_id => @category_id).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)
@current_category = BulletinCategory.from_id(@category_id) rescue nil
elsif !params[:tag_id].blank?
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => params[:tag_id]).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)
else
@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
if !params[:category_id].blank? && !params[:tag_id].blank? if !params[:category_id].blank? && !params[:tag_id].blank?
@posts = 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) @posts = 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)
# @posts = Bulletin.available_for_lang(I18n.locale).can_display.where(:category_id.in=>params[:category_id],:tagged_ids.in=>params[:tag_id]) # @posts = Bulletin.available_for_lang(I18n.locale).can_display.where(:category_id.in=>params[:category_id],:tagged_ids.in=>params[:tag_id])

View File

@ -16,13 +16,13 @@
<% end %> <% end %>
</tr> </tr>
</thead> </thead>
<% @bulletins.each do |post| %> <% @posts.each do |post| %>
<tr class="<%= cycle('odd', '')%>"> <tr class="<%= cycle('odd', '')%>">
<% @widget_fields.each do |wf| %> <% @widget_fields.each do |wf| %>
<td> <td>
<span class="<%= wf[1] %>"> <span class="<%= wf[1] %>">
<% if wf[1] == 'title' %> <% if wf[1] == 'title' %>
<%= link_to post.send("#{wf[0]}"), panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %> <%= link_to post.send("#{wf[0]}"), panel_announcement_front_end_bulletin_path(post, :category_id => post.send("category_id")) %>
<% elsif wf[1] == 'date' %> <% elsif wf[1] == 'date' %>
<%= display_date(post.send(wf[0])) %> <%= display_date(post.send(wf[0])) %>
<% elsif wf[1] == 'category' %> <% elsif wf[1] == 'category' %>
@ -52,13 +52,6 @@
<% end %> <% end %>
</tr> </tr>
<% end %> <% end %>
<% @posts.each do |post| %>
<tr>
<td><%= display_date(post.postdate) %></td>
<td><%= link_to post.title, panel_announcement_front_end_bulletin_path(post, :category_id => post.category_id) %>
</td>
</tr>
<% end %>
</table> </table>
<div class="more"><%= link_to t('announcement.more'), panel_announcement_front_end_bulletins_path() %></div> <div class="more"><%= link_to t('announcement.more'), panel_announcement_front_end_bulletins_path() %></div>
@ -68,14 +61,14 @@
<div class="default_widget_list"> <div class="default_widget_list">
<ul class="newslist"> <ul class="newslist">
<% @bulletins.each do |post| %> <% @posts.each do |post| %>
<li class="<%= cycle('odd', '')%>"> <li class="<%= cycle('odd', '')%>">
<div class="img app-pic" style="width:50px; height:50px;"><%= image_tag(post.image.url) %></div> <div class="img app-pic" style="width:50px; height:50px;"><%= image_tag(post.image.url) %></div>
<% @widget_fields.each do |wf| %> <% @widget_fields.each do |wf| %>
<span class="<%= wf[1] %>"> <span class="<%= wf[1] %>">
<% if wf[1] == 'title' %> <% if wf[1] == 'title' %>
<%= link_to post.send("#{wf[0]}"), panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %> <%= link_to post.send("#{wf[0]}"), panel_announcement_front_end_bulletin_path(post, :category_id => post.send("category_id")) %>
<% elsif wf[1] == 'date' %> <% elsif wf[1] == 'date' %>
<%= display_date(post.send(wf[0])) %> <%= display_date(post.send(wf[0])) %>
<% elsif wf[1] == 'category' %> <% elsif wf[1] == 'category' %>