调整竞赛模块首页中显示的竞赛:既有旧的竞赛又有新的竞赛

This commit is contained in:
wanglinchun 2014-04-19 13:10:25 +08:00
parent 3d02cb7ce0
commit 43064c4bc2
2 changed files with 19 additions and 5 deletions

View File

@ -98,7 +98,14 @@ module WelcomeHelper
end
def find_all_hot_contest limit=10
Contest.reorder("created_on DESC").all.take limit
# Contest.reorder("created_on DESC").all.take limit
mix_bid = []
mix_bid += Contest.reorder("created_on DESC").take(limit).to_a
mix_bid += Bid.visible.where('reward_type = ?', 2).reorder('bids.created_on desc').take(limit).to_a
mix_bid.sort do |older, newer|
newer.created_on - older.created_on
end
mix_bid.take limit
end
def find_all_hot_softapplication limit=10
@ -224,6 +231,10 @@ module WelcomeHelper
def sort_contest_by_hot
sort_bid_by_hot_rails 2
end
#new added by linchun
def sort_contest_by_time
sort_bid_by_time 2
end
#取得所有活动
def find_all_activities limit=6
@ -278,6 +289,10 @@ module WelcomeHelper
Bid.visible.where('reward_type = ?', reward_type).reorder('bids.commit desc').limit(limit)
end
def sort_bid_by_time reward_type, limit = 10
Bid.visible.where('reward_type = ?', reward_type).reorder('bids.created_on desc').limit(limit)
end
def find_all_event_type event
case event.event_type
when 'news'

View File

@ -138,7 +138,7 @@
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", {:controller => 'contests', :action => 'index', :host => Setting.contest_domain}, :target => "_blank" %></span>
<div class="d-p-projectlist-box">
<div class="d-p-projectlist">
<% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %>
<% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[8]) %>
<li style="position:relative;height:6em;" class='<%= cycle("odd", "even") %>'>
<div class="avatar-4"; style="float: left; margin-top: 7px">
@ -146,7 +146,7 @@
</div>
<div style="float: left; margin-left: -8px; margin-top: 5px; width: 380px;">
<%= link_to(contest.name, show_contest_contest_path(contest.id), :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", :target => "_blank") %>
<%= link_to(contest.name, contest.event_url, :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", :target => "_blank") %>
</div>
<div class='text_nowrap' style="float: left;margin:5px; margin-left: -8px; width: 380px;">
@ -154,8 +154,7 @@
</div><br />
<div style="padding-left: 36px; clear: left;">
<!-- <span class="font_lighter"><%= l(:label_contest_project, :count => contest.contesting_projects.count) %>(<strong><span style="font-size: 17px"><%= link_to(contest.contesting_projects.count, show_project_contest_path(contest)) %></span></strong>)</span>
<span class="font_lighter"><%= l(:label_contest_softapplication, :count => contest.contesting_softapplications.count) %>(<strong><span style="font-size: 17px"><%= link_to(contest.contesting_softapplications.count, show_softapplication_contest_path(contest)) %></span></strong>)</span> -->
<span class="font_lighter">发布时间:<%=format_time contest.created_on %></span>
</div>