Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
nieguanghui 2013-11-04 22:01:06 +08:00
commit 5d83a03e5f
4 changed files with 51 additions and 63 deletions

View File

@ -760,24 +760,45 @@ class ProjectsController < ApplicationController
end end
#by young #by young
include CoursesHelper
def member def member
## 有角色参数的才是课程,没有的就是项目
@render_file = 'member_list'
# 判断是否课程
if @project.project_type == 1 if @project.project_type == 1
render :layout => 'base_courses' case params[:role]
when '1'
@subPage_title = l :label_teacher_list
@members = searchTeacherAndAssistant(@project)
when '2'
@subPage_title = l :label_student_list
@members = searchStudent(@project)
else
@subPage_title = 'unKown'
@members = []
end
else
roles = Role.find_all_givable
@subPage_title = l :label_member_list
@members = @project.member_principals.includes(:roles, :principal).all
@members = sort_project_members(@project, @members)
end end
# roles = Role.find_all_givable
# members = @project.member_principals.includes(:roles, :principal).all.sort render :layout => 'base_courses' if @project.project_type == 1
# end
# users = UserGrade.find_by_sql("select * from user_grades where project_id = #{@project.id}").sort {|a,b| a[:grade] <=> b[:grade]}
# def sort_project_members project, members
# temp = [] #userGrade = UserGrade.where(:project_id => project.id)
# users.each do |user| users = UserGrade.where(:project_id => project.id).order('grade DESC').joins("LEFT JOIN users ON users.id = user_grades.id")
# members.each do |member| memberlist = []
# if member[:user_id] == user[:user_id] users.each do |user|
# temp << member members.each do |member|
# end if member[:user_id] == user[:user_id]
# end memberlist << member
# end end
# temps = temp.reverse end
end
memberlist
end end
# def news # def news

View File

@ -9,17 +9,8 @@
<%= content_tag "div", link_to_user(member.principal), :class => "nomargin avatar_name" %> <%= content_tag "div", link_to_user(member.principal), :class => "nomargin avatar_name" %>
<% if @project.project_type == 1 %> <% if @project.project_type == 1 %>
<div class ="clear avatar_name"> <div class ="clear avatar_name"> &nbsp;
<p> <p>
<% if member.roles.sort.collect(&:to_s).join(', ') =='Manager' %>
<%= l(:label_teacher) %>
<% elsif member.roles.sort.collect(&:to_s).join(', ') =='Reporter' %>
<%= l(:label_student) %>
<% elsif member.roles.sort.collect(&:to_s).join(', ') =='TA' %>
<%= l(:label_TA) %>
<% else %>
<% end %>
</p> </p>
</div> </div>
<% else%> <% else%>

View File

@ -1,36 +1,10 @@
<div class="member_header"> <div class="member_header">
<p> <p>
<%= l(:label_member_list) if params[:role].blank? %> <%= @subPage_title %>
</p> </p>
</div> </div>
<div class="member_content"> <div class="member_content">
<%= error_messages_for 'member' %> <%= error_messages_for 'member' %>
<% roles = Role.find_all_givable %> <%= render :partial => @render_file, :locals => {:members => @members} %>
<% members = @project.member_principals.includes(:roles, :principal).all.sort %>
<!-- 如果是课程且点击教师或者学生,则对成员进行过滤 -->
<% members = searchTeacherAndAssistant(@project) if params[:role] == '1' %>
<% members = searchStudent(@project) if params[:role] == '2' %>
<% if @project.project_type == 1 %>
<%= render :partial => 'member_list', :locals => {:members => members} %>
<% else %>
<% users = UserGrade.find_by_sql("select * from user_grades where project_id = #{@project.id}")%>
<% if users %>
<% users = users.sort {|a,b| b[:grade] <=> a[:grade]} %>
<% temp = [] %>
<% users.each do |user|%>
<% members.each do |member|%>
<% if member[:user_id] == user[:user_id] %>
<% temp << member %>
<% end %>
<% end %>
<% end %>
<% temps = temp %>
<%= render :partial => 'member_list', :locals => {:members => temps} %>
<% end %>
<% end %>
<!-- <%= render :partial => 'member_list', :locals => {:members => members} %> -->
</div> </div>

View File

@ -546,6 +546,8 @@ zh:
label_winter: 冬季学期 label_winter: 冬季学期
label_followers: 关注 label_followers: 关注
label_teacher: 教师 label_teacher: 教师
label_teacher_list: 教师列表
label_student_list: 学生列表
label_limit_time: 截止日期 label_limit_time: 截止日期
label_commit_homework: 提交作业 label_commit_homework: 提交作业
label_course_homework: 对应课程 label_course_homework: 对应课程