From 65f1d1d35657a75e33b41c18f7c83e6e9790c34d Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 13 Jul 2019 08:56:48 +0800 Subject: [PATCH 1/6] competition --- app/controllers/competition_teams_controller.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/controllers/competition_teams_controller.rb b/app/controllers/competition_teams_controller.rb index 5b68c433..4c558379 100644 --- a/app/controllers/competition_teams_controller.rb +++ b/app/controllers/competition_teams_controller.rb @@ -206,7 +206,7 @@ class CompetitionTeamsController < ApplicationController teacher_staff = @competition.competition_staffs.where(category: 'teacher').first if teacher_staff.blank? - @status, @message = -1, '该竞赛不能配备导师' + @status, @message = -1, '老师不能参加该竞赛' return end @@ -217,7 +217,10 @@ class CompetitionTeamsController < ApplicationController team.team_members.create!(user_id: User.current.id, role: 3, competition_id: @competition.id, is_teacher: true) else max_member_count = @competition.competition_staffs.where('category != "teacher"').sum(:maximum) - if team.members.count + 1 > max_member_count + if max_member_count.zero? + @status, @message = -1, '学生不能参加该竞赛' + return + elsif team.members.count + 1 > max_member_count @status, @message = -1, '该战队成员人数已满' return end @@ -279,7 +282,7 @@ class CompetitionTeamsController < ApplicationController teacher_count += 1 if is_teacher # 检查老师数量 if teacher_staff.blank? && teacher_count > 0 - @status, @message = -1, '该竞赛不能配备导师' + @status, @message = -1, '老师不能参与该竞赛' return false elsif teacher_staff.present? && (teacher_staff.minimum > teacher_count || teacher_staff.maximum < teacher_count) @status = -1 @@ -293,7 +296,10 @@ class CompetitionTeamsController < ApplicationController member_count = params[:member_ids].try(:size) || 0 member_count += 1 unless is_teacher # 检查成员数据 - if min_member_count > member_count || member_count > max_member_count + if member_relations.count.zero? && member_count > 0 + @status, @message = -1, '学生不能参与该竞赛' + return false + elsif min_member_count > member_count || member_count > max_member_count @status = -1 @message = min_member_count == max_member_count ? "成员数量应为#{max_member_count}人" : "成员数量应为#{min_member_count}-#{max_member_count}人" return false From 6390815ab56780c689edf35b8219fbee13f17c7a Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 13 Jul 2019 09:00:41 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=85=B3=E5=8D=A1?= =?UTF-8?q?=E7=9A=84=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/games_service.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index 7cfe9107..ece6de68 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -530,7 +530,7 @@ class GamesService game = Game.select([:myshixun_id, :status, :challenge_id, :id, :evaluate_count]).find_by_identifier(params[:identifier]) myshixun = Myshixun.select([:updated_at, :gpid, :id, :shixun_id]).find(game.myshixun_id) shixun = Shixun.select([:id, :evaluate_script, :webssh, :exec_time, :sigle_training, :identifier, :status]).find(myshixun.shixun_id) - game_challenge = Challenge.select([:id, :position, :picture_path]).find(game.challenge_id) + game_challenge = Challenge.select([:id, :position, :picture_path, :exec_time]).find(game.challenge_id) # 更新评测次数 game.update_column(:evaluate_count, (game.evaluate_count.to_i + 1)) @@ -573,7 +573,7 @@ class GamesService params = {:tpiID => "#{myshixun.id}", :tpiGitURL => "#{gitUrl}", :buildID => "#{taskId}",:instanceChallenge => "#{step}", :testCases => "#{testCases}", :resubmit => "#{resubmit}", :times => params[:first].to_i, :podType => shixun.webssh, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}", :tpmScript => "#{tpmScript}", - :timeLimit => "#{shixun.exec_time}", :content_modified => content_modified, :persistenceName => shixun.identifier, + :timeLimit => "#{game_challenge.exec_time}", :content_modified => content_modified, :persistenceName => shixun.identifier, :isPublished => (shixun.status < 2 ? 0 : 1), :sec_key => params[:sec_key]} # 评测有文件输出的需要特殊传字段 path:表示文件存储的位置 From 7fe3a0888a9aad64f0a63b74493daf1d6a918a8b Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 13 Jul 2019 09:21:51 +0800 Subject: [PATCH 3/6] fix --- app/controllers/account_controller.rb | 2 +- app/models/verification_code.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 7e474611..0476b8f2 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -787,7 +787,7 @@ class AccountController < ApplicationController else req[:status] = 2 end - elsif params[:type] == 9 + elsif type == 9 if params[:value] =~ /^1\d{10}$/ begin verification_code = code.sample(6).join diff --git a/app/models/verification_code.rb b/app/models/verification_code.rb index 4bc473b3..0dd3863d 100644 --- a/app/models/verification_code.rb +++ b/app/models/verification_code.rb @@ -1,6 +1,6 @@ class VerificationCode < ActiveRecord::Base #status:发送状态 - #code_type:发送类型:type 1:注册手机验证码 2:找回密码手机验证码 3:找回密码邮箱验证码 4:绑定手机 5:绑定邮箱 6:手机验证码登录 7:邮箱验证码登录 8:邮箱注册验证码 + #code_type:发送类型:type 1:注册手机验证码 2:找回密码手机验证码 3:找回密码邮箱验证码 4:绑定手机 5:绑定邮箱 6:手机验证码登录 7:邮箱验证码登录 8:邮箱注册验证码, 9:验证手机号有效 attr_accessible :code, :code_type, :email, :phone, :status def valid_code? From be1b72162b48d34d1a36a64b57dc63db813683b3 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 13 Jul 2019 09:29:47 +0800 Subject: [PATCH 4/6] fix project package content --- app/api/mobile/entities/project_package.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/api/mobile/entities/project_package.rb b/app/api/mobile/entities/project_package.rb index 7313abfc..6bfbef18 100644 --- a/app/api/mobile/entities/project_package.rb +++ b/app/api/mobile/entities/project_package.rb @@ -6,6 +6,7 @@ module Mobile expose :id expose :title + expose :content expose :category expose :status expose :visit_count, if: { type: :index } From f8d12591d3fa7841bd156d7f912dc28130291c08 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 13 Jul 2019 09:42:22 +0800 Subject: [PATCH 5/6] fix --- app/helpers/application_helper.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 87a0e22b..7192d736 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -7461,7 +7461,11 @@ def tiding_url tiding when 'Library' tiding.tiding_type == 'Apply' ? library_applies_path : library_path(tiding.container_id) when 'ProjectPackage' - tiding.container.present? ? "/project_packages/#{tiding.container_id}" : 'javascript:void(0)' + if tiding.container.present? + tiding.tiding_type == 'Apply' ? project_package_applies_path : "/project_packages/#{tiding.container_id}" + else + 'javascript:void(0)' + end end end From b18d9aef0145497cc3a2f9b7b2dc8f1b55e7059d Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 13 Jul 2019 09:48:56 +0800 Subject: [PATCH 6/6] fix --- app/api/mobile/apis/project_packages.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/api/mobile/apis/project_packages.rb b/app/api/mobile/apis/project_packages.rb index e619ce74..1d2b4f69 100644 --- a/app/api/mobile/apis/project_packages.rb +++ b/app/api/mobile/apis/project_packages.rb @@ -59,6 +59,8 @@ module Mobile error!('403 forbidden', 403) end + current_package.increment_visit_count! + present current_package, with: Mobile::Entities::ProjectPackage, type: :show, user: user end