From a5e6ed0d39b825f032f2a0e4584c36854e499e25 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 30 Dec 2016 20:30:45 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E2=80=9C=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E2=80=9D=E7=9A=84=E7=9B=B8=E5=85=B3bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/contestant_works_controller.rb | 16 ++++++++++------ app/controllers/contests_controller.rb | 4 ++-- app/controllers/works_controller.rb | 2 +- app/views/users/_user_message_contest.html.erb | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/controllers/contestant_works_controller.rb b/app/controllers/contestant_works_controller.rb index a73775ae8..fd4e3264b 100644 --- a/app/controllers/contestant_works_controller.rb +++ b/app/controllers/contestant_works_controller.rb @@ -15,13 +15,17 @@ class ContestantWorksController < ApplicationController def new #更新消息 - noEvaluation = @contestwork.contest_messages.where("user_id =? and viewed =?", User.current.id, 0) - noEvaluation.update_all(:viewed => true) + if @contestwork.work_status == 1 + noEvaluation = @contestwork.contest_messages.where("user_id =? and viewed =?", User.current.id, 0) + noEvaluation.update_all(:viewed => true) - @user = User.current - @student_work = ContestantWork.new - respond_to do |format| - format.html{ render :layout => "base_contests"} + @user = User.current + @student_work = ContestantWork.new + respond_to do |format| + format.html{ render :layout => "base_contests"} + end + else + render_403 end end diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index 5295477f5..444b5b03e 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -175,11 +175,11 @@ class ContestsController < ApplicationController end case params[:agree] when 'Y' - if ContestMember.where(:user_id => apply_user.id).first.nil? + if ContestMember.where(:user_id => apply_user.id, :contest_id => applied_contest.contest_id).first.nil? member = ContestMember.new(:user_id => apply_user.id) Contest.find(applied_contest.contest_id).contest_members << member else - member = ContestMember.where(:user_id => apply_user.id).first + member = ContestMember.where(:user_id => apply_user.id, :contest_id => applied_contest.contest_id).first end contest_member_roles = member.contest_member_roles diff --git a/app/controllers/works_controller.rb b/app/controllers/works_controller.rb index 4b64e7fb1..75a30ba57 100644 --- a/app/controllers/works_controller.rb +++ b/app/controllers/works_controller.rb @@ -70,7 +70,7 @@ class WorksController < ApplicationController homework.save_attachments(params[:attachments]) render_attachment_warning_if_needed(homework) - homework.work_status = homework.publish_time > Date.today ? 0 : 1 + homework.work_status = homework.publish_time > Date.today ? 0 : (homework.end_time < Date.today ? 2 : 1) work_detail_manual = WorkDetailManual.new diff --git a/app/views/users/_user_message_contest.html.erb b/app/views/users/_user_message_contest.html.erb index c2c18837a..b0232e75c 100644 --- a/app/views/users/_user_message_contest.html.erb +++ b/app/views/users/_user_message_contest.html.erb @@ -102,7 +102,7 @@ 发布了竞赛题:
  • - <% if User.current.contestant_of_contest?(ma.contest_message.contest) && cur_user_works_for_work(ma.contest_message).nil? %> + <% if User.current.contestant_of_contest?(ma.contest_message.contest) && cur_user_works_for_work(ma.contest_message).nil? && ma.contest_message.work_status == 1 %> <%= link_to ma.contest_message.name, new_contestant_work_path(:work => ma.contest_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank',