解决项目跑到课程里面的bug
This commit is contained in:
parent
9742a94583
commit
02b5f2bafa
|
@ -855,9 +855,9 @@ class ProjectsController < ApplicationController
|
|||
project_status = ProjectStatus.find_by_project_id(@project.id)
|
||||
project_status.destroy
|
||||
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
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
|
||||
module WelcomeHelper
|
||||
|
||||
StudentRoles = [5, 10]
|
||||
|
||||
|
||||
def find_all_hot_project
|
||||
sort_project_by_hot
|
||||
end
|
||||
|
@ -90,6 +93,13 @@ module WelcomeHelper
|
|||
str.html_safe
|
||||
end
|
||||
|
||||
# 返回学生数量,即roles表中定义的Reporter
|
||||
def studentCount project
|
||||
# searchCountByRoles project,StudentRoles
|
||||
# or
|
||||
searchStudent(project).count
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def sort_project_by_hot
|
||||
|
@ -174,5 +184,19 @@ module WelcomeHelper
|
|||
event.event_type
|
||||
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
|
||||
|
|
|
@ -218,6 +218,7 @@
|
|||
<div style="float: left; margin-left: 10px; width: 360px;">
|
||||
<p class="layout">
|
||||
<%= 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 class="layout-1" >
|
||||
<%= 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;">
|
||||
<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">
|
||||
<ul class="d-p-projectlist">
|
||||
<% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %>
|
||||
|
@ -250,7 +251,7 @@
|
|||
</div>
|
||||
|
||||
<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">
|
||||
<ul class="d-p-projectlist">
|
||||
<% find_all_hot_bid.map do |bid| break if(bid == find_all_hot_bid[5]) %>
|
||||
|
|
Loading…
Reference in New Issue