changeset 378:c80fd1ef305f feature_121

Ensure Recent Activity shows only activity on projects the user is actually a member of, if invoked from My Page (rather than on all permitted projects)
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Mon, 04 Apr 2011 10:28:08 +0100
parents 1a514b9347d4
children f25c73364bfb a8d3211a6379
files app/views/activities/_recent.rhtml app/views/my/blocks/_activitymyprojects.rhtml
diffstat 2 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/app/views/activities/_recent.rhtml	Thu Mar 31 15:19:30 2011 +0100
+++ b/app/views/activities/_recent.rhtml	Mon Apr 04 10:28:08 2011 +0100
@@ -2,7 +2,11 @@
 <% max = 5 %>
 <% if (events.nil?) 
      activity = Redmine::Activity::Fetcher.new(User.current, :project => @project)
-     events = activity.events(Date.today - 28, Date.today + 1).first(max)
+     events = activity.events(Date.today - 28, Date.today + 1)
+     if defined? user
+       events = events.select { |e| user.member_of? e.project }
+     end
+     events = events.first(max)
    end
 %>
 
--- a/app/views/my/blocks/_activitymyprojects.rhtml	Thu Mar 31 15:19:30 2011 +0100
+++ b/app/views/my/blocks/_activitymyprojects.rhtml	Mon Apr 04 10:28:08 2011 +0100
@@ -1,4 +1,4 @@
 
-<%= render :partial => 'activities/recent' %>
+<%= render :partial => 'activities/recent', :locals => { :user => User.current } %>