From df19291d2ce6706640ad34ebd5e538b817201b41 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 28 Jun 2019 14:32:26 +0800 Subject: [PATCH] fix competition eroll list --- app/controllers/competitions_controller.rb | 5 ++++- app/views/competitions/_team_list.html.erb | 26 +++++++++++----------- app/views/competitions/enroll.html.erb | 6 ++--- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/app/controllers/competitions_controller.rb b/app/controllers/competitions_controller.rb index bd3134a2..b43bb5c8 100644 --- a/app/controllers/competitions_controller.rb +++ b/app/controllers/competitions_controller.rb @@ -112,7 +112,10 @@ class CompetitionsController < ApplicationController @is_enroll = CompetitionTeam.where(:id => TeamMember.where(:user_id => @user, :competition_team_id => @competition.competition_teams.map(&:id)).pluck(:competition_team_id)).reorder("created_at desc") @show_notice = (@competition.identifier == "gcc-dev-2018" || @competition.identifier == "gcc-annotation-2018") && @competition.competition_teams.joins(:team_members).where(:user_id => User.current.id).group('competition_teams.id').sum('IF(team_members.is_teacher=1, 1, 0)').values.any?(&:zero?) - @teams = paginateHelper @teams, 50 + @teams = paginateHelper @teams.includes(:user, teachers: :user, members: :user), 50 + + @minimum_staff = @competition.competition_staffs.sum(:minimum) + @maximum_staff = @competition.competition_staffs.sum(:maximum) respond_to do |format| format.js format.html diff --git a/app/views/competitions/_team_list.html.erb b/app/views/competitions/_team_list.html.erb index d4552e0f..5e75b3a4 100644 --- a/app/views/competitions/_team_list.html.erb +++ b/app/views/competitions/_team_list.html.erb @@ -5,19 +5,19 @@ <% @teams.each do |team| %>
  • <%= link_to image_tag(url_to_avatar(team.user), :width => "40", :height => "40", :class => "radius fl mr10"), user_path(team.user), :title => team.user.show_name, :target => "_blank", :alt => "用户头像" %> - <%= @competition.max_num > 1 ? team.name : team.user.show_name %> - <% if @competition.max_num > 1 %> - - <% if team.teacher_id.present? %> - <%= image_tag(url_to_avatar(team.teacher), :width => "26", :height => "26", :class => "radius fl mr4") %> - <% end %> - <% team.team_members.where("user_id != #{team.teacher_id.present? ? team.teacher_id : '-1'}")[0, 9].each do |member| %> - <%= link_to image_tag(url_to_avatar(member.user), :width => "20", :height => "20", :class => "radius fl mr4 mt3"), user_path(member.user), :title => member.user.show_name, :target => "_blank", :class => "fl", :alt => "用户头像" %> - <% end %> - <% if team.team_members.size > 9 %> - ... - <% end %> - + <%= @maximum_staff > 1 ? team.name : team.user.show_name %> + <% if @maximum_staff > 1 %> + + <% team.teachers.each do |teacher| %> + <%= link_to image_tag(url_to_avatar(teacher.user), width: 26, height: 26, class: 'radius fl mr4'), user_path(teacher.user), class: 'fl', target: '_blank', data: { 'tip-down' => "指导老师:#{teacher.user.show_name}" } %> + <% end %> + <% team.members.each do |member| %> + <%= link_to image_tag(url_to_avatar(member.user), :width => "20", :height => "20", :class => "radius fl mr4 mt3"), user_path(member.user), :title => member.user.show_name, :target => "_blank", :class => "fl", :alt => "用户头像" %> + <% end %> + <% if team.members.size > 9 %> + ... + <% end %> + <% end %> <%= team.user.school_name %> <%= format_time team.created_at %> diff --git a/app/views/competitions/enroll.html.erb b/app/views/competitions/enroll.html.erb index 8aeb3b45..ab6d5b16 100644 --- a/app/views/competitions/enroll.html.erb +++ b/app/views/competitions/enroll.html.erb @@ -1,7 +1,7 @@
    - <% if @competition.competition_staffs.sum(:minimum) > 1 %> + <% if @minimum_staff > 1 %>

    <% unless User.current.logged? %> <%= link_to "创建战队", signin_path, :remote => true, :class => "enroll-in-b enroll-in-b-green fr" %> @@ -59,7 +59,7 @@

    <% if @is_enroll.present? %>
    - <% if @competition.competition_staffs.sum(:maximum) > 1 %> + <% if @maximum_staff > 1 %>
    <% @is_enroll.each do |team| %> @@ -117,7 +117,7 @@ 搜索 战队数: 成员数: - <%= @competition.max_num > 1 ? "战队总数" : "报名人数" %>:<%= @team_count %> + <%= @maximum_staff > 1 ? "战队总数" : "报名人数" %>:<%= @team_count %>
    <%= render :partial => "competitions/team_list" %> <% else %>