diff options
32 files changed, 25 insertions, 131 deletions
diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index b1b7deb64..442a6a288 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -52,7 +52,7 @@ class DocumentsController < ApplicationController a = Attachment.create(:container => @document, :file => file, :author => logged_in_user) @attachments << a unless a.new_record? } if params[:attachments] and params[:attachments].is_a? Array - Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? && Setting.notified_events.include?('document_added') + Mailer.deliver_attachments_added(@attachments) if !@attachments.empty? && Setting.notified_events.include?('document_added') redirect_to :action => 'show', :id => @document end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 5fcd3ce9c..f39c4536e 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -182,7 +182,7 @@ class ProjectsController < ApplicationController Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0 } if params[:attachments] and params[:attachments].is_a? Array flash[:notice] = l(:notice_successful_create) - Mailer.deliver_document_add(@document) if Setting.notified_events.include?('document_added') + Mailer.deliver_document_added(@document) if Setting.notified_events.include?('document_added') redirect_to :action => 'list_documents', :id => @project end end @@ -449,7 +449,7 @@ class ProjectsController < ApplicationController a = Attachment.create(:container => @version, :file => file, :author => logged_in_user) @attachments << a unless a.new_record? } if params[:attachments] and params[:attachments].is_a? Array - Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? && Setting.notified_events.include?('file_added') + Mailer.deliver_attachments_added(@attachments) if !@attachments.empty? && Setting.notified_events.include?('file_added') redirect_to :controller => 'projects', :action => 'list_files', :id => @project end @versions = @project.versions.sort diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 5f655db85..683045715 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -60,7 +60,7 @@ class Mailer < ActionMailer::Base @body['journal']= journal end - def document_add(document) + def document_added(document) set_language_if_valid(Setting.default_language) @recipients = document.project.users.collect { |u| u.mail if u.mail_notification }.compact @from = Setting.mail_from @@ -68,21 +68,18 @@ class Mailer < ActionMailer::Base @body['document'] = document end - def attachments_add(attachments) + def attachments_added(attachments) set_language_if_valid(Setting.default_language) container = attachments.first.container url = '' added_to = '' case container.class.name when 'Version' - url = url_for(:only_path => false, :host => Setting.host_name, :controller => 'projects', :action => 'list_files', :id => container.project_id) + url = {:only_path => false, :host => Setting.host_name, :controller => 'projects', :action => 'list_files', :id => container.project_id} added_to = "#{l(:label_version)}: #{container.name}" when 'Document' - url = url_for(:only_path => false, :host => Setting.host_name, :controller => 'documents', :action => 'show', :id => container.id) + url = {:only_path => false, :host => Setting.host_name, :controller => 'documents', :action => 'show', :id => container.id} added_to = "#{l(:label_document)}: #{container.title}" - when 'Issue' - url = url = url_for(:only_path => false, :host => Setting.host_name, :controller => 'issues', :action => 'show', :id => container.id) - added_to = "#{container.tracker.name} ##{container.id}: #{container.subject}" end @recipients = container.project.users.collect { |u| u.mail if u.mail_notification }.compact @from = Setting.mail_from diff --git a/app/views/mailer/attachments_add.rhtml b/app/views/mailer/attachments_add.rhtml deleted file mode 100644 index 81e2974c1..000000000 --- a/app/views/mailer/attachments_add.rhtml +++ /dev/null @@ -1,6 +0,0 @@ -<%= @added_to %> -<%= @attachments.size %> files(s) added. -<% @attachments.each do |attachment | %> -- <%= attachment.filename %><% end %> - -<%= @url %>
\ No newline at end of file diff --git a/app/views/mailer/attachments_add_bg.rhtml b/app/views/mailer/attachments_add_bg.rhtml deleted file mode 100644 index e38a97260..000000000 --- a/app/views/mailer/attachments_add_bg.rhtml +++ /dev/null @@ -1,6 +0,0 @@ -<%= @added_to %> -<%= @attachments.size %> файл(а) добавени. -<% @attachments.each do |attachment | %> -- <%= attachment.filename %><% end %> - -<%= @url %>
\ No newline at end of file diff --git a/app/views/mailer/attachments_add_de.rhtml b/app/views/mailer/attachments_add_de.rhtml deleted file mode 100644 index 81e2974c1..000000000 --- a/app/views/mailer/attachments_add_de.rhtml +++ /dev/null @@ -1,6 +0,0 @@ -<%= @added_to %> -<%= @attachments.size %> files(s) added. -<% @attachments.each do |attachment | %> -- <%= attachment.filename %><% end %> - -<%= @url %>
\ No newline at end of file diff --git a/app/views/mailer/attachments_add_fr.rhtml b/app/views/mailer/attachments_add_fr.rhtml deleted file mode 100644 index 8a0430d86..000000000 --- a/app/views/mailer/attachments_add_fr.rhtml +++ /dev/null @@ -1,6 +0,0 @@ -<%= @added_to %> -<%= @attachments.size %> fichier(s) ajouté(s). -<% @attachments.each do |attachment | %> -- <%= attachment.filename %><% end %> - -<%= @url %>
\ No newline at end of file diff --git a/app/views/mailer/attachments_add_it.rhtml b/app/views/mailer/attachments_add_it.rhtml deleted file mode 100644 index 61ad35744..000000000 --- a/app/views/mailer/attachments_add_it.rhtml +++ /dev/null @@ -1,6 +0,0 @@ -<%= @added_to %> -<%= @attachments.size %> file aggiunti. -<% @attachments.each do |attachment | %> -- <%= attachment.filename %><% end %> - -<%= @url %>
\ No newline at end of file diff --git a/app/views/mailer/attachments_add_ja.rhtml b/app/views/mailer/attachments_add_ja.rhtml deleted file mode 100644 index 41131e573..000000000 --- a/app/views/mailer/attachments_add_ja.rhtml +++ /dev/null @@ -1,6 +0,0 @@ -<%= @added_to %> -<%= @attachments.size %> ファイルが追加されました。 -<% @attachments.each do |attachment | %> -- <%= attachment.filename %><% end %> - -<%= @url %>
\ No newline at end of file diff --git a/app/views/mailer/attachments_add_nl.rhtml b/app/views/mailer/attachments_add_nl.rhtml deleted file mode 100644 index 800c38625..000000000 --- a/app/views/mailer/attachments_add_nl.rhtml +++ /dev/null @@ -1,6 +0,0 @@ -<%= @added_to %> -<%= @attachments.size %> bestand(en) toegevoegd. -<% @attachments.each do |attachment | %> -- <%= attachment.filename %><% end %> - -<%= @url %>
\ No newline at end of file diff --git a/app/views/mailer/attachments_add_pl.rhtml b/app/views/mailer/attachments_add_pl.rhtml deleted file mode 100644 index f358a83ce..000000000 --- a/app/views/mailer/attachments_add_pl.rhtml +++ /dev/null @@ -1,6 +0,0 @@ -<%= @added_to %> -<%= @attachments.size %> plik(ów) dodane. -<% @attachments.each do |attachment | %> -- <%= attachment.filename %><% end %> - -<%= @url %>
\ No newline at end of file diff --git a/app/views/mailer/attachments_add_pt-br.rhtml b/app/views/mailer/attachments_add_pt-br.rhtml deleted file mode 100644 index eccc4813e..000000000 --- a/app/views/mailer/attachments_add_pt-br.rhtml +++ /dev/null @@ -1,6 +0,0 @@ -<%= @added_to %> -<%= @attachments.size %> arquivo(s) adicionado. -<% @attachments.each do |attachment | %> -- <%= attachment.filename %><% end %> - -<%= @url %>
\ No newline at end of file diff --git a/app/views/mailer/attachments_add_pt.rhtml b/app/views/mailer/attachments_add_pt.rhtml deleted file mode 100644 index eccc4813e..000000000 --- a/app/views/mailer/attachments_add_pt.rhtml +++ /dev/null @@ -1,6 +0,0 @@ -<%= @added_to %> -<%= @attachments.size %> arquivo(s) adicionado. -<% @attachments.each do |attachment | %> -- <%= attachment.filename %><% end %> - -<%= @url %>
\ No newline at end of file diff --git a/app/views/mailer/attachments_add_sv.rhtml b/app/views/mailer/attachments_add_sv.rhtml deleted file mode 100644 index 14a093e48..000000000 --- a/app/views/mailer/attachments_add_sv.rhtml +++ /dev/null @@ -1,6 +0,0 @@ -<%= @added_to %> -<%= @attachments.size %> fil(er) tillagda. -<% @attachments.each do |attachment | %> -- <%= attachment.filename %><% end %> - -<%= @url %>
\ No newline at end of file diff --git a/app/views/mailer/attachments_add_zh.rhtml b/app/views/mailer/attachments_add_zh.rhtml deleted file mode 100644 index a87fb42ae..000000000 --- a/app/views/mailer/attachments_add_zh.rhtml +++ /dev/null @@ -1,6 +0,0 @@ -<%= @added_to %> -<%= @attachments.size %> ļ. -<% @attachments.each do |attachment | %> -- <%= attachment.filename %><% end %> - -<%= @url %>
\ No newline at end of file diff --git a/app/views/mailer/attachments_added.text.html.rhtml b/app/views/mailer/attachments_added.text.html.rhtml new file mode 100644 index 000000000..336cad69b --- /dev/null +++ b/app/views/mailer/attachments_added.text.html.rhtml @@ -0,0 +1,5 @@ +<%= link_to @added_to, @url %><br /> + +<ul><% @attachments.each do |attachment | %> +<li><%= attachment.filename %></li> +<% end %></ul> diff --git a/app/views/mailer/attachments_added.text.plain.rhtml b/app/views/mailer/attachments_added.text.plain.rhtml new file mode 100644 index 000000000..22df2203c --- /dev/null +++ b/app/views/mailer/attachments_added.text.plain.rhtml @@ -0,0 +1,4 @@ +<%= @added_to %><% @attachments.each do |attachment | %> +- <%= attachment.filename %><% end %> + +<%= url_for @url %> diff --git a/app/views/mailer/document_add.rhtml b/app/views/mailer/document_add.rhtml deleted file mode 100644 index dfd51d359..000000000 --- a/app/views/mailer/document_add.rhtml +++ /dev/null @@ -1,4 +0,0 @@ -A document has been added to <%= @document.project.name %> (<%= @document.category.name %>): -<%= l(:field_title) %>: <%= @document.title %> - -<%= url_for :only_path => false, :host => Setting.host_name, :controller => 'documents', :action => 'show', :id => @document %> diff --git a/app/views/mailer/document_add_bg.rhtml b/app/views/mailer/document_add_bg.rhtml deleted file mode 100644 index fbd65267c..000000000 --- a/app/views/mailer/document_add_bg.rhtml +++ /dev/null @@ -1,4 +0,0 @@ -Добавен е документ в <%= @document.project.name %> (<%= @document.category.name %>): -<%= l(:field_title) %>: <%= @document.title %> - -<%= url_for :only_path => false, :host => Setting.host_name, :controller => 'documents', :action => 'show', :id => @document %> diff --git a/app/views/mailer/document_add_de.rhtml b/app/views/mailer/document_add_de.rhtml deleted file mode 100644 index 4ee5a35a9..000000000 --- a/app/views/mailer/document_add_de.rhtml +++ /dev/null @@ -1,4 +0,0 @@ -Ein Dokument wurde hinzugefügt: <%= @document.project.name %> (<%= @document.category.name %>): -<%= l(:field_title) %>: <%= @document.title %> - -<%= url_for :only_path => false, :host => Setting.host_name, :controller => 'documents', :action => 'show', :id => @document %> diff --git a/app/views/mailer/document_add_fr.rhtml b/app/views/mailer/document_add_fr.rhtml deleted file mode 100644 index 333ae5c92..000000000 --- a/app/views/mailer/document_add_fr.rhtml +++ /dev/null @@ -1,4 +0,0 @@ -Un document a été ajouté à <%= @document.project.name %> (<%= @document.category.name %>): -<%= l(:field_title) %>: <%= @document.title %> - -<%= url_for :only_path => false, :host => Setting.host_name, :controller => 'documents', :action => 'show', :id => @document %> diff --git a/app/views/mailer/document_add_it.rhtml b/app/views/mailer/document_add_it.rhtml deleted file mode 100644 index 73b7632fb..000000000 --- a/app/views/mailer/document_add_it.rhtml +++ /dev/null @@ -1,4 +0,0 @@ -Un documento e' stato aggiunto a <%= @document.project.name %> (<%= @document.category.name %>): -<%= l(:field_title) %>: <%= @document.title %> - -<%= url_for :only_path => false, :host => Setting.host_name, :controller => 'documents', :action => 'show', :id => @document %> diff --git a/app/views/mailer/document_add_ja.rhtml b/app/views/mailer/document_add_ja.rhtml deleted file mode 100644 index 3a883c655..000000000 --- a/app/views/mailer/document_add_ja.rhtml +++ /dev/null @@ -1,4 +0,0 @@ -文書が <%= @document.project.name %> (<%= @document.category.name %>) に追加されました: -<%= l(:field_title) %>: <%= @document.title %> - -<%= url_for :only_path => false, :host => Setting.host_name, :controller => 'documents', :action => 'show', :id => @document %> diff --git a/app/views/mailer/document_add_nl.rhtml b/app/views/mailer/document_add_nl.rhtml deleted file mode 100644 index ff7091584..000000000 --- a/app/views/mailer/document_add_nl.rhtml +++ /dev/null @@ -1,4 +0,0 @@ -Een document is toegevoegd aan <%= @document.project.name %> (<%= @document.category.name %>): -<%= l(:field_title) %>: <%= @document.title %> - -<%= url_for :only_path => false, :host => Setting.host_name, :controller => 'documents', :action => 'show', :id => @document %> diff --git a/app/views/mailer/document_add_pl.rhtml b/app/views/mailer/document_add_pl.rhtml deleted file mode 100644 index bf84f4a4b..000000000 --- a/app/views/mailer/document_add_pl.rhtml +++ /dev/null @@ -1,4 +0,0 @@ -Dokument został dodany do <%= @document.project.name %> (<%= @document.category.name %>): -<%= l(:field_title) %>: <%= @document.title %> - -http://<%= Setting.host_name %>/documents/show/<%= @document.id %>
\ No newline at end of file diff --git a/app/views/mailer/document_add_pt-br.rhtml b/app/views/mailer/document_add_pt-br.rhtml deleted file mode 100644 index 00ee0bb96..000000000 --- a/app/views/mailer/document_add_pt-br.rhtml +++ /dev/null @@ -1,4 +0,0 @@ -Um documento foi adicionado no projeto <%= @document.project.name %> (<%= @document.category.name %>): -<%= l(:field_title) %>: <%= @document.title %> - -<%= url_for :only_path => false, :host => Setting.host_name, :controller => 'documents', :action => 'show', :id => @document %> diff --git a/app/views/mailer/document_add_pt.rhtml b/app/views/mailer/document_add_pt.rhtml deleted file mode 100644 index 00ee0bb96..000000000 --- a/app/views/mailer/document_add_pt.rhtml +++ /dev/null @@ -1,4 +0,0 @@ -Um documento foi adicionado no projeto <%= @document.project.name %> (<%= @document.category.name %>): -<%= l(:field_title) %>: <%= @document.title %> - -<%= url_for :only_path => false, :host => Setting.host_name, :controller => 'documents', :action => 'show', :id => @document %> diff --git a/app/views/mailer/document_add_sv.rhtml b/app/views/mailer/document_add_sv.rhtml deleted file mode 100644 index 2ca0c1eaa..000000000 --- a/app/views/mailer/document_add_sv.rhtml +++ /dev/null @@ -1,4 +0,0 @@ -Ett dokument har lagts till i <%= @document.project.name %> (<%= @document.category.name %>): -<%= l(:field_title) %>: <%= @document.title %> - -<%= url_for :only_path => false, :host => Setting.host_name, :controller => 'documents', :action => 'show', :id => @document %> diff --git a/app/views/mailer/document_add_zh.rhtml b/app/views/mailer/document_add_zh.rhtml deleted file mode 100644 index f416892d0..000000000 --- a/app/views/mailer/document_add_zh.rhtml +++ /dev/null @@ -1,4 +0,0 @@ -��һ���ĵ��ѱ����뵽��Ŀ�� <%= @document.project.name %> (<%= @document.category.name %>): -<%= l(:field_title) %>: <%= @document.title %> - -<%= url_for :only_path => false, :host => Setting.host_name, :controller => 'documents', :action => 'show', :id => @document %> diff --git a/app/views/mailer/document_added.text.html.rhtml b/app/views/mailer/document_added.text.html.rhtml new file mode 100644 index 000000000..2a574a1cc --- /dev/null +++ b/app/views/mailer/document_added.text.html.rhtml @@ -0,0 +1,4 @@ +<%= link_to @document.title, :only_path => false, :host => Setting.host_name, :controller => 'documents', :action => 'show', :id => @document %> +(<%= @document.category.name %>)<br /> +<br /> +<%= textilizable(@document.description) %> diff --git a/app/views/mailer/document_added.text.plain.rhtml b/app/views/mailer/document_added.text.plain.rhtml new file mode 100644 index 000000000..ee8f3e6be --- /dev/null +++ b/app/views/mailer/document_added.text.plain.rhtml @@ -0,0 +1,4 @@ +<%= @document.title %> (<%= @document.category.name %>) +<%= url_for :only_path => false, :host => Setting.host_name, :controller => 'documents', :action => 'show', :id => @document %> + +<%= @document.description %> diff --git a/test/unit/mailer_test.rb b/test/unit/mailer_test.rb index 26a53dcf8..d92c5837b 100644 --- a/test/unit/mailer_test.rb +++ b/test/unit/mailer_test.rb @@ -41,7 +41,7 @@ class MailerTest < Test::Unit::TestCase document = Document.find(1) GLoc.valid_languages.each do |lang| Setting.default_language = lang.to_s - assert Mailer.deliver_document_add(document) + assert Mailer.deliver_document_added(document) end end |