From 29fa624e9dbc10af44cf908e0e530d2c370e8165 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 11 Jun 2014 17:41:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=81=E8=A3=85=E8=8E=B7=E5=8F=96=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E6=88=90=E5=91=98=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 09d357ebf..abbb47c1c 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -18,6 +18,13 @@ class HomeworkAttachController < ApplicationController @project = @homework.bid.courses[0] end + #获取作业的成员 + def get_homework_member homework + @hoemwork_users = users_for_homework(@homework) + @members = members_for_homework(@homework,@hoemwork_users,params[:q]) + @members = paginateHelper @members,10 + end + def index @homeworks = HomeworkAttach.all respond_to do |format| @@ -40,9 +47,7 @@ class HomeworkAttachController < ApplicationController end end @homework.save - @hoemwork_users = users_for_homework(@homework) - @members = members_for_homework(@homework,@hoemwork_users,params[:q]) - @members = paginateHelper @members,10 + get_homework_member @homework respond_to do |format| format.js end @@ -57,9 +62,7 @@ class HomeworkAttachController < ApplicationController if User.current.admin? || User.current == @homework.user homework_user = @homework.homework_users.where("user_id = #{params[:user_id]}").first homework_user.destroy - @hoemwork_users = users_for_homework(@homework) - @members = members_for_homework(@homework,@hoemwork_users,params[:q]) - @members = paginateHelper @members,10 + get_homework_member @homework respond_to do |format| format.js end @@ -136,11 +139,7 @@ class HomeworkAttachController < ApplicationController @homework = HomeworkAttach.find(params[:bid_id]) course = @homework.bid.courses.first if User.current.admin? || User.current.member_of?(course) - @hoemwork_users = users_for_homework(@homework) - @members = members_for_homework(@homework,@hoemwork_users,params[:q]) - #该课程的学生的集合 - #@members = course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => [5, 10]}) - @members = paginateHelper @members,10 + get_homework_member @homework else raise "error" end @@ -165,9 +164,7 @@ class HomeworkAttachController < ApplicationController #@homework = HomeworkAttach.find(params[:id]) if User.current.admin? || User.current.member_of?(@homework.bid.courses.first) #@members = @homework.bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => [5, 10]}) - @hoemwork_users = users_for_homework(@homework) - @members = members_for_homework(@homework,@hoemwork_users,params[:q]) - @members = paginateHelper @members,10 + get_homework_member @homework else render_403 :message => :notice_not_authorized end