summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2010-04-11 14:20:40 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2010-04-11 14:20:40 +0000
commit3e6f42e46d43650b6f561849d0bfaf0f0e018bf6 (patch)
treea467f3553c0604e9ffc9af8cb421633f0c8deb30 /app
parent30c45a6187227a30cf85bc4063ba793c47c53768 (diff)
downloadredmine-3e6f42e46d43650b6f561849d0bfaf0f0e018bf6.tar.gz
redmine-3e6f42e46d43650b6f561849d0bfaf0f0e018bf6.zip
Backported r3608 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/0.9-stable@3642 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/projects_controller.rb26
-rw-r--r--app/models/mailer.rb9
-rw-r--r--app/views/projects/copy.rhtml2
3 files changed, 25 insertions, 12 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index ec22e2206..cb041b9ea 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -102,18 +102,20 @@ class ProjectsController < ApplicationController
redirect_to :controller => 'admin', :action => 'projects'
end
else
- @project = Project.new(params[:project])
- @project.enabled_module_names = params[:enabled_modules]
- if validate_parent_id && @project.copy(@source_project, :only => params[:only])
- @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
- flash[:notice] = l(:notice_successful_create)
- redirect_to :controller => 'admin', :action => 'projects'
- elsif !@project.new_record?
- # Project was created
- # But some objects were not copied due to validation failures
- # (eg. issues from disabled trackers)
- # TODO: inform about that
- redirect_to :controller => 'admin', :action => 'projects'
+ Mailer.with_deliveries(params[:notifications] == '1') do
+ @project = Project.new(params[:project])
+ @project.enabled_module_names = params[:enabled_modules]
+ if validate_parent_id && @project.copy(@source_project, :only => params[:only])
+ @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
+ flash[:notice] = l(:notice_successful_create)
+ redirect_to :controller => 'admin', :action => 'projects'
+ elsif !@project.new_record?
+ # Project was created
+ # But some objects were not copied due to validation failures
+ # (eg. issues from disabled trackers)
+ # TODO: inform about that
+ redirect_to :controller => 'admin', :action => 'projects'
+ end
end
end
rescue ActiveRecord::RecordNotFound
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index 9c409af69..e987c8a87 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -310,6 +310,15 @@ class Mailer < ActionMailer::Base
deliver_reminder(assignee, issues, days) unless assignee.nil?
end
end
+
+ # Activates/desactivates email deliveries during +block+
+ def self.with_deliveries(enabled = true, &block)
+ was_enabled = ActionMailer::Base.perform_deliveries
+ ActionMailer::Base.perform_deliveries = !!enabled
+ yield
+ ensure
+ ActionMailer::Base.perform_deliveries = was_enabled
+ end
private
def initialize_defaults(method_name)
diff --git a/app/views/projects/copy.rhtml b/app/views/projects/copy.rhtml
index 49e262786..dfcd44339 100644
--- a/app/views/projects/copy.rhtml
+++ b/app/views/projects/copy.rhtml
@@ -21,6 +21,8 @@
<label class="block"><%= check_box_tag 'only[]', 'boards', true %> <%= l(:label_board_plural) %> (<%= @source_project.boards.count %>)</label>
<label class="block"><%= check_box_tag 'only[]', 'wiki', true %> <%= l(:label_wiki_page_plural) %> (<%= @source_project.wiki.nil? ? 0 : @source_project.wiki.pages.count %>)</label>
<%= hidden_field_tag 'only[]', '' %>
+ <br />
+ <label class="block"><%= check_box_tag 'notifications', 1, params[:notifications] %> <%= l(:label_project_copy_notifications) %></label>
</fieldset>
<%= submit_tag l(:button_copy) %>