##// 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 redirect_to :controller => 'admin', :action => 'projects'
115 redirect_to :controller => 'admin', :action => 'projects'
116 end
116 end
117 else
117 else
118 @project = Project.new(params[:project])
118 Mailer.with_deliveries(params[:notifications] == '1') do
119 @project.enabled_module_names = params[:enabled_modules]
119 @project = Project.new(params[:project])
120 if validate_parent_id && @project.copy(@source_project, :only => params[:only])
120 @project.enabled_module_names = params[:enabled_modules]
121 @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
121 if validate_parent_id && @project.copy(@source_project, :only => params[:only])
122 flash[:notice] = l(:notice_successful_create)
122 @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
123 redirect_to :controller => 'admin', :action => 'projects'
123 flash[:notice] = l(:notice_successful_create)
124 elsif !@project.new_record?
124 redirect_to :controller => 'admin', :action => 'projects'
125 # Project was created
125 elsif !@project.new_record?
126 # But some objects were not copied due to validation failures
126 # Project was created
127 # (eg. issues from disabled trackers)
127 # But some objects were not copied due to validation failures
128 # TODO: inform about that
128 # (eg. issues from disabled trackers)
129 redirect_to :controller => 'admin', :action => 'projects'
129 # TODO: inform about that
130 redirect_to :controller => 'admin', :action => 'projects'
131 end
130 end
132 end
131 end
133 end
132 rescue ActiveRecord::RecordNotFound
134 rescue ActiveRecord::RecordNotFound
@@ -324,6 +324,15 class Mailer < ActionMailer::Base
324 deliver_reminder(assignee, issues, days) unless assignee.nil?
324 deliver_reminder(assignee, issues, days) unless assignee.nil?
325 end
325 end
326 end
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 private
337 private
329 def initialize_defaults(method_name)
338 def initialize_defaults(method_name)
@@ -21,6 +21,8
21 <label class="block"><%= check_box_tag 'only[]', 'boards', true %> <%= l(:label_board_plural) %> (<%= @source_project.boards.count %>)</label>
21 <label class="block"><%= check_box_tag 'only[]', 'boards', true %> <%= l(:label_board_plural) %> (<%= @source_project.boards.count %>)</label>
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>
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 <%= hidden_field_tag 'only[]', '' %>
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 </fieldset>
26 </fieldset>
25
27
26 <%= submit_tag l(:button_copy) %>
28 <%= submit_tag l(:button_copy) %>
@@ -886,3 +886,4 bg:
886 permission_manage_subtasks: Manage subtasks
886 permission_manage_subtasks: Manage subtasks
887 field_parent_issue: Parent task
887 field_parent_issue: Parent task
888 label_subtask_plural: Subtasks
888 label_subtask_plural: Subtasks
889 label_project_copy_notifications: Send email notifications during the project copy
@@ -910,3 +910,4 bs:
910 permission_manage_subtasks: Manage subtasks
910 permission_manage_subtasks: Manage subtasks
911 field_parent_issue: Parent task
911 field_parent_issue: Parent task
912 label_subtask_plural: Subtasks
912 label_subtask_plural: Subtasks
913 label_project_copy_notifications: Send email notifications during the project copy
@@ -889,3 +889,4 ca:
889 permission_manage_subtasks: Manage subtasks
889 permission_manage_subtasks: Manage subtasks
890 field_parent_issue: Parent task
890 field_parent_issue: Parent task
891 label_subtask_plural: Subtasks
891 label_subtask_plural: Subtasks
892 label_project_copy_notifications: Send email notifications during the project copy
@@ -892,3 +892,4 cs:
892 permission_manage_subtasks: Manage subtasks
892 permission_manage_subtasks: Manage subtasks
893 field_parent_issue: Parent task
893 field_parent_issue: Parent task
894 label_subtask_plural: Subtasks
894 label_subtask_plural: Subtasks
895 label_project_copy_notifications: Send email notifications during the project copy
@@ -912,3 +912,4 da:
912 permission_manage_subtasks: Manage subtasks
912 permission_manage_subtasks: Manage subtasks
913 field_parent_issue: Parent task
913 field_parent_issue: Parent task
914 label_subtask_plural: Subtasks
914 label_subtask_plural: Subtasks
915 label_project_copy_notifications: Send email notifications during the project copy
@@ -909,3 +909,4 de:
909 permission_manage_subtasks: Manage subtasks
909 permission_manage_subtasks: Manage subtasks
910 field_parent_issue: Parent task
910 field_parent_issue: Parent task
911 label_subtask_plural: Subtasks
911 label_subtask_plural: Subtasks
912 label_project_copy_notifications: Send email notifications during the project copy
@@ -892,3 +892,4 el:
892 permission_manage_subtasks: Manage subtasks
892 permission_manage_subtasks: Manage subtasks
893 field_parent_issue: Parent task
893 field_parent_issue: Parent task
894 label_subtask_plural: Subtasks
894 label_subtask_plural: Subtasks
895 label_project_copy_notifications: Send email notifications during the project copy
@@ -754,6 +754,7 en:
754 label_api_access_key_created_on: "API access key created {{value}} ago"
754 label_api_access_key_created_on: "API access key created {{value}} ago"
755 label_profile: Profile
755 label_profile: Profile
756 label_subtask_plural: Subtasks
756 label_subtask_plural: Subtasks
757 label_project_copy_notifications: Send email notifications during the project copy
757
758
758 button_login: Login
759 button_login: Login
759 button_submit: Submit
760 button_submit: Submit
@@ -936,3 +936,4 es:
936 permission_manage_subtasks: Manage subtasks
936 permission_manage_subtasks: Manage subtasks
937 field_parent_issue: Parent task
937 field_parent_issue: Parent task
938 label_subtask_plural: Subtasks
938 label_subtask_plural: Subtasks
939 label_project_copy_notifications: Send email notifications during the project copy
@@ -896,3 +896,4 eu:
896 permission_manage_subtasks: Manage subtasks
896 permission_manage_subtasks: Manage subtasks
897 field_parent_issue: Parent task
897 field_parent_issue: Parent task
898 label_subtask_plural: Subtasks
898 label_subtask_plural: Subtasks
899 label_project_copy_notifications: Send email notifications during the project copy
@@ -922,3 +922,4 fi:
922 permission_manage_subtasks: Manage subtasks
922 permission_manage_subtasks: Manage subtasks
923 field_parent_issue: Parent task
923 field_parent_issue: Parent task
924 label_subtask_plural: Subtasks
924 label_subtask_plural: Subtasks
925 label_project_copy_notifications: Send email notifications during the project copy
@@ -769,6 +769,7 fr:
769 label_revision_id: Revision {{value}}
769 label_revision_id: Revision {{value}}
770 label_profile: Profil
770 label_profile: Profil
771 label_subtask_plural: Sous-tΓ’ches
771 label_subtask_plural: Sous-tΓ’ches
772 label_project_copy_notifications: Envoyer les notifications durant la copie du projet
772
773
773 button_login: Connexion
774 button_login: Connexion
774 button_submit: Soumettre
775 button_submit: Soumettre
@@ -912,3 +912,4 gl:
912 permission_manage_subtasks: Manage subtasks
912 permission_manage_subtasks: Manage subtasks
913 field_parent_issue: Parent task
913 field_parent_issue: Parent task
914 label_subtask_plural: Subtasks
914 label_subtask_plural: Subtasks
915 label_project_copy_notifications: Send email notifications during the project copy
@@ -896,3 +896,4 he:
896 permission_manage_subtasks: Manage subtasks
896 permission_manage_subtasks: Manage subtasks
897 field_parent_issue: Parent task
897 field_parent_issue: Parent task
898 label_subtask_plural: Subtasks
898 label_subtask_plural: Subtasks
899 label_project_copy_notifications: Send email notifications during the project copy
@@ -899,3 +899,4 hr:
899 permission_manage_subtasks: Manage subtasks
899 permission_manage_subtasks: Manage subtasks
900 field_parent_issue: Parent task
900 field_parent_issue: Parent task
901 label_subtask_plural: Subtasks
901 label_subtask_plural: Subtasks
902 label_project_copy_notifications: Send email notifications during the project copy
@@ -917,3 +917,4
917 permission_manage_subtasks: Manage subtasks
917 permission_manage_subtasks: Manage subtasks
918 field_parent_issue: Parent task
918 field_parent_issue: Parent task
919 label_subtask_plural: Subtasks
919 label_subtask_plural: Subtasks
920 label_project_copy_notifications: Send email notifications during the project copy
@@ -904,3 +904,4 id:
904 permission_manage_subtasks: Manage subtasks
904 permission_manage_subtasks: Manage subtasks
905 field_parent_issue: Parent task
905 field_parent_issue: Parent task
906 label_subtask_plural: Subtasks
906 label_subtask_plural: Subtasks
907 label_project_copy_notifications: Send email notifications during the project copy
@@ -899,3 +899,4 it:
899 permission_manage_subtasks: Manage subtasks
899 permission_manage_subtasks: Manage subtasks
900 field_parent_issue: Parent task
900 field_parent_issue: Parent task
901 label_subtask_plural: Subtasks
901 label_subtask_plural: Subtasks
902 label_project_copy_notifications: Send email notifications during the project copy
@@ -921,3 +921,4 ja:
921 permission_manage_subtasks: Manage subtasks
921 permission_manage_subtasks: Manage subtasks
922 field_parent_issue: Parent task
922 field_parent_issue: Parent task
923 label_subtask_plural: Subtasks
923 label_subtask_plural: Subtasks
924 label_project_copy_notifications: Send email notifications during the project copy
@@ -952,3 +952,4 ko:
952 permission_manage_subtasks: Manage subtasks
952 permission_manage_subtasks: Manage subtasks
953 field_parent_issue: Parent task
953 field_parent_issue: Parent task
954 label_subtask_plural: Subtasks
954 label_subtask_plural: Subtasks
955 label_project_copy_notifications: Send email notifications during the project copy
@@ -960,3 +960,4 lt:
960 permission_manage_subtasks: Manage subtasks
960 permission_manage_subtasks: Manage subtasks
961 field_parent_issue: Parent task
961 field_parent_issue: Parent task
962 label_subtask_plural: Subtasks
962 label_subtask_plural: Subtasks
963 label_project_copy_notifications: Send email notifications during the project copy
@@ -874,3 +874,4 nl:
874 permission_manage_subtasks: Manage subtasks
874 permission_manage_subtasks: Manage subtasks
875 field_parent_issue: Parent task
875 field_parent_issue: Parent task
876 label_subtask_plural: Subtasks
876 label_subtask_plural: Subtasks
877 label_project_copy_notifications: Send email notifications during the project copy
@@ -887,3 +887,4
887 permission_manage_subtasks: Manage subtasks
887 permission_manage_subtasks: Manage subtasks
888 field_parent_issue: Parent task
888 field_parent_issue: Parent task
889 label_subtask_plural: Subtasks
889 label_subtask_plural: Subtasks
890 label_project_copy_notifications: Send email notifications during the project copy
@@ -917,3 +917,4 pl:
917 permission_manage_subtasks: Manage subtasks
917 permission_manage_subtasks: Manage subtasks
918 field_parent_issue: Parent task
918 field_parent_issue: Parent task
919 label_subtask_plural: Subtasks
919 label_subtask_plural: Subtasks
920 label_project_copy_notifications: Send email notifications during the project copy
@@ -920,3 +920,4 pt-BR:
920 permission_manage_subtasks: Manage subtasks
920 permission_manage_subtasks: Manage subtasks
921 field_parent_issue: Parent task
921 field_parent_issue: Parent task
922 label_subtask_plural: Subtasks
922 label_subtask_plural: Subtasks
923 label_project_copy_notifications: Send email notifications during the project copy
@@ -904,3 +904,4 pt:
904 permission_manage_subtasks: Manage subtasks
904 permission_manage_subtasks: Manage subtasks
905 field_parent_issue: Parent task
905 field_parent_issue: Parent task
906 label_subtask_plural: Subtasks
906 label_subtask_plural: Subtasks
907 label_project_copy_notifications: Send email notifications during the project copy
@@ -889,3 +889,4 ro:
889 permission_manage_subtasks: Manage subtasks
889 permission_manage_subtasks: Manage subtasks
890 field_parent_issue: Parent task
890 field_parent_issue: Parent task
891 label_subtask_plural: Subtasks
891 label_subtask_plural: Subtasks
892 label_project_copy_notifications: Send email notifications during the project copy
@@ -1013,3 +1013,4 ru:
1013 permission_manage_subtasks: Manage subtasks
1013 permission_manage_subtasks: Manage subtasks
1014 field_parent_issue: Parent task
1014 field_parent_issue: Parent task
1015 label_subtask_plural: Subtasks
1015 label_subtask_plural: Subtasks
1016 label_project_copy_notifications: Send email notifications during the project copy
@@ -891,3 +891,4 sk:
891 permission_manage_subtasks: Manage subtasks
891 permission_manage_subtasks: Manage subtasks
892 field_parent_issue: Parent task
892 field_parent_issue: Parent task
893 label_subtask_plural: Subtasks
893 label_subtask_plural: Subtasks
894 label_project_copy_notifications: Send email notifications during the project copy
@@ -888,3 +888,4 sl:
888 permission_manage_subtasks: Manage subtasks
888 permission_manage_subtasks: Manage subtasks
889 field_parent_issue: Parent task
889 field_parent_issue: Parent task
890 label_subtask_plural: Subtasks
890 label_subtask_plural: Subtasks
891 label_project_copy_notifications: Send email notifications during the project copy
@@ -907,3 +907,4
907 permission_manage_subtasks: Manage subtasks
907 permission_manage_subtasks: Manage subtasks
908 field_parent_issue: Parent task
908 field_parent_issue: Parent task
909 label_subtask_plural: Subtasks
909 label_subtask_plural: Subtasks
910 label_project_copy_notifications: Send email notifications during the project copy
@@ -941,3 +941,4 sv:
941 permission_manage_subtasks: Manage subtasks
941 permission_manage_subtasks: Manage subtasks
942 field_parent_issue: Parent task
942 field_parent_issue: Parent task
943 label_subtask_plural: Subtasks
943 label_subtask_plural: Subtasks
944 label_project_copy_notifications: Send email notifications during the project copy
@@ -889,3 +889,4 th:
889 permission_manage_subtasks: Manage subtasks
889 permission_manage_subtasks: Manage subtasks
890 field_parent_issue: Parent task
890 field_parent_issue: Parent task
891 label_subtask_plural: Subtasks
891 label_subtask_plural: Subtasks
892 label_project_copy_notifications: Send email notifications during the project copy
@@ -919,3 +919,4 tr:
919 permission_manage_subtasks: Manage subtasks
919 permission_manage_subtasks: Manage subtasks
920 field_parent_issue: Parent task
920 field_parent_issue: Parent task
921 label_subtask_plural: Subtasks
921 label_subtask_plural: Subtasks
922 label_project_copy_notifications: Send email notifications during the project copy
@@ -888,3 +888,4 uk:
888 permission_manage_subtasks: Manage subtasks
888 permission_manage_subtasks: Manage subtasks
889 field_parent_issue: Parent task
889 field_parent_issue: Parent task
890 label_subtask_plural: Subtasks
890 label_subtask_plural: Subtasks
891 label_project_copy_notifications: Send email notifications during the project copy
@@ -951,3 +951,4 vi:
951 permission_manage_subtasks: Manage subtasks
951 permission_manage_subtasks: Manage subtasks
952 field_parent_issue: Parent task
952 field_parent_issue: Parent task
953 label_subtask_plural: Subtasks
953 label_subtask_plural: Subtasks
954 label_project_copy_notifications: Send email notifications during the project copy
@@ -983,3 +983,4
983 permission_manage_subtasks: Manage subtasks
983 permission_manage_subtasks: Manage subtasks
984 field_parent_issue: Parent task
984 field_parent_issue: Parent task
985 label_subtask_plural: Subtasks
985 label_subtask_plural: Subtasks
986 label_project_copy_notifications: Send email notifications during the project copy
@@ -914,3 +914,4 zh:
914 permission_manage_subtasks: Manage subtasks
914 permission_manage_subtasks: Manage subtasks
915 field_parent_issue: Parent task
915 field_parent_issue: Parent task
916 label_subtask_plural: Subtasks
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 end
338 end
339 end
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 def test_reminders
349 def test_reminders
342 Mailer.reminders(:days => 42)
350 Mailer.reminders(:days => 42)
343 assert_equal 1, ActionMailer::Base.deliveries.size
351 assert_equal 1, ActionMailer::Base.deliveries.size
@@ -365,4 +373,13 class MailerTest < ActiveSupport::TestCase
365
373
366 assert_equal :it, current_language
374 assert_equal :it, current_language
367 end
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 end
385 end
General Comments 0
You need to be logged in to leave comments. Login now