From 57e2ab9ff17a910af47b21bb3c33249cce9c3b0c Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 30 Dec 2016 19:35:43 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E7=9A=84=E5=9C=A8=E7=BA=BF=E8=AF=84=E5=AE=A1=E5=88=86=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/contest_work_evaluation.rake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/tasks/contest_work_evaluation.rake b/lib/tasks/contest_work_evaluation.rake index d97d4ba3d..6d72d4f01 100644 --- a/lib/tasks/contest_work_evaluation.rake +++ b/lib/tasks/contest_work_evaluation.rake @@ -3,7 +3,10 @@ namespace :contest_work_evaluation do desc "start and end evaluation" def get_assigned_contestant_works(judges, n, index, num) - judges[(index % num) .. ((index + n - 1) % num)] + judges = judges + judges + first_index = (index * n) % num + last_index = (index * n + n - 1) % num < first_index ? ((index * n + n - 1) % num) + num : (index * n + n - 1) % num + judges[first_index .. last_index] end # 获取竞赛的评委人员 def contest_judges contest From 6d894c53d50408e057163c912278909bab765649 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 30 Dec 2016 19:53:00 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E7=9A=84=E7=BD=AE=E9=A1=B6=E5=92=8C=E9=94=81=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/message.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/message.rb b/app/models/message.rb index 177b5f7ee..39902d757 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -103,8 +103,10 @@ class Message < ActiveRecord::Base :if => lambda {|message, user| if message.project user.allowed_to?(:edit_messages, message.project) - else + elsif message.course user.allowed_to?(:edit_messages, message.course) + elsif message.contest + user.admin_of_contest?(message.contest) end } From 0f4e3f0189c549f52869a4d630fb968e87e93bdb Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 30 Dec 2016 20:29:54 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=EF=BC=9A=E8=BF=9B?= =?UTF-8?q?=E5=85=A5=E9=80=9A=E7=9F=A5=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E5=A6=82=E5=9B=BE=E5=B7=A6=E4=BE=A7=E5=AF=BC?= =?UTF-8?q?=E8=88=AA=E7=9A=84=E2=80=9C=E8=AE=A8=E8=AE=BA=E5=8C=BA=E2=80=9D?= =?UTF-8?q?=E5=8D=B4=E5=8A=A0=E4=BA=AE=E6=98=BE=E7=A4=BA=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/news_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 87b021678..e65f4c768 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -273,7 +273,7 @@ class NewsController < ApplicationController elsif @news.contest_id @contest = Contest.find(@news.contest_id) if @contest - @left_nav_type = 4 + @left_nav_type = 5 respond_to do |format| format.js format.html {render :layout => 'base_contests'} From a5e6ed0d39b825f032f2a0e4584c36854e499e25 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 30 Dec 2016 20:30:45 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E2=80=9C=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E2=80=9D=E7=9A=84=E7=9B=B8=E5=85=B3bug=E4=BF=AE?= =?UTF-8?q?=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', From a60c83fe005df589608aeda321f2da885828af02 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 30 Dec 2016 20:35:40 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E8=B6=85=E7=BA=A7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E8=A6=81=E6=9C=89=E5=AF=B9=E7=AB=9E=E8=B5=9B=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E7=BC=96=E8=BE=91=E3=80=81=E5=88=A0=E9=99=A4=E7=9A=84?= =?UTF-8?q?=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/news/_contest_show.html.erb | 4 ++-- app/views/users/_contest_news.html.erb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/news/_contest_show.html.erb b/app/views/news/_contest_show.html.erb index a74007f00..bb846ef43 100644 --- a/app/views/news/_contest_show.html.erb +++ b/app/views/news/_contest_show.html.erb @@ -32,14 +32,14 @@ l(:button_edit), {:action => 'edit', :id => @news}, :class => 'postOptionLink' - ) if User.current == @news.author || User.current.admin_of_contest?(@contest) %> + ) if User.current == @news.author || User.current.admin_of_contest?(@contest) || User.current.admin? %>
  • <%= delete_link( news_path(@news), :data => {:confirm => l(:text_are_you_sure)}, :class => 'postOptionLink' - ) if User.current == @news.author || User.current.admin_of_contest?(@contest) %> + ) if User.current == @news.author || User.current.admin_of_contest?(@contest) || User.current.admin? %>
  • diff --git a/app/views/users/_contest_news.html.erb b/app/views/users/_contest_news.html.erb index b97932124..70c71017a 100644 --- a/app/views/users/_contest_news.html.erb +++ b/app/views/users/_contest_news.html.erb @@ -45,14 +45,14 @@ l(:button_edit), {controller:'news', :action => 'edit', :id => activity.id}, :class => 'postOptionLink' - ) if User.current == activity.author || User.current.admin_of_contest?(activity.contest) %> + ) if User.current == activity.author || User.current.admin_of_contest?(activity.contest) || User.current.admin? %>
  • <%= delete_link( news_path(activity), :data => {:confirm => l(:text_are_you_sure)}, :class => 'postOptionLink' - ) if User.current == activity.author || User.current.admin_of_contest?(activity.contest) %> + ) if User.current == activity.author || User.current.admin_of_contest?(activity.contest) || User.current.admin? %>
  • <% end %> From 055b05bac9fda9da57da5f28aedc9b8a0759b5ec Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 30 Dec 2016 20:42:41 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E5=88=9B=E5=BB=BA=E8=80=85=E5=8A=A0=E4=B8=8A=E9=93=BE?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_contest_list_contents.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/_contest_list_contents.html.erb b/app/views/users/_contest_list_contents.html.erb index 3d9b290c8..b887d87fb 100644 --- a/app/views/users/_contest_list_contents.html.erb +++ b/app/views/users/_contest_list_contents.html.erb @@ -11,7 +11,7 @@

    更新时间:<%= format_date(contest.updated_at) %>     - 创建者:<%= contest.user.show_name %> + 创建者:<%= link_to contest.user.show_name, user_path(contest.user) %>

    From 9d6f75fb3ef91140b7bde33792020822fa886c4e Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 30 Dec 2016 20:59:13 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E6=9C=89=E6=9D=83=E9=99=90=E8=AE=BF=E9=97=AE=E7=AB=9E?= =?UTF-8?q?=E8=B5=9B=E4=BD=9C=E5=93=81=E5=85=B3=E8=81=94=E7=9A=84=E7=A7=81?= =?UTF-8?q?=E6=9C=89=E9=A1=B9=E7=9B=AE=EF=BC=8C=E4=BD=86=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E5=85=B3=E8=81=94=E9=A1=B9=E7=9B=AE=E7=9A=84=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E5=8D=B4=E6=8A=A5403?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/boards_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 493b313cf..8d9d1c20b 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -33,7 +33,7 @@ class BoardsController < ApplicationController #modify by nwb @flag = params[:flag] || false if @project - if !@project.is_public? && !User.current.member_of?(@project) && !User.current.admin? + if !@project.is_public? && !User.current.member_of?(@project) && !User.current.admin? && !User.current.allowed_to?(:view_messages, @project) render_403 else @boards = @project.boards.includes(:last_message => :author).all