修复项目列表成员显示bug

This commit is contained in:
nieguanghui 2013-10-24 09:46:22 +08:00
parent 21ffbe637e
commit 39580a04a2
4 changed files with 9 additions and 9 deletions

View File

@ -20,6 +20,7 @@ class Member < ActiveRecord::Base
belongs_to :principal, :foreign_key => 'user_id'
has_many :member_roles, :dependent => :destroy
has_many :roles, :through => :member_roles
belongs_to :project
validates_presence_of :principal, :project

View File

@ -1,4 +1,5 @@
class UserGrade < ActiveRecord::Base
# attr_accessible :title, :body
attr_accessible :user_id, :project_id, :grade
belongs_to :project
end

View File

@ -24,15 +24,11 @@
</div>
<% else%>
<%= content_tag "div", content_tag("p", member.roles.sort.collect(&:to_s).join(', ')), :class => "clear avatar_name" %>
<% users.each do |user|%>
<% if user[:user_id] == member[:user_id]%>
<div class="clear avatar_user">
<p>
<%= l(:label_user_for_project_grade) %>: <span style="color:red"><%= user[:grade] %></span>
<%= l(:label_user_for_project_grade) %>: <span style="color:red"><%= UserGrade.find_by_user_id_and_project_id(member[:user_id], @project.id).grade %></span>
</p>
</div>
<% end %>
<% end %>
<% end %>
<%= call_hook(:view_projects_settings_members_table_row, { :project => @project, :member => member}) %>

View File

@ -8,23 +8,25 @@
<% roles = Role.find_all_givable
members = @project.member_principals.includes(:roles, :principal).all.sort %>
<% 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.sort {|a,b| a[:grade] <=> b[:grade]} %>
<% 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%>
<% temp << member %>
<% end %>
<% end %>
<% end %>
<% members = temp.reverse %>
<% temps = temp %>
<%= render :partial => 'member_list', :locals => {:members => temps} %>
<% end %>
<% end %>
<%= render :partial => 'member_list', :locals => {:members => members} %>
<!-- <%= render :partial => 'member_list', :locals => {:members => members} %> -->
</div>