Merge remote-tracking branch 'origin/develop' into develop

dev_aliyun
杨树明 5 years ago
commit 658fc3f7e6

@ -30,7 +30,7 @@ class CompetitionsController < ApplicationController
case params[:category]
when 'progressing' then
competitions = competitions.where('end_time > NOW()')
when 'end' then
when 'ended' then
competitions = competitions.where('end_time < NOW()')
end
@competitions = competitions.reorder("published_at desc, online_time desc")

@ -0,0 +1,100 @@
<% if @competitions.count > 0 %>
<div class="clearfix competitionsList">
<% @competitions.each do |competition| %>
<% if competition.status? %>
<div class="competitionsList-item mb20">
<div class="edu-back-white pr">
<% if competition.enroll_end_time.present? && competition.enroll_end_time > Time.now %>
<div class="applycompetitions">报名中</div>
<% end %>
<a href="<%= competition_path(competition) %>" class="competition-Img" target="_blank">
<%= image_tag(url_to_avatar(competition), :width => "100%", :height => "100%") %>
</a>
<div class="pt20 pl20 mb10 clearfix">
<a href="<%= competition_path(competition) %>" style="max-width: 400px;" class="font-16 task-hide fl" target="_blank"><%= [competition.name, competition.sub_title.presence].compact.join('——') %></a>
<% if competition.start_time > Time.now %>
<% unless competition.enroll_end_time.present? && competition.enroll_end_time < Time.now %>
<div class="fr status-orange">
<img src="/images/educoder/competition/home/orange.png" class="fl">
<span class="status-tag fl">报名中</span>
</div>
<% else %>
<div class="fr status-blue">
<img src="/images/educoder/competition/home/blue.png" class="fl">
<span class="status-tag fl">即将开始</span>
</div>
<% end %>
<% elsif competition.end_time < Time.now %>
<div class="fr status-grey">
<img src="/images/educoder/competition/home/grey.png" class="fl">
<span class="status-tag fl">已结束</span>
</div>
<% else %>
<% max_min_stage = max_min_stage_time competition %>
<% if max_min_stage.count == 1 %>
<div class="fr status-blue">
<img src="/images/educoder/competition/home/blue.png" class="fl">
<span class="status-tag fl">距离结束还剩<%= how_much_day competition.end_time %></span>
</div>
<% else %>
<% max_min_stage.each do |stage| %>
<% if stage.min_start_time > Time.now %>
<div class="fr status-blue">
<img src="/images/educoder/competition/home/blue.png" class="fl">
<span class="status-tag fl"><%= stage.competition_stage.name %>即将开始</span>
</div>
<% break %>
<% elsif stage.max_end_time > Time.now %>
<div class="fr status-blue">
<img src="/images/educoder/competition/home/blue.png" class="fl">
<span class="status-tag fl"><%= stage.competition_stage.name %>正在进行</span>
</div>
<% break %>
<% end %>
<% end %>
<% end %>
<% end %>
</div>
<p class="color-grey-B3 clearfix pl20 pr20 pb20">
<span class="fl"><span><%= format_date competition.start_time %></span>&nbsp;~&nbsp;<span><%= com_end_date competition.end_time %></span></span>
<span class="fr">
<span class="fl cdefault" data-tip-down="浏览数"><i class="iconfont icon-liulanyan font-16 fl mr3"></i><span class="font-12 mt3 fl"><%= competition.visits %></span></span>
<% if competition.member_count > 0 %>
<span class="ml30 fl cdefault" data-tip-down="报名数"><i class="iconfont icon-chengyuan font-16 fl mr3"></i>
<span class="font-12 mt4 fl">
<%= competition.identifier == "hn" ? 1125 : competition.member_count %>
</span>
</span>
<% end %>
</span>
</p>
</div>
</div>
<% elsif competition.published_at.present? %>
<% url = admin_or_business? ? competition_path(competition) : 'javascript:void(0)' %>
<div class="competitionsList-item mb20">
<div class="edu-back-white">
<a href="<%= url %>" class="competition-Img">
<%= image_tag(url_to_avatar(competition), :width => "100%", :height => "100%") %>
</a>
<div class="pt30 pb30 pl20 mt2 clearfix">
<a href="<%= url %>" style="max-width: 400px;" class="font-16 task-hide fl"><%= [competition.name, competition.sub_title.presence].compact.join('——') %></a>
<div class="fr status-orange">
<img src="/images/educoder/competition/home/orange.png" class="fl">
<span class="status-tag fl">即将发布</span>
</div>
</div>
<p class="color-grey-B3 clearfix pl20 pr20 pb20"></p>
</div>
<div class="competitionsList-item-tip strongNone">
<div class="color-white font-26">
<p>即将发布</p><p>敬请期待</p>
</div>
</div>
</div>
<% end %>
<% end %>
</div>
<% else %>
<%= render :partial => "welcome/no_data" %>
<% end %>

@ -1,111 +1,19 @@
<div class="educontent mt20 mb80">
<div class="mt20 mb20 clearfix">
<a class="fl mr20 font-16 bestChoose shixun_repertoire active" data-type="order" data-values="publish_time">全部</a>
<a class="fl mr20 font-16 bestChoose shixun_repertoire" data-type="order" data-values="mine">进行中</a>
<a class="fl mr20 font-16 bestChoose shixun_repertoire" data-type="order" data-values="created_at">往期比赛</a>
<%= link_to '全部', competitions_path(category: ''), remote: true,
class: "fl mr20 font-16 bestChoose shixun_repertoire #{params[:category].blank? ? 'active' : ''}" %>
<%= link_to '进行中', competitions_path(category: 'progressing'), remote: true,
class: "fl mr20 font-16 bestChoose shixun_repertoire #{params[:category] == 'progressing' ? 'active' : ''}" %>
<%= link_to '往期比赛', competitions_path(category: 'ended'), remote: true,
class: "fl mr20 font-16 bestChoose shixun_repertoire #{params[:category] == 'ended' ? 'active' : ''}" %>
</div>
<% if @competitions.count > 0 %>
<div class="clearfix competitionsList">
<% @competitions.each do |competition| %>
<% if competition.status? %>
<div class="competitionsList-item mb20">
<div class="edu-back-white pr">
<% if competition.enroll_end_time.present? && competition.enroll_end_time > Time.now %>
<div class="applycompetitions">报名中</div>
<% end %>
<a href="<%= competition_path(competition) %>" class="competition-Img" target="_blank">
<%= image_tag(url_to_avatar(competition), :width => "100%", :height => "100%") %>
</a>
<div class="pt20 pl20 mb10 clearfix">
<a href="<%= competition_path(competition) %>" style="max-width: 400px;" class="font-16 task-hide fl" target="_blank"><%= [competition.name, competition.sub_title.presence].compact.join('——') %></a>
<% if competition.start_time > Time.now %>
<% unless competition.enroll_end_time.present? && competition.enroll_end_time < Time.now %>
<div class="fr status-orange">
<img src="/images/educoder/competition/home/orange.png" class="fl">
<span class="status-tag fl">报名中</span>
</div>
<% else %>
<div class="fr status-blue">
<img src="/images/educoder/competition/home/blue.png" class="fl">
<span class="status-tag fl">即将开始</span>
</div>
<% end %>
<% elsif competition.end_time < Time.now %>
<div class="fr status-grey">
<img src="/images/educoder/competition/home/grey.png" class="fl">
<span class="status-tag fl">已结束</span>
</div>
<% else %>
<% max_min_stage = max_min_stage_time competition %>
<% if max_min_stage.count == 1 %>
<div class="fr status-blue">
<img src="/images/educoder/competition/home/blue.png" class="fl">
<span class="status-tag fl">距离结束还剩<%= how_much_day competition.end_time %></span>
</div>
<% else %>
<% max_min_stage.each do |stage| %>
<% if stage.min_start_time > Time.now %>
<div class="fr status-blue">
<img src="/images/educoder/competition/home/blue.png" class="fl">
<span class="status-tag fl"><%= stage.competition_stage.name %>即将开始</span>
</div>
<% break %>
<% elsif stage.max_end_time > Time.now %>
<div class="fr status-blue">
<img src="/images/educoder/competition/home/blue.png" class="fl">
<span class="status-tag fl"><%= stage.competition_stage.name %>正在进行</span>
</div>
<% break %>
<% end %>
<% end %>
<% end %>
<% end %>
</div>
<p class="color-grey-B3 clearfix pl20 pr20 pb20">
<span class="fl"><span><%= format_date competition.start_time %></span>&nbsp;~&nbsp;<span><%= com_end_date competition.end_time %></span></span>
<span class="fr">
<span class="fl cdefault" data-tip-down="浏览数"><i class="iconfont icon-liulanyan font-16 fl mr3"></i><span class="font-12 mt3 fl"><%= competition.visits %></span></span>
<% if competition.member_count > 0 %>
<span class="ml30 fl cdefault" data-tip-down="报名数"><i class="iconfont icon-chengyuan font-16 fl mr3"></i>
<span class="font-12 mt4 fl">
<%= competition.identifier == "hn" ? 1125 : competition.member_count %>
</span>
</span>
<% end %>
</span>
</p>
</div>
</div>
<% elsif competition.published_at.present? %>
<% url = admin_or_business? ? competition_path(competition) : 'javascript:void(0)' %>
<div class="competitionsList-item mb20">
<div class="edu-back-white">
<a href="<%= url %>" class="competition-Img">
<%= image_tag(url_to_avatar(competition), :width => "100%", :height => "100%") %>
</a>
<div class="pt30 pb30 pl20 mt2 clearfix">
<a href="<%= url %>" style="max-width: 400px;" class="font-16 task-hide fl"><%= [competition.name, competition.sub_title.presence].compact.join('——') %></a>
<div class="fr status-orange">
<img src="/images/educoder/competition/home/orange.png" class="fl">
<span class="status-tag fl">即将发布</span>
</div>
</div>
<p class="color-grey-B3 clearfix pl20 pr20 pb20"></p>
</div>
<div class="competitionsList-item-tip strongNone">
<div class="color-white font-26">
<p>即将发布</p><p>敬请期待</p>
</div>
</div>
</div>
<% end %>
<% end %>
</div>
<% else %>
<%= render :partial => "welcome/no_data" %>
<% end %>
<div class="competition-list">
<%= render 'competitions/competition_list' %>
</div>
</div>
<script>
$(function(){

@ -0,0 +1 @@
$(".competition-list").html("<%= j(render :partial => 'competitions/competition_list') %>");
Loading…
Cancel
Save