diff --git a/app/controllers/competitions_controller.rb b/app/controllers/competitions_controller.rb index a868cbf0..86ea9e08 100644 --- a/app/controllers/competitions_controller.rb +++ b/app/controllers/competitions_controller.rb @@ -25,7 +25,15 @@ class CompetitionsController < ApplicationController end def index - @competitions = Competition.where('status = 1 or published_at is not null').reorder("published_at desc, online_time desc") + competitions = Competition.where('status = 1 or published_at is not null') + + case params[:category] + when 'progressing' then + competitions = competitions.where('end_time > NOW()') + when 'ended' then + competitions = competitions.where('end_time < NOW()') + end + @competitions = competitions.reorder("published_at desc, online_time desc") respond_to do |format| format.html { render :layout => "base_edu"} format.js diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index d3336e08..dc8f6dea 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1083,7 +1083,12 @@ end def enroll_list @order = params[:order].blank? ? "desc" : params[:order] @competition = Competition.where(:id => params[:competition]).first - @team_members = @competition.team_members.includes(:user => [:user_extensions => [:school]]) + + @only_teacher = @competition.competition_staffs.count == 1 && @competition.competition_staffs.first.category == 'teacher' + + @team_members = @competition.team_members + @team_members = @team_members.where(is_teacher: false) unless @only_teacher # 只有老师报名时才显示老师,此时老师作为队员 + if params[:school] || params[:location] school_ids = School.where("schools.name like '%#{params[:school]}%'").pluck(:id) school_ids = school_ids.size == 0 ? "(-1)" : "(" + school_ids.join(",") + ")" @@ -1093,7 +1098,7 @@ end @page = params[:page] || 1 @team_members = @team_members.reorder("team_members.created_at #{@order}") all_members = @team_members - @team_members = paginateHelper @team_members, 50 + @team_members = paginateHelper(@team_members.includes(competition_team: [:user, teachers: :user], user: { user_extensions: :school }), 50) respond_to do |format| format.js format.html diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 345dfadc..39298061 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2996,6 +2996,8 @@ module ApplicationHelper else title << "教学案例" end + elsif params[:controller] == "project_packages" + title << "众包社区" elsif @course title << (@course.name.nil? ? "课堂" : @course.name) elsif params[:controller] == "homework_bank" || params[:controller] == "question_banks" || params[:controller] == "exercise_bank" @@ -7468,7 +7470,7 @@ def tiding_url tiding tiding.tiding_type == 'Apply' ? library_applies_path : library_path(tiding.container_id) when 'ProjectPackage' if tiding.container.present? - tiding.tiding_type == 'Apply' ? project_package_applies_path : "/project_packages/#{tiding.container_id}" + tiding.tiding_type == 'Apply' ? project_package_applies_path : "/crowdsourcing/#{tiding.container_id}" else 'javascript:void(0)' end diff --git a/app/helpers/libraries_helper.rb b/app/helpers/libraries_helper.rb index 4d6956b7..e2e74324 100644 --- a/app/helpers/libraries_helper.rb +++ b/app/helpers/libraries_helper.rb @@ -2,7 +2,7 @@ module LibrariesHelper def show_library_tags(library) html = '' library.library_tags.each do |tag| - html += content_tag(:span, tag.name, class: "edu-filter-btn fl cdefault mt3 ml10 " + library_tag_class(tag)) + html += content_tag(:span, tag.name, class: "edu-filter-btn fl cdefault mt3 ml10 #{library_tag_class(tag)}") end raw html diff --git a/app/views/competitions/_competition_list.html.erb b/app/views/competitions/_competition_list.html.erb new file mode 100644 index 00000000..13e8d3c8 --- /dev/null +++ b/app/views/competitions/_competition_list.html.erb @@ -0,0 +1,100 @@ +<% if @competitions.count > 0 %> +
+ <%= format_date competition.start_time %> ~ <%= com_end_date competition.end_time %> + + <%= competition.visits %> + <% if competition.member_count > 0 %> + + + <%= competition.identifier == "hn" ? 1125 : competition.member_count %> + + + <% end %> + +
+即将发布
敬请期待
+- <%= format_date competition.start_time %> ~ <%= com_end_date competition.end_time %> - - <%= competition.visits %> - <% if competition.member_count > 0 %> - - - <%= competition.identifier == "hn" ? 1125 : competition.member_count %> - - - <% end %> - -
-即将发布
敬请期待
-