登录后主页只显示我的项目

方法定义
功能实现
This commit is contained in:
huang 2015-05-05 16:29:53 +08:00
parent 80a7f47b15
commit 0b524b8a40
4 changed files with 13 additions and 2 deletions

View File

@ -58,12 +58,18 @@ class WelcomeController < ApplicationController
else
case @first_page.sort_type
when 0
@my_projects = find_my_projects
@other_projects = @my_projects.count < 9 ? find_miracle_project( 9 - @my_projects.count, 3,"score desc") : []
@projects = find_miracle_project(10, 3,"created_on desc")
#@projects = @projects_all.order("created_on desc")
when 1
@my_projects = find_my_projects
@other_projects = @my_projects.count < 9 ? find_miracle_project( 9 - @my_projects.count, 3,"score desc") : []
@projects = find_miracle_project(10, 3,"score desc")
#@projects = @projects_all.order("grade desc")
when 2
@my_projects = find_my_projects
@other_projects = @my_projects.count < 9 ? find_miracle_project( 9 - @my_projects.count, 3,"score desc") : []
@projects = find_miracle_project(10, 3,"watchers_count desc")
#@projects = @projects_all.order("watchers_count desc")

View File

@ -443,6 +443,10 @@ module WelcomeHelper
resultSet.take(limit)
end
def find_my_projects
my_projects = User.current.memberships.all(conditions: "projects.project_type = 0")
end
def sort_project_by_hot_rails project_type=0, order_by='score DESC', limit=15
# Project.find_by_sql("
# SELECT p.id, p.name, p.description, p.identifier, t.project_id

View File

@ -39,9 +39,9 @@
</tr>
</table></td>
</tr>
</table>
</li>
<% end %>
</ul>

View File

@ -415,3 +415,4 @@ zh:
#
field_sharing: 共享
label_title_code_review: 代码评审
label_home_non_project: 您还没有创建项目,您可能对系统的其它项目感兴趣!