Feature #33868 » 0001-Make-adding-notes-to-closed-issues-configurable-per-.patch
| app/models/issue.rb | ||
|---|---|---|
| 222 | 222 | |
| 223 | 223 |
# Returns true if user or current user is allowed to add notes to the issue |
| 224 | 224 |
def notes_addable?(user=User.current) |
| 225 |
return false unless tracker |
|
| 226 | ||
| 227 |
# Adding notes on closed issues can be restricted per tracker settings |
|
| 228 |
is_closed_without_transition = closed? && !closing? && !reopening? |
|
| 229 |
return false if !tracker.notes_allowed_on_closed? && is_closed_without_transition |
|
| 230 | ||
| 225 | 231 |
user_tracker_permission?(user, :add_issue_notes) |
| 226 | 232 |
end |
| 227 | 233 | |
| app/models/tracker.rb | ||
|---|---|---|
| 74 | 74 |
'name', |
| 75 | 75 |
'default_status_id', |
| 76 | 76 |
'is_in_roadmap', |
| 77 |
'notes_allowed_on_closed', |
|
| 77 | 78 |
'core_fields', |
| 78 | 79 |
'position', |
| 79 | 80 |
'custom_field_ids', |
| app/views/issues/_edit.html.erb | ||
|---|---|---|
| 27 | 27 |
<% end %> |
| 28 | 28 |
</fieldset> |
| 29 | 29 |
<% end %> |
| 30 |
<% if @issue.notes_addable? %> |
|
| 31 |
<fieldset id="add_notes"><legend><%= l(:field_notes) %></legend> |
|
| 30 |
<fieldset id="add_notes" style="<%= @issue.notes_addable? ? '' : 'display:none;' %>"><legend><%= l(:field_notes) %></legend> |
|
| 32 | 31 |
<%= f.textarea :notes, :cols => 60, :rows => 10, :class => 'wiki-edit', |
| 33 | 32 |
:data => {
|
| 34 | 33 |
:auto_complete => true |
| ... | ... | |
| 42 | 41 | |
| 43 | 42 |
<%= call_hook(:view_issues_edit_notes_bottom, { :issue => @issue, :notes => @notes, :form => f }) %>
|
| 44 | 43 |
</fieldset> |
| 45 |
<% end %> |
|
| 46 | 44 |
<% if !@issue.attributes_editable? && User.current.allowed_to?(:add_issue_watchers, @issue.project) %> |
| 47 | 45 |
<%= update_data_sources_for_auto_complete({users: watchers_autocomplete_for_mention_path(project_id: @issue.project, q: '', object_type: 'issue',
|
| 48 | 46 |
object_id: @issue.id)}) %> |
| app/views/trackers/_form.html.erb | ||
|---|---|---|
| 11 | 11 |
:required => true %> |
| 12 | 12 |
</p> |
| 13 | 13 |
<p><%= f.check_box :is_in_roadmap %></p> |
| 14 |
<p><%= f.check_box :notes_allowed_on_closed %></p> |
|
| 14 | 15 |
<p><%= f.textarea :description, :rows => 4 %></p> |
| 15 | 16 |
<p> |
| 16 | 17 |
<label><%= l(:field_core_fields) %></label> |
| config/locales/en.yml | ||
|---|---|---|
| 429 | 429 |
field_last_activity_date: Last activity |
| 430 | 430 |
field_thousands_delimiter: Thousands delimiter |
| 431 | 431 |
field_ratio_interval: Ratio interval |
| 432 |
field_notes_allowed_on_closed: Allow notes on closed issues |
|
| 432 | 433 | |
| 433 | 434 |
setting_app_title: Application title |
| 434 | 435 |
setting_welcome_text: Welcome text |
| db/migrate/20260201094039_add_notes_allowed_on_closed_to_trackers.rb | ||
|---|---|---|
| 1 |
class AddNotesAllowedOnClosedToTrackers < ActiveRecord::Migration[6.1] |
|
| 2 |
def change |
|
| 3 |
add_column :trackers, :notes_allowed_on_closed, :boolean, default: true, null: false |
|
| 4 |
end |
|
| 5 |
end |
|
| test/unit/issue_test.rb | ||
|---|---|---|
| 953 | 953 |
assert_equal '', issue.notes |
| 954 | 954 |
end |
| 955 | 955 | |
| 956 |
def test_should_not_allow_notes_on_closed_issue_when_tracker_disallows |
|
| 957 |
tracker = Tracker.find(1) |
|
| 958 |
tracker.update!(notes_allowed_on_closed: false) |
|
| 959 | ||
| 960 |
issue = Issue.find(8) |
|
| 961 |
user = User.find(2) |
|
| 962 |
issue.init_journal(user) |
|
| 963 |
issue.send :safe_attributes=, {'notes' => 'note'}, user
|
|
| 964 |
assert_equal '', issue.notes |
|
| 965 |
end |
|
| 966 | ||
| 967 |
def test_should_allow_notes_on_closed_issue_when_reopening |
|
| 968 |
tracker = Tracker.find(1) |
|
| 969 |
tracker.update!(notes_allowed_on_closed: false) |
|
| 970 | ||
| 971 |
issue = Issue.find(8) |
|
| 972 |
issue.status_id = 1 |
|
| 973 |
user = User.find(2) |
|
| 974 |
issue.init_journal(user) |
|
| 975 |
issue.send :safe_attributes=, {'notes' => 'note'}, user
|
|
| 976 |
assert_equal 'note', issue.notes |
|
| 977 |
end |
|
| 978 | ||
| 956 | 979 |
def test_safe_attributes_should_accept_target_tracker_enabled_fields |
| 957 | 980 |
source = Tracker.find(1) |
| 958 | 981 |
source.core_fields = [] |
| test/unit/mail_handler_test.rb | ||
|---|---|---|
| 972 | 972 |
assert !journal.notes.match(/^Start Date:/i) |
| 973 | 973 |
end |
| 974 | 974 | |
| 975 |
def test_update_issue_should_not_allow_notes_on_closed_issue_when_tracker_disallows |
|
| 976 |
issue = Issue.find(2) |
|
| 977 |
issue.update!(status: IssueStatus.find_by(:is_closed => true)) |
|
| 978 |
issue.tracker.update!(notes_allowed_on_closed: false) |
|
| 979 |
assert_no_difference 'Journal.count' do |
|
| 980 |
submit_email('ticket_reply.eml')
|
|
| 981 |
end |
|
| 982 |
end |
|
| 983 | ||
| 975 | 984 |
def test_update_issue_with_attachment |
| 976 | 985 |
assert_difference 'Journal.count' do |
| 977 | 986 |
assert_difference 'JournalDetail.count' do |
- « Previous
- 1
- 2
- 3
- 4
- Next »