summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-01-20 18:22:43 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-01-20 18:22:43 +0000
commitfbf30eec7c58786d615852bc17ffe5a1c49229b6 (patch)
treeff3e3183f87dcb2f18ea02e33b3a154501c5b980 /app
parent8a3623733fa2ef879bb2a3f4355e0ce0df49b278 (diff)
downloadredmine-fbf30eec7c58786d615852bc17ffe5a1c49229b6.tar.gz
redmine-fbf30eec7c58786d615852bc17ffe5a1c49229b6.zip
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
Diffstat (limited to 'app')
-rw-r--r--app/controllers/issues_controller.rb14
-rw-r--r--app/models/issue.rb8
-rw-r--r--app/views/issues/new.html.erb7
3 files changed, 21 insertions, 8 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index 82fa5f8ea..e3e6ffedc 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -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
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 16257bf83..ad91ab488 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -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
diff --git a/app/views/issues/new.html.erb b/app/views/issues/new.html.erb
index 7ff994de5..bddb62788 100644
--- a/app/views/issues/new.html.erb
+++ b/app/views/issues/new.html.erb
@@ -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' -%>