refactor memberlist
This commit is contained in:
parent
ea8a87c3a6
commit
397eb11dca
|
@ -510,14 +510,14 @@ class ProjectsController < ApplicationController
|
|||
@course.extra='course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s
|
||||
@course.safe_attributes = params[:project][:course]
|
||||
@course.tea_id = User.current.id
|
||||
# added by bai
|
||||
# added by bai
|
||||
@course.term = params[:term]
|
||||
@course.time = params[:time]
|
||||
@course.setup_time = params[:setup_time]
|
||||
@course.endup_time = params[:endup_time]
|
||||
@course.class_period = params[:class_period]
|
||||
@course.setup_time = params[:setup_time]
|
||||
@course.endup_time = params[:endup_time]
|
||||
@course.class_period = params[:class_period]
|
||||
end
|
||||
# end
|
||||
# end
|
||||
# @course.save
|
||||
# project = ProjectInfo.create(:user_id => User.current.id, :project_id => @project.id)
|
||||
# project_status = ProjectStatus.create(:project_id => @project.id)
|
||||
|
@ -760,24 +760,45 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
#by young
|
||||
include CoursesHelper
|
||||
def member
|
||||
## 有角色参数的才是课程,没有的就是项目
|
||||
@render_file = 'member_list'
|
||||
# 判断是否课程
|
||||
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
|
||||
# roles = Role.find_all_givable
|
||||
# members = @project.member_principals.includes(:roles, :principal).all.sort
|
||||
#
|
||||
# users = UserGrade.find_by_sql("select * from user_grades where project_id = #{@project.id}").sort {|a,b| a[:grade] <=> b[:grade]}
|
||||
#
|
||||
# temp = []
|
||||
# users.each do |user|
|
||||
# members.each do |member|
|
||||
# if member[:user_id] == user[:user_id]
|
||||
# temp << member
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# temps = temp.reverse
|
||||
|
||||
render :layout => 'base_courses' if @project.project_type == 1
|
||||
end
|
||||
|
||||
def sort_project_members project, members
|
||||
#userGrade = UserGrade.where(:project_id => project.id)
|
||||
users = UserGrade.where(:project_id => project.id).order('grade DESC').joins("LEFT JOIN users ON users.id = user_grades.id")
|
||||
memberlist = []
|
||||
users.each do |user|
|
||||
members.each do |member|
|
||||
if member[:user_id] == user[:user_id]
|
||||
memberlist << member
|
||||
end
|
||||
end
|
||||
end
|
||||
memberlist
|
||||
end
|
||||
|
||||
# def news
|
||||
|
@ -809,13 +830,13 @@ class ProjectsController < ApplicationController
|
|||
@course = Course.find_by_extra(@project.identifier)
|
||||
unless @course.nil?
|
||||
@course.password = params[:project][:course][:password]
|
||||
# added by bai
|
||||
# added by bai
|
||||
@course.term = params[:term]
|
||||
@course.time = params[:time]
|
||||
@course.setup_time = params[:setup_time]
|
||||
@course.endup_time = params[:endup_time]
|
||||
@course.class_period = params[:class_period]
|
||||
# end
|
||||
@course.setup_time = params[:setup_time]
|
||||
@course.endup_time = params[:endup_time]
|
||||
@course.class_period = params[:class_period]
|
||||
# end
|
||||
@course.save
|
||||
end
|
||||
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
|
||||
|
|
|
@ -9,17 +9,8 @@
|
|||
<%= content_tag "div", link_to_user(member.principal), :class => "nomargin avatar_name" %>
|
||||
|
||||
<% if @project.project_type == 1 %>
|
||||
<div class ="clear avatar_name">
|
||||
<div class ="clear avatar_name">
|
||||
<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>
|
||||
</div>
|
||||
<% else%>
|
||||
|
|
|
@ -1,36 +1,10 @@
|
|||
<div class="member_header">
|
||||
<p>
|
||||
<%= l(:label_member_list) if params[:role].blank? %>
|
||||
<%= @subPage_title %>
|
||||
</p>
|
||||
</div>
|
||||
<div class="member_content">
|
||||
<%= error_messages_for 'member' %>
|
||||
<% roles = Role.find_all_givable %>
|
||||
<% 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} %> -->
|
||||
|
||||
|
||||
<%= render :partial => @render_file, :locals => {:members => @members} %>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -546,6 +546,8 @@ zh:
|
|||
label_winter: 冬季学期
|
||||
label_followers: 关注
|
||||
label_teacher: 教师
|
||||
label_teacher_list: 教师列表
|
||||
label_student_list: 学生列表
|
||||
label_limit_time: 截止日期
|
||||
label_commit_homework: 提交作业
|
||||
label_course_homework: 对应课程
|
||||
|
|
Loading…
Reference in New Issue