From 1ae15fedad5b143386f6d767e6fefb57d541f91e Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 5 Jul 2019 14:19:05 +0800 Subject: [PATCH 1/3] competition project 2019 --- app/models/competition.rb | 2 +- .../_qg_second_opensource.html.erb | 92 ++++++++++++------- app/views/competitions/index.html.erb | 11 ++- app/views/competitions/show.html.erb | 2 + 4 files changed, 68 insertions(+), 39 deletions(-) diff --git a/app/models/competition.rb b/app/models/competition.rb index 96747b0b..7ccf067b 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -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 diff --git a/app/views/competitions/_qg_second_opensource.html.erb b/app/views/competitions/_qg_second_opensource.html.erb index a3384f6b..ec05b3c5 100644 --- a/app/views/competitions/_qg_second_opensource.html.erb +++ b/app/views/competitions/_qg_second_opensource.html.erb @@ -1,47 +1,71 @@ -
-
-
+<% index = 0 %> +
+<% index += 1 %> +
+<% index += 1 %> + +<% @competition.competition_stages.each_with_index do |stage, i| %> +
+ <% + first_section = stage.competition_stage_sections[0] + second_section = stage.competition_stage_sections[1] + %>

    - 开源任务征集 - 2019年7月1日~2019年7月20日 + <%= first_section.try(:name) %> + <%= first_section.start_time.try(:strftime, '%Y年%m月%d日') %> ~ <%= first_section.end_time.try(:strftime, '%Y年%m月%d日') %> - 开源任务发布 - 2019年7月21日 + <%= second_section.try(:name) %> + <%= second_section.try(:start_time).try(:strftime, '%Y年%m月%d日') %> ~ <%= second_section.try(:end_time).try(:strftime, '%Y年%m月%d日') %>

  • - 项目名称1 - 项目名称2 - 项目名称3 + <% 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);" + %> + <%= entry.name %> + <% end %>
-
-
- -
-
-
-
-
\ No newline at end of file +<% index += 1 %> +<% end %> + +
+<% index += 1 %> +
+<% index += 1 %> +
+ + \ No newline at end of file diff --git a/app/views/competitions/index.html.erb b/app/views/competitions/index.html.erb index 9332dda9..b95bec63 100644 --- a/app/views/competitions/index.html.erb +++ b/app/views/competitions/index.html.erb @@ -69,13 +69,14 @@
<% elsif competition.published_at.present? %> + <% url = admin_or_business? ? competition_path(competition) : 'javascript:void(0)' %>
- + <%= image_tag(url_to_avatar(competition), :width => "100%", :height => "100%") %>
- <%= [competition.name, competition.sub_title.presence].compact.join('——') %> + <%= [competition.name, competition.sub_title.presence].compact.join('——') %>
即将发布 @@ -98,10 +99,12 @@
diff --git a/app/views/competitions/show.html.erb b/app/views/competitions/show.html.erb index 0df98a24..28200db3 100644 --- a/app/views/competitions/show.html.erb +++ b/app/views/competitions/show.html.erb @@ -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 %>
\ No newline at end of file From 2510631db92c92494dffe0532cfdc6e23e86c05a Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 5 Jul 2019 14:22:40 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/shixun.rb | 1 + app/models/shixun_info.rb | 4 ++++ ...aluate_script_and_description_for_shixuns.rb | 17 +++++++++++++++++ spec/factories/shixun_infos.rb | 5 +++++ spec/models/shixun_info_spec.rb | 5 +++++ 5 files changed, 32 insertions(+) create mode 100644 app/models/shixun_info.rb create mode 100644 db/migrate/20190705061233_add_evaluate_script_and_description_for_shixuns.rb create mode 100644 spec/factories/shixun_infos.rb create mode 100644 spec/models/shixun_info_spec.rb diff --git a/app/models/shixun.rb b/app/models/shixun.rb index fe9a00b1..6a83c5c4 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -53,6 +53,7 @@ class Shixun < ActiveRecord::Base has_many :tag_repertoires, :through => :shixun_tag_repertoires has_many :shixun_tag_repertoires, :dependent => :destroy has_many :shixun_service_configs, :dependent => :destroy + has_one :shixun_info, :dependent => :destroy scope :visible, lambda{where(status: [2,3])} scope :min, lambda { select([:id, :name, :gpid, :modify_time, :reset_time, :language, :status, :identifier, diff --git a/app/models/shixun_info.rb b/app/models/shixun_info.rb new file mode 100644 index 00000000..a87c0a85 --- /dev/null +++ b/app/models/shixun_info.rb @@ -0,0 +1,4 @@ +class ShixunInfo < ActiveRecord::Base + # attr_accessible :title, :body + belongs_to :shixun +end diff --git a/db/migrate/20190705061233_add_evaluate_script_and_description_for_shixuns.rb b/db/migrate/20190705061233_add_evaluate_script_and_description_for_shixuns.rb new file mode 100644 index 00000000..eaeed889 --- /dev/null +++ b/db/migrate/20190705061233_add_evaluate_script_and_description_for_shixuns.rb @@ -0,0 +1,17 @@ +class AddEvaluateScriptAndDescriptionForShixuns < ActiveRecord::Migration + def up + add_column :shixuns, :evaluate_script, :text + add_column :shixuns, :description, :text + add_column :shixuns, :propaedeutics, :text + + shixuns = Shixun.where(nil).unscoped + shixuns.find_each do |shixun| + shixun.update_attributes(evaluate_script: shixun.shixun_info.try(:evaluate_script), + description: shixun.shixun_info.try(:description), + propaedeutics: shixun.shixun_info.try(:description)) + end + end + + def down + end +end diff --git a/spec/factories/shixun_infos.rb b/spec/factories/shixun_infos.rb new file mode 100644 index 00000000..35c80a06 --- /dev/null +++ b/spec/factories/shixun_infos.rb @@ -0,0 +1,5 @@ +FactoryGirl.define do + factory :shixun_info do + + end +end diff --git a/spec/models/shixun_info_spec.rb b/spec/models/shixun_info_spec.rb new file mode 100644 index 00000000..988bdeae --- /dev/null +++ b/spec/models/shixun_info_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe ShixunInfo, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 71300897a5eed4cb3ad3535dca41eb64909e8e83 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 5 Jul 2019 14:36:56 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/shixun.rb | 13 ------------- app/models/shixun_info.rb | 4 ---- ...aluate_script_and_description_for_shixuns.rb | 17 ----------------- 3 files changed, 34 deletions(-) delete mode 100644 app/models/shixun_info.rb delete mode 100644 db/migrate/20190705061233_add_evaluate_script_and_description_for_shixuns.rb diff --git a/app/models/shixun.rb b/app/models/shixun.rb index 6a83c5c4..0d201ed3 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -53,7 +53,6 @@ class Shixun < ActiveRecord::Base has_many :tag_repertoires, :through => :shixun_tag_repertoires has_many :shixun_tag_repertoires, :dependent => :destroy has_many :shixun_service_configs, :dependent => :destroy - has_one :shixun_info, :dependent => :destroy scope :visible, lambda{where(status: [2,3])} scope :min, lambda { select([:id, :name, :gpid, :modify_time, :reset_time, :language, :status, :identifier, @@ -67,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 diff --git a/app/models/shixun_info.rb b/app/models/shixun_info.rb deleted file mode 100644 index a87c0a85..00000000 --- a/app/models/shixun_info.rb +++ /dev/null @@ -1,4 +0,0 @@ -class ShixunInfo < ActiveRecord::Base - # attr_accessible :title, :body - belongs_to :shixun -end diff --git a/db/migrate/20190705061233_add_evaluate_script_and_description_for_shixuns.rb b/db/migrate/20190705061233_add_evaluate_script_and_description_for_shixuns.rb deleted file mode 100644 index eaeed889..00000000 --- a/db/migrate/20190705061233_add_evaluate_script_and_description_for_shixuns.rb +++ /dev/null @@ -1,17 +0,0 @@ -class AddEvaluateScriptAndDescriptionForShixuns < ActiveRecord::Migration - def up - add_column :shixuns, :evaluate_script, :text - add_column :shixuns, :description, :text - add_column :shixuns, :propaedeutics, :text - - shixuns = Shixun.where(nil).unscoped - shixuns.find_each do |shixun| - shixun.update_attributes(evaluate_script: shixun.shixun_info.try(:evaluate_script), - description: shixun.shixun_info.try(:description), - propaedeutics: shixun.shixun_info.try(:description)) - end - end - - def down - end -end