Commit 624ecec5 authored by maeda's avatar maeda

Add my activities to my page (#2471).

Patch by Mizuki ISHIKAWA.


git-svn-id: https://svn.redmine.org/redmine/trunk@17443 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 07239fce
......@@ -28,6 +28,7 @@ class MyController < ApplicationController
helper :users
helper :custom_fields
helper :queries
helper :activities
def index
page
......
......@@ -164,4 +164,10 @@ module MyHelper
render :partial => 'my/blocks/timelog', :locals => {:block => block, :entries => entries, :entries_by_day => entries_by_day, :days => days}
end
def render_activity_block(block, settings)
events_by_day = Redmine::Activity::Fetcher.new(User.current, :author => User.current).events(nil, nil, :limit => 10).group_by(&:event_date)
render :partial => 'my/blocks/activity', :locals => {:events_by_day => events_by_day}
end
end
<div id="activity">
<% events_by_day.keys.sort.reverse_each do |day| %>
<h3><%= format_activity_day(day) %></h3>
<dl>
<% sort_activity_events(events_by_day[day]).each do |e, in_group| -%>
<dt class="<%= e.event_type %> icon icon-<%= e.event_type %> <%= "grouped" if in_group %> <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>">
<%= avatar(e.event_author, :size => "24") if e.respond_to?(:event_author) %>
<span class="time"><%= format_time(e.event_datetime, false) %></span>
<%= content_tag('span', e.project, :class => 'project') if @project.nil? || @project != e.project %>
<%= link_to format_activity_title(e.event_title), e.event_url %>
</dt>
<dd class="<%= "grouped" if in_group %>"><span class="description"><%= format_activity_description(e.event_description) %></span>
<span class="author"><%= link_to_user(e.event_author) if e.respond_to?(:event_author) %></span></dd>
<% end -%>
</dl>
<% end -%>
</div>
<h2><%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)).html_safe %></h2>
<p class="subtitle"><%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %></p>
<div id="activity">
<% @events_by_day.keys.sort.reverse_each do |day| %>
<h3><%= format_activity_day(day) %></h3>
<dl>
<% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%>
<dt class="<%= e.event_type %> icon icon-<%= e.event_type %> <%= "grouped" if in_group %> <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>">
<%= avatar(e.event_author, :size => "24") if e.respond_to?(:event_author) %>
<span class="time"><%= format_time(e.event_datetime, false) %></span>
<%= content_tag('span', e.project, :class => 'project') if @project.nil? || @project != e.project %>
<%= link_to format_activity_title(e.event_title), e.event_url %>
</dt>
<dd class="<%= "grouped" if in_group %>"><span class="description"><%= format_activity_description(e.event_description) %></span>
<span class="author"><%= link_to_user(e.event_author) if e.respond_to?(:event_author) %></span></dd>
<% end -%>
</dl>
<% end -%>
</div>
<p class="subtitle"><%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %></p>
<%= render :partial => 'activities/activities', :locals => {:events_by_day => @events_by_day} %>
<%= content_tag('p', l(:label_no_data), :class => 'nodata') if @events_by_day.empty? %>
<span class="pagination">
......
<h3><%= link_to l(:label_activity), :controller => 'activities',
:action => 'index', :id => nil, :user_id => User.current,
:from => events_by_day.keys.first %></h3>
<%= render :partial => 'activities/activities', :locals => {:events_by_day => events_by_day} %>
......@@ -51,21 +51,7 @@
<h3><%= link_to l(:label_activity), :controller => 'activities',
:action => 'index', :id => nil, :user_id => @user,
:from => @events_by_day.keys.first %></h3>
<div id="activity">
<% @events_by_day.keys.sort.reverse_each do |day| %>
<h4><%= format_activity_day(day) %></h4>
<dl>
<% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%>
<dt class="<%= e.event_type %> icon icon-<%= e.event_type %> <%= "grouped" if in_group %> <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>">
<span class="time"><%= format_time(e.event_datetime, false) %></span>
<%= content_tag('span', e.project, :class => 'project') %>
<%= link_to format_activity_title(e.event_title), e.event_url %></dt>
<dd class="<%= "grouped" if in_group %>"><span class="description"><%= format_activity_description(e.event_description) %></span>
<% end -%>
</dl>
<% end -%>
</div>
<%= render :partial => 'activities/activities', :locals => {:events_by_day => @events_by_day} %>
<% other_formats_links do |f| %>
<%= f.link_to 'Atom', :url => {:controller => 'activities', :action => 'index', :id => nil, :user_id => @user, :key => User.current.rss_key} %>
......
......@@ -29,7 +29,8 @@ module Redmine
'news' => {:label => :label_news_latest},
'calendar' => {:label => :label_calendar},
'documents' => {:label => :label_document_plural},
'timelog' => {:label => :label_spent_time}
'timelog' => {:label => :label_spent_time},
'activity' => {:label => :label_activity}
}
def self.groups
......
......@@ -198,6 +198,24 @@ class MyControllerTest < Redmine::ControllerTest
end
end
def test_page_with_activity
user = User.find(2)
user.pref.my_page_layout = {'top' => ['activity']}
user.pref.save!
get :page
assert_response :success
assert_select 'div#block-activity' do
assert_select 'h3' do
assert_select 'a[href=?]', activity_path(from: Date.today, user_id: user.id), :text => 'Activity'
end
assert_select 'div#activity' do
assert_select 'dt', 10
end
end
end
def test_page_with_all_blocks
blocks = Redmine::MyPage.blocks.keys
preferences = User.find(2).pref
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment