member_list ,group by roles in course#show

This commit is contained in:
yanxd 2013-10-31 16:52:06 +08:00
parent 9f8c764053
commit 369e5eccc0
5 changed files with 158 additions and 143 deletions

View File

@ -17,12 +17,18 @@ module CoursesHelper
# 根据角色查询 # 根据角色查询
def searchCountByRoles project, roles_id def searchCountByRoles project, roles_id
count = -1 people = searchPeopleByRoles project, roles_id
people.count
end
# 根据角色查人
def searchPeopleByRoles project, roles_id
people = []
begin begin
count = project.members.joins(:member_roles).where("member_roles.role_id = :role_id", {:role_id => roles_id }).count people = project.members.joins(:member_roles).where("member_roles.role_id = :role_id", {:role_id => roles_id })
rescue Exception => e rescue Exception => e
logger.error "[CoursesHelper] ===> #{e}" logger.error "[CoursesHelper] ===> #{e}"
end end
count people
end end
end end

View File

@ -2,6 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title><%= h html_title %></title>
<meta name="description" content="<%= Redmine::Info.app_name %>" /> <meta name="description" content="<%= Redmine::Info.app_name %>" />
<meta name="keywords" content="issue,bug,tracker" /> <meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %> <%= csrf_meta_tag %>

View File

@ -1,73 +1,73 @@
<% content_for :header_tags do %> <% content_for :header_tags do %>
<%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %> <%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %>
<% end %> <% end %>
<%= form_tag(:controller => 'projects', :action => "search", :method => :get) do %> <%= form_tag(:controller => 'projects', :action => "search", :method => :get) do %>
<div class="project-search-block"> <div class="project-search-block">
<table width="100%" valign="center"> <table width="100%" valign="center">
<tr> <tr>
<td width="16%"><span style="margin-left:0px"><%= l(:label_project_plural)%></span></td> <td width="16%"><span style="margin-left:0px"><%= l(:label_project_plural)%></span></td>
<td valign="center"><%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new', :course => 0, :project_type => @project_type}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %></td> <td valign="center"><%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new', :course => 0, :project_type => @project_type}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %></td>
<td align="right"> <td align="right">
<div class="project-search"> <div class="project-search">
<%= text_field_tag 'name', params[:name], :size => 30 %> <%= text_field_tag 'name', params[:name], :size => 30 %>
<%= hidden_field_tag 'project_type', params[:project_type] %> <%= hidden_field_tag 'project_type', params[:project_type] %>
<%= submit_tag l(:label_search), :class => "small", :name => nil %> <%= submit_tag l(:label_search), :class => "small", :name => nil %>
</div></td> </div></td>
</tr> </tr>
</table> </table>
</div> </div>
<% end %> <% end %>
<%= sort_project(@s_type, @project_type) %> <%= sort_project(@s_type, @project_type) %>
<!--end--> <!--end-->
<!-- <div class="pagination_list"> <!-- <div class="pagination_list">
<ul> <ul>
<li> <li>
<%= link_to l(:label_sort_by_time), projects_path(:project_sort_type => '0'),:class=>"test_new" %> <%= link_to l(:label_sort_by_time), projects_path(:project_sort_type => '0'),:class=>"test_new" %>
</li> </li>
<li> <li>
<%= link_to l(:label_sort_by_active), projects_path(:project_sort_type => '1'),:class=>"test_new" %> <%= link_to l(:label_sort_by_active), projects_path(:project_sort_type => '1'),:class=>"test_new" %>
</li> </li>
<li> <li>
<%= link_to l(:label_sort_by_influence), projects_path(:project_sort_type => '2'),:class=>"test_new" %> <%= link_to l(:label_sort_by_influence), projects_path(:project_sort_type => '2'),:class=>"test_new" %>
</li> </li>
</ul> </ul>
</div> --> </div> -->
<div id="projects-index"> <div id="projects-index">
<%= render_project_hierarchy(@projects)%> <%= render_project_hierarchy(@projects)%>
</div> </div>
<div class="pagination"> <div class="pagination">
<ul> <ul>
<%= pagination_links_full @project_pages %> <%= pagination_links_full @project_pages %>
</ul> </ul>
</div> </div>
<% if User.current.logged? %> <% if User.current.logged? %>
<p style="text-align:right;"> <p style="text-align:right;">
<span class="my-project"><%= l(:label_my_projects) %></span> <span class="my-project"><%= l(:label_my_projects) %></span>
</p> </p>
<% end %> <% end %>
<% other_formats_links do |f| %> <% other_formats_links do |f| %>
<%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
<% end %> <% end %>
<% content_for :sidebar do %> <% content_for :sidebar do %>
<%= form_tag({}, :method => :get) do %> <%= form_tag({}, :method => :get) do %>
<h3><%= l(:label_project_plural) %></h3> <h3><%= l(:label_project_plural) %></h3>
<label for="closed"><%= check_box_tag 'closed', 1, params[:closed] %> <%= l(:label_show_closed_projects) %></label> <label for="closed"><%= check_box_tag 'closed', 1, params[:closed] %> <%= l(:label_show_closed_projects) %></label>
<p> <p>
<%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %> <%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %>
</p> </p>
<% end %> <% end %>
<% end %> <% end %>
<% html_title(l(:label_project_plural)) -%> <% html_title(l(:label_project_plural)) -%>

View File

@ -5,8 +5,10 @@
</div> </div>
<div class="member_content"> <div class="member_content">
<%= error_messages_for 'member' %> <%= error_messages_for 'member' %>
<% roles = Role.find_all_givable <% roles = Role.find_all_givable %>
members = @project.member_principals.includes(:roles, :principal).all.sort %> <% members = @project.member_principals.includes(:roles, :principal).all.sort %>
<% members = searchPeopleByRoles(@project, 3).sort if params[:role] == '1' %>
<% members = searchPeopleByRoles(@project, 5).sort if params[:role] == '2' %>
<% if @project.project_type == 1 %> <% if @project.project_type == 1 %>
<%= render :partial => 'member_list', :locals => {:members => members} %> <%= render :partial => 'member_list', :locals => {:members => members} %>
<% else %> <% else %>

View File

@ -1,66 +1,72 @@
<p> <p>
<% if @events_by_day.size >0 %> <% if @events_by_day.size >0 %>
<div style="padding-left: 8px"> <div style="padding-left: 8px">
<h3><%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)).html_safe %></h3> <h3><%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)).html_safe %></h3>
<p class="subtitle"> <p class="subtitle">
<%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %> <%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %>
</p> </p>
<div id="activity"> <div id="activity">
<% @events_by_day.keys.sort.reverse.each do |day| %> <% @events_by_day.keys.sort.reverse.each do |day| %>
<h3></h3> <h3></h3>
<div> <div>
<% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%> <% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%>
<div class="issue-note"> <div class="issue-note">
<table width="660px" border="0" align="center" style="font-size: 14px;"> <table width="660px" border="0" align="center" style="font-size: 14px;">
<tr> <tr>
<td colspan="2" valign="top" width="50" ><%= image_tag(url_to_avatar(e.event_author), :class => "avatar")%></td> <td colspan="2" valign="top" width="50" ><%= image_tag(url_to_avatar(e.event_author), :class => "avatar")%></td>
<td> <td>
<table width="580px" border="0"> <table width="580px" border="0">
<tr> <tr>
<td colspan="2" valign="top"><strong> <%= h(e.project) if @project.nil? || @project.id != e.project.id %></strong><span class="font_lighter"> <%= link_to_user(e.event_author) if e.respond_to?(:event_author) %> <%= l(:label_new_activity) %> </span> <%= link_to format_activity_title(e.event_title), e.event_url %> </td> <td colspan="2" valign="top">
</tr> <strong> <%= h(e.project) if @project.nil? || @project.id != e.project.id %></strong>
<tr> <span class="font_lighter">
<td colspan="2" width="580px" > <%= link_to_user(e.event_author) if e.respond_to?(:event_author) %>
<p class="font_description"> <%= l(:label_new_activity) %> </span>
<!-- modify by nyan --> <%= link_to format_activity_title(e.event_title), e.event_url %>
<%= textilizable( stringCut240(e.event_description) ) %> </td>
</p></td> </tr>
</tr> <tr>
<tr> <td colspan="2" width="580px" >
<td align="left"><a class="font_lighter"> <%= format_activity_day(day) %> <%= format_time(e.event_datetime, false) %></a></td> <p class="font_description">
<% if e.event_type == "issue" %> <!-- modify by nyan -->
<td align="right"><span> <%= link_to l(:label_find_all_comments), issue_path(e) %> </span><span class="font_lighter"><%= l(:label_comments_count, :count => e.journals.count)%></span></td> <%= textilizable( stringCut240(e.event_description) ) %>
<% end %> </p></td>
</tr> </tr>
</table></td> <tr>
</tr> <td align="left"><a class="font_lighter"> <%= format_activity_day(day) %> <%= format_time(e.event_datetime, false) %></a></td>
</table> <% if e.event_type == "issue" %>
</div> <td align="right"><span> <%= link_to l(:label_find_all_comments), issue_path(e) %> </span><span class="font_lighter"><%= l(:label_comments_count, :count => e.journals.count)%></span></td>
<% end %> <% end %>
</div> </tr>
<% end -%> </table></td>
<div class="pagination"> </tr>
<ul> </table>
<%= pagination_links_full @events_pages%> </div>
</ul> <% end %>
</div> </div>
</div> <% end -%>
</div> <div class="pagination">
<% else %> <ul>
<p class="font_description"> <%= pagination_links_full @events_pages%>
<table width="660"> </ul>
<tr> </div>
<td><%= link_to image_tag(url_to_avatar(@user), :class => "avatar"), user_path(@user)%></td> </div>
<td colspan="2"> </div>
<table width="580"> <% else %>
<tr> <p class="font_description">
<td > <%= link_to (h @user.lastname+@user.firstname), user_path(@user) %> <%= l(:label_user_create_project) %> <%= link_to @project.name %><strong> !</strong></td> <table width="660">
</tr> <tr>
<tr> <td><%= link_to image_tag(url_to_avatar(@user), :class => "avatar"), user_path(@user)%></td>
<td class="font_lighter" style="float: right"><%= format_time(@project.created_on) %> <td colspan="2">
</table></td> <table width="580">
</tr> <tr>
</table> <td > <%= link_to (h @user.lastname+@user.firstname), user_path(@user) %> <%= l(:label_user_create_project) %> <%= link_to @project.name %><strong> !</strong></td>
</p> </tr>
<% end %> <tr>
<td class="font_lighter" style="float: right"><%= format_time(@project.created_on) %>
</table></td>
</tr>
</table>
</p>
<% end %>
</p> </p>