dev_bj
caishi 5 years ago
commit 374d91449c

@ -2,7 +2,7 @@
class Competition < ActiveRecord::Base
# status 0下架 1上架
attr_accessible :end_time, :identifier, :name, :online_time, :start_time, :status, :visits, :competition_lists_count,
:min_num, :max_num, :enroll_end_time, :sub_title
:min_num, :max_num, :enroll_end_time, :sub_title, :published_at
has_many :competition_modules, :dependent => :destroy
has_many :competition_stages, :dependent => :destroy

@ -66,18 +66,6 @@ class Shixun < ActiveRecord::Base
#scope :visible, -> { where(status: -1) }
after_create :send_tiding
def description
self.has_attribute?(:description) ? self[:description] : ""
end
def propaedeutics
self.has_attribute?(:propaedeutics) ? self[:propaedeutics] : ""
end
def evaluate_script
self.has_attribute?(:evaluate_script) ? self[:evaluate_script] : ""
end
def should_compile?
self.mirror_repositories.published_main_mirror.first.try(:should_compile)
end

@ -1,47 +1,71 @@
<div class="openSource_1" style="background: url('/images/educoder/competition/qg/qg_open_1.png') no-repeat top center;"></div>
<div class="openSource_2" style="background: url('/images/educoder/competition/qg/qg_open_2.png') no-repeat top center;"></div>
<div class="openSource_3" style="background: url('/images/educoder/competition/qg/qg_open_3.png') no-repeat top center;">
<% index = 0 %>
<div class="openSource_1" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<% index += 1 %>
<div class="openSource_2" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<% index += 1 %>
<% @competition.competition_stages.each_with_index do |stage, i| %>
<div class="openSource_<%= index + 1 %>" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;">
<%
first_section = stage.competition_stage_sections[0]
second_section = stage.competition_stage_sections[1]
%>
<div class="enter_panel" style="height: 285px">
<ul>
<p class="font-22 enter_title padding30 clearfix">
<span class="fl ml30">
<span class="mr20 font-bd">开源任务征集</span>
<span>2019年7月1日~2019年7月20日</span>
<span class="mr20 font-bd"><%= first_section.try(:name) %></span>
<span><%= first_section.start_time.try(:strftime, '%Y年%m月%d日') %> ~ <%= first_section.end_time.try(:strftime, '%Y年%m月%d日') %></span>
</span>
<span class="fr mr30">
<span class="mr20 font-bd">开源任务发布</span>
<span>2019年7月21日</span>
<span class="mr20 font-bd"><%= second_section.try(:name) %></span>
<span><%= second_section.try(:start_time).try(:strftime, '%Y年%m月%d日') %> ~ <%= second_section.try(:end_time).try(:strftime, '%Y年%m月%d日') %></span>
</span>
</p>
<li class="inline enter_btn mt20">
<a href="javascript:void(0);" class="li-1">项目名称1</a>
<a href="javascript:void(0);" class="li-1">项目名称2</a>
<a href="javascript:void(0);" class="li-1">项目名称3</a>
<% is_start = Time.now > first_section.start_time %>
<% first_section.competition_entries.each_with_index do |entry, j| %>
<%
competition_url = User.current.logged? ? "#{entry.url}?eid=#{User.current.id}" : "#{entry.url}"
btn_url = is_start ? "#{competition_url}" : "javascript:void(0);"
%>
<a class="li-1 <%= is_start ? 'active' : '' %>"
href="javascript:void(0);"
data-url="<%= btn_url %>"><%= entry.name %></a>
<% end %>
</li>
</ul>
</div>
</div>
<div class="openSource_4" style="background: url('/images/educoder/competition/qg/qg_open_4.png') no-repeat top center;">
<div class="enter_panel" style="height: 285px">
<ul>
<p class="font-22 enter_title padding30 clearfix">
<span class="fl ml30">
<span class="mr20 font-bd">开源开发阶段</span>
<span>2019年7月1日~2019年7月20日</span>
</span>
<span class="fr mr30">
<span class="mr20 font-bd">成绩发布阶段</span>
<span>2019年7月21日</span>
</span>
</p>
<li class="inline enter_btn mt20">
<a href="javascript:void(0);" class="li-1">项目名称1</a>
<a href="javascript:void(0);" class="li-1">项目名称2</a>
<a href="javascript:void(0);" class="li-1">项目名称3</a>
</li>
</ul>
</div>
</div>
<div class="openSource_5" style="background: url('/images/educoder/competition/qg/qg_open_5.png') no-repeat top center;"></div>
<div class="openSource_6" style="background: url('/images/educoder/competition/qg/qg_open_6.png') no-repeat top center;"></div>
<div class="openSource_7" style="background: url('/images/educoder/competition/qg/qg_open_7.png') no-repeat top center;"></div>
<% index += 1 %>
<% end %>
<div class="openSource_5" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<% index += 1 %>
<div class="openSource_6" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<% index += 1 %>
<div class="openSource_7" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<script>
$(function(){
var userLogged = <%= @user.present? && @user.logged? %>;
var userEnrolled = <%= @enrolled %>;
$(".enter_btn .li-1.active").on("click", function(){
var url = $(this).data("url");
if (!userLogged) {
location.href = "<%= signin_url(back_url: competition_path(id: params[:id])) %>";
return;
}
if (!userEnrolled) {
sure_box_redirect_without_newtab_btn("<%= enroll_competition_path(id: params[:id]) %>", "完成报名后即可参赛", "我要报名");
return;
}
var newTab = window.open("_blank");
newTab.location = url;
})
})
</script>

@ -69,13 +69,14 @@
</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="javascript:void(0)" class="competition-Img">
<a href="<%= url %>" class="competition-Img">
<%= image_tag(url_to_avatar(competition), :width => "100%", :height => "100%") %>
</a>
<div class="pt20 pl20 mb10 clearfix">
<a href="javascript:void(0)" style="max-width: 400px;" class="font-16 task-hide fl"><%= [competition.name, competition.sub_title.presence].compact.join('——') %></a>
<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>
@ -98,10 +99,12 @@
</div>
<script>
$(function(){
$(".competitionsList-item").on("hover",function(){
<% unless admin_or_business? %>
$(".competitionsList-item").hover(function(){
$(this).find(".competitionsList-item-tip").removeClass("strongNone");
},function(){
$(this).find(".competitionsList-item-tip").addClass("strongNone");
})
});
<% end %>
})
</script>

@ -13,5 +13,7 @@
<%= render :partial => "gq_second_code_competition" %>
<% elsif @competition.identifier == "gcc-course-2019" %>
<%= render :partial => "qg_second_course_competition" %>
<% elsif @competition.identifier == "gcc-project-2019" %>
<%= render :partial => "qg_second_opensource" %>
<% end %>
</div>

@ -0,0 +1,5 @@
FactoryGirl.define do
factory :shixun_info do
end
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe ShixunInfo, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save