Feature #29894 » feature-29894.patch
app/helpers/queries_helper.rb | ||
---|---|---|
234 | 234 |
link_to_if(value > 0, format_hours(value), project_time_entries_path(item.project, :issue_id => "~#{item.id}")) |
235 | 235 |
when :attachments |
236 | 236 |
value.to_a.map {|a| format_object(a)}.join(" ").html_safe |
237 |
when :visible_watchers |
|
238 |
value.to_a.map {|watcher| format_object(watcher.user)}.join(" ").html_safe |
|
237 | 239 |
else |
238 | 240 |
format_object(value) |
239 | 241 |
end |
... | ... | |
252 | 254 |
case column.name |
253 | 255 |
when :attachments |
254 | 256 |
value.to_a.map {|a| a.filename}.join("\n") |
257 |
when :visible_watchers |
|
258 |
value.to_a.map {|watcher| watcher.user.name}.join("\n") |
|
255 | 259 |
else |
256 | 260 |
format_object(value, false) do |value| |
257 | 261 |
case value.class.name |
app/models/issue.rb | ||
---|---|---|
871 | 871 |
result |
872 | 872 |
end |
873 | 873 | |
874 |
def visible_watchers |
|
875 |
if User.current.allowed_to?(:view_issue_watchers, project) |
|
876 |
watchers.reorder(id: :asc) |
|
877 |
else |
|
878 |
watchers.where(user: User.current) |
|
879 |
end |
|
880 |
end |
|
881 | ||
874 | 882 |
# Returns the initial status of the issue |
875 | 883 |
# Returns nil for a new issue |
876 | 884 |
def status_was |
app/models/issue_query.rb | ||
---|---|---|
46 | 46 |
QueryColumn.new(:last_updated_by, :sortable => lambda {User.fields_for_order_statement("last_journal_user")}), |
47 | 47 |
QueryColumn.new(:relations, :caption => :label_related_issues), |
48 | 48 |
QueryColumn.new(:attachments, :caption => :label_attachment_plural), |
49 |
QueryColumn.new(:visible_watchers, :caption => :label_issue_watchers), |
|
49 | 50 |
QueryColumn.new(:description, :inline => false), |
50 | 51 |
QueryColumn.new(:last_notes, :caption => :label_last_notes, :inline => false) |
51 | 52 |
] |
... | ... | |
291 | 292 |
limit(options[:limit]). |
292 | 293 |
offset(options[:offset]) |
293 | 294 | |
294 |
scope = scope.preload([:tracker, :author, :assigned_to, :fixed_version, :category, :attachments] & columns.map(&:name)) |
|
295 |
scope = scope.preload([:tracker, :author, :assigned_to, :fixed_version, :category, :attachments, :watchers] & columns.map(&:name))
|
|
295 | 296 |
if has_custom_field_column? |
296 | 297 |
scope = scope.preload(:custom_values) |
297 | 298 |
end |
lib/redmine/export/pdf/issues_pdf_helper.rb | ||
---|---|---|
379 | 379 |
value = " " * level + value |
380 | 380 |
when :attachments |
381 | 381 |
value = value.to_a.map {|a| a.filename}.join("\n") |
382 |
when :visible_watchers |
|
383 |
value = value.to_a.map {|watcher| watcher.user.name}.join("\n") |
|
382 | 384 |
end |
383 | 385 |
if value.is_a?(Date) |
384 | 386 |
format_date(value) |
public/stylesheets/application.css | ||
---|---|---|
222 | 222 |
table.list td {text-align:center; vertical-align:middle; padding-right:10px;} |
223 | 223 |
table.list td.id { width: 2%; text-align: center;} |
224 | 224 |
table.list td.name, table.list td.description, table.list td.subject, table.list td.comments, table.list td.roles, table.list td.attachments {text-align: left;} |
225 |
table.list td.attachments a {display:block;} |
|
225 |
table.list td.attachments a, table.list td.visible_watchers a {display:block;}
|
|
226 | 226 |
table.list td.tick {width:15%} |
227 | 227 |
table.list td.checkbox { width: 15px; padding: 2px 0 0 0; } |
228 | 228 |
table.list td.checkbox input {padding:0px;} |
test/functional/issues_controller_test.rb | ||
---|---|---|
43 | 43 |
:journal_details, |
44 | 44 |
:queries, |
45 | 45 |
:repositories, |
46 |
:changesets |
|
46 |
:changesets, |
|
47 |
:watchers |
|
47 | 48 | |
48 | 49 |
include Redmine::I18n |
49 | 50 | |
... | ... | |
1385 | 1386 |
assert_include "\"source.rb\npicture.jpg\"", response.body |
1386 | 1387 |
end |
1387 | 1388 | |
1389 |
def test_index_with_permission_should_display_watchers_column |
|
1390 |
@request.session[:user_id] = 3 |
|
1391 |
User.find(3).roles.first.add_permission! :view_issue_watchers |
|
1392 |
get :index, :params => { |
|
1393 |
:c => %w(subject visible_watchers), |
|
1394 |
:set_filter => '1', |
|
1395 |
:sort => 'id' |
|
1396 |
} |
|
1397 |
assert_response :success |
|
1398 |
assert_select 'td.visible_watchers' |
|
1399 |
assert_select 'tr#issue-2' do |
|
1400 |
assert_select 'td.visible_watchers' do |
|
1401 |
assert_select 'a:nth-of-type(1)', :text => 'Redmine Admin' |
|
1402 |
assert_select 'a:nth-of-type(2)', :text => 'Dave Lopper' |
|
1403 |
end |
|
1404 |
end |
|
1405 |
end |
|
1406 | ||
1407 |
def test_index_without_permission_should_display_visible_watchers_only |
|
1408 |
@request.session[:user_id] = 3 |
|
1409 |
User.find(3).roles.first.remove_permission! :view_issue_watchers |
|
1410 | ||
1411 |
get :index, :params => { |
|
1412 |
:c => %w(subject visible_watchers), |
|
1413 |
:set_filter => '1', |
|
1414 |
:sort => 'id' |
|
1415 |
} |
|
1416 |
assert_response :success |
|
1417 |
assert_select 'td.visible_watchers' |
|
1418 |
assert_select 'tr#issue-2' do |
|
1419 |
assert_select 'td.visible_watchers' do |
|
1420 |
# You can only know that you are a watcher yourself |
|
1421 |
assert_select 'a:nth-of-type(1)', :text =>'Dave Lopper' |
|
1422 |
assert_select 'a', { :text => 'Redmine Admin', :count => 0 } |
|
1423 |
end |
|
1424 |
end |
|
1425 |
end |
|
1426 | ||
1427 |
def test_index_with_watchers_column_as_csv |
|
1428 |
@request.session[:user_id] = 2 |
|
1429 |
get :index, :params => { |
|
1430 |
:c => %w(subject visible_watchers), |
|
1431 |
:set_filter => '1', |
|
1432 |
:sort => 'id', |
|
1433 |
:format => 'csv' |
|
1434 |
} |
|
1435 |
assert_response :success |
|
1436 |
assert_include "\"Redmine Admin\nDave Lopper\"", response.body |
|
1437 |
end |
|
1438 | ||
1388 | 1439 |
def test_index_with_estimated_hours_total |
1389 | 1440 |
Issue.delete_all |
1390 | 1441 |
Issue.generate!(:estimated_hours => 5.5) |
test/unit/issue_test.rb | ||
---|---|---|
2902 | 2902 |
assert_equal [Journal.find(1), Journal.find(2)], Issue.find(1).journals_after('') |
2903 | 2903 |
end |
2904 | 2904 | |
2905 |
def test_visible_watcher_with_permission_should_return_watchers |
|
2906 |
User.current = User.find(3) |
|
2907 |
User.current.roles.first.add_permission! :view_issue_watchers |
|
2908 | ||
2909 |
issue = Issue.find(2) |
|
2910 |
assert_equal issue.visible_watchers, issue.watchers.reorder(:id => :asc) |
|
2911 |
end |
|
2912 | ||
2913 |
def test_visible_watcher_without_permission_should_return_only_current_user_watcher |
|
2914 |
User.current = User.find(3) |
|
2915 |
User.current.roles.first.remove_permission! :view_issue_watchers |
|
2916 | ||
2917 |
issue = Issue.find(2) |
|
2918 |
assert_equal issue.visible_watchers, issue.watchers.where(:user_id => 3) |
|
2919 |
end |
|
2920 | ||
2905 | 2921 |
def test_css_classes_should_include_tracker |
2906 | 2922 |
issue = Issue.new(:tracker => Tracker.find(2)) |
2907 | 2923 |
classes = issue.css_classes.split(' ') |