课程列表中课程成员数量显示n+(不显示精确数)

只有课程成员能点击教师数量学生数量的链接和查看已提交作业的列表
This commit is contained in:
z9hang 2014-05-21 17:33:02 +08:00
parent 45339e53d8
commit 21e58ce3df
4 changed files with 24 additions and 5 deletions

View File

@ -14,6 +14,8 @@ class BidsController < ApplicationController
# end
before_filter :require_login,:only => [:set_reward, :destroy, :add, :new, ]
before_filter :memberAccess, only: :show_project
helper :watchers
helper :attachments
include AttachmentsHelper
@ -875,7 +877,14 @@ class BidsController < ApplicationController
end
rescue
render_404
end
end
def memberAccess
# 是课程,则判断当前用户是否参加了课程
return 0 if @bid.courses.first.project_type == Project::ProjectType_project
currentUser = User.current
render_403 unless currentUser.member_of?(@bid.courses.first)
end
end

View File

@ -114,10 +114,18 @@
<td class="font_index">
<!-- 1 教师; 2 学生0 全部-->
<%= link_to "#{teacherCount(@project)}", project_member_path(@project, :role => 1), :course => '1' %>
<% if User.current.member_of?(@project) %>
<%= link_to "#{teacherCount(@project)}", project_member_path(@project, :role => 1), :course => '1' %>
<% else %>
<span><%= teacherCount(@project)%></span> <!--<%= link_to "#{teacherCount(@project)}", "javascript:void(0)", :course => '1' %>-->
<% end%>
</td>
<td class="font_index">
<%= link_to "#{studentCount(@project)}", project_member_path(@project, :role => 2), :course => '1' %>
<% if User.current.member_of?(@project) %>
<%= link_to "#{studentCount(@project)}", project_member_path(@project, :role => 2), :course => '1' %>
<% else %>
<span><%= studentCount(@project)%></span>
<% end %>
</td>
<td class="font_index"><%= link_to files_count, project_files_path(@project) %></td>
<tr class="font_aram">

View File

@ -151,6 +151,7 @@
<li>
<%= link_to l(:label_question_student), {:controller => 'bids', :action => 'show' },:class => link_class(:respond)%>
</li>
<% if User.current.member_of? @bid.courses.first%>
<li>
<% if User.current.logged? && @bid.courses.first && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0) %>
<%= link_to l(:label_homework_commit), {:controller => 'bids', :action => 'show_project' },:class => link_class(:project)%>
@ -159,9 +160,10 @@
<% end %>
</li>
<% end %>
<!-- <li><%= link_to l(:label_homework_statistics), { :controller => 'bids', :action => 'homework_statistics' },:class => link_class(:homework_statistics)%></li> -->
<!-- <li><%= link_to l(:label_homework_respond), { :controller => 'bids', :action => 'homework_respond' },:class => link_class(:homework_respond)%></li>
--><ul>
--></ul>
</div>
<%= yield %>

View File

@ -45,7 +45,7 @@
<%= content_tag('span', l(:label_x_data,:count => files_count)) %>
</p>
<p class="stats">
<%= content_tag('span', "#{@project.members.count}", :class => "info") %>
<%= content_tag('span', "#{garble @project.members.count}", :class => "info") %>
<%= content_tag('span', l(:label_x_member, :count => @project.members.count)) %>
</p>