增加搜索用户功能
This commit is contained in:
parent
d0dd6eb781
commit
2abd8187d0
|
@ -41,7 +41,7 @@ class HomeworkAttachController < ApplicationController
|
|||
end
|
||||
@homework.save
|
||||
@hoemwork_users = users_for_homework(@homework)
|
||||
@members = members_for_homework(@homework,@hoemwork_users)
|
||||
@members = members_for_homework(@homework,@hoemwork_users,params[:q])
|
||||
@members = paginateHelper @members,10
|
||||
respond_to do |format|
|
||||
format.js
|
||||
|
@ -54,7 +54,7 @@ class HomeworkAttachController < ApplicationController
|
|||
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)
|
||||
@members = members_for_homework(@homework,@hoemwork_users,params[:q])
|
||||
@members = paginateHelper @members,10
|
||||
respond_to do |format|
|
||||
format.js
|
||||
|
@ -126,11 +126,11 @@ class HomeworkAttachController < ApplicationController
|
|||
|
||||
#获取作业成员的集合
|
||||
def get_homework_member_list
|
||||
@homework = HomeworkAttach.includes(:homework_users).includes(:user).find(params[:bid_id])
|
||||
@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)
|
||||
@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
|
||||
|
@ -150,16 +150,16 @@ class HomeworkAttachController < ApplicationController
|
|||
#获取可选成员列表
|
||||
#homework:作业
|
||||
#users:该作业所有成员
|
||||
def members_for_homework homework,users
|
||||
homework.bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and user_id not in (:users)", {:role_id => [5, 10],:users => users})
|
||||
def members_for_homework homework,users,q
|
||||
homework.bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and user_id not in (:users)", {:role_id => [5, 10],:users => users}).joins(:user).where("users.login like '%#{q}%'")
|
||||
end
|
||||
|
||||
def edit
|
||||
@homework = HomeworkAttach.includes(:homework_users).includes(:user).find(params[:id])
|
||||
@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)
|
||||
@members = members_for_homework(@homework,@hoemwork_users,params[:q])
|
||||
@members = paginateHelper @members,10
|
||||
else
|
||||
render_403 :message => :notice_not_authorized
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
<fieldset>
|
||||
<legend><%= l(:label_member_new) %></legend>
|
||||
<p><%= label_tag "principal_search", l(:label_principal_search) %><%= text_field_tag 'principal_search', nil %></p>
|
||||
<%= javascript_tag "observeSearchfield('principal_search', null, '#{ escape_javascript get_homework_member_list_homework_attach_index_path(:q => params[:q], :bid_id => params[:id]||homework, :format => 'js') }')" %>
|
||||
<div id="principals_for_new_member">
|
||||
<%= render_new_members_for_homework(members) %>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue