Mercurial > hg > soundsoftware-site
annotate app/views/activities/_recent.rhtml @ 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 |
rev | line source |
---|---|
chris@344 | 1 <% events = @events_by_day %> |
chris@344 | 2 <% max = 5 %> |
chris@344 | 3 <% if (events.nil?) |
chris@344 | 4 activity = Redmine::Activity::Fetcher.new(User.current, :project => @project) |
chris@378 | 5 events = activity.events(Date.today - 28, Date.today + 1) |
chris@378 | 6 if defined? user |
chris@378 | 7 events = events.select { |e| user.member_of? e.project } |
chris@378 | 8 end |
chris@378 | 9 events = events.first(max) |
chris@344 | 10 end |
chris@344 | 11 %> |
chris@344 | 12 |
chris@344 | 13 <div id="activity"> |
chris@344 | 14 |
chris@344 | 15 <% if @project.nil? %> |
chris@344 | 16 <%= content_tag('h3', l(:label_activity_my_recent)) %> |
chris@344 | 17 <div class="activity box"> |
chris@344 | 18 <% end %> |
chris@344 | 19 |
chris@344 | 20 <% if events.empty? %> |
chris@344 | 21 |
chris@344 | 22 <% if @project.nil? %> |
chris@344 | 23 <p><%= l(:label_activity_my_recent_none) %></p> |
chris@344 | 24 <% end %> |
chris@344 | 25 |
chris@344 | 26 <% else %> |
chris@344 | 27 |
chris@344 | 28 <% if !@project.nil? %> |
chris@344 | 29 <div class="activity box"> |
chris@344 | 30 <%= content_tag('h3', l(:label_activity_recent)) %> |
chris@344 | 31 <% end %> |
chris@344 | 32 |
chris@344 | 33 <dl> |
chris@344 | 34 <% events.sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%> |
chris@344 | 35 <dt class="<%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>"> |
chris@344 | 36 <%= avatar(e.event_author, :size => "24") if e.respond_to?(:event_author) %> |
chris@344 | 37 <span class="time"><%= format_time(e.event_datetime) %></span> |
chris@344 | 38 <%= content_tag('span', link_to_project(e.project), :class => 'project') if @project.nil? || @project != e.project %> |
chris@344 | 39 <% if e.respond_to?(:event_author) %> |
chris@344 | 40 <span class="author"><%= e.event_author %></span> |
chris@344 | 41 <% end %> |
chris@344 | 42 </dt> |
chris@344 | 43 <dd><%= link_to format_activity_title(e.event_title), e.event_url %> |
chris@344 | 44 <span class="description"><%= format_activity_description(e.event_description) %></span> |
chris@344 | 45 </dd> |
chris@344 | 46 <% end -%> |
chris@344 | 47 </dl> |
chris@344 | 48 |
chris@344 | 49 </div> |
chris@344 | 50 |
chris@344 | 51 <% end %> |
chris@344 | 52 |
chris@344 | 53 <% if events.empty? and @project.nil? %></div><% end %> |
chris@344 | 54 |
chris@344 | 55 </div> |