]> source.dussan.org Git - redmine.git/commitdiff
add plain text option for mail #2029
authorNicolas Chuche <nicolas.chuche@barna.be>
Wed, 15 Oct 2008 23:50:33 +0000 (23:50 +0000)
committerNicolas Chuche <nicolas.chuche@barna.be>
Wed, 15 Oct 2008 23:50:33 +0000 (23:50 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@1932 e93f8b46-1217-0410-a6f0-8f06a7374b81

33 files changed:
app/models/mailer.rb
app/views/settings/_notifications.rhtml
config/settings.yml
lang/bg.yml
lang/ca.yml
lang/cs.yml
lang/da.yml
lang/de.yml
lang/en.yml
lang/es.yml
lang/fi.yml
lang/fr.yml
lang/he.yml
lang/hu.yml
lang/it.yml
lang/ja.yml
lang/ko.yml
lang/lt.yml
lang/nl.yml
lang/no.yml
lang/pl.yml
lang/pt-br.yml
lang/pt.yml
lang/ro.yml
lang/ru.yml
lang/sr.yml
lang/sv.yml
lang/th.yml
lang/tr.yml
lang/uk.yml
lang/zh-tw.yml
lang/zh.yml
test/unit/mailer_test.rb

index a2d9ddba57abafe3072834df7f0ca15dc891587c..60a5a827d36f499337863f3920ee702454c8fb42 100644 (file)
@@ -219,6 +219,21 @@ class Mailer < ActionMailer::Base
     body[:content_for_layout] = render(:file => method_name, :body => body)
     ActionView::Base.new(template_root, body, self).render(:file => "mailer/#{layout}", :use_full_path => true)
   end
+
+  # for the case of plain text only
+  def body(*params)
+    value = super(*params)
+    if Setting.plain_text_mail?
+      templates = Dir.glob("#{template_path}/#{@template}.text.plain.{rhtml,erb}")
+      unless String === @body or templates.empty?
+        template = File.basename(templates.first)
+        @body[:content_for_layout] = render(:file => template, :body => @body)
+        @body = ActionView::Base.new(template_root, @body, self).render(:file => "mailer/layout.text.plain.rhtml", :use_full_path => true)
+        return @body
+      end
+    end
+    return value
+  end
   
   # Makes partial rendering work with Rails 1.2 (retro-compatibility)
   def self.controller_path
index 36701463a6b924161b4274e9b60c6ac5a1f26d7d..a9a5f4742e240573373e7c1ea16125aa0be759c7 100644 (file)
@@ -8,6 +8,10 @@
 <p><label><%= l(:setting_bcc_recipients) %></label>
 <%= check_box_tag 'settings[bcc_recipients]', 1, Setting.bcc_recipients? %>
 <%= hidden_field_tag 'settings[bcc_recipients]', 0 %></p>
+
+<p><label><%= l(:setting_plain_text_mail) %></label>
+<%= check_box_tag 'settings[plain_text_mail]', 1, Setting.plain_text_mail? %>
+<%= hidden_field_tag 'settings[plain_text_mail]', 0 %></p>
 </div>
 
 <fieldset class="box" id="notified_events"><legend><%=l(:text_select_mail_notifications)%></legend>
index e1ad341def107e36420bd7ae9160fd8a9d4962b3..7d6a9d1dfb941d2b3965d2d4c36a42dbef4170d7 100644 (file)
@@ -46,6 +46,8 @@ mail_from:
   default: redmine@example.net
 bcc_recipients:
   default: 1
+plain_text_mail:
+  default: 0
 text_formatting:
   default: textile
 wiki_compression:
index f8d2e5e2ca62d0951bb2592f35ca052d1564c664..b6aa4774b3c0852a60b738ac5f500531ea813e14 100644 (file)
@@ -640,3 +640,4 @@ setting_sequential_project_identifiers: Generate sequential project identifiers
 notice_unable_delete_version: Unable to delete version
 label_renamed: renamed
 label_copied: copied
+setting_plain_text_mail: plain text only (no HTML)
index 40ba5feae39bd45b090e409f7cef46d8bebb3a0c..f4d185c5dfe0025ff4012a5aec6522e4c1683b03 100644 (file)
@@ -641,3 +641,4 @@ default_activity_development: Desenvolupament
 enumeration_issue_priorities: Prioritat dels assumptes
 enumeration_doc_categories: Categories del document
 enumeration_activities: Activitats (seguidor de temps)
+setting_plain_text_mail: plain text only (no HTML)
index cf2cb09929817c115b297fd13874547d1e88adf2..dcf778f010f8de83aa9479a5b86042c99e4bd99a 100644 (file)
@@ -645,3 +645,4 @@ setting_sequential_project_identifiers: Generate sequential project identifiers
 notice_unable_delete_version: Unable to delete version
 label_renamed: renamed
 label_copied: copied
+setting_plain_text_mail: plain text only (no HTML)
index 0ee1b25122744833d348b72299d364a00c9f7ab5..21bfb3a01e92012199b2ceb20a7f4aa02c884703 100644 (file)
@@ -641,3 +641,4 @@ default_activity_development: Udvikling
 enumeration_issue_priorities: Sagsprioriteter
 enumeration_doc_categories: Dokumentkategorier
 enumeration_activities: Aktiviteter (tidsregistrering)
+setting_plain_text_mail: plain text only (no HTML)
index 7aa2d971b7844139618936ce0da3d5267e7646c7..5041a31b4df5f75d35bfca7865eb710d8be9e9ef 100644 (file)
@@ -641,3 +641,4 @@ default_activity_development: Entwicklung
 enumeration_issue_priorities: Ticket-Prioritäten
 enumeration_doc_categories: Dokumentenkategorien
 enumeration_activities: Aktivitäten (Zeiterfassung)
+setting_plain_text_mail: plain text only (no HTML)
index 8a73a3992605a2ae1054ef8660607e4463d88ef8..5c7e30c21f30593407797d8b276c36520ea0b150 100644 (file)
@@ -195,6 +195,7 @@ setting_attachment_max_size: Attachment max. size
 setting_issues_export_limit: Issues export limit
 setting_mail_from: Emission email address
 setting_bcc_recipients: Blind carbon copy recipients (bcc)
+setting_plain_text_mail: plain text mail (no HTML)
 setting_host_name: Host name
 setting_text_formatting: Text formatting
 setting_wiki_compression: Wiki history compression
index ae367d8429700dd25c262f23ed3f108e9de24ed1..70b09f7690f03a29f6cc2a02fa8119936f2d547a 100644 (file)
@@ -643,3 +643,4 @@ setting_sequential_project_identifiers: Generate sequential project identifiers
 notice_unable_delete_version: Unable to delete version
 label_renamed: renamed
 label_copied: copied
+setting_plain_text_mail: plain text only (no HTML)
index 225563b37f93020c859a40c0868d854dad28a21a..ce7a3e0680fe9c63759e0668086b263b2bcaa053 100644 (file)
@@ -640,3 +640,4 @@ setting_commit_logs_encoding: Commit messages encoding
 notice_unable_delete_version: Unable to delete version
 label_renamed: renamed
 label_copied: copied
+setting_plain_text_mail: plain text only (no HTML)
index b640780681737b1c109ce8081956f58681ca8648..b81c6d3cc728c43ffb9ea7041473316a0507d29c 100644 (file)
@@ -641,3 +641,4 @@ enumeration_issue_priorities: Priorités des demandes
 enumeration_doc_categories: Catégories des documents
 enumeration_activities: Activités (suivi du temps)
 notice_unable_delete_version: Unable to delete version
+setting_plain_text_mail: mail texte brut (non HTML)
index 07962d2de039aa1ae2be6a99eddbb0fc4c1589ec..e43733651ced664e71d53a40639ba9d387f76b42 100644 (file)
@@ -640,3 +640,4 @@ setting_sequential_project_identifiers: Generate sequential project identifiers
 notice_unable_delete_version: Unable to delete version
 label_renamed: renamed
 label_copied: copied
+setting_plain_text_mail: plain text only (no HTML)
index 3a3d18a12e82f5635499865d0a5612a46415d131..c1fcdd2b8de13ba13052c25c8c90a08bb19da4ec 100644 (file)
@@ -641,3 +641,4 @@ setting_sequential_project_identifiers: Szekvenciális projekt azonosítók gene
 notice_unable_delete_version: A verziót nem lehet törölni
 label_renamed: átnevezve
 label_copied: lemásolva
+setting_plain_text_mail: plain text only (no HTML)
index bca755605587d8c58778f5c2be42cc49852994fc..4e40fa0853bc8627765ab791c2106053d362e41f 100644 (file)
@@ -640,3 +640,4 @@ setting_sequential_project_identifiers: Genera progetti con identificativi in se
 notice_unable_delete_version: Impossibile cancellare la versione
 label_renamed: rinominato
 label_copied: copiato
+setting_plain_text_mail: plain text only (no HTML)
index 4e46212b20e8e71b3483d02491df11e3d8b4ea26..165aabd3df748cfa03b0a549bfc896e140a04a71 100644 (file)
@@ -552,6 +552,7 @@ notice_account_pending: アカウントは作成済みで、管理者の承認
 field_time_zone: タイムゾーン
 text_caracters_minimum: 最低%d文字の長さが必要です
 setting_bcc_recipients: ブラインドカーボンコピーで受信(bcc)
+setting_plain_text_mail: プレインテキストのみ(HTMLなし)
 button_annotate: 注釈
 label_issues_by: %s別のチケット
 field_searchable: Searchable
index 95aa8716d139d69e4aafe73a0572899c8cca8339..fae3345a19f20c13d20d7b61e871af17b0d102c8 100644 (file)
@@ -640,3 +640,4 @@ setting_sequential_project_identifiers: 프로젝트 실별자를 순자적으
 notice_unable_delete_version: 삭제 할 수 없는 버전 입니다.
 label_renamed: renamed
 label_copied: copied
+setting_plain_text_mail: plain text only (no HTML)
index f29c28c4f8aefe3b55014102aa1c2192bc460f45..a92b2f007d9f9314af14c1c4bc70d9d80ff91706 100644 (file)
@@ -642,3 +642,4 @@ button_quote: Cituoti
 notice_unable_delete_version: Neimanoma panaikinti versiją
 label_renamed: pervardintas
 label_copied: nukopijuotas
+setting_plain_text_mail: plain text only (no HTML)
index 19d84500263f3dd6eafb5b9412e872bf8601d005..ee96aa7f72a2c4d90310ebd5513015ffcbca0d26 100644 (file)
@@ -641,4 +641,5 @@ button_quote: Citaat
 setting_sequential_project_identifiers: Genereer sequentiële projectidentiteiten
 notice_unable_delete_version: Niet mogelijk om deze versie te verwijderen.
 label_renamed: hernoemd
-label_copied: gekopieerd
\ No newline at end of file
+label_copied: gekopieerd
+setting_plain_text_mail: plain text only (no HTML)
index 8cd6952c62988999e09b41b0a614b26eb694b8d0..4005f0683151af14dd9d2db0234581ab8512bfe9 100644 (file)
@@ -641,3 +641,4 @@ setting_sequential_project_identifiers: Generate sequential project identifiers
 notice_unable_delete_version: Unable to delete version
 label_renamed: renamed
 label_copied: copied
+setting_plain_text_mail: plain text only (no HTML)
index ee9bbaaafdb7d8a2406617216cd64bd18eee1eff..45624771ecc4b81b279f92ed0eaccceafa78a59b 100644 (file)
@@ -646,3 +646,4 @@ label_renamed: przemianowano
 label_copied: skopiowano
 field_vf_watcher: Obserwator
 field_vf_personnel: Personel
+setting_plain_text_mail: plain text only (no HTML)
index 7c07729fe487a28d4f433c5aec39e85384e816c3..5dea29a205ede88caba35ccb0d2af693eda3761b 100644 (file)
@@ -641,3 +641,4 @@ enumeration_activities: Atividades (time tracking)
 notice_unable_delete_version: Não foi possível excluir a versão
 label_renamed: renomeado\r
 label_copied: copiado
+setting_plain_text_mail: plain text only (no HTML)
index 1cf9f3a104c696b181951218f36dfebb8b163675..e9f91b7fa62147d0af72bd4931189aba82a0d8a8 100644 (file)
@@ -642,3 +642,4 @@ default_activity_development: Desenvolvimento
 enumeration_issue_priorities: Prioridade de tarefas
 enumeration_doc_categories: Categorias de documentos
 enumeration_activities: Actividades (Contagem de tempo)
+setting_plain_text_mail: plain text only (no HTML)
index 94278256e29ef4238199a69f7d5cc64ff9526a82..2aabe67155ef54a84bc52ab763bcccc32f10b499 100644 (file)
@@ -640,3 +640,4 @@ setting_sequential_project_identifiers: Generate sequential project identifiers
 notice_unable_delete_version: Unable to delete version
 label_renamed: renamed
 label_copied: copied
+setting_plain_text_mail: plain text only (no HTML)
index ce5e43b7d84f542f9744e6c847bde32aa5c0c501..70149283f6478465305e8f71531700f749eff8ff 100644 (file)
@@ -673,3 +673,4 @@ text_user_wrote: '%s написал(а):'
 text_wiki_destroy_confirmation: Вы уверены, что хотите удалить данную Wiki и все содержимое?
 text_workflow_edit: Выберите роль и трекер для редактирования последовательности состояний
 
+setting_plain_text_mail: plain text only (no HTML)
index 720dfcdffa07c8f162ba40e625fe5e2773bb68ff..5de1c695387f3be118556477bb82cbb32e9bdce1 100644 (file)
@@ -641,3 +641,4 @@ setting_sequential_project_identifiers: Generate sequential project identifiers
 notice_unable_delete_version: Unable to delete version
 label_renamed: renamed
 label_copied: copied
+setting_plain_text_mail: plain text only (no HTML)
index 393ade8187318c03ed1932d2a2804364d7636419..8cd2eb7e594c1185c95ad2c9da9602e801ca3ec3 100644 (file)
@@ -641,3 +641,4 @@ setting_sequential_project_identifiers: Generate sequential project identifiers
 notice_unable_delete_version: Unable to delete version
 label_renamed: renamed
 label_copied: copied
+setting_plain_text_mail: plain text only (no HTML)
index 362e447569ba74fad92d62dafd53d683046a5a3d..b0f51e8ef3794d1ad09979765687298c652e93d5 100644 (file)
@@ -643,3 +643,4 @@ setting_sequential_project_identifiers: Generate sequential project identifiers
 notice_unable_delete_version: Unable to delete version
 label_renamed: renamed
 label_copied: copied
+setting_plain_text_mail: plain text only (no HTML)
index ba9c0b41b63b82bb12c0224cfcb5fc6fdec27aa9..7661e24ff3ce1641f8b60174d94c53b60fe05637 100644 (file)
@@ -641,3 +641,4 @@ general_csv_decimal_separator: '.'
 notice_unable_delete_version: Unable to delete version
 label_renamed: renamed
 label_copied: copied
+setting_plain_text_mail: plain text only (no HTML)
index de5f65eb0c019b9aff9c9d8ef9ce9f75d154a09c..074aa9a828441724af7881dc2a68bf3cb381b9fe 100644 (file)
@@ -642,3 +642,4 @@ setting_sequential_project_identifiers: Generate sequential project identifiers
 notice_unable_delete_version: Unable to delete version
 label_renamed: renamed
 label_copied: copied
+setting_plain_text_mail: plain text only (no HTML)
index 6feb0a0e809ab06c18de2a4aeb756ac98ad767b4..74943363744ec499fb8e709784f4715d5331b918 100644 (file)
@@ -641,3 +641,4 @@ default_activity_development: 開發
 enumeration_issue_priorities: 項目優先權
 enumeration_doc_categories: 文件分類
 enumeration_activities: 活動 (時間追蹤)
+setting_plain_text_mail: plain text only (no HTML)
index d2e571b4d3849f5e7229d9cf39250912448004f0..fd752eec7b5c52e28ab6d26cd915f1d802eb94d6 100644 (file)
@@ -641,3 +641,4 @@ default_activity_development: 开发
 enumeration_issue_priorities: 问题优先级
 enumeration_doc_categories: 文档类别
 enumeration_activities: 活动(时间跟踪)
+setting_plain_text_mail: plain text only (no HTML)
index 1c03bafb3ed69d0b181c073144a0169cceba59a0..e3a21a576388007408d17f85addd67a3ae55f7ab 100644 (file)
@@ -32,12 +32,22 @@ class MailerTest < Test::Unit::TestCase
     assert_kind_of TMail::Mail, mail
     # link to the main ticket
     assert mail.body.include?('<a href="https://mydomain.foo/issues/show/1">Bug #1: Can\'t print recipes</a>')
-    
     # link to a referenced ticket
     assert mail.body.include?('<a href="https://mydomain.foo/issues/show/2" class="issue" title="Add ingredients categories (Assigned)">#2</a>')
     # link to a changeset
     assert mail.body.include?('<a href="https://mydomain.foo/repositories/revision/ecookbook/2" class="changeset" title="This commit fixes #1, #2 and references #1 &amp; #3">r2</a>')
   end
+
+  def test_plain_text_mail
+    Setting.plain_text_mail = 1
+    journal = Journal.find(2)
+    Mailer.deliver_issue_edit(journal)
+    mail = ActionMailer::Base.deliveries.last
+    assert !mail.body.include?('<a href="https://mydomain.foo/issues/show/1">Bug #1: Can\'t print recipes</a>')
+  end
+  
+
   
   # test mailer methods for each language
   def test_issue_add