From a100193373a0d9d926792408e741f1f2a39b8bd0 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 12 Jun 2014 15:25:59 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BD=9C=E4=B8=9A=E5=8F=82=E4=B8=8E=E4=BA=BA?= =?UTF-8?q?=E5=91=98=E5=8F=AF=E4=BB=A5=E5=AF=B9=E4=BD=9C=E4=B8=9A=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E4=BF=AE=E6=94=B9=EF=BC=8C=E4=BD=86=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E5=88=A0=E9=99=A4=202.=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=88=90=E5=91=98(=E5=8F=91=E5=B8=83=E4=BA=BA=E5=91=98?= =?UTF-8?q?=E5=92=8C=E5=8F=82=E4=B8=8E=E4=BA=BA=E5=91=98)=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E5=AF=B9=E4=BD=9C=E4=B8=9A=E8=BF=9B=E8=A1=8C=E8=AF=84?= =?UTF-8?q?=E5=88=86=203.=E4=BF=AE=E6=94=B9=E8=BF=9B=E8=A1=8C=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E5=88=A0=E9=99=A4=E3=80=81=E6=B7=BB=E5=8A=A0=E3=80=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=81=E6=B7=BB=E5=8A=A0=E6=88=90=E5=91=98?= =?UTF-8?q?=E7=AD=89=E6=96=B9=E6=B3=95=E7=9A=84=E6=9D=83=E9=99=90=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 6 +++--- app/helpers/courses_helper.rb | 5 +++++ app/views/bids/_homework_list.html.erb | 10 ++++++---- app/views/homework_attach/show.html.erb | 3 ++- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index e5f9685f0..d10f09ffa 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -35,7 +35,7 @@ class HomeworkAttachController < ApplicationController #作业添加成员(参与人员) def add_homework_users - if User.current.admin? || User.current == @homework.user + if User.current.admin? || User.current.member_of?(@homework.bid.courses.first) #@homework = HomeworkAttach.find(params[:id]) if params[:membership] if params[:membership][:user_ids] @@ -59,7 +59,7 @@ class HomeworkAttachController < ApplicationController #作业删除成员(参与人员) def destory_homework_users #@homework = HomeworkAttach.find(params[:id]) - if User.current.admin? || User.current == @homework.user + if User.current.admin? || User.current.member_of?(@homework.bid.courses.first) homework_user = @homework.homework_users.where("user_id = #{params[:user_id]}").first homework_user.destroy get_homework_member @homework @@ -196,7 +196,7 @@ class HomeworkAttachController < ApplicationController def destroy #@homework = HomeworkAttach.find(params[:id]) - if User.current.admin? || User.current.member_of?(@homework.bid.courses.first) + if User.current.admin? || User.current == @homework if @homework.destroy respond_to do |format| format.html { redirect_to project_for_bid_path @homework.bid } diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index eef630996..0602e52d2 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -177,4 +177,9 @@ module CoursesHelper seem_count = homework.rates(:quality).where("rater_id = ?",User.current).count seem_count > 0 end + + #获取指定作业的所有成员 + def users_for_homework homework + homework.nil? ? [] : (homework.users + [homework.user]) + end end diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 0f605d6fa..18778f5e9 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -90,10 +90,12 @@ <% end %>