Feature #2471 » add-my-activities-to-my-page.patch
| app/controllers/my_controller.rb | ||
|---|---|---|
|
helper :users
|
||
|
helper :custom_fields
|
||
|
helper :queries
|
||
|
helper :activities
|
||
|
def index
|
||
|
page
|
||
| app/helpers/my_helper.rb | ||
|---|---|---|
|
render :partial => 'my/blocks/timelog', :locals => {:block => block, :entries => entries, :entries_by_day => entries_by_day, :days => days}
|
||
|
end
|
||
|
def render_my_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/my_activity', :locals => {:events_by_day => events_by_day}
|
||
|
end
|
||
|
end
|
||
| app/views/activities/_activities.html.erb | ||
|---|---|---|
|
<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>
|
||
| app/views/activities/index.html.erb | ||
|---|---|---|
|
<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">
|
||
| app/views/my/blocks/_my_activity.html.erb | ||
|---|---|---|
|
<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} %>
|
||
| app/views/users/show.html.erb | ||
|---|---|---|
|
<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} %>
|
||
| config/locales/en.yml | ||
|---|---|---|
|
label_reported_issues: Reported issues
|
||
|
label_assigned_issues: Assigned issues
|
||
|
label_assigned_to_me_issues: Issues assigned to me
|
||
|
label_my_activity: My activity
|
||
|
label_last_login: Last connection
|
||
|
label_registered_on: Registered on
|
||
|
label_activity: Activity
|
||
| lib/redmine/my_page.rb | ||
|---|---|---|
|
'news' => {:label => :label_news_latest},
|
||
|
'calendar' => {:label => :label_calendar},
|
||
|
'documents' => {:label => :label_document_plural},
|
||
|
'timelog' => {:label => :label_spent_time}
|
||
|
'timelog' => {:label => :label_spent_time},
|
||
|
'my_activity' => {:label => :label_my_activity}
|
||
|
}
|
||
|
def self.groups
|
||
| test/functional/my_controller_test.rb | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
def test_page_with_my_activity
|
||
|
user = User.find(2)
|
||
|
user.pref.my_page_layout = {'top' => ['my_activity']}
|
||
|
user.pref.save!
|
||
|
get :page
|
||
|
assert_response :success
|
||
|
assert_select 'div#block-my_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
|
||