1、修改用户动态每页显示条目不正确

2、用户动态增加新闻、留言等权限判断的补全,以及部分权限判断不正确
This commit is contained in:
sw 2015-03-07 11:30:21 +08:00
parent ce792f6ce8
commit ff2b4c610c
1 changed files with 15 additions and 7 deletions

View File

@ -442,16 +442,24 @@ class UsersController < ApplicationController
watcher.push(User.current)
activity = Activity.where(where_condition).where('user_id in (?)', watcher).order('id desc')
else
activity = Activity.where(where_condition).where('user_id = ?', @user.id).order('id desc')
activity = Activity.where(where_condition).where('user_id = ?', @user.id).order('id desc')
activity = activity.reject { |e|
!User.current.admin? &&
(((e.act_type == "Issue") && !e.act.project.visible?(User.current)) ||
(e.act_type == "Bid" && e.act.courses.first.is_public == 0 && !User.current.member_of_course?(e.act.courses.first)) ||
(e.act_type == "Journal" && e.act.respond_to?("Project") && !e.act.project.visible?(User.current)) ||
(e.act_type == "News" && ((!e.act.project.nil? && !e.act.project.visible?(User.current)) || (!e.act.course.nil? && e.act.course.is_public == 0 && !User.current.member_of_course?(e.act.course)))) ||
(e.act_type == "Message" && !e.act.board.nil? && ((!e.act.board.project.nil? && !e.act.board.project.visible?(User.current)) || (!e.act.board.course.nil? && e.act.board.course.is_public == 0 && !User.current.member_of_course?(e.act.board.course)))))
}
end
@activity_count = activity.count
@activity_pages = Paginator.new @activity_count, pre_count, params['page']
@activity = activity.slice(@activity_pages.offset,@activity_pages.per_page )
@activity = @activity.reject { |e|
((e.act_type=="Issue") && ( !e.act.visible?(User.current))) ||
((e.act_type == "Journal") && (!e.act.project.visible?(User.current))) ||
((e.act_type == "Bid") && ((!User.current.member_of_course?(e.act.courses.first) || !User.current.admin?)))
}
@activity = activity.slice(@activity_pages.offset,@activity_pages.per_page)
# @activity = @activity.reject { |e|
# ((e.act_type=="Issue") && ( !e.act.visible?(User.current))) ||
# ((e.act_type == "Journal") && (!e.act.project.visible?(User.current))) ||
# ((e.act_type == "Bid") && ((!User.current.member_of_course?(e.act.courses.first) || !User.current.admin?)))
# }
@state = 0
end