add plain text option for mail #2029

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@1932 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Nicolas Chuche 2008-10-15 23:50:33 +00:00
parent 1894bef48a
commit a4b07a36ed
33 changed files with 62 additions and 2 deletions

View 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

View 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>

View 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:

View 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)

View 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)

View 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)

View 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)

View 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)

View 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

View 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)

View 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)

View 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)

View 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)

View 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)

View 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)

View 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

View 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)

View 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)

View 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
label_copied: gekopieerd
setting_plain_text_mail: plain text only (no HTML)

View 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)

View 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)

View 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
label_copied: copiado
setting_plain_text_mail: plain text only (no HTML)

View 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)

View 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)

View 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)

View 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)

View 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)

View 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)

View 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)

View 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)

View 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)

View 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)

View 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