##// END OF EJS Templates
Adds an option to enable/disable email notifications during a project copy (#4672)....
Jean-Philippe Lang -
r3494:79b4f681760e
parent child
Show More
@@ -115,18 +115,20 class ProjectsController < ApplicationController
115 115 redirect_to :controller => 'admin', :action => 'projects'
116 116 end
117 117 else
118 @project = Project.new(params[:project])
119 @project.enabled_module_names = params[:enabled_modules]
120 if validate_parent_id && @project.copy(@source_project, :only => params[:only])
121 @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
122 flash[:notice] = l(:notice_successful_create)
123 redirect_to :controller => 'admin', :action => 'projects'
124 elsif !@project.new_record?
125 # Project was created
126 # But some objects were not copied due to validation failures
127 # (eg. issues from disabled trackers)
128 # TODO: inform about that
129 redirect_to :controller => 'admin', :action => 'projects'
118 Mailer.with_deliveries(params[:notifications] == '1') do
119 @project = Project.new(params[:project])
120 @project.enabled_module_names = params[:enabled_modules]
121 if validate_parent_id && @project.copy(@source_project, :only => params[:only])
122 @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
123 flash[:notice] = l(:notice_successful_create)
124 redirect_to :controller => 'admin', :action => 'projects'
125 elsif !@project.new_record?
126 # Project was created
127 # But some objects were not copied due to validation failures
128 # (eg. issues from disabled trackers)
129 # TODO: inform about that
130 redirect_to :controller => 'admin', :action => 'projects'
131 end
130 132 end
131 133 end
132 134 rescue ActiveRecord::RecordNotFound
@@ -324,6 +324,15 class Mailer < ActionMailer::Base
324 324 deliver_reminder(assignee, issues, days) unless assignee.nil?
325 325 end
326 326 end
327
328 # Activates/desactivates email deliveries during +block+
329 def self.with_deliveries(enabled = true, &block)
330 was_enabled = ActionMailer::Base.perform_deliveries
331 ActionMailer::Base.perform_deliveries = !!enabled
332 yield
333 ensure
334 ActionMailer::Base.perform_deliveries = was_enabled
335 end
327 336
328 337 private
329 338 def initialize_defaults(method_name)
@@ -21,6 +21,8
21 21 <label class="block"><%= check_box_tag 'only[]', 'boards', true %> <%= l(:label_board_plural) %> (<%= @source_project.boards.count %>)</label>
22 22 <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>
23 23 <%= hidden_field_tag 'only[]', '' %>
24 <br />
25 <label class="block"><%= check_box_tag 'notifications', 1, params[:notifications] %> <%= l(:label_project_copy_notifications) %></label>
24 26 </fieldset>
25 27
26 28 <%= submit_tag l(:button_copy) %>
@@ -886,3 +886,4 bg:
886 886 permission_manage_subtasks: Manage subtasks
887 887 field_parent_issue: Parent task
888 888 label_subtask_plural: Subtasks
889 label_project_copy_notifications: Send email notifications during the project copy
@@ -910,3 +910,4 bs:
910 910 permission_manage_subtasks: Manage subtasks
911 911 field_parent_issue: Parent task
912 912 label_subtask_plural: Subtasks
913 label_project_copy_notifications: Send email notifications during the project copy
@@ -889,3 +889,4 ca:
889 889 permission_manage_subtasks: Manage subtasks
890 890 field_parent_issue: Parent task
891 891 label_subtask_plural: Subtasks
892 label_project_copy_notifications: Send email notifications during the project copy
@@ -892,3 +892,4 cs:
892 892 permission_manage_subtasks: Manage subtasks
893 893 field_parent_issue: Parent task
894 894 label_subtask_plural: Subtasks
895 label_project_copy_notifications: Send email notifications during the project copy
@@ -912,3 +912,4 da:
912 912 permission_manage_subtasks: Manage subtasks
913 913 field_parent_issue: Parent task
914 914 label_subtask_plural: Subtasks
915 label_project_copy_notifications: Send email notifications during the project copy
@@ -909,3 +909,4 de:
909 909 permission_manage_subtasks: Manage subtasks
910 910 field_parent_issue: Parent task
911 911 label_subtask_plural: Subtasks
912 label_project_copy_notifications: Send email notifications during the project copy
@@ -892,3 +892,4 el:
892 892 permission_manage_subtasks: Manage subtasks
893 893 field_parent_issue: Parent task
894 894 label_subtask_plural: Subtasks
895 label_project_copy_notifications: Send email notifications during the project copy
@@ -754,6 +754,7 en:
754 754 label_api_access_key_created_on: "API access key created {{value}} ago"
755 755 label_profile: Profile
756 756 label_subtask_plural: Subtasks
757 label_project_copy_notifications: Send email notifications during the project copy
757 758
758 759 button_login: Login
759 760 button_submit: Submit
@@ -936,3 +936,4 es:
936 936 permission_manage_subtasks: Manage subtasks
937 937 field_parent_issue: Parent task
938 938 label_subtask_plural: Subtasks
939 label_project_copy_notifications: Send email notifications during the project copy
@@ -896,3 +896,4 eu:
896 896 permission_manage_subtasks: Manage subtasks
897 897 field_parent_issue: Parent task
898 898 label_subtask_plural: Subtasks
899 label_project_copy_notifications: Send email notifications during the project copy
@@ -922,3 +922,4 fi:
922 922 permission_manage_subtasks: Manage subtasks
923 923 field_parent_issue: Parent task
924 924 label_subtask_plural: Subtasks
925 label_project_copy_notifications: Send email notifications during the project copy
@@ -769,6 +769,7 fr:
769 769 label_revision_id: Revision {{value}}
770 770 label_profile: Profil
771 771 label_subtask_plural: Sous-tâches
772 label_project_copy_notifications: Envoyer les notifications durant la copie du projet
772 773
773 774 button_login: Connexion
774 775 button_submit: Soumettre
@@ -912,3 +912,4 gl:
912 912 permission_manage_subtasks: Manage subtasks
913 913 field_parent_issue: Parent task
914 914 label_subtask_plural: Subtasks
915 label_project_copy_notifications: Send email notifications during the project copy
@@ -896,3 +896,4 he:
896 896 permission_manage_subtasks: Manage subtasks
897 897 field_parent_issue: Parent task
898 898 label_subtask_plural: Subtasks
899 label_project_copy_notifications: Send email notifications during the project copy
@@ -899,3 +899,4 hr:
899 899 permission_manage_subtasks: Manage subtasks
900 900 field_parent_issue: Parent task
901 901 label_subtask_plural: Subtasks
902 label_project_copy_notifications: Send email notifications during the project copy
@@ -917,3 +917,4
917 917 permission_manage_subtasks: Manage subtasks
918 918 field_parent_issue: Parent task
919 919 label_subtask_plural: Subtasks
920 label_project_copy_notifications: Send email notifications during the project copy
@@ -904,3 +904,4 id:
904 904 permission_manage_subtasks: Manage subtasks
905 905 field_parent_issue: Parent task
906 906 label_subtask_plural: Subtasks
907 label_project_copy_notifications: Send email notifications during the project copy
@@ -899,3 +899,4 it:
899 899 permission_manage_subtasks: Manage subtasks
900 900 field_parent_issue: Parent task
901 901 label_subtask_plural: Subtasks
902 label_project_copy_notifications: Send email notifications during the project copy
@@ -921,3 +921,4 ja:
921 921 permission_manage_subtasks: Manage subtasks
922 922 field_parent_issue: Parent task
923 923 label_subtask_plural: Subtasks
924 label_project_copy_notifications: Send email notifications during the project copy
@@ -952,3 +952,4 ko:
952 952 permission_manage_subtasks: Manage subtasks
953 953 field_parent_issue: Parent task
954 954 label_subtask_plural: Subtasks
955 label_project_copy_notifications: Send email notifications during the project copy
@@ -960,3 +960,4 lt:
960 960 permission_manage_subtasks: Manage subtasks
961 961 field_parent_issue: Parent task
962 962 label_subtask_plural: Subtasks
963 label_project_copy_notifications: Send email notifications during the project copy
@@ -874,3 +874,4 nl:
874 874 permission_manage_subtasks: Manage subtasks
875 875 field_parent_issue: Parent task
876 876 label_subtask_plural: Subtasks
877 label_project_copy_notifications: Send email notifications during the project copy
@@ -887,3 +887,4
887 887 permission_manage_subtasks: Manage subtasks
888 888 field_parent_issue: Parent task
889 889 label_subtask_plural: Subtasks
890 label_project_copy_notifications: Send email notifications during the project copy
@@ -917,3 +917,4 pl:
917 917 permission_manage_subtasks: Manage subtasks
918 918 field_parent_issue: Parent task
919 919 label_subtask_plural: Subtasks
920 label_project_copy_notifications: Send email notifications during the project copy
@@ -920,3 +920,4 pt-BR:
920 920 permission_manage_subtasks: Manage subtasks
921 921 field_parent_issue: Parent task
922 922 label_subtask_plural: Subtasks
923 label_project_copy_notifications: Send email notifications during the project copy
@@ -904,3 +904,4 pt:
904 904 permission_manage_subtasks: Manage subtasks
905 905 field_parent_issue: Parent task
906 906 label_subtask_plural: Subtasks
907 label_project_copy_notifications: Send email notifications during the project copy
@@ -889,3 +889,4 ro:
889 889 permission_manage_subtasks: Manage subtasks
890 890 field_parent_issue: Parent task
891 891 label_subtask_plural: Subtasks
892 label_project_copy_notifications: Send email notifications during the project copy
@@ -1013,3 +1013,4 ru:
1013 1013 permission_manage_subtasks: Manage subtasks
1014 1014 field_parent_issue: Parent task
1015 1015 label_subtask_plural: Subtasks
1016 label_project_copy_notifications: Send email notifications during the project copy
@@ -891,3 +891,4 sk:
891 891 permission_manage_subtasks: Manage subtasks
892 892 field_parent_issue: Parent task
893 893 label_subtask_plural: Subtasks
894 label_project_copy_notifications: Send email notifications during the project copy
@@ -888,3 +888,4 sl:
888 888 permission_manage_subtasks: Manage subtasks
889 889 field_parent_issue: Parent task
890 890 label_subtask_plural: Subtasks
891 label_project_copy_notifications: Send email notifications during the project copy
@@ -907,3 +907,4
907 907 permission_manage_subtasks: Manage subtasks
908 908 field_parent_issue: Parent task
909 909 label_subtask_plural: Subtasks
910 label_project_copy_notifications: Send email notifications during the project copy
@@ -941,3 +941,4 sv:
941 941 permission_manage_subtasks: Manage subtasks
942 942 field_parent_issue: Parent task
943 943 label_subtask_plural: Subtasks
944 label_project_copy_notifications: Send email notifications during the project copy
@@ -889,3 +889,4 th:
889 889 permission_manage_subtasks: Manage subtasks
890 890 field_parent_issue: Parent task
891 891 label_subtask_plural: Subtasks
892 label_project_copy_notifications: Send email notifications during the project copy
@@ -919,3 +919,4 tr:
919 919 permission_manage_subtasks: Manage subtasks
920 920 field_parent_issue: Parent task
921 921 label_subtask_plural: Subtasks
922 label_project_copy_notifications: Send email notifications during the project copy
@@ -888,3 +888,4 uk:
888 888 permission_manage_subtasks: Manage subtasks
889 889 field_parent_issue: Parent task
890 890 label_subtask_plural: Subtasks
891 label_project_copy_notifications: Send email notifications during the project copy
@@ -951,3 +951,4 vi:
951 951 permission_manage_subtasks: Manage subtasks
952 952 field_parent_issue: Parent task
953 953 label_subtask_plural: Subtasks
954 label_project_copy_notifications: Send email notifications during the project copy
@@ -983,3 +983,4
983 983 permission_manage_subtasks: Manage subtasks
984 984 field_parent_issue: Parent task
985 985 label_subtask_plural: Subtasks
986 label_project_copy_notifications: Send email notifications during the project copy
@@ -914,3 +914,4 zh:
914 914 permission_manage_subtasks: Manage subtasks
915 915 field_parent_issue: Parent task
916 916 label_subtask_plural: Subtasks
917 label_project_copy_notifications: Send email notifications during the project copy
@@ -338,6 +338,14 class MailerTest < ActiveSupport::TestCase
338 338 end
339 339 end
340 340
341 def test_test
342 user = User.find(1)
343 valid_languages.each do |lang|
344 user.update_attribute :language, lang.to_s
345 assert Mailer.deliver_test(user)
346 end
347 end
348
341 349 def test_reminders
342 350 Mailer.reminders(:days => 42)
343 351 assert_equal 1, ActionMailer::Base.deliveries.size
@@ -365,4 +373,13 class MailerTest < ActiveSupport::TestCase
365 373
366 374 assert_equal :it, current_language
367 375 end
376
377 def test_with_deliveries_off
378 Mailer.with_deliveries false do
379 Mailer.deliver_test(User.find(1))
380 end
381 assert ActionMailer::Base.deliveries.empty?
382 # should restore perform_deliveries
383 assert ActionMailer::Base.perform_deliveries
384 end
368 385 end
General Comments 0
You need to be logged in to leave comments. Login now