Advertisement
Guest User

redmine emails with attachments

a guest
Jan 22nd, 2012
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 1.94 KB | None | 0 0
  1. diff --git a/app/models/attachment.rb b/app/models/attachment.rb
  2. index ff434d8..0a7e69a 100644
  3. --- a/app/models/attachment.rb
  4. +++ b/app/models/attachment.rb
  5. @@ -116,6 +116,11 @@ class Attachment < ActiveRecord::Base
  6.    def deletable?(user=User.current)
  7.      container.attachments_deletable?(user)
  8.    end
  9. +  
  10. +  # my fix for email attachment
  11. +  def to_s
  12. +        self.filename
  13. +  end
  14.  
  15.    def image?
  16.      self.filename =~ /\.(jpe?g|gif|png)$/i
  17. diff --git a/app/views/mailer/_issue_text_html.rhtml b/app/views/mailer/_issue_text_html.rhtml
  18. index 3d851d4..06f0aec 100644
  19. --- a/app/views/mailer/_issue_text_html.rhtml
  20. +++ b/app/views/mailer/_issue_text_html.rhtml
  21. @@ -7,6 +7,16 @@
  22.  <li><%=l(:field_assigned_to)%>: <%=h issue.assigned_to %></li>
  23.  <li><%=l(:field_category)%>: <%=h issue.category %></li>
  24.  <li><%=l(:field_fixed_version)%>: <%=h issue.fixed_version %></li>
  25. +<% if issue.attachments.size > 0 %>
  26. +    <li>
  27. +        <ul>
  28. +           <%=l(:label_attachment)%>:
  29. +           <% issue.attachments.each do | c | %>
  30. +               <li> <%= link_to(c.to_s(), "http://redmine.tnt.it-solutions.cz/attachments/"+ c.id.to_s() + "/" + c.to_s() ) %> </li>
  31. +        <% end %>
  32. +        </ul>
  33. +    </li>
  34. +<% end %>
  35.  <% issue.custom_field_values.each do |c| %>
  36.    <li><%=h c.custom_field.name %>: <%=h show_value(c) %></li>
  37.  <% end %>
  38. diff --git a/app/views/mailer/_issue_text_plain.rhtml b/app/views/mailer/_issue_text_plain.rhtml
  39. index bea2a58..5e49b99 100644
  40. --- a/app/views/mailer/_issue_text_plain.rhtml
  41. +++ b/app/views/mailer/_issue_text_plain.rhtml
  42. @@ -7,6 +7,7 @@
  43.  <%=l(:field_assigned_to)%>: <%= issue.assigned_to %>
  44.  <%=l(:field_category)%>: <%= issue.category %>
  45.  <%=l(:field_fixed_version)%>: <%= issue.fixed_version %>
  46. +<% if issue.attachments.size > 0 %><%=l(:label_attachment)%>: <%= issue.attachments.join(", ") %><% end %>
  47.  <% issue.custom_field_values.each do |c| %><%= c.custom_field.name %>: <%= show_value(c) %>
  48.  <% end %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement