Adds an option of the copy form to enable/disable attachments copy (#3055).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8677 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -360,11 +360,15 @@ private
|
||||
def build_new_issue_from_params
|
||||
if params[:id].blank?
|
||||
@issue = Issue.new
|
||||
begin
|
||||
@issue.copy_from(params[:copy_from]) if params[:copy_from]
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
return
|
||||
if params[:copy_from]
|
||||
begin
|
||||
@copy_from = Issue.visible.find(params[:copy_from])
|
||||
@copy_attachments = params[:copy_attachments].present? || request.get?
|
||||
@issue.copy_from(@copy_from, :attachments => @copy_attachments)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
return
|
||||
end
|
||||
end
|
||||
@issue.project = @project
|
||||
else
|
||||
|
||||
+5
-3
@@ -129,14 +129,16 @@ class Issue < ActiveRecord::Base
|
||||
end
|
||||
|
||||
# Copies attributes from another issue, arg can be an id or an Issue
|
||||
def copy_from(arg)
|
||||
def copy_from(arg, options={})
|
||||
issue = arg.is_a?(Issue) ? arg : Issue.visible.find(arg)
|
||||
self.attributes = issue.attributes.dup.except("id", "root_id", "parent_id", "lft", "rgt", "created_on", "updated_on")
|
||||
self.custom_field_values = issue.custom_field_values.inject({}) {|h,v| h[v.custom_field_id] = v.value; h}
|
||||
self.status = issue.status
|
||||
self.author = User.current
|
||||
self.attachments = issue.attachments.map do |attachement|
|
||||
attachement.copy(:container => self)
|
||||
unless options[:attachments] == false
|
||||
self.attachments = issue.attachments.map do |attachement|
|
||||
attachement.copy(:container => self)
|
||||
end
|
||||
end
|
||||
@copied_from = issue
|
||||
self
|
||||
|
||||
@@ -11,6 +11,13 @@
|
||||
<%= render :partial => 'issues/form', :locals => {:f => f} %>
|
||||
</div>
|
||||
|
||||
<% if @copy_from && @copy_from.attachments.any? %>
|
||||
<p>
|
||||
<label for="copy_attachments"><%= l(:label_copy_attachments) %></label>
|
||||
<%= check_box_tag 'copy_attachments', '1', @copy_attachments %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<p id="attachments_form"><%= label_tag('attachments[1][file]', l(:label_attachment_plural))%><%= render :partial => 'attachments/form' %></p>
|
||||
|
||||
<% if @issue.safe_attribute? 'watcher_user_ids' -%>
|
||||
|
||||
Reference in New Issue
Block a user