Feature #1739 » redmine_changeable_author_r21324.patch
| app/helpers/issues_helper.rb | ||
|---|---|---|
|
old_value = format_date(detail.old_value.to_date) if detail.old_value
|
||
|
when 'project_id', 'status_id', 'tracker_id', 'assigned_to_id',
|
||
|
'priority_id', 'category_id', 'fixed_version_id'
|
||
|
'priority_id', 'category_id', 'fixed_version_id', 'author_id'
|
||
|
value = find_name_by_reflection(field, detail.value)
|
||
|
old_value = find_name_by_reflection(field, detail.old_value)
|
||
| app/models/issue.rb | ||
|---|---|---|
|
safe_attributes(
|
||
|
'deleted_attachment_ids',
|
||
|
:if => lambda {|issue, user| issue.attachments_deletable?(user)})
|
||
|
safe_attributes(
|
||
|
'author_id',
|
||
|
:if => lambda {|issue, user| user.allowed_to?(:change_issue_author, issue.project)})
|
||
|
def safe_attribute_names(user=nil)
|
||
|
names = super
|
||
| app/views/issues/_attributes.html.erb | ||
|---|---|---|
|
<div class="splitcontent">
|
||
|
<div class="splitcontentleft">
|
||
|
<% if @issue.safe_attribute?('status_id') && @allowed_statuses.present? %>
|
||
|
<% if User.current.allowed_to?(:change_issue_author, @project) %>
|
||
|
<p><%= f.select :author_id, principals_options_for_select(@issue.assignable_users.select {|m| m.is_a?(User) && m.allowed_to?(:add_issues, @project) }, @issue.author), :include_blank => false, :required => true %>
|
||
|
<% end %>
|
||
|
<p>
|
||
|
<%= f.select :status_id, (@allowed_statuses.collect {|p| [p.name, p.id]}), {:required => true},
|
||
|
:onchange => "updateIssueFrom('#{escape_javascript(update_issue_form_path(@project, @issue))}', this)" %>
|
||
| config/locales/en.yml | ||
|---|---|---|
|
permission_view_private_notes: View private notes
|
||
|
permission_set_notes_private: Set notes as private
|
||
|
permission_delete_issues: Delete issues
|
||
|
permission_change_issue_author: Change issue author
|
||
|
permission_manage_public_queries: Manage public queries
|
||
|
permission_save_queries: Save queries
|
||
|
permission_view_gantt: View gantt chart
|
||
| lib/redmine/preparation.rb | ||
|---|---|---|
|
map.permission :view_private_notes, {}, :read => true, :require => :member
|
||
|
map.permission :set_notes_private, {}, :require => :member
|
||
|
map.permission :delete_issues, {:issues => :destroy}, :require => :member
|
||
|
map.permission :change_issue_author, {:issues => [:edit, :update]}
|
||
|
# Watchers
|
||
|
map.permission :view_issue_watchers, {}, :read => true
|
||
|
map.permission :add_issue_watchers, {:watchers => [:new, :create, :append, :autocomplete_for_user]}
|
||
| test/unit/issue_test.rb | ||
|---|---|---|
|
r = Issue.like('issue today')
|
||
|
assert_include Issue.find(7), r
|
||
|
end
|
||
|
def test_author_should_be_changed_when_user_with_permission_change_issue_author
|
||
|
Role.all.each do |r|
|
||
|
r.add_permission! :change_issue_author
|
||
|
end
|
||
|
User.current = User.find(2)
|
||
|
issue = Issue.generate!(:author => User.find(3))
|
||
|
assert_equal 3, issue.author_id
|
||
|
issue.safe_attributes = { 'author_id' => 4 }
|
||
|
assert_equal 4, issue.author_id
|
||
|
assert_not_equal 3, issue.author_id
|
||
|
end
|
||
|
def test_author_should_not_be_changed_when_user_without_permission_change_issue_author
|
||
|
Role.all.each do |r|
|
||
|
r.remove_permission! :change_issue_author
|
||
|
end
|
||
|
User.current = User.find(2)
|
||
|
issue = Issue.generate!(:author => User.find(3))
|
||
|
assert_equal 3, issue.author_id
|
||
|
issue.safe_attributes = { 'author_id' => 4 }
|
||
|
assert_not_equal 4, issue.author_id
|
||
|
assert_equal 3, issue.author_id
|
||
|
end
|
||
|
end
|
||