This commit is contained in:
yanxd 2014-06-04 21:26:57 +08:00
parent ed84ec633f
commit 2e11d76652
2 changed files with 10 additions and 10 deletions

View File

@ -46,7 +46,7 @@ class Contestnotification < ActiveRecord::Base
# returns latest news for contests visible by user
def self.latest(user = User.current, count = 5)
visible(user).includes([:author, :contest]).order("#{Contestnotifications.table_name}.created_on DESC").limit(count).all
visible(user).includes([:author, :contest]).order("#{Contestnotifications.table_name}.created_at DESC").limit(count).all
end
private

View File

@ -1,12 +1,11 @@
<span style="font-size: 16px; border-bottom:1px solid #f0f0f0; margin-right: 15px;">
<%= l(:label_news) %>
</span>
<%= link_to(l(:label_news_new),
new_contest_contestnotification_path(@contest),
:class => 'icon icon-add',
:onclick => 'showAndScrollTo("add-contestnotifications", "contestnotifications_title"); return false;') %>
new_contest_contestnotification_path(@contest),
:class => 'icon icon-add',
:onclick => 'showAndScrollTo("add-contestnotifications", "contestnotifications_title"); return false;') %>
<% if @contest && User.current.allowed_to?(:manage_contestnotifications, @contest) %>
<div id="add-contestnotifications" class="add_frame" style="display:none;">
@ -36,10 +35,11 @@
<table width="580px" border="0">
<tr>
<td colspan="2" valign="top">
<strong><%= link_to_user(contestnotifications.author) if contestnotifications.respond_to?(:author) %></strong><span style="margin-left: 4px;" class="font_lighter"><%= l(:label_project_notice) %></span><span><%#= link_to h(contestnotifications.title), contest_contestnotification_path(contestnotifications) %></span>
<span style="float: right"><%= delete_link contest_contestnotification_path(contestnotifications) if User.current.allowed_to?(:manage_contestnotifications, @contest) %> </span>
</td>
<td colspan="2" valign="top">
<strong><%= link_to_user(contestnotifications.author) if contestnotifications.respond_to?(:author) %></strong><span style="margin-left: 4px;" class="font_lighter">
<%= l(:label_project_notice) %></span><span><%= link_to h(contestnotifications.title), contest_contestnotification_path(@contest, contestnotifications) %></span>
<span style="float: right"><%= delete_link contest_contestnotification_path(@contest, contestnotifications) if true || User.current.allowed_to?(:manage_contestnotifications, @contest) %> </span>
</td>
</tr>
<tr>
<td colspan="2" width="580px">
@ -48,7 +48,7 @@
<tr>
<td align="left"><span class="font_lighter"> <%= l :label_update_time %>
&nbsp;<%= format_time(contestnotifications.created_at) %></span></td>
<td width="350" align="right" class="a"><%#= link_to l(:label_project_newother), contest_contestnotification_path(contestnotifications) %><%#= "(#{l(:label_x_comments, :count => contestnotifications.comments_count)})" if(contestnotifications.comments_count >= 0)%></td>
<td width="350" align="right" class="a"><%= link_to l(:label_project_newother), contest_contestnotification_path(@contest, contestnotifications) %><%= "(#{l(:label_x_comments, :count => contestnotifications.comments.count)})" if(contestnotifications.comments.count >= 0)%></td>
</tr>
</table>
</td>