项目按更新时间倒排

This commit is contained in:
huang 2015-07-10 09:28:58 +08:00
parent 8de307d198
commit 4411136cb4
1 changed files with 9 additions and 4 deletions

View File

@ -104,13 +104,20 @@ class UsersController < ApplicationController
#added by young #added by young
def user_projects def user_projects
if User.current.admin? if User.current.admin?
@memberships = @user.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}") @memberships = @user.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}")
else else
cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1"
@memberships = @user.memberships.all(:conditions => cond) @memberships = @user.memberships.all(:conditions => cond)
end end
@memberships = @memberships.sort {|a,b| b.created_on.to_i <=> a.created_on.to_i}
# unless @memberships.nil?
# @user_projects = []
# @memberships.each do |membership|
# @user_projects << membership.project
# end
# @user_projects = @user_projects.sort {|a,b| b.created_on.to_i <=> a.created_on.to_i}
# end
#events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20) #events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20)
#@events_by_day = events.group_by(&:event_date) #@events_by_day = events.group_by(&:event_date)
@state = 0 @state = 0
@ -256,9 +263,7 @@ class UsersController < ApplicationController
membership.sort! {|older, newer| newer.created_on <=> older.created_on } membership.sort! {|older, newer| newer.created_on <=> older.created_on }
@memberships = [] @memberships = []
membership.collect { |e| membership.collect { |e| @memberships.push(e)}
@memberships.push(e)
}
## 判断课程是否过期 [需封装] ## 判断课程是否过期 [需封装]
@memberships_doing = [] @memberships_doing = []
@memberships_done = [] @memberships_done = []