diff options
-rw-r--r-- | app/models/incoming_message.rb | 12 | ||||
-rw-r--r-- | app/views/request/_bubble.rhtml | 2 |
2 files changed, 12 insertions, 2 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 5e57694c2..7e3f65cf4 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -19,7 +19,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: incoming_message.rb,v 1.138 2008-08-29 22:39:36 francis Exp $ +# $Id: incoming_message.rb,v 1.139 2008-08-29 23:13:30 francis Exp $ # TODO # Move some of the (e.g. quoting) functions here into rblib, as they feel @@ -128,6 +128,16 @@ class FOIAttachment end end end + + def display_size + s = self.body.size + + if s > 1024 * 1024 + return sprintf("%.1f", s.to_f / 1024 / 1024) + 'M' + else + return (s / 1024).to_s + 'K' + end + end end class IncomingMessage < ActiveRecord::Base diff --git a/app/views/request/_bubble.rhtml b/app/views/request/_bubble.rhtml index 25bff29b3..4787fcdcd 100644 --- a/app/views/request/_bubble.rhtml +++ b/app/views/request/_bubble.rhtml @@ -16,7 +16,7 @@ <strong><%= h a.display_filename %></strong> <!-- <%= link_to h(a.display_filename), attachment_url %> --> <br> - <%= (a.body.size > 1024 * 1024) ? ((a.body.size / 1024 / 1024).to_s + 'M') : ((a.body.size / 1024).to_s + 'K') %> + <%= a.display_size %> <%= link_to "Download", attachment_url %> <!-- (<%= a.content_type %>) --> </p> |