解决项目跑到课程里面的bug

This commit is contained in:
nieguanghui 2013-12-07 09:47:54 +08:00
parent 9742a94583
commit 02b5f2bafa
3 changed files with 29 additions and 4 deletions

View File

@ -855,9 +855,9 @@ class ProjectsController < ApplicationController
project_status = ProjectStatus.find_by_project_id(@project.id) project_status = ProjectStatus.find_by_project_id(@project.id)
project_status.destroy project_status.destroy
elsif params[:project][:is_public] == '1' elsif params[:project][:is_public] == '1'
project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0,:grade => 0, :project_type => 1) project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => @project.watchers.count, :changesets_count => @project.changesets.count,:grade => 0, :project_type => @project.project_type)
end end
respond_to do |format| respond_to do |format|
format.html { format.html {
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)

View File

@ -19,6 +19,9 @@
module WelcomeHelper module WelcomeHelper
StudentRoles = [5, 10]
def find_all_hot_project def find_all_hot_project
sort_project_by_hot sort_project_by_hot
end end
@ -90,6 +93,13 @@ module WelcomeHelper
str.html_safe str.html_safe
end end
# 返回学生数量即roles表中定义的Reporter
def studentCount project
# searchCountByRoles project,StudentRoles
# or
searchStudent(project).count
end
private private
def sort_project_by_hot def sort_project_by_hot
@ -174,5 +184,19 @@ module WelcomeHelper
event.event_type event.event_type
end end
end end
def searchStudent project
searchPeopleByRoles(project, StudentRoles)
end
def searchPeopleByRoles project, roles_id
people = []
begin
people = project.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => roles_id})
rescue Exception => e
logger.error "[CoursesHelper] ===> #{e}"
end
people
end
end end

View File

@ -218,6 +218,7 @@
<div style="float: left; margin-left: 10px; width: 360px;"> <div style="float: left; margin-left: 10px; width: 360px;">
<p class="layout"> <p class="layout">
<%= link_to( project.name, project_path(project.project_id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}")%> <%= link_to( project.name, project_path(project.project_id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}")%>
<span style="cursor: pointer; display: inline-block; float: right; color: #ec6300; white-space: nowrap;">学生人数:<%= link_to "#{studentCount(project)}", project_member_path(project, :role => 2) ,:course =>'1'%></span>
</p> </p>
<p class="layout-1" > <p class="layout-1" >
<%= content_tag "span", project.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => project.description %> <%= content_tag "span", project.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => project.description %>
@ -231,7 +232,7 @@
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;"> <div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;">
<h3 style="margin-left: 5px; color: rgb(21, 188, 207);"><strong>热门竞赛</strong></h3> <h3 style="margin-left: 5px; color: color: (51, 119, 51);"><strong>热门竞赛</strong></h3>
<div class="d-p-projectlist-box"> <div class="d-p-projectlist-box">
<ul class="d-p-projectlist"> <ul class="d-p-projectlist">
<% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %> <% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %>
@ -250,7 +251,7 @@
</div> </div>
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;"> <div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;">
<h3 style="margin-left: 5px; color: rgb(21, 188, 207);"><strong>热门众包</strong></h3> <h3 style="margin-left: 5px; color: color: (51, 119, 51);"><strong>热门众包</strong></h3>
<div class="d-p-projectlist-box"> <div class="d-p-projectlist-box">
<ul class="d-p-projectlist"> <ul class="d-p-projectlist">
<% find_all_hot_bid.map do |bid| break if(bid == find_all_hot_bid[5]) %> <% find_all_hot_bid.map do |bid| break if(bid == find_all_hot_bid[5]) %>