summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2018-07-11 14:51:07 +0000
committerGo MAEDA <maeda@farend.jp>2018-07-11 14:51:07 +0000
commit87a671ce75fd2b1d402b96df4fb92f55e6009fd4 (patch)
tree1897e3d21c4569f55c8aa70dfd2913c0754c1734
parent3a894f3a9112fcba80fc95d4edf17c5783bcdbdb (diff)
downloadredmine-87a671ce75fd2b1d402b96df4fb92f55e6009fd4.tar.gz
redmine-87a671ce75fd2b1d402b96df4fb92f55e6009fd4.zip
Add my activities to my page (#2471).
Patch by Mizuki ISHIKAWA. git-svn-id: http://svn.redmine.org/redmine/trunk@17443 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/my_controller.rb1
-rw-r--r--app/helpers/my_helper.rb6
-rw-r--r--app/views/activities/_activities.html.erb17
-rw-r--r--app/views/activities/index.html.erb20
-rw-r--r--app/views/my/blocks/_activity.html.erb5
-rw-r--r--app/views/users/show.html.erb16
-rw-r--r--lib/redmine/my_page.rb3
-rw-r--r--test/functional/my_controller_test.rb18
8 files changed, 52 insertions, 34 deletions
diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb
index 4e9f67d7d..0a1d40349 100644
--- a/app/controllers/my_controller.rb
+++ b/app/controllers/my_controller.rb
@@ -28,6 +28,7 @@ class MyController < ApplicationController
helper :users
helper :custom_fields
helper :queries
+ helper :activities
def index
page
diff --git a/app/helpers/my_helper.rb b/app/helpers/my_helper.rb
index 9acc9e644..8320749fc 100644
--- a/app/helpers/my_helper.rb
+++ b/app/helpers/my_helper.rb
@@ -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
diff --git a/app/views/activities/_activities.html.erb b/app/views/activities/_activities.html.erb
new file mode 100644
index 000000000..2a1f46cd7
--- /dev/null
+++ b/app/views/activities/_activities.html.erb
@@ -0,0 +1,17 @@
+<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>
diff --git a/app/views/activities/index.html.erb b/app/views/activities/index.html.erb
index 196984d64..64f7f6a85 100644
--- a/app/views/activities/index.html.erb
+++ b/app/views/activities/index.html.erb
@@ -1,24 +1,8 @@
<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">
diff --git a/app/views/my/blocks/_activity.html.erb b/app/views/my/blocks/_activity.html.erb
new file mode 100644
index 000000000..40f43559f
--- /dev/null
+++ b/app/views/my/blocks/_activity.html.erb
@@ -0,0 +1,5 @@
+<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} %>
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index 3907d6192..84e95ead5 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -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} %>
diff --git a/lib/redmine/my_page.rb b/lib/redmine/my_page.rb
index 1bbefe493..4bec1c29f 100644
--- a/lib/redmine/my_page.rb
+++ b/lib/redmine/my_page.rb
@@ -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
diff --git a/test/functional/my_controller_test.rb b/test/functional/my_controller_test.rb
index 6a618c4a3..026129399 100644
--- a/test/functional/my_controller_test.rb
+++ b/test/functional/my_controller_test.rb
@@ -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