Patch #12664 » 12664.diff
app/helpers/my_helper.rb | ||
---|---|---|
163 | 163 |
render :partial => 'my/blocks/news', :locals => {:block => block, :news => news} |
164 | 164 |
end |
165 | 165 | |
166 |
def render_forum_block(block, settings) |
|
167 |
messages = Message.visible. |
|
168 |
joins(:board). |
|
169 |
where("#{Board.table_name}.project_id" => User.current.projects). |
|
170 |
limit(5). |
|
171 |
includes(:author). |
|
172 |
references(:author). |
|
173 |
order("#{Message.table_name}.created_on DESC"). |
|
174 |
to_a |
|
175 | ||
176 |
render :partial => 'my/blocks/forum', :locals => {:block => block, :messages => messages} |
|
177 |
end |
|
178 | ||
166 | 179 |
def render_timelog_block(block, settings) |
167 | 180 |
days = settings[:days].to_i |
168 | 181 |
days = 7 if days < 1 || days > 365 |
app/views/messages/_latest_messages.html.erb | ||
---|---|---|
1 |
<% if messages && messages.any? %> |
|
2 |
<table id="latest_message" class="list messages"> |
|
3 |
<thead><tr> |
|
4 |
<th><%= l(:label_board) %></th> |
|
5 |
<th><%= l(:field_subject) %></th> |
|
6 |
<th><%= l(:field_content) %></th> |
|
7 |
<th><%= l(:field_author) %></th> |
|
8 |
<th><%= l(:field_created_on) %></th> |
|
9 |
</tr></thead> |
|
10 |
<tbody> |
|
11 |
<% messages.each do |message| %> |
|
12 |
<tr id="message-<%= message.id %>" class="message"> |
|
13 |
<td class="board"><%= link_to message.board.name, project_board_path(message.board.project, message.board), :class => "board" %> |
|
14 |
<td class="subject"><%= link_to message.subject, board_message_path(message.board, message) %></td> |
|
15 |
<td class="content"><%= message.content %></td> |
|
16 |
<td class="author"><%= link_to_user(message.author) %></td> |
|
17 |
<td class="created_on"><%= format_time(message.created_on) %></td> |
|
18 |
</tr> |
|
19 |
<% end %> |
|
20 |
</tbody> |
|
21 |
</table> |
|
22 |
<% end %> |
app/views/my/blocks/_forum.html.erb | ||
---|---|---|
1 |
<h3><%=l(:label_message_latest)%></h3> |
|
2 | ||
3 |
<%= render :partial => 'messages/latest_messages', :locals => {:messages => messages} %> |
config/locales/en.yml | ||
---|---|---|
902 | 902 |
label_topic_plural: Topics |
903 | 903 |
label_message_plural: Messages |
904 | 904 |
label_message_last: Last message |
905 |
label_message_latest: Latest Message |
|
905 | 906 |
label_message_new: New message |
906 | 907 |
label_message_posted: Message added |
907 | 908 |
label_reply_plural: Replies |
lib/redmine/my_page.rb | ||
---|---|---|
30 | 30 |
'issueswatched' => {:label => :label_watched_issues}, |
31 | 31 |
'issuequery' => {:label => :label_issue_plural, :max_occurs => 3}, |
32 | 32 |
'news' => {:label => :label_news_latest}, |
33 |
'forum' => {:label => :label_message_latest}, |
|
33 | 34 |
'calendar' => {:label => :label_calendar}, |
34 | 35 |
'documents' => {:label => :label_document_plural}, |
35 | 36 |
'timelog' => {:label => :label_spent_time}, |
test/functional/my_controller_test.rb | ||
---|---|---|
24 | 24 |
:roles, :projects, :members, :member_roles, |
25 | 25 |
:issues, :issue_statuses, :trackers, :enumerations, |
26 | 26 |
:custom_fields, :auth_sources, :queries, :enabled_modules, |
27 |
:journals, :projects_trackers |
|
27 |
:journals, :projects_trackers, :boards, :messages
|
|
28 | 28 | |
29 | 29 |
def setup |
30 | 30 |
@request.session[:user_id] = 2 |
... | ... | |
459 | 459 |
end |
460 | 460 |
end |
461 | 461 | |
462 |
def test_page_with_forum |
|
463 |
user = User.find(2) |
|
464 |
user.pref.my_page_layout = {'top' => ['forum']} |
|
465 |
user.pref.time_zone = 'UTC' |
|
466 |
user.pref.save! |
|
467 | ||
468 |
get :page |
|
469 |
assert_response :success |
|
470 | ||
471 |
assert_select 'div#block-forum' do |
|
472 |
assert_select 'h3', :text => /Latest Message/ |
|
473 |
assert_select 'table#latest_message' do |
|
474 |
assert_select 'tbody tr', 5 |
|
475 |
end |
|
476 |
end |
|
477 |
end |
|
478 | ||
462 | 479 |
def test_update_account |
463 | 480 |
put( |
464 | 481 |
:account, |